Logo Search packages:      
Sourcecode: avahi version File versions

const char* avahi_get_type_from_subtype ( const char *  t  ) 

Return a pointer to the type section of a subtype i.e. _foo._sub._bar._tcp => _bar._tcp

Definition at line 308 of file domain.c.

References AVAHI_DOMAIN_NAME_MAX, and AVAHI_LABEL_MAX.

                                                       {
    char label[AVAHI_LABEL_MAX];
    const char *ret;
    assert(t);

    if (strlen(t) >= AVAHI_DOMAIN_NAME_MAX || !*t)
        return NULL;

    /* Subtype name */
    
    if (!(avahi_unescape_label(&t, label, sizeof(label))))
        return NULL;

    if (strlen(label) <= 2 || label[0] != '_')
        return NULL;

    if (!*t)
        return NULL;

    /* String "_sub" */
    
    if (!(avahi_unescape_label(&t, label, sizeof(label))))
        return NULL;

    if (strcasecmp(label, "_sub"))
        return NULL;

    if (!*t)
        return NULL;

    ret = t;
    
    /* Application name */

    if (!(avahi_unescape_label(&t, label, sizeof(label))))
        return NULL;

    if (strlen(label) <= 2 || label[0] != '_')
        return NULL;

    if (!*t)
        return NULL;
    
    /* _tcp or _udp boilerplate */
    
    if (!(avahi_unescape_label(&t, label, sizeof(label))))
        return NULL;

    if (strcasecmp(label, "_tcp") && strcasecmp(label, "_udp"))
        return NULL;

    if (*t)
        return NULL;

    return ret;
}


Generated by  Doxygen 1.6.0   Back to index