diff options
author | Theodore Ts'o <tytso@mit.edu> | 2004-03-22 16:22:28 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2004-03-22 16:22:28 -0500 |
commit | d3d741fc383d3eb1f8636393bc1c68c9bd467cc0 (patch) | |
tree | 5a6a7ac78e611c2348ca58651a7c4324b47501d7 /lib | |
parent | 6c6f170cbfed1eeddc545cf1974d0ac997b749b8 (diff) | |
download | e2fsprogs-d3d741fc383d3eb1f8636393bc1c68c9bd467cc0.tar.gz |
Add the uuid_unparse_upper and uuid_unparse_lower functions to the
uuid library.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/uuid/ChangeLog | 5 | ||||
-rw-r--r-- | lib/uuid/unparse.c | 31 | ||||
-rw-r--r-- | lib/uuid/uuid.h | 2 | ||||
-rw-r--r-- | lib/uuid/uuid_unparse.3.in | 17 |
4 files changed, 49 insertions, 6 deletions
diff --git a/lib/uuid/ChangeLog b/lib/uuid/ChangeLog index e6de9f00..7a043a1f 100644 --- a/lib/uuid/ChangeLog +++ b/lib/uuid/ChangeLog @@ -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 diff --git a/lib/uuid/unparse.c b/lib/uuid/unparse.c index b5b9f58b..c0e08ef4 100644 --- a/lib/uuid/unparse.c +++ b/lib/uuid/unparse.c @@ -36,16 +36,41 @@ #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); +} diff --git a/lib/uuid/uuid.h b/lib/uuid/uuid.h index a037c7bc..ff5459ed 100644 --- a/lib/uuid/uuid.h +++ b/lib/uuid/uuid.h @@ -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); diff --git a/lib/uuid/uuid_unparse.3.in b/lib/uuid/uuid_unparse.3.in index 7099ed22..80aa9a81 100644 --- a/lib/uuid/uuid_unparse.3.in +++ b/lib/uuid/uuid_unparse.3.in @@ -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. |