OSSP CVS Repository

ossp - Check-in [3927]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3927
Date: 2003-Jan-22 12:37:22 (local)
2003-Jan-22 11:37:22 (UTC)
User:ms
Branch:
Comment: Bring to buildable status.
Tickets:
Inspections:
Files:
ossp-pkg/as/as-gui/as_uuid.cpp      1.5 -> 1.6     26 inserted, 26 deleted
ossp-pkg/as/as-gui/as_uuid.h      1.1 -> 1.2     27 inserted, 12 deleted

ossp-pkg/as/as-gui/as_uuid.cpp 1.5 -> 1.6

--- 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,


ossp-pkg/as/as-gui/as_uuid.h 1.1 -> 1.2

--- as_uuid.h    2003/01/21 14:41:15     1.1
+++ as_uuid.h    2003/01/22 11:37:22     1.2
@@ -44,6 +44,7 @@
 #else
 ?==Error: Undefined 8 bit type
 #endif // __u8
+
 #if (SIZEOF_SHORT == 2)
 typedef unsigned short       __u16;
 #elif (SIZEOF_INT == 2)
@@ -53,6 +54,7 @@
 #else
 ?==Error: Undefined 16 bit type
 #endif // __u16
+
 #if (SIZEOF_SHORT == 4)
 typedef unsigned short       __u32;
 #elif (SIZEOF_INT == 4)
@@ -62,6 +64,7 @@
 #else
 ?==Error: Undefined 32 bit type
 #endif // __u32
+
 #if (SIZEOF_SHORT == 8)
 typedef unsigned short       __u64;
 #elif (SIZEOF_INT == 8)
@@ -73,8 +76,8 @@
 #else
 ?==Error: Undefined 64 bit type
 #endif // __u64
-#endif // SIZEOF_INT
-#else // HAVE_CONFIG_H
+
+#else // HAVE_CONFIG_H (not defined)
 typedef unsigned char        __u8;
 #if (4 == 8)
 typedef unsigned int         __u64;
@@ -106,20 +109,32 @@
 #endif // HAVE_CONFIG_H
 
 
+typedef unsigned char uuid_t[16];
+
+struct uuid {
+        __u32   time_low;
+        __u16   time_mid;
+        __u16   time_hi_and_version;
+        __u16   clock_seq;
+        __u8    node[6];
+};
+
 class Uuid
 {
 public:
-    static int get_random_fd(void);
-    static void get_random_bytes(void *, int);
-    static int get_node_id(unsigned char *);
-    static int get_clock(__u32 *, __u32 *, __u16 *);
-    void uuid_generate_time(uuid_t);
-    void uuid_generate_random(uuid_t);
-    void uuid_generate(uuid_t);
-    void uuid_pack(const struct uuid *, uuid_t);
-    void uuid_unpack(const uuid_t, struct uuid *);
-    void uuid_unparse(const uuid_t, char *);
+    void genTime(uuid_t);
+    void genRand(uuid_t);
+    void genId(uuid_t);
+
+    void packId(const uuid *, uuid_t);
+    void unpackId(const uuid_t, uuid *);
+    void unparseId(const uuid_t, char *);
+
 private:
+    int getRandfd(void);
+    void getRandbytes(void *, int);
+    int getNodeid(unsigned char *);
+    int getClock(__u32 *, __u32 *, __u16 *);
 };
 
 #endif // UUIDGEN_H

CVSTrac 2.0.1