4 This file is part of avahi.
6 avahi is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
11 avahi is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with avahi; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
32 int main(int argc, char *argv[]) {
35 AvahiStringList *a = NULL, *b, *p;
39 a = avahi_string_list_new("prefix", "a", "b", NULL);
41 a = avahi_string_list_add(a, "start");
42 a = avahi_string_list_add(a, "foo=99");
43 a = avahi_string_list_add(a, "bar");
44 a = avahi_string_list_add(a, "quux");
45 a = avahi_string_list_add_arbitrary(a, (const uint8_t*) "null\0null", 9);
46 a = avahi_string_list_add_printf(a, "seven=%i %c", 7, 'x');
47 a = avahi_string_list_add_pair(a, "blubb", "blaa");
48 a = avahi_string_list_add_pair(a, "uxknurz", NULL);
49 a = avahi_string_list_add_pair_arbitrary(a, "uxknurz2", (const uint8_t*) "blafasel\0oerks", 14);
51 a = avahi_string_list_add(a, "end");
53 t = avahi_string_list_to_string(a);
54 printf("--%s--\n", t);
57 n = avahi_string_list_serialize(a, NULL, 0);
58 size = avahi_string_list_serialize(a, data, sizeof(data));
63 for (t = (char*) data, n = 0; n < size; n++, t++) {
72 b = avahi_string_list_parse(data, size);
74 assert(avahi_string_list_equal(a, b));
76 t = avahi_string_list_to_string(b);
77 printf("--%s--\n", t);
80 avahi_string_list_free(b);
82 b = avahi_string_list_copy(a);
84 assert(avahi_string_list_equal(a, b));
86 t = avahi_string_list_to_string(b);
87 printf("--%s--\n", t);
90 p = avahi_string_list_find(a, "seven");
93 r = avahi_string_list_get_pair(p, &t, &v, NULL);
98 printf("<%s>=<%s>\n", t, v);
102 p = avahi_string_list_find(a, "quux");
105 r = avahi_string_list_get_pair(p, &t, &v, NULL);
110 printf("<%s>=<%s>\n", t, v);
114 avahi_string_list_free(a);
115 avahi_string_list_free(b);
117 n = avahi_string_list_serialize(NULL, NULL, 0);
118 size = avahi_string_list_serialize(NULL, data, sizeof(data));
122 a = avahi_string_list_parse(data, size);