OSSP CVS Repository

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

Check-in Number: 4418
Date: 2004-Feb-13 17:17:07 (local)
2004-Feb-13 16:17:07 (UTC)
User:rse
Branch:
Comment: Add support to uuid(1) CLI for decoding from stdin for both binary and string representations.
Tickets:
Inspections:
Files:
ossp-pkg/uuid/ChangeLog      1.41 -> 1.42     7 inserted, 1 deleted
ossp-pkg/uuid/uuid_cli.c      1.15 -> 1.16     27 inserted, 6 deleted
ossp-pkg/uuid/uuid_cli.pod      1.14 -> 1.15     3 inserted, 2 deleted

ossp-pkg/uuid/ChangeLog 1.41 -> 1.42

--- ChangeLog    2004/02/13 16:01:23     1.41
+++ ChangeLog    2004/02/13 16:17:07     1.42
@@ -11,7 +11,11 @@
   This is a list of all changes to OSSP uuid.
   For a more brief summary please have a look at the NEWS file.
 
-  Changes between 0.9.5 and 0.9.6 (06-Feb-2004 to 13-Feb-2004)
+  Changes between 0.9.6 and 0.9.7 (11-Feb-2004 to 13-Feb-2004)
+
+   o Add support to uuid(1) CLI for decoding from stdin for
+     both binary and string representations.
+     [Ralf S. Engelschall]
    
    o Add missing documentation entries for UUID_XXXX API constants and
      uuid_version() function.
@@ -28,6 +32,8 @@
    o Fixed "uuid -h" command.
      [<fuyuki@nigredo.org>]
 
+  Changes between 0.9.5 and 0.9.6 (06-Feb-2004 to 11-Feb-2004)
+
    o Added an experimental additional DCE 1.1 API for backward
      compatibility with existing applications.
      [Ralf S. Engelschall]


ossp-pkg/uuid/uuid_cli.c 1.15 -> 1.16

--- uuid_cli.c   2004/02/13 14:29:32     1.15
+++ uuid_cli.c   2004/02/13 16:17:07     1.16
@@ -71,6 +71,8 @@
 /* main procedure */
 int main(int argc, char *argv[])
 {
+    char uuid_buf_bin[UUID_LEN_BIN];
+    char uuid_buf_str[UUID_LEN_STR+1];
     uuid_t *uuid;
     uuid_t *uuid_ns;
     uuid_rc_t rc;
@@ -147,14 +149,33 @@
 
     if (decode) {
         /* decoding */
-        if (argc != 1)
-            usage("invalid number of arguments");
         if ((rc = uuid_create(&uuid)) != UUID_RC_OK)
             error(1, "uuid_create: %s", uuid_error(rc));
-        if (strlen(argv[0]) != UUID_LEN_STR)
-            error(1, "invalid length of UUID string representation");
-        if ((rc = uuid_import(uuid, UUID_FMT_STR, argv[0], strlen(argv[0]))) != UUID_RC_OK)
-            error(1, "uuid_import: %s", uuid_error(rc));
+        if (argc != 1)
+            usage("invalid number of arguments");
+        if (strcmp(argv[0], "-") == 0) {
+            if (raw) {
+                if (fread(uuid_buf_bin, UUID_LEN_BIN, 1, stdin) != 1)
+                    error(1, "fread: failed to read %d (UUID_LEN_BIN) bytes from stdin", UUID_LEN_BIN);
+                if ((rc = uuid_import(uuid, UUID_FMT_BIN, uuid_buf_bin, UUID_LEN_BIN)) != UUID_RC_OK)
+                    error(1, "uuid_import: %s", uuid_error(rc));
+            }
+            else {
+                if (fread(uuid_buf_str, UUID_LEN_STR, 1, stdin) != 1)
+                    error(1, "fread: failed to read %d (UUID_LEN_STR) bytes from stdin", UUID_LEN_STR);
+                uuid_buf_str[UUID_LEN_STR] = '\0';
+                if ((rc = uuid_import(uuid, UUID_FMT_STR, uuid_buf_str, UUID_LEN_STR)) != UUID_RC_OK)
+                    error(1, "uuid_import: %s", uuid_error(rc));
+            }
+        }
+        else {
+            if (raw)
+                error(1, "raw input mode only possible if reading from stdin");
+            if (strlen(argv[0]) != UUID_LEN_STR)
+                error(1, "invalid length of UUID string representation");
+            if ((rc = uuid_import(uuid, UUID_FMT_STR, argv[0], strlen(argv[0]))) != UUID_RC_OK)
+                error(1, "uuid_import: %s", uuid_error(rc));
+        }
         vp = NULL;
         if ((rc = uuid_export(uuid, UUID_FMT_TXT, &vp, NULL)) != UUID_RC_OK)
             error(1, "uuid_export: %s", uuid_error(rc));


ossp-pkg/uuid/uuid_cli.pod 1.14 -> 1.15

--- uuid_cli.pod 2004/02/13 14:29:32     1.14
+++ uuid_cli.pod 2004/02/13 16:17:07     1.15
@@ -121,8 +121,9 @@
 
 =item B<-d>
 
-Decode a given UUID (either on F<stdin> or as an argument on the command
-line) and dump textual information about the UUID.
+Decode a given UUID (given as a command line argument or if the command
+line argument is "C<->" the UUID is read from F<stdin>) and dump textual
+information about the UUID.
 
 =back
 

CVSTrac 2.0.1