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

char* avahi_string_list_to_string ( AvahiStringList l  ) 

Convert the string list object to a single character string, seperated by spaces and enclosed in "". avahi_free() the result! This function doesn't work well with strings that contain NUL bytes.

Definition at line 133 of file strlst.c.

References avahi_new, AvahiStringList::next, AvahiStringList::size, and AvahiStringList::text.

                                                      {
    AvahiStringList *n;
    size_t s = 0;
    char *t, *e;

    for (n = l; n; n = n->next) {
        if (n != l)
            s ++;

        s += n->size+2;
    }

    if (!(t = e = avahi_new(char, s+1)))
        return NULL;

    l = avahi_string_list_reverse(l);
    
    for (n = l; n; n = n->next) {
        if (n != l)
            *(e++) = ' ';

        *(e++) = '"';
        strncpy(e, (char*) n->text, n->size);
        e[n->size] = 0;
        e = strchr(e, 0);
        *(e++) = '"';

        assert(e);
    }

    l = avahi_string_list_reverse(l);
    
    *e = 0;

    return t;
}


Generated by  Doxygen 1.6.0   Back to index