Whamcloud - gitweb
Add the uuid_unparse_upper and uuid_unparse_lower functions to the
authorTheodore Ts'o <tytso@mit.edu>
Mon, 22 Mar 2004 21:22:28 +0000 (16:22 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 22 Mar 2004 21:22:28 +0000 (16:22 -0500)
uuid library.

lib/uuid/ChangeLog
lib/uuid/unparse.c
lib/uuid/uuid.h
lib/uuid/uuid_unparse.3.in

index e6de9f0..7a043a1 100644 (file)
@@ -1,3 +1,8 @@
+2004-03-22  Theodore Ts'o  <tytso@mit.edu>
+
+       * unparse.c (uuid_unparse_lower, uuid_unparse_upper),
+               uuid_unparse.3.in, uuid.h: Add new functions.
+
 2004-03-19  Theodore Ts'o  <tytso@mit.edu>
 
        * Change the license to be the 3-clause BSD-style license
index b5b9f58..c0e08ef 100644 (file)
 
 #include "uuidP.h"
 
-void uuid_unparse(const uuid_t uu, char *out)
+static const char *fmt_lower = 
+       "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x";
+
+static const char *fmt_upper = 
+       "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X";
+
+#ifdef UUID_UNPARSE_DEFAULT_UPPER
+#define FMT_DEFAULT fmt_upper
+#else
+#define FMT_DEFAULT fmt_lower
+#endif
+
+static void uuid_unparse_x(const uuid_t uu, char *out, const char *fmt)
 {
        struct uuid uuid;
 
        uuid_unpack(uu, &uuid);
-       sprintf(out,
-               "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+       sprintf(out, fmt,
                uuid.time_low, uuid.time_mid, uuid.time_hi_and_version,
                uuid.clock_seq >> 8, uuid.clock_seq & 0xFF,
                uuid.node[0], uuid.node[1], uuid.node[2],
                uuid.node[3], uuid.node[4], uuid.node[5]);
 }
 
+void uuid_unparse_lower(const uuid_t uu, char *out)
+{
+       uuid_unparse_x(uu, out, fmt_lower);
+}
+
+void uuid_unparse_upper(const uuid_t uu, char *out)
+{
+       uuid_unparse_x(uu, out, fmt_upper);
+}
+
+void uuid_unparse(const uuid_t uu, char *out)
+{
+       uuid_unparse_x(uu, out, FMT_DEFAULT);
+}
index a037c7b..ff5459e 100644 (file)
@@ -81,6 +81,8 @@ int uuid_parse(const char *in, uuid_t uu);
 
 /* unparse.c */
 void uuid_unparse(const uuid_t uu, char *out);
+void uuid_unparse_lower(const uuid_t uu, char *out);
+void uuid_unparse_upper(const uuid_t uu, char *out);
 
 /* uuid_time.c */
 time_t uuid_time(const uuid_t uu, struct timeval *ret_tv);
index 7099ed2..80aa9a8 100644 (file)
@@ -13,6 +13,8 @@ uuid_unparse \- output UUID variable in string format
 .B #include <uuid/uuid.h>
 .sp
 .BI "void uuid_unparse(uuid_t " uu ", char *" out );
+.BI "void uuid_unparse_upper(uuid_t " uu ", char *" out );
+.BI "void uuid_unparse_lower(uuid_t " uu ", char *" out );
 .fi
 .SH DESCRIPTION
 The
@@ -22,9 +24,18 @@ function converts the supplied UUID
 from the internal binary format into a 36\-byte string (plus tailing '\\0')
 of the form 1b4e28ba\-2fa1\-11d2\-883f\-b9a76 and stores this value in the
 character string pointed to by
-.IR out .
-.SH "CONFORMING TO"
-OSF DCE 1.1
+.IR out .  
+The case of the hex digits returned by 
+.B uuid_unparse
+may be upper or lower case, and is
+dependent on the system-dependent local default.  
+.PP
+If the case of the
+hex digits is important then the functions
+.B uuid_unparse_upper
+and 
+.B uuid_unparse_lower
+may be used.
 .SH AUTHOR
 .B uuid_unparse
 was written by Theodore Y. Ts'o for the ext2 filesystem utilties.