Logo Search packages:      
Sourcecode: avahi version File versions  Download package

int avahi_is_valid_fqdn ( const char *  t  ) 

Return 1 when the specified string contains a valid FQDN host name (i.e. with more than one label and non-numerical), 0 otherwise.

Since:
0.6.9

Definition at line 575 of file domain.c.

References AVAHI_DOMAIN_NAME_MAX, and AVAHI_LABEL_MAX.

                                       {
    char label[AVAHI_LABEL_MAX];
    char normalized[AVAHI_DOMAIN_NAME_MAX];
    const char *k = t;
    AvahiAddress a;
    assert(t);

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

    if (!avahi_is_valid_domain_name(t))
        return 0;

    /* Check if there are at least two labels*/
    if (!(avahi_unescape_label(&k, label, sizeof(label))))
        return 0;

    if (label[0] == 0 || !k)
        return 0;

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

    if (label[0] == 0 || !k)
        return 0;

    /* Make sure that the name is not an IP address */
    if (!(avahi_normalize_name(t, normalized, sizeof(normalized))))
        return 0;

    if (avahi_address_parse(normalized, AVAHI_PROTO_UNSPEC, &a))
        return 0;

    return 1;
}


Generated by  Doxygen 1.6.0   Back to index