예제 #1
0
파일: zuuid.c 프로젝트: wy182000/czmq
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 (&copy);
    //  @end

    printf ("OK\n");
}
예제 #2
0
///
//  Return UUID in the canonical string format: 8-4-4-4-12, in lower
//  case. Caller does not modify or free returned value. See        
//  http://en.wikipedia.org/wiki/Universally_unique_identifier      
const QString QZuuid::strCanonical ()
{
    const QString rv = QString (zuuid_str_canonical (self));
    return rv;
}
예제 #3
0
///
//  Return UUID in the canonical string format: 8-4-4-4-12, in lower
//  case. Caller does not modify or free returned value. See        
//  http://en.wikipedia.org/wiki/Universally_unique_identifier      
const QString QmlZuuid::strCanonical () {
    return QString (zuuid_str_canonical (self));
};
예제 #4
0
파일: zuuid.c 프로젝트: wy182000/czmq
void
zuuid_print (zuuid_t *self)
{
    printf ("%s", zuuid_str_canonical (self));
}
예제 #5
0
void
zproto_example_print (zproto_example_t *self)
{
    assert (self);
    switch (self->id) {
        case ZPROTO_EXAMPLE_LOG:
            zsys_debug ("ZPROTO_EXAMPLE_LOG:");
            zsys_debug ("    sequence=%ld", (long) self->sequence);
            zsys_debug ("    version=3");
            zsys_debug ("    level=%ld", (long) self->level);
            zsys_debug ("    event=%ld", (long) self->event);
            zsys_debug ("    node=%ld", (long) self->node);
            zsys_debug ("    peer=%ld", (long) self->peer);
            zsys_debug ("    time=%ld", (long) self->time);
            zsys_debug ("    host='%s'", self->host);
            if (self->data)
                zsys_debug ("    data='%s'", self->data);
            else
                zsys_debug ("    data=");
            break;

        case ZPROTO_EXAMPLE_STRUCTURES:
            zsys_debug ("ZPROTO_EXAMPLE_STRUCTURES:");
            zsys_debug ("    sequence=%ld", (long) self->sequence);
            zsys_debug ("    aliases=");
            if (self->aliases) {
                char *aliases = (char *) zlist_first (self->aliases);
                while (aliases) {
                    zsys_debug ("        '%s'", aliases);
                    aliases = (char *) zlist_next (self->aliases);
                }
            }
            zsys_debug ("    headers=");
            if (self->headers) {
                char *item = (char *) zhash_first (self->headers);
                while (item) {
                    zsys_debug ("        %s=%s", zhash_cursor (self->headers), item);
                    item = (char *) zhash_next (self->headers);
                }
            }
            else
                zsys_debug ("(NULL)");
            break;

        case ZPROTO_EXAMPLE_BINARY:
            zsys_debug ("ZPROTO_EXAMPLE_BINARY:");
            zsys_debug ("    sequence=%ld", (long) self->sequence);
            zsys_debug ("    flags=[ ... ]");
            zsys_debug ("    public_key=[ ... ]");
            zsys_debug ("    identifier=");
            if (self->identifier)
                zsys_debug ("        %s", zuuid_str_canonical (self->identifier));
            else
                zsys_debug ("        (NULL)");
            zsys_debug ("    address=");
            if (self->address)
                zframe_print (self->address, NULL);
            else
                zsys_debug ("(NULL)");
            zsys_debug ("    content=");
            if (self->content)
                zmsg_print (self->content);
            else
                zsys_debug ("(NULL)");
            break;

        case ZPROTO_EXAMPLE_TYPES:
            zsys_debug ("ZPROTO_EXAMPLE_TYPES:");
            zsys_debug ("    sequence=%ld", (long) self->sequence);
            zsys_debug ("    client_forename='%s'", self->client_forename);
            zsys_debug ("    client_surname='%s'", self->client_surname);
            zsys_debug ("    client_mobile='%s'", self->client_mobile);
            zsys_debug ("    client_email='%s'", self->client_email);
            zsys_debug ("    supplier_forename='%s'", self->supplier_forename);
            zsys_debug ("    supplier_surname='%s'", self->supplier_surname);
            zsys_debug ("    supplier_mobile='%s'", self->supplier_mobile);
            zsys_debug ("    supplier_email='%s'", self->supplier_email);
            break;

    }
}
예제 #6
0
void
xrap_traffic_print (xrap_traffic_t *self)
{
    assert (self);
    switch (self->id) {
        case XRAP_TRAFFIC_CONNECTION_OPEN:
            zsys_debug ("XRAP_TRAFFIC_CONNECTION_OPEN:");
            zsys_debug ("    protocol=malamute");
            zsys_debug ("    version=1");
            zsys_debug ("    address='%s'", self->address);
            break;

        case XRAP_TRAFFIC_CONNECTION_PING:
            zsys_debug ("XRAP_TRAFFIC_CONNECTION_PING:");
            break;

        case XRAP_TRAFFIC_CONNECTION_PONG:
            zsys_debug ("XRAP_TRAFFIC_CONNECTION_PONG:");
            break;

        case XRAP_TRAFFIC_CONNECTION_CLOSE:
            zsys_debug ("XRAP_TRAFFIC_CONNECTION_CLOSE:");
            break;

        case XRAP_TRAFFIC_XRAP_SEND:
            zsys_debug ("XRAP_TRAFFIC_XRAP_SEND:");
            zsys_debug ("    timeout=%ld", (long) self->timeout);
            zsys_debug ("    content=");
            if (self->content)
                zmsg_print (self->content);
            else
                zsys_debug ("(NULL)");
            break;

        case XRAP_TRAFFIC_XRAP_OFFER:
            zsys_debug ("XRAP_TRAFFIC_XRAP_OFFER:");
            zsys_debug ("    route='%s'", self->route);
            zsys_debug ("    method='%s'", self->method);
            break;

        case XRAP_TRAFFIC_XRAP_DELIVER:
            zsys_debug ("XRAP_TRAFFIC_XRAP_DELIVER:");
            zsys_debug ("    sender=");
            if (self->sender)
                zsys_debug ("        %s", zuuid_str_canonical (self->sender));
            else
                zsys_debug ("        (NULL)");
            zsys_debug ("    content=");
            if (self->content)
                zmsg_print (self->content);
            else
                zsys_debug ("(NULL)");
            break;

        case XRAP_TRAFFIC_OK:
            zsys_debug ("XRAP_TRAFFIC_OK:");
            zsys_debug ("    status_code=%ld", (long) self->status_code);
            zsys_debug ("    status_reason='%s'", self->status_reason);
            break;

        case XRAP_TRAFFIC_FAIL:
            zsys_debug ("XRAP_TRAFFIC_FAIL:");
            zsys_debug ("    status_code=%ld", (long) self->status_code);
            zsys_debug ("    status_reason='%s'", self->status_reason);
            break;

        case XRAP_TRAFFIC_ERROR:
            zsys_debug ("XRAP_TRAFFIC_ERROR:");
            zsys_debug ("    status_code=%ld", (long) self->status_code);
            zsys_debug ("    status_reason='%s'", self->status_reason);
            break;

    }
}