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
31 int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
36 char name[64], type[AVAHI_DOMAIN_NAME_MAX], domain[AVAHI_DOMAIN_NAME_MAX];
38 printf("%s\n", s = avahi_normalize_name_strdup("foo.foo\\046."));
41 printf("%s\n", s = avahi_normalize_name_strdup("foo.foo\\.foo."));
45 printf("%s\n", s = avahi_normalize_name_strdup("fo\\\\o\\..f oo."));
48 printf("%i\n", avahi_domain_equal("\\065aa bbb\\.\\046cc.cc\\\\.dee.fff.", "Aaa BBB\\.\\.cc.cc\\\\.dee.fff"));
49 printf("%i\n", avahi_domain_equal("A", "a"));
51 printf("%i\n", avahi_domain_equal("a", "aaa"));
53 printf("%u = %u\n", avahi_domain_hash("ccc\\065aa.aa\\.b\\\\."), avahi_domain_hash("cccAaa.aa\\.b\\\\"));
56 avahi_service_name_join(t, sizeof(t), "foo.foo.foo \\.", "_http._tcp", "test.local");
59 avahi_service_name_split(t, name, sizeof(name), type, sizeof(type), domain, sizeof(domain));
60 printf("name: <%s>; type: <%s>; domain <%s>\n", name, type, domain);
62 avahi_service_name_join(t, sizeof(t), NULL, "_http._tcp", "one.two\\. .local");
65 avahi_service_name_split(t, NULL, 0, type, sizeof(type), domain, sizeof(domain));
66 printf("name: <>; type: <%s>; domain <%s>\n", type, domain);
69 p = "--:---\\\\\\123\\065_äöü\\064\\.\\\\sjöödfhh.sdfjhskjdf";
70 printf("unescaped: <%s>, rest: %s\n", avahi_unescape_label(&p, t, sizeof(t)), p);
75 printf("escaped: <%s>\n", avahi_escape_label(t, strlen(t), &s, &size));
78 printf("unescaped: <%s>\n", avahi_unescape_label(&p, t, sizeof(t)));
80 assert(avahi_is_valid_service_type_generic("_foo._bar._waldo"));
81 assert(!avahi_is_valid_service_type_strict("_foo._bar._waldo"));
82 assert(!avahi_is_valid_service_subtype("_foo._bar._waldo"));
84 assert(avahi_is_valid_service_type_generic("_foo._tcp"));
85 assert(avahi_is_valid_service_type_strict("_foo._tcp"));
86 assert(!avahi_is_valid_service_subtype("_foo._tcp"));
88 assert(!avahi_is_valid_service_type_generic("_foo._bar.waldo"));
89 assert(!avahi_is_valid_service_type_strict("_foo._bar.waldo"));
90 assert(!avahi_is_valid_service_subtype("_foo._bar.waldo"));
92 assert(!avahi_is_valid_service_type_generic(""));
93 assert(!avahi_is_valid_service_type_strict(""));
94 assert(!avahi_is_valid_service_subtype(""));
96 assert(avahi_is_valid_service_type_generic("_foo._sub._bar._tcp"));
97 assert(!avahi_is_valid_service_type_strict("_foo._sub._bar._tcp"));
98 assert(avahi_is_valid_service_subtype("_foo._sub._bar._tcp"));
100 printf("%s\n", avahi_get_type_from_subtype("_foo._sub._bar._tcp"));
102 assert(!avahi_is_valid_host_name("sf.ooo."));
103 assert(avahi_is_valid_host_name("sfooo."));
104 assert(avahi_is_valid_host_name("sfooo"));
106 assert(avahi_is_valid_domain_name("."));
107 assert(avahi_is_valid_domain_name(""));
109 assert(avahi_normalize_name(".", t, sizeof(t)));
110 assert(avahi_normalize_name("", t, sizeof(t)));
112 assert(!avahi_is_valid_fqdn("."));
113 assert(!avahi_is_valid_fqdn(""));
114 assert(!avahi_is_valid_fqdn("foo"));
115 assert(avahi_is_valid_fqdn("foo.bar"));
116 assert(avahi_is_valid_fqdn("foo.bar."));
117 assert(avahi_is_valid_fqdn("gnurz.foo.bar."));
118 assert(!avahi_is_valid_fqdn("192.168.50.1"));
119 assert(!avahi_is_valid_fqdn("::1"));
120 assert(!avahi_is_valid_fqdn(".192.168.50.1."));