Logo Search packages:      
Sourcecode: avahi version File versions

char* avahi_normalize_name ( const char *  s,
char *  ret_s,
size_t  size 
)

Normalize a domain name into canonical form. This drops trailing dots and removes useless backslash escapes.

Definition at line 180 of file domain.c.

References AVAHI_LABEL_MAX.

                                                                    {
    int empty = 1;
    char *r;
    
    assert(s);
    assert(ret_s);
    assert(size > 0);

    r = ret_s;
    *ret_s = 0;

    while (*s) {
        char label[AVAHI_LABEL_MAX];

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

        if (label[0] == 0) {

            if (*s == 0 && empty)
                return ret_s;

            return NULL;
        }
        
        if (!empty) {
            if (size < 1)
                return NULL;
            
            *(r++) = '.';
            size--;
            
        } else
            empty = 0;
            
        avahi_escape_label(label, strlen(label), &r, &size);
    }

    return ret_s;
}


Generated by  Doxygen 1.6.0   Back to index