require libuuid
- require libuuid at build time and remove insufficiently seeded replacement for uuid()
This commit is contained in:
committed by
Paul Beckingham
parent
779e32540a
commit
fcfd50bd25
29
src/util.cpp
29
src/util.cpp
@@ -230,8 +230,6 @@ int autoComplete (
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef HAVE_UUID
|
||||
|
||||
#ifndef HAVE_UUID_UNPARSE_LOWER
|
||||
// Older versions of libuuid don't have uuid_unparse_lower(), only uuid_unparse()
|
||||
void uuid_unparse_lower (uuid_t uu, char *out)
|
||||
@@ -256,33 +254,6 @@ const std::string uuid ()
|
||||
return std::string (buffer);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#else
|
||||
|
||||
#ifdef HAVE_RANDOM
|
||||
#define rand() random()
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string uuid ()
|
||||
{
|
||||
uint32_t time_low = ((rand () << 16) & 0xffff0000) | (rand () & 0xffff);
|
||||
uint16_t time_mid = rand () & 0xffff;
|
||||
uint16_t time_high_and_version = (rand () & 0x0fff) | 0x4000;
|
||||
uint16_t clock_seq = (rand () & 0x3fff) | 0x8000;
|
||||
uint8_t node [6];
|
||||
for (size_t i = 0; i < 6; i++)
|
||||
node[i] = rand() & 0xff;
|
||||
|
||||
char buffer[37];
|
||||
sprintf(buffer, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
time_low, time_mid, time_high_and_version, clock_seq >> 8, clock_seq & 0xff,
|
||||
node[0], node[1], node[2], node[3], node[4], node[5]);
|
||||
|
||||
return std::string (buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// On Solaris no flock function exists.
|
||||
#ifdef SOLARIS
|
||||
|
||||
Reference in New Issue
Block a user