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 size = avahi_string_list_serialize(a, data, sizeof(data));
61 for (t = (char*) data, n = 0; n < size; n++, t++) {
70 b = avahi_string_list_parse(data, size);
72 assert(avahi_string_list_equal(a, b));
74 t = avahi_string_list_to_string(b);
75 printf("--%s--\n", t);
78 avahi_string_list_free(b);
80 b = avahi_string_list_copy(a);
82 assert(avahi_string_list_equal(a, b));
84 t = avahi_string_list_to_string(b);
85 printf("--%s--\n", t);
88 p = avahi_string_list_find(a, "seven");
91 r = avahi_string_list_get_pair(p, &t, &v, NULL);
96 printf("<%s>=<%s>\n", t, v);
100 p = avahi_string_list_find(a, "quux");
103 r = avahi_string_list_get_pair(p, &t, &v, NULL);
108 printf("<%s>=<%s>\n", t, v);
112 avahi_string_list_free(a);
113 avahi_string_list_free(b);