22 #ifndef XAPIAN_INCLUDED_SAFEUUID_H 23 #define XAPIAN_INCLUDED_SAFEUUID_H 25 #ifdef USE_WIN32_UUID_API 27 #elif defined HAVE_UUID_UUID_H 28 # include <uuid/uuid.h> 38 # define uuid_parse(IN, UU) (uuid_parse)(const_cast<char*>(IN), (UU)) 41 # ifndef HAVE_UUID_UNPARSE_LOWER 46 uuid_unparse(uu, out);
50 for (
size_t i = 0; i < 36; ++i) out[i] |= 0x20;
54 #elif defined HAVE_UUID_H 62 # define byte xapian_hack_aix_uuid_byte 73 typedef unsigned char uuid_t_[16];
79 uuid_create(&uuid, &status);
80 if (status != uuid_s_ok) {
82 throw std::bad_alloc();
84 std::memcpy(out, &uuid,
sizeof(uuid_t_));
94 char * nonconst_in =
const_cast<char*
>(in);
95 unsigned char * unsigned_in =
reinterpret_cast<unsigned char *
>(nonconst_in);
96 uuid_from_string(unsigned_in, &uuid, &status);
98 uuid_from_string(in, &uuid, &status);
100 if (status != uuid_s_ok)
102 std::memcpy(uu, &uuid,
sizeof(uuid_t_));
111 std::memcpy(&uuid, uu,
sizeof(
uuid_t));
114 unsigned char * result;
118 uuid_to_string(&uuid, &result, &status);
119 std::memcpy(out, result, 36);
121 if (status != uuid_s_ok) {
123 throw std::bad_alloc();
128 for (
size_t i = 0; i < 36; ++i) out[i] |= 0x20;
134 std::memset(uu, 0,
sizeof(uuid_t_));
141 while (i <
sizeof(uuid_t_)) {
149 # define uuid_t uuid_t_ 151 #elif defined USE_PROC_FOR_UUID 154 # error Do not know how to generate UUIDs 157 #endif // XAPIAN_INCLUDED_SAFEUUID_H
void uuid_generate(uuid_t uu)
int uuid_parse(const char *in, uuid_t uu)
void uuid_clear(uuid_t uu)
int uuid_is_null(const uuid_t uu)
void uuid_unparse_lower(const uuid_t uu, char *out)