void zuuid_test (bool verbose) { printf (" * zuuid: "); // @selftest // Simple create/destroy test zuuid_t *uuid = zuuid_new (); assert (uuid); assert (zuuid_size (uuid) == 16); assert (strlen (zuuid_str (uuid)) == 32); 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 [16]; zuuid_export (uuid, copy_uuid); zuuid_set (uuid, copy_uuid); assert (streq (zuuid_str (uuid), myuuid)); zuuid_destroy (&uuid); zuuid_destroy (©); // @end printf ("OK\n"); }
void zproto_example_set_identifier (zproto_example_t *self, zuuid_t *uuid) { assert (self); zuuid_destroy (&self->identifier); self->identifier = zuuid_dup (uuid); }
void xrap_traffic_set_sender (xrap_traffic_t *self, zuuid_t *uuid) { assert (self); zuuid_destroy (&self->sender); self->sender = zuuid_dup (uuid); }
void zuuid_test (bool verbose) { printf (" * zuuid: "); // @selftest // 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"; const char *myuuid2 = "8CB3E9A9-649B-4BEF-8DE2-25E9C2CEBB38"; const char *myuuid3 = "{8CB3E9A9-649B-4BEF-8DE2-25E9C2CEBB38}"; const char *myuuid4 = "8CB3E9A9649B4BEF8DE225E9C2CEBB3838"; int rc = zuuid_set_str (uuid, myuuid); assert (rc == 0); assert (streq (zuuid_str (uuid), myuuid)); rc = zuuid_set_str (uuid, myuuid2); assert (rc == 0); assert (streq (zuuid_str (uuid), myuuid)); rc = zuuid_set_str (uuid, myuuid3); assert (rc == 0); assert (streq (zuuid_str (uuid), myuuid)); rc = zuuid_set_str (uuid, myuuid4); assert (rc == -1); byte copy_uuid [ZUUID_LEN]; zuuid_export (uuid, copy_uuid); zuuid_set (uuid, copy_uuid); assert (streq (zuuid_str (uuid), myuuid)); // Check the canonical string format assert (streq (zuuid_str_canonical (uuid), "8cb3e9a9-649b-4bef-8de2-25e9c2cebb38")); zuuid_destroy (&uuid); zuuid_destroy (©); // @end printf ("OK\n"); }
zyre_peer_t * zyre_peer_new (zhash_t *container, zuuid_t *uuid) { zyre_peer_t *self = (zyre_peer_t *) zmalloc (sizeof (zyre_peer_t)); self->uuid = zuuid_dup (uuid); self->ready = false; self->connected = false; self->sent_sequence = 0; self->want_sequence = 0; // Insert into container if requested if (container) { int rc = zhash_insert (container, zuuid_str (self->uuid), self); assert (rc == 0); zhash_freefn (container, zuuid_str (self->uuid), s_delete_peer); } return self; }
/// // Make copy of UUID object; if uuid is null, or memory was exhausted, // returns null. QZuuid * QZuuid::dup () { QZuuid *rv = new QZuuid (zuuid_dup (self)); return rv; }