summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorKeith M Wesolowski <wesolows@foobazco.org>2014-04-14 16:03:11 +0000
committerKeith M Wesolowski <wesolows@foobazco.org>2014-04-14 16:03:11 +0000
commitc6792ab8e3a90c6f7a922910f3f393c566900010 (patch)
tree4d92a99b367fd1fd0062b31991cabde8471712bb /usr/src
parentd1061eade4daa793a479465665e5329050dd5609 (diff)
parent0b5ce10aee80822ecc7df77df92a5e24078ba196 (diff)
downloadillumos-joyent-c6792ab8e3a90c6f7a922910f3f393c566900010.tar.gz
[illumos-gate merge]
commit 0b5ce10aee80822ecc7df77df92a5e24078ba196 4118 libuuid should provide uuid_unparse_{upper,lower} functions
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/head/uuid/uuid.h8
-rw-r--r--usr/src/lib/libuuid/common/mapfile-vers7
-rw-r--r--usr/src/lib/libuuid/common/uuid.c39
-rw-r--r--usr/src/man/man3uuid/Makefile7
-rw-r--r--usr/src/man/man3uuid/uuid_clear.3uuid35
-rw-r--r--usr/src/pkg/manifests/system-library.man3uuid.inc5
6 files changed, 80 insertions, 21 deletions
diff --git a/usr/src/head/uuid/uuid.h b/usr/src/head/uuid/uuid.h
index 570a2c0912..78d3c7dedc 100644
--- a/usr/src/head/uuid/uuid.h
+++ b/usr/src/head/uuid/uuid.h
@@ -24,11 +24,13 @@
* Use is subject to license terms.
*/
+/*
+ * Copyright 2014 Andrew Stormont.
+ */
+
#ifndef _UUID_H
#define _UUID_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -65,6 +67,8 @@ extern void uuid_generate_time(uuid_t);
extern void uuid_copy(uuid_t, uuid_t);
extern void uuid_clear(uuid_t);
extern void uuid_unparse(uuid_t, char *);
+extern void uuid_unparse_lower(uuid_t, char *);
+extern void uuid_unparse_upper(uuid_t, char *);
extern int uuid_compare(uuid_t, uuid_t);
extern int uuid_is_null(uuid_t);
extern int uuid_parse(char *, uuid_t);
diff --git a/usr/src/lib/libuuid/common/mapfile-vers b/usr/src/lib/libuuid/common/mapfile-vers
index 6cea7998d1..cac86f666a 100644
--- a/usr/src/lib/libuuid/common/mapfile-vers
+++ b/usr/src/lib/libuuid/common/mapfile-vers
@@ -20,6 +20,7 @@
#
#
# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2014 Andrew Stormont.
#
#
@@ -38,6 +39,12 @@
$mapfile_version 2
+SYMBOL_VERSION ILLUMOS_0.1 {
+ global:
+ uuid_unparse_lower;
+ uuid_unparse_upper;
+} SUNW_1.1;
+
SYMBOL_VERSION SUNW_1.1 {
global:
uuid_clear;
diff --git a/usr/src/lib/libuuid/common/uuid.c b/usr/src/lib/libuuid/common/uuid.c
index d0601e4fbf..6e9d9cb439 100644
--- a/usr/src/lib/libuuid/common/uuid.c
+++ b/usr/src/lib/libuuid/common/uuid.c
@@ -23,6 +23,7 @@
* Use is subject to license terms.
* Copyright 2012 Milan Jurik. All rights reserved.
* Copyright 2013 Joyent, Inc. All rights reserved.
+ * Copyright 2014 Andrew Stormont.
*/
/*
@@ -578,8 +579,8 @@ uuid_clear(uuid_t uu)
* binary format into a 36-byte string (plus trailing null char)
* and stores this value in the character string pointed to by out.
*/
-void
-uuid_unparse(uuid_t uu, char *out)
+static void
+uuid_unparse_common(uuid_t uu, char *out, boolean_t upper)
{
struct uuid uuid;
uint16_t clock_seq;
@@ -591,26 +592,44 @@ uuid_unparse(uuid_t uu, char *out)
return;
}
- /* XXX user should have allocated enough memory */
- /*
- * if (strlen(out) < UUID_PRINTABLE_STRING_LENGTH) {
- * return;
- * }
- */
string_to_struct(&uuid, uu);
clock_seq = uuid.clock_seq_hi_and_reserved;
clock_seq = (clock_seq << 8) | uuid.clock_seq_low;
for (i = 0; i < 6; i++) {
- (void) sprintf(&etheraddr[index++], "%.2x", uuid.node_addr[i]);
+ (void) sprintf(&etheraddr[index++], upper ? "%.2X" : "%.2x",
+ uuid.node_addr[i]);
index++;
}
etheraddr[index] = '\0';
- (void) snprintf(out, 25, "%08x-%04x-%04x-%04x-",
+ (void) snprintf(out, 25,
+ upper ? "%08X-%04X-%04X-%04X-" : "%08x-%04x-%04x-%04x-",
uuid.time_low, uuid.time_mid, uuid.time_hi_and_version, clock_seq);
(void) strlcat(out, etheraddr, UUID_PRINTABLE_STRING_LENGTH);
}
+void
+uuid_unparse_upper(uuid_t uu, char *out)
+{
+ uuid_unparse_common(uu, out, B_TRUE);
+}
+
+void
+uuid_unparse_lower(uuid_t uu, char *out)
+{
+ uuid_unparse_common(uu, out, B_FALSE);
+}
+
+void
+uuid_unparse(uuid_t uu, char *out)
+{
+ /*
+ * Historically uuid_unparse on Solaris returns lower case,
+ * for compatibility we preserve this behaviour.
+ */
+ uuid_unparse_common(uu, out, B_FALSE);
+}
+
/*
* The uuid_is_null function compares the value of the supplied
* UUID variable uu to the NULL value. If the value is equal
diff --git a/usr/src/man/man3uuid/Makefile b/usr/src/man/man3uuid/Makefile
index 52ee447875..bcdd8c3b12 100644
--- a/usr/src/man/man3uuid/Makefile
+++ b/usr/src/man/man3uuid/Makefile
@@ -12,6 +12,7 @@
#
# Copyright 2011, Richard Lowe
# Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+# Copyright 2014 Andrew Stormont.
#
include $(SRC)/Makefile.master
@@ -28,7 +29,9 @@ MANLINKS= uuid_compare.3uuid \
uuid_is_null.3uuid \
uuid_parse.3uuid \
uuid_time.3uuid \
- uuid_unparse.3uuid
+ uuid_unparse.3uuid \
+ uuid_unparse_lower.3uuid \
+ uuid_unparse_upper.3uuid
uuid_compare.3uuid := LINKSRC = uuid_clear.3uuid
uuid_copy.3uuid := LINKSRC = uuid_clear.3uuid
@@ -39,6 +42,8 @@ uuid_is_null.3uuid := LINKSRC = uuid_clear.3uuid
uuid_parse.3uuid := LINKSRC = uuid_clear.3uuid
uuid_time.3uuid := LINKSRC = uuid_clear.3uuid
uuid_unparse.3uuid := LINKSRC = uuid_clear.3uuid
+uuid_unparse_lower.3uuid := LINKSRC = uuid_clear.3uuid
+uuid_unparse_upper.3uuid := LINKSRC = uuid_clear.3uuid
.KEEP_STATE:
diff --git a/usr/src/man/man3uuid/uuid_clear.3uuid b/usr/src/man/man3uuid/uuid_clear.3uuid
index bcea26d14c..fc2cc86bf0 100644
--- a/usr/src/man/man3uuid/uuid_clear.3uuid
+++ b/usr/src/man/man3uuid/uuid_clear.3uuid
@@ -1,13 +1,15 @@
'\" te
.\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
+.\" Copyright 2014 Andrew Stormont.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH UUID_CLEAR 3UUID "Jan 16, 2006"
+.TH UUID_CLEAR 3UUID "Apr 9, 2014"
.SH NAME
uuid_clear, uuid_compare, uuid_copy, uuid_generate, uuid_generate_random,
-uuid_generate_time, uuid_is_null, uuid_parse, uuid_time, uuid_unparse \-
-universally unique identifier (UUID) operations
+uuid_generate_time, uuid_is_null, uuid_parse, uuid_time, uuid_unparse,
+uuid_unparse_lower, uuid_unparse_upper \- universally unique identifier (UUID)
+operations
.SH SYNOPSIS
.LP
.nf
@@ -62,6 +64,16 @@ cc [ \fIflag \&.\|.\|.\fR ] \fIfile\fR\&.\|.\|. \fB-luuid\fR [ \fIlibrary \&.\|.
\fBvoid\fR \fBuuid_unparse\fR(\fBuuid_t\fR \fIuu\fR, \fBchar *\fR\fIout\fR);
.fi
+.LP
+.nf
+\fBvoid\fR \fBuuid_unparse_lower\fR(\fBuuid_t\fR \fIuu\fR, \fBchar *\fR\fIout\fR);
+.fi
+
+.LP
+.nf
+\fBvoid\fR \fBuuid_unparse_upper\fR(\fBuuid_t\fR \fIuu\fR, \fBchar *\fR\fIout\fR);
+.fi
+
.SH DESCRIPTION
.sp
.LP
@@ -121,11 +133,18 @@ seconds and microseconds since the epoch is also stored in the location pointed
to by \fBret_tv\fR (see \fBgettimeofday\fR(3C)).
.sp
.LP
-The \fBuuid_unparse()\fR function converts the specified UUID \fIuu\fR from the
-internal binary format to a string of the length defined in the \fBuuid.h\fR
-macro, \fBUUID_PRINTABLE_STRING_LENGTH\fR, which includes the trailing null
-character. The resulting value is stored in the character string pointed to by
-\fIout\fR.
+The \fBuuid_unparse()\fR and \fBuuid_unparse_lower()\fR functions convert the
+specified UUID \fIuu\fR from the internal binary format to a lower case string
+of the length defined in the \fBuuid.h\fR macro,
+\fBUUID_PRINTABLE_STRING_LENGTH\fR, which includes the trailing null character.
+The resulting value is stored in the character string pointed to by \fIout\fR.
+.sp
+.LP
+The \fBuuid_unparse_upper()\fR function converts the specified UUID \fIuu\fR
+from the internal binary format to a upper case string of the length defined in
+the \fBuuid.h\fR macro, \fBUUID_PRINTABLE_STRING_LENGTH\fR, which includes the
+trailing null character. The resulting value is stored in the character string
+pointed to by \fIout\fR.
.SH ATTRIBUTES
.sp
.LP
diff --git a/usr/src/pkg/manifests/system-library.man3uuid.inc b/usr/src/pkg/manifests/system-library.man3uuid.inc
index a9921efd5c..dff46d8a68 100644
--- a/usr/src/pkg/manifests/system-library.man3uuid.inc
+++ b/usr/src/pkg/manifests/system-library.man3uuid.inc
@@ -12,6 +12,7 @@
#
# Copyright 2011, Richard Lowe
# Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+# Copyright 2014 Andrew Stormont.
#
file path=usr/share/man/man3uuid/uuid_clear.3uuid
@@ -26,3 +27,7 @@ link path=usr/share/man/man3uuid/uuid_is_null.3uuid target=uuid_clear.3uuid
link path=usr/share/man/man3uuid/uuid_parse.3uuid target=uuid_clear.3uuid
link path=usr/share/man/man3uuid/uuid_time.3uuid target=uuid_clear.3uuid
link path=usr/share/man/man3uuid/uuid_unparse.3uuid target=uuid_clear.3uuid
+link path=usr/share/man/man3uuid/uuid_unparse_lower.3uuid \
+ target=uuid_clear.3uuid
+link path=usr/share/man/man3uuid/uuid_unparse_upper.3uuid \
+ target=uuid_clear.3uuid