zuuid(3)
CZMQ Manual - CZMQ/3.0.1
Name
zuuid - UUID support class
Synopsis
// Constructor
CZMQ_EXPORT zuuid_t *
zuuid_new (void);
// Destructor
CZMQ_EXPORT void
zuuid_destroy (zuuid_t **self_p);
// Return UUID binary data
CZMQ_EXPORT byte *
zuuid_data (zuuid_t *self);
// Return UUID binary size
CZMQ_EXPORT size_t
zuuid_size (zuuid_t *self);
// Returns UUID as string
CZMQ_EXPORT char *
zuuid_str (zuuid_t *self);
// Return UUID as formatted string in the canonical format 8-4-4-4-12,
// lower case. The caller should free the freshly allocated string.
// See: http://en.wikipedia.org/wiki/Universally_unique_identifier
CZMQ_EXPORT char *
zuuid_formatted_str (zuuid_t *self);
// Set UUID to new supplied ZUUID_LEN-octet value
CZMQ_EXPORT void
zuuid_set (zuuid_t *self, byte *source);
// Set UUID to new supplied ZUUID_STR_LEN-char string value;
// return 0 if OK, else returns -1.
CZMQ_EXPORT int
zuuid_set_str (zuuid_t *self, const char *source);
// Store UUID blob in target array
CZMQ_EXPORT void
zuuid_export (zuuid_t *self, byte *target);
// Check if UUID is same as supplied value
CZMQ_EXPORT bool
zuuid_eq (zuuid_t *self, byte *compare);
// Check if UUID is different from supplied value
CZMQ_EXPORT bool
zuuid_neq (zuuid_t *self, byte *compare);
// Make copy of UUID object; if uuid is null, or memory was exhausted,
// returns null.
CZMQ_EXPORT zuuid_t *
zuuid_dup (zuuid_t *self);
// Self test of this class
CZMQ_EXPORT void
zuuid_test (bool verbose);
Description
The zuuid class generates UUIDs and provides methods for working with them. If you build CZMQ with libuuid, on Unix/Linux, it will use that library. On Windows it will use UuidCreate(). Otherwise it will use a random number generator to produce convincing imitations of uuids.
Example
From zuuid_test method
// Simple create/destroy test
assert (ZUUID_LEN == 16);
assert (ZUUID_STR_LEN == 32);
zuuid_t *uuid = zuuid_new ();
assert (uuid);
assert (zuuid_size (uuid) == ZUUID_LEN);
assert (strlen (zuuid_str (uuid)) == ZUUID_STR_LEN);
zuuid_t *copy = zuuid_dup (uuid);
assert (streq (zuuid_str (uuid), zuuid_str (copy)));
// Check set/set_str/export methods
const char *myuuid = "8CB3E9A9649B4BEF8DE225E9C2CEBB38";
zuuid_set_str (uuid, myuuid);
assert (streq (zuuid_str (uuid), myuuid));
byte copy_uuid [ZUUID_LEN];
zuuid_export (uuid, copy_uuid);
zuuid_set (uuid, copy_uuid);
assert (streq (zuuid_str (uuid), myuuid));
// Check the formatted string output
char *formatted_str = zuuid_formatted_str (uuid);
assert (streq (formatted_str, "8cb3e9a9-649b-4bef-8de2-25e9c2cebb38"));
zstr_free (&formatted_str);
zuuid_destroy (&uuid); zuuid_destroy (©);
See also
Authors
The CZMQ manual was written by Pieter Hintjens<moc.xitami|hp#moc.xitami|hp>.
Resources
Main web site: http://czmq.zeromq.org/
Report bugs to the ØMQ development mailing list: <gro.qmorez.stsil|ved-qmorez#gro.qmorez.stsil|ved-qmorez>
Copyright
Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for ØMQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.