1ZUUID(3) CZMQ Manual ZUUID(3)
2
3
4
6 zuuid - Class for UUID support class
7
9 // This is a stable class, and may not change except for emergencies. It
10 // is provided in stable builds.
11 // Create a new UUID object.
12 CZMQ_EXPORT zuuid_t *
13 zuuid_new (void);
14
15 // Create UUID object from supplied ZUUID_LEN-octet value.
16 CZMQ_EXPORT zuuid_t *
17 zuuid_new_from (const byte *source);
18
19 // Destroy a specified UUID object.
20 CZMQ_EXPORT void
21 zuuid_destroy (zuuid_t **self_p);
22
23 // Set UUID to new supplied ZUUID_LEN-octet value.
24 CZMQ_EXPORT void
25 zuuid_set (zuuid_t *self, const byte *source);
26
27 // Set UUID to new supplied string value skipping '-' and '{' '}'
28 // optional delimiters. Return 0 if OK, else returns -1.
29 CZMQ_EXPORT int
30 zuuid_set_str (zuuid_t *self, const char *source);
31
32 // Return UUID binary data.
33 CZMQ_EXPORT const byte *
34 zuuid_data (zuuid_t *self);
35
36 // Return UUID binary size
37 CZMQ_EXPORT size_t
38 zuuid_size (zuuid_t *self);
39
40 // Returns UUID as string
41 CZMQ_EXPORT const char *
42 zuuid_str (zuuid_t *self);
43
44 // Return UUID in the canonical string format: 8-4-4-4-12, in lower
45 // case. Caller does not modify or free returned value. See
46 // http://en.wikipedia.org/wiki/Universally_unique_identifier
47 CZMQ_EXPORT const char *
48 zuuid_str_canonical (zuuid_t *self);
49
50 // Store UUID blob in target array
51 CZMQ_EXPORT void
52 zuuid_export (zuuid_t *self, byte *target);
53
54 // Check if UUID is same as supplied value
55 CZMQ_EXPORT bool
56 zuuid_eq (zuuid_t *self, const byte *compare);
57
58 // Check if UUID is different from supplied value
59 CZMQ_EXPORT bool
60 zuuid_neq (zuuid_t *self, const byte *compare);
61
62 // Make copy of UUID object; if uuid is null, or memory was exhausted,
63 // returns null.
64 CZMQ_EXPORT zuuid_t *
65 zuuid_dup (zuuid_t *self);
66
67 // Self test of this class.
68 CZMQ_EXPORT void
69 zuuid_test (bool verbose);
70
71 Please add '@interface' section in './../src/zuuid.c'.
72
74 The zuuid class generates UUIDs and provides methods for working with
75 them. If you build CZMQ with libuuid, on Unix/Linux, it will use that
76 library. On Windows it will use UuidCreate(). Otherwise it will use a
77 random number generator to produce convincing imitations of UUIDs.
78
79 Please add @discuss section in ./../src/zuuid.c.
80
82 From zuuid_test method.
83
84 // Simple create/destroy test
85 assert (ZUUID_LEN == 16);
86 assert (ZUUID_STR_LEN == 32);
87
88 zuuid_t *uuid = zuuid_new ();
89 assert (uuid);
90 assert (zuuid_size (uuid) == ZUUID_LEN);
91 assert (strlen (zuuid_str (uuid)) == ZUUID_STR_LEN);
92 zuuid_t *copy = zuuid_dup (uuid);
93 assert (streq (zuuid_str (uuid), zuuid_str (copy)));
94
95 // Check set/set_str/export methods
96 const char *myuuid = "8CB3E9A9649B4BEF8DE225E9C2CEBB38";
97 const char *myuuid2 = "8CB3E9A9-649B-4BEF-8DE2-25E9C2CEBB38";
98 const char *myuuid3 = "{8CB3E9A9-649B-4BEF-8DE2-25E9C2CEBB38}";
99 const char *myuuid4 = "8CB3E9A9649B4BEF8DE225E9C2CEBB3838";
100 int rc = zuuid_set_str (uuid, myuuid);
101 assert (rc == 0);
102 assert (streq (zuuid_str (uuid), myuuid));
103 rc = zuuid_set_str (uuid, myuuid2);
104 assert (rc == 0);
105 assert (streq (zuuid_str (uuid), myuuid));
106 rc = zuuid_set_str (uuid, myuuid3);
107 assert (rc == 0);
108 assert (streq (zuuid_str (uuid), myuuid));
109 rc = zuuid_set_str (uuid, myuuid4);
110 assert (rc == -1);
111 byte copy_uuid [ZUUID_LEN];
112 zuuid_export (uuid, copy_uuid);
113 zuuid_set (uuid, copy_uuid);
114 assert (streq (zuuid_str (uuid), myuuid));
115
116 // Check the canonical string format
117 assert (streq (zuuid_str_canonical (uuid),
118 "8cb3e9a9-649b-4bef-8de2-25e9c2cebb38"));
119
120 zuuid_destroy (&uuid);
121 zuuid_destroy (©);
122
123 #if defined (__WINDOWS__)
124 zsys_shutdown();
125 #endif
126
127
129 The czmq manual was written by the authors in the AUTHORS file.
130
132 Main web site:
133
134 Report bugs to the email <zeromq-dev@lists.zeromq.org[1]>
135
137 Copyright (c) the Contributors as noted in the AUTHORS file. This file
138 is part of CZMQ, the high-level C binding for 0MQ:
139 http://czmq.zeromq.org. This Source Code Form is subject to the terms
140 of the Mozilla Public License, v. 2.0. If a copy of the MPL was not
141 distributed with this file, You can obtain one at
142 http://mozilla.org/MPL/2.0/. LICENSE included with the czmq
143 distribution.
144
146 1. zeromq-dev@lists.zeromq.org
147 mailto:zeromq-dev@lists.zeromq.org
148
149
150
151CZMQ 4.1.1 01/31/2019 ZUUID(3)