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(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED 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, "");
45 a = avahi_string_list_add(a, "");
46 a = avahi_string_list_add(a, "quux");
47 a = avahi_string_list_add(a, "");
48 a = avahi_string_list_add_arbitrary(a, (const uint8_t*) "null\0null", 9);
49 a = avahi_string_list_add_printf(a, "seven=%i %c", 7, 'x');
50 a = avahi_string_list_add_pair(a, "blubb", "blaa");
51 a = avahi_string_list_add_pair(a, "uxknurz", NULL);
52 a = avahi_string_list_add_pair_arbitrary(a, "uxknurz2", (const uint8_t*) "blafasel\0oerks", 14);
54 a = avahi_string_list_add(a, "end");
56 t = avahi_string_list_to_string(a);
57 printf("--%s--\n", t);
60 n = avahi_string_list_serialize(a, NULL, 0);
61 size = avahi_string_list_serialize(a, data, sizeof(data));
66 for (t = (char*) data, n = 0; n < size; n++, t++) {
75 assert(avahi_string_list_parse(data, size, &b) == 0);
77 printf("equal: %i\n", avahi_string_list_equal(a, b));
79 t = avahi_string_list_to_string(b);
80 printf("--%s--\n", t);
83 avahi_string_list_free(b);
85 b = avahi_string_list_copy(a);
87 assert(avahi_string_list_equal(a, b));
89 t = avahi_string_list_to_string(b);
90 printf("--%s--\n", t);
93 p = avahi_string_list_find(a, "seven");
96 r = avahi_string_list_get_pair(p, &t, &v, NULL);
101 printf("<%s>=<%s>\n", t, v);
105 p = avahi_string_list_find(a, "quux");
108 r = avahi_string_list_get_pair(p, &t, &v, NULL);
113 printf("<%s>=<%s>\n", t, v);
117 avahi_string_list_free(a);
118 avahi_string_list_free(b);
120 n = avahi_string_list_serialize(NULL, NULL, 0);
121 size = avahi_string_list_serialize(NULL, data, sizeof(data));
125 assert(avahi_string_list_parse(data, size, &a) == 0);