2 This file is part of avahi.
4 avahi is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 avahi is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
12 Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with avahi; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
30 int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
33 AvahiStringList *a = NULL, *b, *p;
37 a = avahi_string_list_new("prefix", "a", "b", NULL);
39 a = avahi_string_list_add(a, "start");
40 a = avahi_string_list_add(a, "foo=99");
41 a = avahi_string_list_add(a, "bar");
42 a = avahi_string_list_add(a, "");
43 a = avahi_string_list_add(a, "");
44 a = avahi_string_list_add(a, "quux");
45 a = avahi_string_list_add(a, "");
46 a = avahi_string_list_add_arbitrary(a, (const uint8_t*) "null\0null", 9);
47 a = avahi_string_list_add_printf(a, "seven=%i %c", 7, 'x');
48 a = avahi_string_list_add_pair(a, "blubb", "blaa");
49 a = avahi_string_list_add_pair(a, "uxknurz", NULL);
50 a = avahi_string_list_add_pair_arbitrary(a, "uxknurz2", (const uint8_t*) "blafasel\0oerks", 14);
52 a = avahi_string_list_add(a, "end");
54 t = avahi_string_list_to_string(a);
55 printf("--%s--\n", t);
58 n = avahi_string_list_serialize(a, NULL, 0);
59 size = avahi_string_list_serialize(a, data, sizeof(data));
62 printf("%zu\n", size);
64 for (t = (char*) data, n = 0; n < size; n++, t++) {
73 assert(avahi_string_list_parse(data, size, &b) == 0);
75 printf("equal: %i\n", avahi_string_list_equal(a, b));
77 t = avahi_string_list_to_string(b);
78 printf("--%s--\n", t);
81 avahi_string_list_free(b);
83 b = avahi_string_list_copy(a);
85 assert(avahi_string_list_equal(a, b));
87 t = avahi_string_list_to_string(b);
88 printf("--%s--\n", t);
91 p = avahi_string_list_find(a, "seven");
94 r = avahi_string_list_get_pair(p, &t, &v, NULL);
99 printf("<%s>=<%s>\n", t, v);
103 p = avahi_string_list_find(a, "quux");
106 r = avahi_string_list_get_pair(p, &t, &v, NULL);
111 printf("<%s>=<%s>\n", t, v);
115 avahi_string_list_free(a);
116 avahi_string_list_free(b);
118 n = avahi_string_list_serialize(NULL, NULL, 0);
119 size = avahi_string_list_serialize(NULL, data, sizeof(data));
123 assert(avahi_string_list_parse(data, size, &a) == 0);