X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-common%2Fstrlst.h;h=a4a4202a19c16ca9ca9f1962b3b10b60d85811e9;hb=d859c4c4c0b5889af50355f6552fbcd2eae36bd3;hp=4fde8eb8b7e4ebaf0fcaf3250fc7a88495bc1646;hpb=9962a048634c590db23a00db1d01daada779844c;p=catta diff --git a/avahi-common/strlst.h b/avahi-common/strlst.h index 4fde8eb..a4a4202 100644 --- a/avahi-common/strlst.h +++ b/avahi-common/strlst.h @@ -23,9 +23,14 @@ ***/ #include +#include + +/** \file strlst.h Implementation of a data type to store lists of strings */ + +AVAHI_C_DECL_BEGIN /** Linked list of strings that can contain any number of binary - * characters, include NUL bytes. An empty list is created by + * characters, including NUL bytes. An empty list is created by * assigning a NULL to a pointer to AvahiStringList. The string list * is stored in reverse order, so that appending to the string list is * effectively a prepending to the linked list. This object is used @@ -44,6 +49,11 @@ AvahiStringList *avahi_string_list_new(const gchar *txt, ...); /** Same as avahi_string_list_new() but pass a va_list structure */ AvahiStringList *avahi_string_list_new_va(va_list va); +/** Create a new string list from a string array. The strings are + * copied using g_strdup(). length should contain the length of the + * array, or -1 if the array is NULL terminated*/ +AvahiStringList *avahi_string_list_new_from_array(const gchar **array, gint length); + /** Free a string list */ void avahi_string_list_free(AvahiStringList *l); @@ -52,10 +62,17 @@ void avahi_string_list_free(AvahiStringList *l); * start. */ AvahiStringList *avahi_string_list_add(AvahiStringList *l, const gchar *text); -/** Append am arbitrary length byte string to the list. Returns the +/** Append an arbitrary length byte string to the list. Returns the * new list start. */ AvahiStringList *avahi_string_list_add_arbitrary(AvahiStringList *l, const guint8 *text, guint size); +/** Append a new entry to the string list. The string is not filled +with data. The caller should fill in string data afterwards by writing +it to l->text, where l is the pointer returned by this function. This +function exists solely to optimize a few operations where otherwise +superfluous string copying would be necessary. */ +AvahiStringList*avahi_string_list_add_anonymous(AvahiStringList *l, guint size); + /** Same as avahi_string_list_add(), but takes a variable number of * NUL terminated strings. The argument list must be terminated by a * NULL pointer. Returns the new list start. */ @@ -83,5 +100,14 @@ gboolean avahi_string_list_equal(const AvahiStringList *a, const AvahiStringList /** Copy a string list */ AvahiStringList *avahi_string_list_copy(const AvahiStringList *l); +/** Reverse the string list. */ +AvahiStringList* avahi_string_list_reverse(AvahiStringList *l); + +/** Return the number of elements in the string list */ +guint avahi_string_list_length(const AvahiStringList *l); + + +AVAHI_C_DECL_END + #endif