avahi  0.7
strlst.h
Go to the documentation of this file.
1 #ifndef footxtlisthfoo
2 #define footxtlisthfoo
3 
4 /***
5  This file is part of avahi.
6 
7  avahi is free software; you can redistribute it and/or modify it
8  under the terms of the GNU Lesser General Public License as
9  published by the Free Software Foundation; either version 2.1 of the
10  License, or (at your option) any later version.
11 
12  avahi is distributed in the hope that it will be useful, but WITHOUT
13  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
15  Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License along with avahi; if not, write to the Free Software
19  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20  USA.
21 ***/
22 
25 #include <sys/types.h>
26 #include <inttypes.h>
27 #include <stdarg.h>
28 
29 #include <avahi-common/cdecl.h>
30 #include <avahi-common/gccmacro.h>
31 
32 AVAHI_C_DECL_BEGIN
33 
40 typedef struct AvahiStringList {
42  size_t size;
43  uint8_t text[1];
45 
51 AvahiStringList *avahi_string_list_new(const char *txt, ...) AVAHI_GCC_SENTINEL;
52 
55 AvahiStringList *avahi_string_list_new_va(va_list va);
61 AvahiStringList *avahi_string_list_new_from_array(const char **array, int length);
62 
65 
74 
76 AvahiStringList *avahi_string_list_add_printf(AvahiStringList *l, const char *format, ...) AVAHI_GCC_PRINTF_ATTR23;
77 
80 AvahiStringList *avahi_string_list_add_vprintf(AvahiStringList *l, const char *format, va_list va);
86 
93 
98 
102 AvahiStringList *avahi_string_list_add_many_va(AvahiStringList *r, va_list va);
113 
117 size_t avahi_string_list_serialize(AvahiStringList *l, void * data, size_t size);
118 
120 int avahi_string_list_parse(const void *data, size_t size, AvahiStringList **ret);
125 
128 
131 
133 unsigned avahi_string_list_length(const AvahiStringList *l);
134 
141 
144 
147 
154 
160 int avahi_string_list_get_pair(AvahiStringList *l, char **key, char **value, size_t *size);
161 
164 AvahiStringList *avahi_string_list_add_pair(AvahiStringList *l, const char *key, const char *value);
165 
167 AvahiStringList *avahi_string_list_add_pair_arbitrary(AvahiStringList *l, const char *key, const uint8_t *value, size_t size);
168 
174 uint32_t avahi_string_list_get_service_cookie(AvahiStringList *l);
177 AVAHI_C_DECL_END
178 
179 #endif
180 
size_t avahi_string_list_get_size(AvahiStringList *l)
Returns the size of the current text.
uint8_t text[1]
Character data.
Definition: strlst.h:43
void avahi_string_list_free(AvahiStringList *l)
Free a string list.
AvahiStringList * avahi_string_list_add_printf(AvahiStringList *l, const char *format,...) AVAHI_GCC_PRINTF_ATTR23
Append a new NUL terminated formatted string to the specified string list.
AvahiStringList * avahi_string_list_add_many(AvahiStringList *r,...) AVAHI_GCC_SENTINEL
Same as avahi_string_list_add(), but takes a variable number of NUL terminated strings.
AvahiStringList * avahi_string_list_add_anonymous(AvahiStringList *l, size_t size)
Append a new entry to the string list.
size_t size
Size of text[].
Definition: strlst.h:42
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.
AvahiStringList * avahi_string_list_get_next(AvahiStringList *l)
Returns the next item in the string list.
uint8_t * avahi_string_list_get_text(AvahiStringList *l)
Returns the text for the current item.
AvahiStringList * avahi_string_list_add(AvahiStringList *l, const char *text)
Append a NUL terminated string to the specified string list.
char * avahi_string_list_to_string(AvahiStringList *l)
Convert the string list object to a single character string, seperated by spaces and enclosed in ""...
AvahiStringList * avahi_string_list_new(const char *txt,...) AVAHI_GCC_SENTINEL
Create a new string list by taking a variable list of NUL terminated strings.
Linked list of strings that can contain any number of binary characters, including NUL bytes...
Definition: strlst.h:40
unsigned avahi_string_list_length(const AvahiStringList *l)
Return the number of elements in the string list.
AvahiStringList * avahi_string_list_reverse(AvahiStringList *l)
Reverse the string list.
AvahiStringList * avahi_string_list_find(AvahiStringList *l, const char *key)
Find the string list entry for the given DNS-SD TXT key.
AvahiStringList * avahi_string_list_add_pair(AvahiStringList *l, const char *key, const char *value)
Add a new DNS-SD TXT key value pair to the string list.
struct AvahiStringList * next
Pointer to the next linked list element.
Definition: strlst.h:41
AvahiStringList * avahi_string_list_new_from_array(const char **array, int length)
Create a new string list from a string array.
AvahiStringList * avahi_string_list_add_arbitrary(AvahiStringList *l, const uint8_t *text, size_t size)
Append an arbitrary length byte string to the list.
int avahi_string_list_equal(const AvahiStringList *a, const AvahiStringList *b)
Compare to string lists.
struct AvahiStringList AvahiStringList
Linked list of strings that can contain any number of binary characters, including NUL bytes...
AvahiStringList * avahi_string_list_add_pair_arbitrary(AvahiStringList *l, const char *key, const uint8_t *value, size_t size)
Same as avahi_string_list_add_pair() but allow strings containing NUL bytes in *value.
AvahiStringList * avahi_string_list_copy(const AvahiStringList *l)
Copy a string list.