]> git.meshlink.io Git - catta/blob - avahi-common/strlst.h
* recreate DNS query in simple protocol on host or domain name changes
[catta] / avahi-common / strlst.h
1 #ifndef footxtlisthfoo
2 #define footxtlisthfoo
3
4 /* $Id$ */
5
6 /***
7   This file is part of avahi.
8  
9   avahi is free software; you can redistribute it and/or modify it
10   under the terms of the GNU Lesser General Public License as
11   published by the Free Software Foundation; either version 2.1 of the
12   License, or (at your option) any later version.
13  
14   avahi is distributed in the hope that it will be useful, but WITHOUT
15   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16   or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
17   Public License for more details.
18  
19   You should have received a copy of the GNU Lesser General Public
20   License along with avahi; if not, write to the Free Software
21   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22   USA.
23 ***/
24
25 #include <glib.h>
26 #include <avahi-common/cdecl.h>
27
28 AVAHI_C_DECL_BEGIN
29
30 /** Linked list of strings that can contain any number of binary
31  * characters, including NUL bytes. An empty list is created by
32  * assigning a NULL to a pointer to AvahiStringList. The string list
33  * is stored in reverse order, so that appending to the string list is
34  * effectively a prepending to the linked list.  This object is used
35  * primarily for storing DNS TXT record data. */
36 typedef struct AvahiStringList {
37     struct AvahiStringList *next; /**< Pointe to the next linked list element */
38     guint size;  /**< Size of text[] */
39     guint8 text[1]; /**< Character data */
40 } AvahiStringList;
41
42 /** Create a new string list by taking a variable list of NUL
43  * terminated strings. The strings are copied using g_strdup(). The
44  * argument list must be terminated by a NULL pointer. */
45 AvahiStringList *avahi_string_list_new(const gchar *txt, ...);
46
47 /** Same as avahi_string_list_new() but pass a va_list structure */
48 AvahiStringList *avahi_string_list_new_va(va_list va);
49
50 /** Free a string list */
51 void avahi_string_list_free(AvahiStringList *l);
52
53 /** Append a NUL terminated string to the specified string list. The
54  * passed string is copied using g_strdup(). Returns the new list
55  * start. */
56 AvahiStringList *avahi_string_list_add(AvahiStringList *l, const gchar *text);
57
58 /** Append am arbitrary length byte string to the list. Returns the
59  * new list start. */
60 AvahiStringList *avahi_string_list_add_arbitrary(AvahiStringList *l, const guint8 *text, guint size);
61
62 /** Same as avahi_string_list_add(), but takes a variable number of
63  * NUL terminated strings. The argument list must be terminated by a
64  * NULL pointer. Returns the new list start. */
65 AvahiStringList *avahi_string_list_add_many(AvahiStringList *r, ...);
66
67 /** Same as avahi_string_list_add_many(), but use a va_list
68  * structure. Returns the new list start. */
69 AvahiStringList *avahi_string_list_add_many_va(AvahiStringList *r, va_list va);
70
71 /** Convert the string list object to a single character string,
72  * seperated by spaces and enclosed in "". g_free() the result! This
73  * function doesn't work well with string that contain NUL bytes. */
74 gchar* avahi_string_list_to_string(AvahiStringList *l);
75
76 /** Serialize the string list object in a way that is compatible with
77  * the storing of DNS TXT records. Strings longer than 255 bytes are truncated. */
78 guint avahi_string_list_serialize(AvahiStringList *l, gpointer data, guint size);
79
80 /** Inverse of avahi_string_list_serialize() */
81 AvahiStringList *avahi_string_list_parse(gconstpointer data, guint size);
82
83 /** Compare to string lists */
84 gboolean avahi_string_list_equal(const AvahiStringList *a, const AvahiStringList *b);
85
86 /** Copy a string list */
87 AvahiStringList *avahi_string_list_copy(const AvahiStringList *l);
88
89 AVAHI_C_DECL_END
90
91 #endif
92