1 #ifndef _BABELTRACE_COMPAT_UUID_H
2 #define _BABELTRACE_COMPAT_UUID_H
5 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 /* Includes final \0. */
27 #define BABELTRACE_UUID_STR_LEN 37
28 #define BABELTRACE_UUID_LEN 16
30 #ifdef BABELTRACE_HAVE_LIBUUID
31 #include <uuid/uuid.h>
34 int bt_uuid_generate(unsigned char *uuid_out
)
36 uuid_generate(uuid_out
);
40 /* Sun's libuuid lacks const qualifiers */
43 int bt_uuid_unparse(const unsigned char *uuid_in
, char *str_out
)
45 uuid_unparse((unsigned char *) uuid_in
, str_out
);
50 int bt_uuid_parse(const char *str_in
, unsigned char *uuid_out
)
52 return uuid_parse((char *) str_in
, uuid_out
);
56 int bt_uuid_compare(const unsigned char *uuid_a
,
57 const unsigned char *uuid_b
)
59 return uuid_compare((unsigned char *) uuid_a
,
60 (unsigned char *) uuid_b
);
64 int bt_uuid_unparse(const unsigned char *uuid_in
, char *str_out
)
66 uuid_unparse(uuid_in
, str_out
);
71 int bt_uuid_parse(const char *str_in
, unsigned char *uuid_out
)
73 return uuid_parse(str_in
, uuid_out
);
77 int bt_uuid_compare(const unsigned char *uuid_a
,
78 const unsigned char *uuid_b
)
80 return uuid_compare(uuid_a
, uuid_b
);
84 #elif defined(BABELTRACE_HAVE_LIBC_UUID)
91 int bt_uuid_generate(unsigned char *uuid_out
)
95 uuid_create((uuid_t
*) uuid_out
, &status
);
96 if (status
== uuid_s_ok
)
103 int bt_uuid_unparse(const unsigned char *uuid_in
, char *str_out
)
109 uuid_to_string((uuid_t
*) uuid_in
, &alloc_str
, &status
);
110 if (status
== uuid_s_ok
) {
111 strcpy(str_out
, alloc_str
);
121 int bt_uuid_parse(const char *str_in
, unsigned char *uuid_out
)
125 uuid_from_string(str_in
, (uuid_t
*) uuid_out
, &status
);
126 if (status
== uuid_s_ok
)
133 int bt_uuid_compare(const unsigned char *uuid_a
,
134 const unsigned char *uuid_b
)
138 uuid_compare((uuid_t
*) uuid_a
, (uuid_t
*) uuid_b
, &status
);
139 if (status
== uuid_s_ok
)
145 #elif defined(__MINGW32__)
147 int bt_uuid_generate(unsigned char *uuid_out
);
148 int bt_uuid_unparse(const unsigned char *uuid_in
, char *str_out
);
149 int bt_uuid_parse(const char *str_in
, unsigned char *uuid_out
);
150 int bt_uuid_compare(const unsigned char *uuid_a
,
151 const unsigned char *uuid_b
);
154 #error "Babeltrace needs to have a UUID generator configured."
157 #endif /* _BABELTRACE_COMPAT_UUID_H */
This page took 0.032045 seconds and 4 git commands to generate.