X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-common%2Falternative.c;h=1306a22c2f66d53e502f257754d339fa9fff16ed;hb=a97605e07ad7f44f2f65e15be64880e61a39ab43;hp=6ff9c355f09ebb8f57c2cb0ff621ca2276264d87;hpb=238909aaff10489fe538c8c54e3f82fe8a54b849;p=catta diff --git a/avahi-common/alternative.c b/avahi-common/alternative.c index 6ff9c35..1306a22 100644 --- a/avahi-common/alternative.c +++ b/avahi-common/alternative.c @@ -2,17 +2,17 @@ /*** 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 @@ -37,12 +37,12 @@ static void drop_incomplete_utf8(char *c) { char *e; e = strchr(c, 0) - 1; - + while (e >= c) { if (avahi_utf8_valid(c)) break; - + assert(*e & 128); *e = 0; @@ -58,12 +58,12 @@ char *avahi_alternative_host_name(const char *s) { if (!avahi_is_valid_host_name(s)) return NULL; - + if ((e = strrchr(s, '-'))) { const char *p; e++; - + for (p = e; *p; p++) if (!isdigit(*p)) { e = NULL; @@ -94,11 +94,11 @@ char *avahi_alternative_host_name(const char *s) { } drop_incomplete_utf8(c); - + r = avahi_strdup_printf("%s-%s", c, m); avahi_free(c); avahi_free(m); - + } else { char *c; @@ -106,7 +106,7 @@ char *avahi_alternative_host_name(const char *s) { return NULL; drop_incomplete_utf8(c); - + r = avahi_strdup_printf("%s-2", c); avahi_free(c); } @@ -124,11 +124,11 @@ char *avahi_alternative_service_name(const char *s) { if (!avahi_is_valid_service_name(s)) return NULL; - + if ((e = strstr(s, " #"))) { const char *n, *p; e += 2; - + while ((n = strstr(e, " #"))) e = n + 2; @@ -141,7 +141,7 @@ char *avahi_alternative_service_name(const char *s) { if (e && (*e == '0' || *e == 0)) e = NULL; } - + if (e) { char *c, *m; size_t l; @@ -162,7 +162,7 @@ char *avahi_alternative_service_name(const char *s) { } drop_incomplete_utf8(c); - + r = avahi_strdup_printf("%s #%s", c, m); avahi_free(c); avahi_free(m); @@ -171,14 +171,14 @@ char *avahi_alternative_service_name(const char *s) { if (!(c = avahi_strndup(s, AVAHI_LABEL_MAX-1-3))) return NULL; - + drop_incomplete_utf8(c); - + r = avahi_strdup_printf("%s #2", c); avahi_free(c); } assert(avahi_is_valid_service_name(r)); - + return r; }