--- as_uuid.cpp 2003/01/21 14:41:15 1.5
+++ as_uuid.cpp 2003/01/22 11:37:22 1.6
@@ -79,7 +79,7 @@
#endif /* HAVE_NET_IF_H */
-static int Uuid::get_random_fd(void)
+int Uuid::getRandfd(void)
{
struct timeval tv;
static int fd = -2;
@@ -103,9 +103,9 @@
* Generate a series of random bytes. Use /dev/urandom if possible,
* and if not, use srandom/random.
*/
-static void Uuid::get_random_bytes(void *buf, int nbytes)
+void Uuid::getRandbytes(void *buf, int nbytes)
{
- int i, fd = get_random_fd();
+ int i, fd = getRandfd();
int lose_counter = 0;
char *cp = (char *) buf;
@@ -135,7 +135,7 @@
/*
* Get the ethernet hardware address, if we can find it...
*/
-static int Uuid::get_node_id(unsigned char *node_id)
+int Uuid::getNodeid(unsigned char *node_id)
{
#if 0 // FIXME: Fix this broken code some other day
#ifdef HAVE_NET_IF_H
@@ -196,7 +196,7 @@
/* Assume that the gettimeofday() has microsecond granularity */
#define MAX_ADJUSTMENT 10
-static int Uuid::get_clock(__u32 *clock_high, __u32 *clock_low, __u16 *ret_clock_seq)
+int Uuid::getClock(__u32 *clock_high, __u32 *clock_low, __u16 *ret_clock_seq)
{
static int adjustment = 0;
static struct timeval last = {0, 0};
@@ -207,7 +207,7 @@
try_again:
gettimeofday(&tv, 0);
if ((last.tv_sec == 0) && (last.tv_usec == 0)) {
- get_random_bytes(&clock_seq, sizeof(clock_seq));
+ getRandbytes(&clock_seq, sizeof(clock_seq));
clock_seq &= 0x1FFF;
last = tv;
last.tv_sec--;
@@ -238,16 +238,16 @@
return 0;
}
-void Uuid::uuid_generate_time(uuid_t out)
+void Uuid::genTime(uuid_t out)
{
static unsigned char node_id[6];
static int has_init = 0;
- struct uuid uu;
+ uuid uu;
__u32 clock_mid;
if (!has_init) {
- if (get_node_id(node_id) <= 0) {
- get_random_bytes(node_id, 6);
+ if (getNodeid(node_id) <= 0) {
+ getRandbytes(node_id, 6);
/*
* Set multicast bit, to prevent conflicts
* with IEEE 802 addresses obtained from
@@ -257,25 +257,25 @@
}
has_init = 1;
}
- get_clock(&clock_mid, &uu.time_low, &uu.clock_seq);
+ getClock(&clock_mid, &uu.time_low, &uu.clock_seq);
uu.clock_seq |= 0x8000;
uu.time_mid = (__u16) clock_mid;
uu.time_hi_and_version = (clock_mid >> 16) | 0x1000;
memcpy(uu.node, node_id, 6);
- uuid_pack(&uu, out);
+ packId(&uu, out);
}
-void Uuid::uuid_generate_random(uuid_t out)
+void Uuid::genRand(uuid_t out)
{
uuid_t buf;
- struct uuid uu;
+ uuid uu;
- get_random_bytes(buf, sizeof(buf));
- uuid_unpack(buf, &uu);
+ getRandbytes(buf, sizeof(buf));
+ unpackId(buf, &uu);
uu.clock_seq = (uu.clock_seq & 0x3FFF) | 0x8000;
uu.time_hi_and_version = (uu.time_hi_and_version & 0x0FFF) | 0x4000;
- uuid_pack(&uu, out);
+ packId(&uu, out);
}
/*
@@ -284,15 +284,15 @@
* /dev/urandom is available, since otherwise we won't have
* high-quality randomness.
*/
-void Uuid::uuid_generate(uuid_t out)
+void Uuid::genId(uuid_t out)
{
- if (get_random_fd() >= 0)
- uuid_generate_random(out);
+ if (getRandfd() >= 0)
+ genRand(out);
else
- uuid_generate_time(out);
+ genTime(out);
}
-void Uuid::uuid_pack(const struct uuid *uu, uuid_t ptr)
+void Uuid::packId(const uuid *uu, uuid_t ptr)
{
__u32 tmp;
unsigned char *out = ptr;
@@ -324,7 +324,7 @@
memcpy(out+10, uu->node, 6);
}
-void Uuid::uuid_unpack(const uuid_t in, struct uuid *uu)
+void Uuid::unpackId(const uuid_t in, uuid *uu)
{
const __u8 *ptr = in;
__u32 tmp;
@@ -350,11 +350,11 @@
memcpy(uu->node, ptr, 6);
}
-void Uuid::uuid_unparse(const uuid_t uu, char *out)
+void Uuid::unparseId(const uuid_t uu, char *out)
{
- struct uuid uuid;
+ uuid uuid;
- uuid_unpack(uu, &uuid);
+ unpackId(uu, &uuid);
sprintf(out,
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
uuid.time_low, uuid.time_mid, uuid.time_hi_and_version,
|