X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-common%2Fstrlst.h;h=26708a52d68d820e03f72e31fdf99218716ecc38;hb=ef51c776fa80e67b84e2a6d48829f9040ac76c20;hp=b4e387705a8f813922de27e9e61c02c45385cbb9;hpb=f61b06f15ae185410e4d5795b4fd22aeb08bbb56;p=catta diff --git a/avahi-common/strlst.h b/avahi-common/strlst.h index b4e3877..26708a5 100644 --- a/avahi-common/strlst.h +++ b/avahi-common/strlst.h @@ -40,7 +40,7 @@ AVAHI_C_DECL_BEGIN * effectively a prepending to the linked list. This object is used * primarily for storing DNS TXT record data. */ typedef struct AvahiStringList { - struct AvahiStringList *next; /**< Pointe to the next linked list element */ + struct AvahiStringList *next; /**< Pointer to the next linked list element */ size_t size; /**< Size of text[] */ uint8_t text[1]; /**< Character data */ } AvahiStringList; @@ -93,7 +93,7 @@ AvahiStringList *avahi_string_list_add_many(AvahiStringList *r, ...) AVAHI_GCC_S AvahiStringList *avahi_string_list_add_many_va(AvahiStringList *r, va_list va); /** Convert the string list object to a single character string, - * seperated by spaces and enclosed in "". g_free() the result! This + * seperated by spaces and enclosed in "". avahi_free() the result! This * function doesn't work well with string that contain NUL bytes. */ char* avahi_string_list_to_string(AvahiStringList *l); @@ -102,7 +102,7 @@ char* avahi_string_list_to_string(AvahiStringList *l); size_t avahi_string_list_serialize(AvahiStringList *l, void * data, size_t size); /** Inverse of avahi_string_list_serialize() */ -AvahiStringList *avahi_string_list_parse(const void *data, size_t size); +int avahi_string_list_parse(const void *data, size_t size, AvahiStringList **ret); /** Compare to string lists */ int avahi_string_list_equal(const AvahiStringList *a, const AvahiStringList *b); @@ -116,6 +116,36 @@ AvahiStringList* avahi_string_list_reverse(AvahiStringList *l); /** Return the number of elements in the string list */ unsigned avahi_string_list_length(const AvahiStringList *l); +/** Find the string list entry for the given DNS-SD TXT key */ +AvahiStringList *avahi_string_list_find(AvahiStringList *l, const char *key); + +/** 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. */ +int avahi_string_list_get_pair(AvahiStringList *l, char **key, char **value, size_t *size); + +/** Add a new DNS-SD TXT key value pair to the string list. value may + * be NULL in case you want to specify a key without a value */ +AvahiStringList *avahi_string_list_add_pair(AvahiStringList *l, const char *key, const char *value); + +/** Same as avahi_string_list_add_pair() but allow strings containing NUL bytes in *value. */ +AvahiStringList *avahi_string_list_add_pair_arbitrary(AvahiStringList *l, const char *key, const uint8_t *value, size_t size); + +/** Returns the next item in the string list */ +AvahiStringList *avahi_string_list_get_next(AvahiStringList *l); + +/** Returns the text for the current item */ +uint8_t *avahi_string_list_get_text(AvahiStringList *l); + +/** Returns the size of the current text */ +size_t avahi_string_list_get_size(AvahiStringList *l); + +/** Try to find a magic service cookie in the specified DNS-SD string + * list. Or return AVAHI_SERVICE_COOKIE_INVALID if none is found. */ +uint32_t avahi_string_list_get_service_cookie(AvahiStringList *l); + AVAHI_C_DECL_END #endif