X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fcompat%2Fuuid.h;h=0da0b80db72c47be979167687d3309459301df17;hb=52a0e9318791b1f188742059e904d42ee0d7e231;hp=35faf538875053ccc240ceb2253230d39cdf695e;hpb=5d2e1e66a968d9e555f9b8b00d0589ebfaf3de32;p=lttng-tools.git diff --git a/src/common/compat/uuid.h b/src/common/compat/uuid.h index 35faf5388..0da0b80db 100644 --- a/src/common/compat/uuid.h +++ b/src/common/compat/uuid.h @@ -23,13 +23,16 @@ #ifndef LTTNG_UUID_H #define LTTNG_UUID_H -#include +#include + /* * Includes final \0. */ #define UUID_STR_LEN 37 #define UUID_LEN 16 +typedef unsigned char lttng_uuid[UUID_LEN]; + #ifdef LTTNG_HAVE_LIBUUID #include @@ -37,7 +40,7 @@ * uuid_out is of len UUID_LEN. */ static inline -int lttng_uuid_generate(unsigned char *uuid_out) +int lttng_uuid_generate(lttng_uuid uuid_out) { uuid_generate(uuid_out); return 0; @@ -51,7 +54,7 @@ int lttng_uuid_generate(unsigned char *uuid_out) * uuid_out is of len UUID_LEN. */ static inline -int lttng_uuid_generate(unsigned char *uuid_out) +int lttng_uuid_generate(lttng_uuid uuid_out) { uint32_t status; @@ -66,4 +69,13 @@ int lttng_uuid_generate(unsigned char *uuid_out) #error "LTTng-Tools needs to have a UUID generator configured." #endif +/* + * Convert a UUID to a human-readable, NULL-terminated, string of the form + * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. + * + * Assumes uuid_str is at least UUID_STR_LEN byte long. + */ +LTTNG_HIDDEN +void lttng_uuid_to_str(const lttng_uuid uuid, char *uuid_str); + #endif /* LTTNG_UUID_H */