Azure IoT / azure_c_shared_utility

Dependents:   STM32F746_iothub_client_sample_mqtt f767zi_mqtt iothub_client_sample_amqp iothub_client_sample_http ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers uuid.h Source File

uuid.h

00001 // Copyright (c) Microsoft. All rights reserved.
00002 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
00003 
00004 #ifndef UUID_H
00005 #define UUID_H
00006 
00007 #ifdef __cplusplus
00008 #include <cstddef>
00009 #include <cstdint>
00010 extern "C" {
00011 #else
00012 #include <stddef.h>
00013 #include <stdint.h>
00014 #include <stdbool.h>
00015 #endif /* __cplusplus */
00016 
00017 #include "azure_c_shared_utility/umock_c_prod.h"
00018 
00019 typedef unsigned char UUID_T[16];
00020 
00021 /* These 2 strings can be conveniently used directly in printf statements
00022   Notice that PRI_UUID has to be used like any other print format specifier, meaning it
00023   has to be preceded with % */
00024 #define PRI_UUID        "02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
00025 #define UUID_FORMAT_VALUES(uuid) \
00026     (uuid)[0], (uuid)[1], (uuid)[2], (uuid)[3], (uuid)[4], (uuid)[5], (uuid)[6], (uuid)[7], \
00027     (uuid)[8], (uuid)[9], (uuid)[10], (uuid)[11], (uuid)[12], (uuid)[13], (uuid)[14], (uuid)[15] \
00028 
00029 /* @brief               Generates a true UUID
00030 *  @param uuid          A pre-allocated buffer for the bytes of the generated UUID
00031 *  @returns             Zero if no failures occur, non-zero otherwise.
00032 */
00033 MOCKABLE_FUNCTION(, int, UUID_generate, UUID_T*, uuid);
00034 
00035 /* @brief               Gets the UUID value (byte sequence) of an well-formed UUID string.
00036 *  @param uuid_string   A null-terminated well-formed UUID string (e.g., "7f907d75-5e13-44cf-a1a3-19a01a2b4528").
00037 *  @param uuid          Sequence of bytes representing an UUID.
00038 *  @returns             Zero if no failures occur, non-zero otherwise.
00039 */
00040 MOCKABLE_FUNCTION(, int, UUID_from_string, const char*, uuid_string, UUID_T*, uuid);
00041 
00042 /* @brief               Gets the string representation of the UUID value.
00043 *  @param uuid          Sequence of bytes representing an UUID.
00044 *  @returns             A null-terminated string representation of the UUID value provided (e.g., "7f907d75-5e13-44cf-a1a3-19a01a2b4528").
00045 */
00046 MOCKABLE_FUNCTION(, char*, UUID_to_string, const UUID_T*, uuid);
00047 
00048 #ifdef __cplusplus
00049 }
00050 #endif
00051 
00052 #endif /* UUID_H */