Logo Search packages:      
Sourcecode: avahi version File versions

int avahi_is_valid_domain_name ( const char *  t  ) 

Return 1 when the specified string contains a valid domain name, 0 otherwise

Definition at line 371 of file domain.c.

References AVAHI_DOMAIN_NAME_MAX, and AVAHI_LABEL_MAX.

                                              {
    int is_first = 1;
    assert(t);

    if (strlen(t) >= AVAHI_DOMAIN_NAME_MAX)
        return 0;

    do {
        char label[AVAHI_LABEL_MAX];

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

        /* Explicitly allow the root domain name */
        if (is_first && label[0] == 0 && *t == 0)
            return 1;
        
        is_first = 0;
        
        if (label[0] == 0)
            return 0;
        
    } while (*t);

    return 1;
}


Generated by  Doxygen 1.6.0   Back to index