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

int avahi_string_list_get_pair ( AvahiStringList l,
char **  key,
char **  value,
size_t *  size 
)

Return the DNS-SD TXT key and value for the specified string list item. If size is not NULL it will be filled with the length of value. (for strings containing NUL bytes). If the entry doesn't contain a value *value will be set to NULL. You need to avahi_free() the strings returned in *key and *value.

Definition at line 423 of file strlst.c.

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

                                                                                           {
    char *e;

    assert(l);

    if (!(e = memchr(l->text, '=', l->size))) {

        if (key)
            if (!(*key = avahi_strdup((char*) l->text)))
                return -1;

        if (value)
            *value = NULL;

        if (size)
            *size = 0;

    } else {
        size_t n;

        if (key)
            if (!(*key = avahi_strndup((char*) l->text, e - (char *) l->text)))
                return -1;

        e++; /* Advance after '=' */

        n = l->size - (e - (char*) l->text);

        if (value) {

            if (!(*value = avahi_memdup(e, n+1))) {
                if (key)
                    avahi_free(*key);
                return -1;
            }

            (*value)[n] = 0;
        }

        if (size)
            *size = n;
    }

    return 0;
}


Generated by  Doxygen 1.6.0   Back to index