OSSP CVS Repository

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

Check-in Number: 3717
Date: 2004-Jan-09 22:01:04 (local)
2004-Jan-09 21:01:04 (UTC)
User:rse
Branch:
Comment: fix framework and print ASCII output by default
Tickets:
Inspections:
Files:
ossp-pkg/uuid/uuid.c      1.7 -> 1.8     18 inserted, 21 deleted
ossp-pkg/uuid/uuid_cli.c      1.5 -> 1.6     14 inserted, 14 deleted
ossp-pkg/uuid/uuidtool.c      1.5 -> 1.6     14 inserted, 14 deleted

ossp-pkg/uuid/uuid.c 1.7 -> 1.8

--- uuid.c       2004/01/09 16:11:40     1.7
+++ uuid.c       2004/01/09 21:01:04     1.8
@@ -317,7 +317,6 @@
 
 uuid_rc_t uuid_parse(uuid_t *uuid, const char *str)
 {
-    uuid_t uuid_tmp;
     uuid_uint16_t tmp16;
     const char *cp;
     char hexbuf[3];
@@ -353,18 +352,18 @@
     /*
      * pass 2: parse hex values of string representation syntax
      */
-    uuid_tmp.time_low            = (uuid_uint32_t)strtoul(str,    NULL, 16);
-    uuid_tmp.time_mid            = (uuid_uint16_t)strtoul(str+9,  NULL, 16);
-    uuid_tmp.time_hi_and_version = (uuid_uint16_t)strtoul(str+14, NULL, 16);
+    uuid->time_low            = (uuid_uint32_t)strtoul(str,    NULL, 16);
+    uuid->time_mid            = (uuid_uint16_t)strtoul(str+9,  NULL, 16);
+    uuid->time_hi_and_version = (uuid_uint16_t)strtoul(str+14, NULL, 16);
     tmp16 = (uuid_uint16_t)strtoul(str+19, NULL, 16);
-    uuid_tmp.clock_seq_low             = (uuid_uint8_t)(tmp16 & 0xff); tmp16 >>= 8;
-    uuid_tmp.clock_seq_hi_and_reserved = (uuid_uint8_t)(tmp16 & 0xff);
+    uuid->clock_seq_low             = (uuid_uint8_t)(tmp16 & 0xff); tmp16 >>= 8;
+    uuid->clock_seq_hi_and_reserved = (uuid_uint8_t)(tmp16 & 0xff);
     cp = str+24;
     hexbuf[2] = '\0';
-    for (i = 0; i < sizeof(uuid_tmp.node); i++) {
+    for (i = 0; i < sizeof(uuid->node); i++) {
         hexbuf[0] = *cp++;
         hexbuf[1] = *cp++;
-        uuid_tmp.node[i] = strtoul(hexbuf, NULL, 16);
+        uuid->node[i] = strtoul(hexbuf, NULL, 16);
     }
 
     return UUID_RC_OK;
@@ -372,8 +371,6 @@
 
 uuid_rc_t uuid_format(uuid_t *uuid, char **str)
 {
-    uuid_t uuid_tmp;
-
     /* sanity check argument(s) */
     if (uuid == NULL || str == NULL)
         return UUID_RC_ARG;
@@ -386,17 +383,17 @@
     /* format UUID into string representation */
     sprintf(*str,
         "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
-        (unsigned long)uuid_tmp.time_low,
-        (unsigned int)uuid_tmp.time_mid,
-        (unsigned int)uuid_tmp.time_hi_and_version,
-        (unsigned int)uuid_tmp.clock_seq_hi_and_reserved,
-        (unsigned int)uuid_tmp.clock_seq_low,
-        (unsigned int)uuid_tmp.node[0],
-        (unsigned int)uuid_tmp.node[1],
-        (unsigned int)uuid_tmp.node[2],
-        (unsigned int)uuid_tmp.node[3],
-        (unsigned int)uuid_tmp.node[4],
-        (unsigned int)uuid_tmp.node[5]);
+        (unsigned long)uuid->time_low,
+        (unsigned int)uuid->time_mid,
+        (unsigned int)uuid->time_hi_and_version,
+        (unsigned int)uuid->clock_seq_hi_and_reserved,
+        (unsigned int)uuid->clock_seq_low,
+        (unsigned int)uuid->node[0],
+        (unsigned int)uuid->node[1],
+        (unsigned int)uuid->node[2],
+        (unsigned int)uuid->node[3],
+        (unsigned int)uuid->node[4],
+        (unsigned int)uuid->node[5]);
 
     return UUID_RC_OK;
 }


ossp-pkg/uuid/uuid_cli.c 1.5 -> 1.6

--- uuid_cli.c   2004/01/09 16:11:40     1.5
+++ uuid_cli.c   2004/01/09 21:01:04     1.6
@@ -78,7 +78,7 @@
     int count;
     int i;
     int iterate;
-    int ascii;
+    int raw;
     int decode;
     char *cp;
     void *vp;
@@ -88,10 +88,10 @@
     count = -1;     /* no count yet */
     fp = stdout;    /* default output file */
     iterate = 0;    /* not one at a time */
-    ascii = 0;      /* default is binary output */
+    raw = 0;        /* default is ASCII output */
     decode = 0;     /* default is to encode */
     version = UUID_VERSION1;
-    while ((ch = getopt(argc, argv, "1n:ado:v:")) != -1) {
+    while ((ch = getopt(argc, argv, "1n:rdo:v:")) != -1) {
         switch (ch) {
             case '1':
                 iterate = 1;
@@ -103,8 +103,8 @@
                 if (*p != '\0' || count < 1)
                     usage("invalid argument to option 'n'");
                 break;
-            case 'a':
-                ascii = 1;
+            case 'r':
+                raw = 1;
                 break;
             case 'd':
                 decode = 1;
@@ -165,20 +165,20 @@
                 rc = uuid_generate(uuid, version);
             if (rc != UUID_RC_OK)
                 error(1, "uuid_generate: %s", uuid_error(rc));
-            if (ascii) {
+            if (raw) {
+                vp = NULL;
+                if ((rc = uuid_pack(uuid, &vp)) != UUID_RC_OK)
+                    error(1, "uuid_pack: %s", uuid_error(rc));
+                fwrite(vp, UUID_LEN_BIN, 1, fp);
+                free(vp);
+            }
+            else {
                 cp = NULL;
                 if ((rc = uuid_format(uuid, &cp)) != UUID_RC_OK)
-                    error(1, "uuid_unparse: %s", uuid_error(rc));
+                    error(1, "uuid_format: %s", uuid_error(rc));
                 fprintf(fp, "%s\n", cp);
                 free(cp);
             }
-            else {
-                vp = NULL;
-                if ((rc = uuid_pack(uuid, &vp)) != UUID_RC_OK)
-                    error(1, "uuid_unpack: %s", uuid_error(rc));
-                fwrite(vp, UUID_LEN_BIN, 1, vp);
-                free(vp);
-            }
         }
         if ((rc = uuid_destroy(uuid)) != UUID_RC_OK)
             error(1, "uuid_destroy: %s", uuid_error(rc));


CVSTrac 2.0.1