X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;ds=sidebyside;f=avahi-common%2Fdomain-test.c;h=cf763eca6ee6462c578238b26f4adeb098b2af1f;hb=826ad91480c05fb3672aa938fc9f1ced3034a0e8;hp=9926a1f011369ca7f380cc73172344b7078ca04a;hpb=7d45167a88dceefc521bf94a618f29bfc1886932;p=catta diff --git a/avahi-common/domain-test.c b/avahi-common/domain-test.c index 9926a1f..cf763ec 100644 --- a/avahi-common/domain-test.c +++ b/avahi-common/domain-test.c @@ -1,18 +1,16 @@ -/* $Id$ */ - /*** This file is part of avahi. - + avahi is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + avahi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with avahi; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -30,15 +28,12 @@ #include "domain.h" #include "malloc.h" -int main(int argc, char *argv[]) { +int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { char *s; char t[256], r[256]; const char *p; size_t size; char name[64], type[AVAHI_DOMAIN_NAME_MAX], domain[AVAHI_DOMAIN_NAME_MAX]; - - printf("host name: %s\n", s = avahi_get_host_name_strdup()); - avahi_free(s); printf("%s\n", s = avahi_normalize_name_strdup("foo.foo\\046.")); avahi_free(s); @@ -46,7 +41,7 @@ int main(int argc, char *argv[]) { printf("%s\n", s = avahi_normalize_name_strdup("foo.foo\\.foo.")); avahi_free(s); - + printf("%s\n", s = avahi_normalize_name_strdup("fo\\\\o\\..f oo.")); avahi_free(s); @@ -63,7 +58,7 @@ int main(int argc, char *argv[]) { avahi_service_name_split(t, name, sizeof(name), type, sizeof(type), domain, sizeof(domain)); printf("name: <%s>; type: <%s>; domain <%s>\n", name, type, domain); - + avahi_service_name_join(t, sizeof(t), NULL, "_http._tcp", "one.two\\. .local"); printf("<%s>\n", t); @@ -76,14 +71,12 @@ int main(int argc, char *argv[]) { size = sizeof(r); s = r; - + printf("escaped: <%s>\n", avahi_escape_label(t, strlen(t), &s, &size)); p = r; printf("unescaped: <%s>\n", avahi_unescape_label(&p, t, sizeof(t))); - assert(avahi_domain_ends_with("foo.bar.\\065\\\\\\.aaaa", "\\065\\\\\\.aaaa")); - assert(avahi_is_valid_service_type_generic("_foo._bar._waldo")); assert(!avahi_is_valid_service_type_strict("_foo._bar._waldo")); assert(!avahi_is_valid_service_subtype("_foo._bar._waldo")); @@ -95,7 +88,7 @@ int main(int argc, char *argv[]) { assert(!avahi_is_valid_service_type_generic("_foo._bar.waldo")); assert(!avahi_is_valid_service_type_strict("_foo._bar.waldo")); assert(!avahi_is_valid_service_subtype("_foo._bar.waldo")); - + assert(!avahi_is_valid_service_type_generic("")); assert(!avahi_is_valid_service_type_strict("")); assert(!avahi_is_valid_service_subtype("")); @@ -116,6 +109,15 @@ int main(int argc, char *argv[]) { assert(avahi_normalize_name(".", t, sizeof(t))); assert(avahi_normalize_name("", t, sizeof(t))); - + assert(!avahi_is_valid_fqdn(".")); + assert(!avahi_is_valid_fqdn("")); + assert(!avahi_is_valid_fqdn("foo")); + assert(avahi_is_valid_fqdn("foo.bar")); + assert(avahi_is_valid_fqdn("foo.bar.")); + assert(avahi_is_valid_fqdn("gnurz.foo.bar.")); + assert(!avahi_is_valid_fqdn("192.168.50.1")); + assert(!avahi_is_valid_fqdn("::1")); + assert(!avahi_is_valid_fqdn(".192.168.50.1.")); + return 0; }