1 #ifndef _BABELTRACE_UUID_H
2 #define _BABELTRACE_UUID_H
5 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
8 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
10 * Permission is hereby granted to use or copy this program
11 * for any purpose, provided the above notices are retained on all copies.
12 * Permission to modify the code and to distribute modified code is granted,
13 * provided the above notices are retained, and a notice that the code was
14 * modified is included with the above copyright notice.
19 /* Includes final \0. */
20 #define BABELTRACE_UUID_STR_LEN 37
21 #define BABELTRACE_UUID_LEN 16
23 #ifdef BABELTRACE_HAVE_LIBUUID
24 #include <uuid/uuid.h>
27 int babeltrace_uuid_generate(unsigned char *uuid_out
)
29 uuid_generate(uuid_out
);
34 int babeltrace_uuid_unparse(const unsigned char *uuid_in
, char *str_out
)
36 uuid_unparse(uuid_in
, str_out
);
41 int babeltrace_uuid_parse(const char *str_in
, unsigned char *uuid_out
)
43 return uuid_parse(str_in
, uuid_out
);
47 int babeltrace_uuid_compare(const unsigned char *uuid_a
,
48 const unsigned char *uuid_b
)
50 return uuid_compare(uuid_a
, uuid_b
);
53 #elif defined(BABELTRACE_HAVE_LIBC_UUID)
60 int babeltrace_uuid_generate(unsigned char *uuid_out
)
64 uuid_create((uuid_t
*) uuid_out
, &status
);
65 if (status
== uuid_s_ok
)
72 int babeltrace_uuid_unparse(const unsigned char *uuid_in
, char *str_out
)
78 uuid_to_string((uuid_t
*) uuid_in
, &alloc_str
, &status
);
79 if (status
== uuid_s_ok
) {
80 strcpy(str_out
, alloc_str
);
90 int babeltrace_uuid_parse(const char *str_in
, unsigned char *uuid_out
)
94 uuid_from_string(str_in
, (uuid_t
*) uuid_out
, &status
);
95 if (status
== uuid_s_ok
)
102 int babeltrace_uuid_compare(const unsigned char *uuid_a
,
103 const unsigned char *uuid_b
)
107 uuid_compare((uuid_t
*) uuid_a
, (uuid_t
*) uuid_b
, &status
);
108 if (status
== uuid_s_ok
)
115 #error "Babeltrace needs to have a UUID generator configured."
118 #endif /* _BABELTRACE_UUID_H */
This page took 0.030539 seconds and 4 git commands to generate.