diff options
Diffstat (limited to 'avahi-common')
-rw-r--r-- | avahi-common/strlst.c | 12 | ||||
-rw-r--r-- | avahi-common/strlst.h | 5 |
2 files changed, 17 insertions, 0 deletions
diff --git a/avahi-common/strlst.c b/avahi-common/strlst.c index 0853414..d962188 100644 --- a/avahi-common/strlst.c +++ b/avahi-common/strlst.c @@ -243,3 +243,15 @@ AvahiStringList *avahi_string_list_copy(const AvahiStringList *l) { return string_list_reverse(r); } + +AvahiStringList *avahi_string_list_new_from_array(const gchar *array[], gint length) { + AvahiStringList *r = NULL; + gint index; + + g_assert(array); + + for (index = 0; length >= 0 ? index < length : !!array[index]; index++) + r = avahi_string_list_add(r, array[index]); + + return r; +} diff --git a/avahi-common/strlst.h b/avahi-common/strlst.h index 01a2c41..85a16f4 100644 --- a/avahi-common/strlst.h +++ b/avahi-common/strlst.h @@ -49,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); |