1 #ifndef _BABELTRACE_UUID_H
2 #define _BABELTRACE_UUID_H
7 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
22 /* Includes final \0. */
23 #define BABELTRACE_UUID_STR_LEN 37
24 #define BABELTRACE_UUID_LEN 16
26 #ifdef BABELTRACE_HAVE_LIBUUID
27 #include <uuid/uuid.h>
30 int babeltrace_uuid_generate(unsigned char *uuid_out
)
32 uuid_generate(uuid_out
);
37 int babeltrace_uuid_unparse(const unsigned char *uuid_in
, char *str_out
)
39 uuid_unparse(uuid_in
, str_out
);
44 int babeltrace_uuid_parse(const char *str_in
, unsigned char *uuid_out
)
46 return uuid_parse(str_in
, uuid_out
);
50 int babeltrace_uuid_compare(const unsigned char *uuid_a
,
51 const unsigned char *uuid_b
)
53 return uuid_compare(uuid_a
, uuid_b
);
56 #elif defined(BABELTRACE_HAVE_LIBC_UUID)
63 int babeltrace_uuid_generate(unsigned char *uuid_out
)
67 uuid_create((uuid_t
*) uuid_out
, &status
);
68 if (status
== uuid_s_ok
)
75 int babeltrace_uuid_unparse(const unsigned char *uuid_in
, char *str_out
)
81 uuid_to_string((uuid_t
*) uuid_in
, &alloc_str
, &status
);
82 if (status
== uuid_s_ok
) {
83 strcpy(str_out
, alloc_str
);
93 int babeltrace_uuid_parse(const char *str_in
, unsigned char *uuid_out
)
97 uuid_from_string(str_in
, (uuid_t
*) uuid_out
, &status
);
98 if (status
== uuid_s_ok
)
105 int babeltrace_uuid_compare(const unsigned char *uuid_a
,
106 const unsigned char *uuid_b
)
110 uuid_compare((uuid_t
*) uuid_a
, (uuid_t
*) uuid_b
, &status
);
111 if (status
== uuid_s_ok
)
118 #error "Babeltrace needs to have a UUID generator configured."
121 #endif /* _BABELTRACE_UUID_H */
This page took 0.044365 seconds and 4 git commands to generate.