From a97605e07ad7f44f2f65e15be64880e61a39ab43 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 25 Jun 2010 01:08:29 +0200 Subject: from now on we enforce a strict whitespace regime --- avahi-common/address.h | 6 +-- avahi-common/alternative-test.c | 16 +++--- avahi-common/alternative.c | 34 ++++++------ avahi-common/alternative.h | 6 +-- avahi-common/cdecl.h | 6 +-- avahi-common/dbus-watch-glue.c | 44 ++++++++-------- avahi-common/dbus-watch-glue.h | 6 +-- avahi-common/dbus.c | 16 +++--- avahi-common/dbus.h | 6 +-- avahi-common/domain-test.c | 18 +++---- avahi-common/domain.c | 112 ++++++++++++++++++++-------------------- avahi-common/domain.h | 6 +-- avahi-common/error.h | 16 +++--- avahi-common/gccmacro.h | 6 +-- avahi-common/llist.h | 6 +-- avahi-common/malloc.c | 26 +++++----- avahi-common/malloc.h | 6 +-- avahi-common/rlist.c | 10 ++-- avahi-common/rlist.h | 6 +-- avahi-common/simple-watch.c | 90 ++++++++++++++++---------------- avahi-common/simple-watch.h | 6 +-- avahi-common/strlst.c | 72 +++++++++++++------------- avahi-common/strlst.h | 6 +-- avahi-common/thread-watch.h | 6 +-- avahi-common/timeval.c | 18 +++---- avahi-common/timeval.h | 6 +-- avahi-common/utf8-test.c | 8 +-- avahi-common/utf8.c | 18 +++---- avahi-common/utf8.h | 6 +-- avahi-common/watch-test.c | 14 ++--- avahi-common/watch.h | 10 ++-- 31 files changed, 306 insertions(+), 306 deletions(-) (limited to 'avahi-common') diff --git a/avahi-common/address.h b/avahi-common/address.h index 6023a03..70d1521 100644 --- a/avahi-common/address.h +++ b/avahi-common/address.h @@ -5,17 +5,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 diff --git a/avahi-common/alternative-test.c b/avahi-common/alternative-test.c index 28ae789..f40ec8e 100644 --- a/avahi-common/alternative-test.c +++ b/avahi-common/alternative-test.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 @@ -60,19 +60,19 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { "gurke ###", NULL }; - + char *r = NULL; int i, j, k; for (k = 0; test_strings[k]; k++) { printf(">>>>>%s<<<<\n", test_strings[k]); - + for (j = 0; j < 2; j++) { - + for (i = 0; i <= 100; i++) { char *n; - + n = i == 0 ? avahi_strdup(test_strings[k]) : (j ? avahi_alternative_service_name(r) : avahi_alternative_host_name(r)); avahi_free(r); r = n; @@ -81,7 +81,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { assert(avahi_is_valid_service_name(n)); else assert(avahi_is_valid_host_name(n)); - + printf("%s\n", r); } } 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; } diff --git a/avahi-common/alternative.h b/avahi-common/alternative.h index f4216f6..63c30ad 100644 --- a/avahi-common/alternative.h +++ b/avahi-common/alternative.h @@ -5,17 +5,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 diff --git a/avahi-common/cdecl.h b/avahi-common/cdecl.h index fc89197..df77794 100644 --- a/avahi-common/cdecl.h +++ b/avahi-common/cdecl.h @@ -5,17 +5,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 diff --git a/avahi-common/dbus-watch-glue.c b/avahi-common/dbus-watch-glue.c index 35e2b45..eeecf23 100644 --- a/avahi-common/dbus-watch-glue.c +++ b/avahi-common/dbus-watch-glue.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 @@ -116,7 +116,7 @@ static void dispatch_timeout_callback(AvahiTimeout *t, void *userdata) { static void watch_callback(AvahiWatch *avahi_watch, AVAHI_GCC_UNUSED int fd, AvahiWatchEvent events, void *userdata) { DBusWatch *dbus_watch = userdata; - + assert(avahi_watch); assert(dbus_watch); @@ -127,13 +127,13 @@ static void watch_callback(AvahiWatch *avahi_watch, AVAHI_GCC_UNUSED int fd, Ava static dbus_bool_t update_watch(const AvahiPoll *poll_api, DBusWatch *dbus_watch) { AvahiWatch *avahi_watch; dbus_bool_t b; - + assert(dbus_watch); avahi_watch = dbus_watch_get_data(dbus_watch); b = dbus_watch_get_enabled(dbus_watch); - + if (b && !avahi_watch) { if (!(avahi_watch = poll_api->watch_new( @@ -149,14 +149,14 @@ static dbus_bool_t update_watch(const AvahiPoll *poll_api, DBusWatch *dbus_watch return FALSE; dbus_watch_set_data(dbus_watch, avahi_watch, NULL); - + } else if (!b && avahi_watch) { - + poll_api->watch_free(avahi_watch); dbus_watch_set_data(dbus_watch, NULL, NULL); } else if (avahi_watch) { - + /* Update flags */ poll_api->watch_update(avahi_watch, dbus_watch_get_flags(dbus_watch)); } @@ -166,7 +166,7 @@ static dbus_bool_t update_watch(const AvahiPoll *poll_api, DBusWatch *dbus_watch static dbus_bool_t add_watch(DBusWatch *dbus_watch, void *userdata) { ConnectionData *d = userdata; - + assert(dbus_watch); assert(d); @@ -176,7 +176,7 @@ static dbus_bool_t add_watch(DBusWatch *dbus_watch, void *userdata) { static void remove_watch(DBusWatch *dbus_watch, void *userdata) { ConnectionData *d = userdata; AvahiWatch *avahi_watch; - + assert(dbus_watch); assert(d); @@ -188,7 +188,7 @@ static void remove_watch(DBusWatch *dbus_watch, void *userdata) { static void watch_toggled(DBusWatch *dbus_watch, void *userdata) { ConnectionData *d = userdata; - + assert(dbus_watch); assert(d); @@ -217,7 +217,7 @@ static void timeout_data_unref(TimeoutData *t) { if (--t->ref <= 0) { if (t->avahi_timeout) t->poll_api->timeout_free(t->avahi_timeout); - + avahi_free(t); } } @@ -225,7 +225,7 @@ static void timeout_data_unref(TimeoutData *t) { static void update_timeout(TimeoutData *timeout) { assert(timeout); assert(timeout->ref >= 1); - + if (dbus_timeout_get_enabled(timeout->dbus_timeout)) { struct timeval tv; avahi_elapse_time(&tv, dbus_timeout_get_interval(timeout->dbus_timeout), 0); @@ -238,7 +238,7 @@ static void update_timeout(TimeoutData *timeout) { static void timeout_callback(AvahiTimeout *avahi_timeout, void *userdata) { TimeoutData *timeout = userdata; - + assert(avahi_timeout); assert(timeout); @@ -249,7 +249,7 @@ static void timeout_callback(AvahiTimeout *avahi_timeout, void *userdata) { if (timeout->avahi_timeout) update_timeout(timeout); - + timeout_data_unref(timeout); } @@ -271,7 +271,7 @@ static dbus_bool_t add_timeout(DBusTimeout *dbus_timeout, void *userdata) { if ((b = dbus_timeout_get_enabled(dbus_timeout))) avahi_elapse_time(&tv, dbus_timeout_get_interval(dbus_timeout), 0); - + if (!(timeout->avahi_timeout = d->poll_api->timeout_new( d->poll_api, b ? &tv : NULL, @@ -311,14 +311,14 @@ static void timeout_toggled(DBusTimeout *dbus_timeout, AVAHI_GCC_UNUSED void *us static void dispatch_status(AVAHI_GCC_UNUSED DBusConnection *connection, DBusDispatchStatus new_status, void *userdata) { ConnectionData *d = userdata; - + if (new_status == DBUS_DISPATCH_DATA_REMAINS) request_dispatch(d, 1); } int avahi_dbus_connection_glue(DBusConnection *c, const AvahiPoll *poll_api) { ConnectionData *d = NULL; - + assert(c); assert(poll_api); @@ -328,10 +328,10 @@ int avahi_dbus_connection_glue(DBusConnection *c, const AvahiPoll *poll_api) { d->poll_api = poll_api; d->connection = c; d->ref = 1; - + if (!(d->dispatch_timeout = poll_api->timeout_new(poll_api, NULL, dispatch_timeout_callback, d))) goto fail; - + if (!(dbus_connection_set_watch_functions(c, add_watch, remove_watch, watch_toggled, connection_data_ref(d), (DBusFreeFunction)connection_data_unref))) goto fail; @@ -344,7 +344,7 @@ int avahi_dbus_connection_glue(DBusConnection *c, const AvahiPoll *poll_api) { request_dispatch(d, 1); connection_data_unref(d); - + return 0; fail: diff --git a/avahi-common/dbus-watch-glue.h b/avahi-common/dbus-watch-glue.h index 101fa3f..f78d350 100644 --- a/avahi-common/dbus-watch-glue.h +++ b/avahi-common/dbus-watch-glue.h @@ -5,17 +5,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 diff --git a/avahi-common/dbus.c b/avahi-common/dbus.c index ac54848..80b03c6 100644 --- a/avahi-common/dbus.c +++ b/avahi-common/dbus.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 @@ -41,7 +41,7 @@ static const char * const table[- AVAHI_ERR_MAX] = { AVAHI_DBUS_ERR_IS_PATTERN, AVAHI_DBUS_ERR_COLLISION, AVAHI_DBUS_ERR_INVALID_RECORD, - + AVAHI_DBUS_ERR_INVALID_SERVICE_NAME, AVAHI_DBUS_ERR_INVALID_SERVICE_TYPE, AVAHI_DBUS_ERR_INVALID_PORT, @@ -52,7 +52,7 @@ static const char * const table[- AVAHI_ERR_MAX] = { AVAHI_DBUS_ERR_TOO_MANY_OBJECTS, AVAHI_DBUS_ERR_TOO_MANY_ENTRIES, AVAHI_DBUS_ERR_OS, - + AVAHI_DBUS_ERR_ACCESS_DENIED, AVAHI_DBUS_ERR_INVALID_OPERATION, AVAHI_DBUS_ERR_DBUS_ERROR, @@ -63,7 +63,7 @@ static const char * const table[- AVAHI_ERR_MAX] = { AVAHI_DBUS_ERR_INVALID_INTERFACE, AVAHI_DBUS_ERR_INVALID_PROTOCOL, AVAHI_DBUS_ERR_INVALID_FLAGS, - + AVAHI_DBUS_ERR_NOT_FOUND, AVAHI_DBUS_ERR_INVALID_CONFIG, AVAHI_DBUS_ERR_VERSION_MISMATCH, @@ -74,7 +74,7 @@ static const char * const table[- AVAHI_ERR_MAX] = { AVAHI_DBUS_ERR_DNS_SERVFAIL, AVAHI_DBUS_ERR_DNS_NXDOMAIN, AVAHI_DBUS_ERR_DNS_NOTIMP, - + AVAHI_DBUS_ERR_DNS_REFUSED, AVAHI_DBUS_ERR_DNS_YXDOMAIN, AVAHI_DBUS_ERR_DNS_YXRRSET, @@ -128,7 +128,7 @@ int avahi_error_dbus_to_number(const char *s) { for (m = error_map; m->dbus_error; m++) if (strcmp(m->dbus_error, s) == 0) return m->avahi_error; - + return AVAHI_ERR_DBUS_ERROR; } diff --git a/avahi-common/dbus.h b/avahi-common/dbus.h index a93988d..5f1e37d 100644 --- a/avahi-common/dbus.h +++ b/avahi-common/dbus.h @@ -5,17 +5,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 diff --git a/avahi-common/domain-test.c b/avahi-common/domain-test.c index 0f7d851..cf26c77 100644 --- a/avahi-common/domain-test.c +++ b/avahi-common/domain-test.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 @@ -36,14 +36,14 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { const char *p; size_t size; char name[64], type[AVAHI_DOMAIN_NAME_MAX], domain[AVAHI_DOMAIN_NAME_MAX]; - + printf("%s\n", s = avahi_normalize_name_strdup("foo.foo\\046.")); avahi_free(s); 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); @@ -60,7 +60,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED 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); @@ -73,7 +73,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { size = sizeof(r); s = r; - + printf("escaped: <%s>\n", avahi_escape_label(t, strlen(t), &s, &size)); p = r; @@ -90,7 +90,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED 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("")); @@ -120,6 +120,6 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { 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; } diff --git a/avahi-common/domain.c b/avahi-common/domain.c index 8d339c7..b4a6fc1 100644 --- a/avahi-common/domain.c +++ b/avahi-common/domain.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 @@ -43,13 +43,13 @@ char *avahi_unescape_label(const char **name, char *dest, size_t size) { unsigned i = 0; char *d; - + assert(dest); assert(size > 0); assert(name); d = dest; - + for (;;) { if (i >= size) return NULL; @@ -58,10 +58,10 @@ char *avahi_unescape_label(const char **name, char *dest, size_t size) { (*name)++; break; } - + if (**name == 0) break; - + if (**name == '\\') { /* Escaped character */ @@ -70,7 +70,7 @@ char *avahi_unescape_label(const char **name, char *dest, size_t size) { if (**name == 0) /* Ending NUL */ return NULL; - + else if (**name == '\\' || **name == '.') { /* Escaped backslash or dot */ *(d++) = *((*name) ++); @@ -79,7 +79,7 @@ char *avahi_unescape_label(const char **name, char *dest, size_t size) { int n; /* Escaped literal ASCII character */ - + if (!isdigit(*(*name+1)) || !isdigit(*(*name+2))) return NULL; @@ -87,18 +87,18 @@ char *avahi_unescape_label(const char **name, char *dest, size_t size) { if (n > 255 || n == 0) return NULL; - + *(d++) = (char) n; i++; (*name) += 3; } else return NULL; - + } else { /* Normal character */ - + *(d++) = *((*name) ++); i++; } @@ -130,14 +130,14 @@ char *avahi_escape_label(const char* src, size_t src_length, char **ret_name, si if (*src == '.' || *src == '\\') { /* Dot or backslash */ - + if (*ret_size < 3) return NULL; - + *((*ret_name) ++) = '\\'; *((*ret_name) ++) = *src; (*ret_size) -= 2; - + } else if ( *src == '_' || *src == '-' || @@ -146,13 +146,13 @@ char *avahi_escape_label(const char* src, size_t src_length, char **ret_name, si (*src >= 'A' && *src <= 'Z')) { /* Proper character */ - + if (*ret_size < 2) return NULL; - + *((*ret_name)++) = *src; (*ret_size) --; - + } else { /* Everything else */ @@ -164,7 +164,7 @@ char *avahi_escape_label(const char* src, size_t src_length, char **ret_name, si *((*ret_name) ++) = '0' + (char) ((uint8_t) *src / 100); *((*ret_name) ++) = '0' + (char) (((uint8_t) *src / 10) % 10); *((*ret_name) ++) = '0' + (char) ((uint8_t) *src % 10); - + (*ret_size) -= 4; } @@ -180,7 +180,7 @@ char *avahi_escape_label(const char* src, size_t src_length, char **ret_name, si char *avahi_normalize_name(const char *s, char *ret_s, size_t size) { int empty = 1; char *r; - + assert(s); assert(ret_s); assert(size > 0); @@ -201,17 +201,17 @@ char *avahi_normalize_name(const char *s, char *ret_s, size_t size) { return NULL; } - + if (!empty) { if (size < 1) return NULL; - + *(r++) = '.'; size--; - + } else empty = 0; - + avahi_escape_label(label, strlen(label), &r, &size); } @@ -234,7 +234,7 @@ int avahi_domain_equal(const char *a, const char *b) { if (a == b) return 1; - + for (;;) { char ca[AVAHI_LABEL_MAX], cb[AVAHI_LABEL_MAX], *r; @@ -245,7 +245,7 @@ int avahi_domain_equal(const char *a, const char *b) { if (strcasecmp(ca, cb)) return 0; - + if (!*a && !*b) return 1; } @@ -267,7 +267,7 @@ int avahi_is_valid_service_type_generic(const char *t) { if (strlen(label) <= 2 || label[0] != '_') return 0; - + } while (*t); return 1; @@ -281,7 +281,7 @@ int avahi_is_valid_service_type_strict(const char *t) { return 0; /* Application name */ - + if (!(avahi_unescape_label(&t, label, sizeof(label)))) return 0; @@ -292,7 +292,7 @@ int avahi_is_valid_service_type_strict(const char *t) { return 0; /* _tcp or _udp boilerplate */ - + if (!(avahi_unescape_label(&t, label, sizeof(label)))) return 0; @@ -301,7 +301,7 @@ int avahi_is_valid_service_type_strict(const char *t) { if (*t) return 0; - + return 1; } @@ -314,7 +314,7 @@ const char *avahi_get_type_from_subtype(const char *t) { return NULL; /* Subtype name */ - + if (!(avahi_unescape_label(&t, label, sizeof(label)))) return NULL; @@ -325,7 +325,7 @@ const char *avahi_get_type_from_subtype(const char *t) { return NULL; /* String "_sub" */ - + if (!(avahi_unescape_label(&t, label, sizeof(label)))) return NULL; @@ -336,7 +336,7 @@ const char *avahi_get_type_from_subtype(const char *t) { return NULL; ret = t; - + /* Application name */ if (!(avahi_unescape_label(&t, label, sizeof(label)))) @@ -347,9 +347,9 @@ const char *avahi_get_type_from_subtype(const char *t) { if (!*t) return NULL; - + /* _tcp or _udp boilerplate */ - + if (!(avahi_unescape_label(&t, label, sizeof(label)))) return NULL; @@ -384,12 +384,12 @@ int avahi_is_valid_domain_name(const char *t) { /* Explicitly allow the root domain name */ if (is_first && label[0] == 0 && *t == 0) return 1; - + is_first = 0; - + if (label[0] == 0) return 0; - + } while (*t); return 1; @@ -400,7 +400,7 @@ int avahi_is_valid_service_name(const char *t) { if (strlen(t) >= AVAHI_LABEL_MAX || !*t) return 0; - + return 1; } @@ -425,7 +425,7 @@ int avahi_is_valid_host_name(const char *t) { unsigned avahi_domain_hash(const char *s) { unsigned hash = 0; - + while (*s) { char c[AVAHI_LABEL_MAX], *p, *r; @@ -443,22 +443,22 @@ int avahi_service_name_join(char *p, size_t size, const char *name, const char * char escaped_name[AVAHI_LABEL_MAX*4]; char normalized_type[AVAHI_DOMAIN_NAME_MAX]; char normalized_domain[AVAHI_DOMAIN_NAME_MAX]; - + assert(p); /* Validity checks */ - + if ((name && !avahi_is_valid_service_name(name))) return AVAHI_ERR_INVALID_SERVICE_NAME; if (!avahi_is_valid_service_type_generic(type)) return AVAHI_ERR_INVALID_SERVICE_TYPE; - + if (!avahi_is_valid_domain_name(domain)) return AVAHI_ERR_INVALID_DOMAIN_NAME; /* Preparation */ - + if (name) { size_t l = sizeof(escaped_name); char *e = escaped_name, *r; @@ -473,7 +473,7 @@ int avahi_service_name_join(char *p, size_t size, const char *name, const char * return AVAHI_ERR_INVALID_DOMAIN_NAME; /* Concatenation */ - + snprintf(p, size, "%s%s%s.%s", name ? escaped_name : "", name ? "." : "", normalized_type, normalized_domain); return AVAHI_OK; @@ -484,12 +484,12 @@ int avahi_service_name_join(char *p, size_t size, const char *name, const char * static size_t strlcpy(char *dest, const char *src, size_t n) { assert(dest); assert(src); - + if (n > 0) { strncpy(dest, src, n-1); dest[n-1] = 0; } - + return strlen(src); } @@ -502,7 +502,7 @@ int avahi_service_name_split(const char *p, char *name, size_t name_size, char * DOMAIN } state; int type_empty = 1, domain_empty = 1; - + assert(p); assert(type); assert(type_size > 0); @@ -515,12 +515,12 @@ int avahi_service_name_split(const char *p, char *name, size_t name_size, char * state = NAME; } else state = TYPE; - + *type = *domain = 0; - + while (*p) { char buf[64]; - + if (!(avahi_unescape_label(&p, buf, sizeof(buf)))) return -1; @@ -537,18 +537,18 @@ int avahi_service_name_split(const char *p, char *name, size_t name_size, char * if (!type_empty) { if (!type_size) return AVAHI_ERR_NO_MEMORY; - + *(type++) = '.'; type_size --; } else type_empty = 0; - + if (!(avahi_escape_label(buf, strlen(buf), &type, &type_size))) return AVAHI_ERR_NO_MEMORY; break; - } + } state = DOMAIN; /* fall through */ @@ -558,7 +558,7 @@ int avahi_service_name_split(const char *p, char *name, size_t name_size, char * if (!domain_empty) { if (!domain_size) return AVAHI_ERR_NO_MEMORY; - + *(domain++) = '.'; domain_size --; } else @@ -603,7 +603,7 @@ int avahi_is_valid_fqdn(const char *t) { /* Make sure that the name is not an IP address */ if (!(avahi_normalize_name(t, normalized, sizeof(normalized)))) return 0; - + if (avahi_address_parse(normalized, AVAHI_PROTO_UNSPEC, &a)) return 0; diff --git a/avahi-common/domain.h b/avahi-common/domain.h index 14d069d..1ed6fce 100644 --- a/avahi-common/domain.h +++ b/avahi-common/domain.h @@ -5,17 +5,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 diff --git a/avahi-common/error.h b/avahi-common/error.h index 3e4d25f..ede5b2a 100644 --- a/avahi-common/error.h +++ b/avahi-common/error.h @@ -5,17 +5,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 @@ -29,7 +29,7 @@ AVAHI_C_DECL_BEGIN /** Error codes used by avahi */ -enum { +enum { AVAHI_OK = 0, /**< OK */ AVAHI_ERR_FAILURE = -1, /**< Generic error code */ AVAHI_ERR_BAD_STATE = -2, /**< Object was in a bad state */ @@ -79,17 +79,17 @@ enum { AVAHI_ERR_DNS_YXRRSET = -42, AVAHI_ERR_DNS_NXRRSET = -43, AVAHI_ERR_DNS_NOTAUTH = -44, /**< DNS Error: Not authorized */ - AVAHI_ERR_DNS_NOTZONE = -45, + AVAHI_ERR_DNS_NOTZONE = -45, AVAHI_ERR_INVALID_RDATA = -46, /**< Invalid RDATA */ AVAHI_ERR_INVALID_DNS_CLASS = -47, /**< Invalid DNS class */ AVAHI_ERR_INVALID_DNS_TYPE = -48, /**< Invalid DNS type */ AVAHI_ERR_NOT_SUPPORTED = -49, /**< Not supported */ - + AVAHI_ERR_NOT_PERMITTED = -50, /**< Operation not permitted */ AVAHI_ERR_INVALID_ARGUMENT = -51, /**< Invalid argument */ AVAHI_ERR_IS_EMPTY = -52, /**< Is empty */ AVAHI_ERR_NO_CHANGE = -53, /**< The requested operation is invalid because it is redundant */ - + /**** **** IF YOU ADD A NEW ERROR CODE HERE, PLEASE DON'T FORGET TO ADD **** IT TO THE STRING ARRAY IN avahi_strerror() IN error.c AND @@ -97,7 +97,7 @@ enum { **** **** Also remember to update the MAX value below. ****/ - + AVAHI_ERR_MAX = -54 }; diff --git a/avahi-common/gccmacro.h b/avahi-common/gccmacro.h index dd49502..81b34cd 100644 --- a/avahi-common/gccmacro.h +++ b/avahi-common/gccmacro.h @@ -5,17 +5,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 diff --git a/avahi-common/llist.h b/avahi-common/llist.h index 37474e1..217e895 100644 --- a/avahi-common/llist.h +++ b/avahi-common/llist.h @@ -5,17 +5,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 diff --git a/avahi-common/malloc.c b/avahi-common/malloc.c index 51b8ff6..8c25474 100644 --- a/avahi-common/malloc.c +++ b/avahi-common/malloc.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 @@ -44,13 +44,13 @@ static const AvahiAllocator *allocator = NULL; static void oom(void) AVAHI_GCC_NORETURN; static void oom(void) { - + static const char msg[] = "Out of memory, aborting ...\n"; const char *n = msg; while (strlen(n) > 0) { ssize_t r; - + if ((r = write(2, n, strlen(n))) < 0) break; @@ -90,7 +90,7 @@ static void *xrealloc(void *p, size_t size) { /* Default implementation for avahi_calloc() */ static void *xcalloc(size_t nmemb, size_t size) { void *p; - + if (size == 0 || nmemb == 0) return NULL; @@ -104,7 +104,7 @@ void *avahi_malloc(size_t size) { if (size <= 0) return NULL; - + if (!allocator) return xmalloc(size); @@ -135,7 +135,7 @@ void avahi_free(void *p) { if (!p) return; - + if (!allocator) { free(p); return; @@ -162,7 +162,7 @@ void *avahi_realloc(void *p, size_t size) { char *avahi_strdup(const char *s) { char *r; size_t size; - + if (!s) return NULL; @@ -178,14 +178,14 @@ char *avahi_strndup(const char *s, size_t max) { char *r; size_t size; const char *p; - + if (!s) return NULL; for (p = s, size = 0; size < max && *p; p++, size++); - + if (!(r = avahi_new(char, size+1))) return NULL; @@ -202,7 +202,7 @@ void avahi_set_allocator(const AvahiAllocator *a) { char *avahi_strdup_vprintf(const char *fmt, va_list ap) { size_t len = 80; char *buf; - + assert(fmt); if (!(buf = avahi_malloc(len))) @@ -239,7 +239,7 @@ char *avahi_strdup_printf(const char *fmt, ... ) { va_list ap; assert(fmt); - + va_start(ap, fmt); s = avahi_strdup_vprintf(fmt, ap); va_end(ap); diff --git a/avahi-common/malloc.h b/avahi-common/malloc.h index 511b51c..ec74679 100644 --- a/avahi-common/malloc.h +++ b/avahi-common/malloc.h @@ -5,17 +5,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 diff --git a/avahi-common/rlist.c b/avahi-common/rlist.c index f24ab03..0451590 100644 --- a/avahi-common/rlist.c +++ b/avahi-common/rlist.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 @@ -35,7 +35,7 @@ AvahiRList* avahi_rlist_prepend(AvahiRList *r, void *data) { return NULL; n->data = data; - + AVAHI_LLIST_PREPEND(AvahiRList, rlist, r, n); return r; } @@ -56,7 +56,7 @@ AvahiRList* avahi_rlist_remove(AvahiRList *r, void *data) { AvahiRList* avahi_rlist_remove_by_link(AvahiRList *r, AvahiRList *n) { assert(n); - + AVAHI_LLIST_REMOVE(AvahiRList, rlist, r, n); avahi_free(n); diff --git a/avahi-common/rlist.h b/avahi-common/rlist.h index 0b88955..62e6dc4 100644 --- a/avahi-common/rlist.h +++ b/avahi-common/rlist.h @@ -5,17 +5,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 diff --git a/avahi-common/simple-watch.c b/avahi-common/simple-watch.c index c970c3c..aab71f6 100644 --- a/avahi-common/simple-watch.c +++ b/avahi-common/simple-watch.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 @@ -42,7 +42,7 @@ struct AvahiWatch { int idx; struct pollfd pollfd; - + AvahiWatchCallback callback; void *userdata; @@ -55,10 +55,10 @@ struct AvahiTimeout { int enabled; struct timeval expiry; - + AvahiTimeoutCallback callback; void *userdata; - + AVAHI_LLIST_FIELDS(AvahiTimeout, timeouts); }; @@ -111,7 +111,7 @@ static void clear_wakeup(AvahiSimplePoll *s) { return; s->wakeup_issued = 0; - + for(;;) if (read(s->wakeup_pipe[0], &c, sizeof(c)) != sizeof(c)) break; @@ -119,7 +119,7 @@ static void clear_wakeup(AvahiSimplePoll *s) { static int set_nonblock(int fd) { int n; - + assert(fd >= 0); if ((n = fcntl(fd, F_GETFL)) < 0) @@ -134,7 +134,7 @@ static int set_nonblock(int fd) { static AvahiWatch* watch_new(const AvahiPoll *api, int fd, AvahiWatchEvent event, AvahiWatchCallback callback, void *userdata) { AvahiWatch *w; AvahiSimplePoll *s; - + assert(api); assert(fd >= 0); assert(callback); @@ -147,7 +147,7 @@ static AvahiWatch* watch_new(const AvahiPoll *api, int fd, AvahiWatchEvent event /* If there is a background thread running the poll() for us, tell it to exit the poll() */ avahi_simple_poll_wakeup(s); - + w->simple_poll = s; w->dead = 0; @@ -198,7 +198,7 @@ static void remove_pollfd(AvahiWatch *w) { if (w->idx == -1) return; - + w->simple_poll->rebuild_pollfds = 1; } @@ -209,9 +209,9 @@ static void watch_free(AvahiWatch *w) { /* If there is a background thread running the poll() for us, tell it to exit the poll() */ avahi_simple_poll_wakeup(w->simple_poll); - + remove_pollfd(w); - + w->dead = 1; w->simple_poll->n_watches --; w->simple_poll->watch_req_cleanup = 1; @@ -225,7 +225,7 @@ static void destroy_watch(AvahiWatch *w) { if (!w->dead) w->simple_poll->n_watches --; - + avahi_free(w); } @@ -246,7 +246,7 @@ static void cleanup_watches(AvahiSimplePoll *s, int all) { static AvahiTimeout* timeout_new(const AvahiPoll *api, const struct timeval *tv, AvahiTimeoutCallback callback, void *userdata) { AvahiTimeout *t; AvahiSimplePoll *s; - + assert(api); assert(callback); @@ -258,13 +258,13 @@ static AvahiTimeout* timeout_new(const AvahiPoll *api, const struct timeval *tv, /* If there is a background thread running the poll() for us, tell it to exit the poll() */ avahi_simple_poll_wakeup(s); - + t->simple_poll = s; t->dead = 0; if ((t->enabled = !!tv)) t->expiry = *tv; - + t->callback = callback; t->userdata = userdata; @@ -278,7 +278,7 @@ static void timeout_update(AvahiTimeout *t, const struct timeval *tv) { /* If there is a background thread running the poll() for us, tell it to exit the poll() */ avahi_simple_poll_wakeup(t->simple_poll); - + if ((t->enabled = !!tv)) t->expiry = *tv; } @@ -330,7 +330,7 @@ AvahiSimplePoll *avahi_simple_poll_new(void) { set_nonblock(s->wakeup_pipe[0]); set_nonblock(s->wakeup_pipe[1]); - + s->api.userdata = s; s->api.watch_new = watch_new; @@ -341,14 +341,14 @@ AvahiSimplePoll *avahi_simple_poll_new(void) { s->api.timeout_new = timeout_new; s->api.timeout_free = timeout_free; s->api.timeout_update = timeout_update; - + s->pollfds = NULL; s->max_pollfds = s->n_pollfds = 0; s->rebuild_pollfds = 1; s->quit = 0; s->n_watches = 0; s->events_valid = 0; - + s->watch_req_cleanup = 0; s->timeout_req_cleanup = 0; @@ -357,7 +357,7 @@ AvahiSimplePoll *avahi_simple_poll_new(void) { s->state = STATE_INIT; s->wakeup_issued = 0; - + avahi_simple_poll_set_func(s, NULL, NULL); AVAHI_LLIST_HEAD_INIT(AvahiWatch, s->watches); @@ -372,7 +372,7 @@ void avahi_simple_poll_free(AvahiSimplePoll *s) { cleanup_timeouts(s, 1); cleanup_watches(s, 1); assert(s->n_watches == 0); - + avahi_free(s->pollfds); if (s->wakeup_pipe[0] >= 0) @@ -380,34 +380,34 @@ void avahi_simple_poll_free(AvahiSimplePoll *s) { if (s->wakeup_pipe[1] >= 0) close(s->wakeup_pipe[1]); - + avahi_free(s); } static int rebuild(AvahiSimplePoll *s) { AvahiWatch *w; int idx; - + assert(s); if (s->n_watches+1 > s->max_pollfds) { struct pollfd *n; s->max_pollfds = s->n_watches + 10; - + if (!(n = avahi_realloc(s->pollfds, sizeof(struct pollfd) * s->max_pollfds))) return -1; s->pollfds = n; } - + s->pollfds[0].fd = s->wakeup_pipe[0]; s->pollfds[0].events = POLLIN; s->pollfds[0].revents = 0; idx = 1; - + for (w = s->watches; w; w = w->watches_next) { if(w->dead) @@ -429,10 +429,10 @@ static AvahiTimeout* find_next_timeout(AvahiSimplePoll *s) { assert(s); for (t = s->timeouts; t; t = t->timeouts_next) { - + if (t->dead || !t->enabled) continue; - + if (!n || avahi_timeval_compare(&t->expiry, &n->expiry) < 0) n = t; } @@ -451,11 +451,11 @@ static void timeout_callback(AvahiTimeout *t) { int avahi_simple_poll_prepare(AvahiSimplePoll *s, int timeout) { AvahiTimeout *next_timeout; - + assert(s); assert(s->state == STATE_INIT || s->state == STATE_DISPATCHED || s->state == STATE_FAILURE); s->state = STATE_PREPARING; - + /* Clear pending wakeup requests */ clear_wakeup(s); @@ -492,7 +492,7 @@ int avahi_simple_poll_prepare(AvahiSimplePoll *s, int timeout) { timeout = 0; goto finish; } - + gettimeofday(&now, NULL); usec = avahi_timeval_diff(&next_timeout->expiry, &now); @@ -520,17 +520,17 @@ finish: int avahi_simple_poll_run(AvahiSimplePoll *s) { assert(s); assert(s->state == STATE_PREPARED || s->state == STATE_FAILURE); - + s->state = STATE_RUNNING; if (s->poll_func(s->pollfds, s->n_pollfds, s->prepared_timeout, s->poll_func_userdata) < 0) { s->state = STATE_FAILURE; return -1; } - + /* The poll events are now valid again */ s->events_valid = 1; - + /* Update state */ s->state = STATE_RAN; return 0; @@ -545,17 +545,17 @@ int avahi_simple_poll_dispatch(AvahiSimplePoll *s) { s->state = STATE_DISPATCHING; /* We execute only on callback in every iteration */ - + /* Check whether the wakeup time has been reached now */ if ((next_timeout = find_next_timeout(s))) { - + if (next_timeout->expiry.tv_sec == 0 && next_timeout->expiry.tv_usec == 0) { /* Just a shortcut so that we don't need to call gettimeofday() */ timeout_callback(next_timeout); goto finish; } - + if (avahi_age(&next_timeout->expiry) >= 0) { /* Timeout elapsed */ @@ -566,13 +566,13 @@ int avahi_simple_poll_dispatch(AvahiSimplePoll *s) { /* Look for some kind of I/O event */ for (w = s->watches; w; w = w->watches_next) { - + if (w->dead) continue; - + assert(w->idx >= 0); assert(w->idx < s->n_pollfds); - + if (s->pollfds[w->idx].revents != 0) { w->callback(w, w->pollfd.fd, s->pollfds[w->idx].revents, w->userdata); goto finish; @@ -596,7 +596,7 @@ int avahi_simple_poll_iterate(AvahiSimplePoll *s, int timeout) { if ((r = avahi_simple_poll_dispatch(s)) != 0) return r; - + return 0; } @@ -611,7 +611,7 @@ void avahi_simple_poll_quit(AvahiSimplePoll *s) { const AvahiPoll* avahi_simple_poll_get(AvahiSimplePoll *s) { assert(s); - + return &s->api; } @@ -633,7 +633,7 @@ int avahi_simple_poll_loop(AvahiSimplePoll *s) { int r; assert(s); - + for (;;) if ((r = avahi_simple_poll_iterate(s, -1)) != 0) if (r >= 0 || errno != EINTR) diff --git a/avahi-common/simple-watch.h b/avahi-common/simple-watch.h index 7c83db3..20e8f79 100644 --- a/avahi-common/simple-watch.h +++ b/avahi-common/simple-watch.h @@ -5,17 +5,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 diff --git a/avahi-common/strlst.c b/avahi-common/strlst.c index f8be273..d179cc0 100644 --- a/avahi-common/strlst.c +++ b/avahi-common/strlst.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 @@ -38,7 +38,7 @@ AvahiStringList*avahi_string_list_add_anonymous(AvahiStringList *l, size_t size) if (!(n = avahi_malloc(sizeof(AvahiStringList) + size))) return NULL; - + n->next = l; n->size = size; @@ -71,14 +71,14 @@ AvahiStringList *avahi_string_list_add(AvahiStringList *l, const char *text) { int avahi_string_list_parse(const void* data, size_t size, AvahiStringList **ret) { const uint8_t *c; AvahiStringList *r = NULL; - + assert(data); assert(ret); c = data; while (size > 0) { size_t k; - + k = *(c++); size--; @@ -88,18 +88,18 @@ int avahi_string_list_parse(const void* data, size_t size, AvahiStringList **ret if (k > 0) { /* Ignore empty strings */ AvahiStringList *n; - if (!(n = avahi_string_list_add_arbitrary(r, c, k))) + if (!(n = avahi_string_list_add_arbitrary(r, c, k))) goto fail; /* OOM */ r = n; } - + c += k; size -= k; } *ret = r; - + return 0; fail: @@ -146,7 +146,7 @@ char* avahi_string_list_to_string(AvahiStringList *l) { return NULL; l = avahi_string_list_reverse(l); - + for (n = l; n; n = n->next) { if (n != l) *(e++) = ' '; @@ -161,7 +161,7 @@ char* avahi_string_list_to_string(AvahiStringList *l) { } l = avahi_string_list_reverse(l); - + *e = 0; return t; @@ -176,18 +176,18 @@ size_t avahi_string_list_serialize(AvahiStringList *l, void *data, size_t size) l = avahi_string_list_reverse(l); c = data; - + for (n = l; size > 1 && n; n = n->next) { size_t k; if ((k = n->size) == 0) /* Skip empty strings */ continue; - + if (k > 255) /* Truncate strings at 255 characters */ k = 255; - + if (k > size-1) /* Make sure this string fits in */ k = size-1; @@ -195,15 +195,15 @@ size_t avahi_string_list_serialize(AvahiStringList *l, void *data, size_t size) *(c++) = (uint8_t) k; memcpy(c, n->text, k); c += k; - + used += 1 + k; size -= 1 + k; } - + l = avahi_string_list_reverse(l); if (used == 0 && size > 0) { - + /* Empty lists are treated specially. To comply with * section 6.1 of the DNS-SD spec, we return a single * empty string (i.e. a NUL byte)*/ @@ -211,19 +211,19 @@ size_t avahi_string_list_serialize(AvahiStringList *l, void *data, size_t size) *(uint8_t*) data = 0; used = 1; } - + } else { AvahiStringList *n; for (n = l; n; n = n->next) { size_t k; - + if ((k = n->size) == 0) continue; - + if (k > 255) k = 255; - + used += 1+k; } @@ -260,7 +260,7 @@ AvahiStringList *avahi_string_list_add_many(AvahiStringList *r, ...) { va_start(va, r); r = avahi_string_list_add_many_va(r, va); va_end(va); - + return r; } @@ -328,7 +328,7 @@ unsigned avahi_string_list_length(const AvahiStringList *l) { AvahiStringList *avahi_string_list_add_vprintf(AvahiStringList *l, const char *format, va_list va) { size_t len = 80; AvahiStringList *r; - + assert(format); if (!(r = avahi_malloc(sizeof(AvahiStringList) + len))) @@ -338,7 +338,7 @@ AvahiStringList *avahi_string_list_add_vprintf(AvahiStringList *l, const char *f int n; AvahiStringList *nr; va_list va2; - + va_copy(va2, va); n = vsnprintf((char*) r->text, len, format, va2); va_end(va2); @@ -358,28 +358,28 @@ AvahiStringList *avahi_string_list_add_vprintf(AvahiStringList *l, const char *f r = nr; } - + r->next = l; - r->size = strlen((char*) r->text); + r->size = strlen((char*) r->text); return r; } AvahiStringList *avahi_string_list_add_printf(AvahiStringList *l, const char *format, ...) { va_list va; - + assert(format); va_start(va, format); l = avahi_string_list_add_vprintf(l, format, va); va_end(va); - return l; + return l; } AvahiStringList *avahi_string_list_find(AvahiStringList *l, const char *key) { size_t n; - + assert(key); n = strlen(key); @@ -411,7 +411,7 @@ AvahiStringList *avahi_string_list_add_pair_arbitrary(AvahiStringList *l, const return avahi_string_list_add(l, key); n = strlen(key); - + if (!(l = avahi_string_list_add_anonymous(l, n + 1 + size))) return NULL; @@ -424,12 +424,12 @@ AvahiStringList *avahi_string_list_add_pair_arbitrary(AvahiStringList *l, const int avahi_string_list_get_pair(AvahiStringList *l, char **key, char **value, size_t *size) { char *e; - + assert(l); if (!(e = memchr(l->text, '=', l->size))) { - if (key) + if (key) if (!(*key = avahi_strdup((char*) l->text))) return -1; @@ -447,9 +447,9 @@ int avahi_string_list_get_pair(AvahiStringList *l, char **key, char **value, siz return -1; e++; /* Advance after '=' */ - + n = l->size - (e - (char*) l->text); - + if (value) { if (!(*value = avahi_memdup(e, n+1))) { @@ -487,7 +487,7 @@ uint32_t avahi_string_list_get_service_cookie(AvahiStringList *l) { AvahiStringList *f; char *value = NULL, *end = NULL; uint32_t ret; - + if (!(f = avahi_string_list_find(l, AVAHI_SERVICE_COOKIE))) return AVAHI_SERVICE_COOKIE_INVALID; @@ -502,6 +502,6 @@ uint32_t avahi_string_list_get_service_cookie(AvahiStringList *l) { } avahi_free(value); - + return ret; } diff --git a/avahi-common/strlst.h b/avahi-common/strlst.h index 8d827d6..8bf5981 100644 --- a/avahi-common/strlst.h +++ b/avahi-common/strlst.h @@ -5,17 +5,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 diff --git a/avahi-common/thread-watch.h b/avahi-common/thread-watch.h index 92b5dfc..98da293 100644 --- a/avahi-common/thread-watch.h +++ b/avahi-common/thread-watch.h @@ -5,17 +5,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 diff --git a/avahi-common/timeval.c b/avahi-common/timeval.c index edab241..0cfb136 100644 --- a/avahi-common/timeval.c +++ b/avahi-common/timeval.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 @@ -77,7 +77,7 @@ struct timeval* avahi_timeval_add(struct timeval *a, AvahiUsec usec) { AvahiUsec avahi_age(const struct timeval *a) { struct timeval now; - + assert(a); gettimeofday(&now, NULL); @@ -100,7 +100,7 @@ struct timeval *avahi_elapse_time(struct timeval *tv, unsigned msec, unsigned ji time_t now; int r; - + now = time(NULL); pthread_mutex_lock(&mutex); @@ -108,18 +108,18 @@ struct timeval *avahi_elapse_time(struct timeval *tv, unsigned msec, unsigned ji timestamp = now; last_rand = rand(); } - + r = last_rand; - + pthread_mutex_unlock(&mutex); /* We use the same jitter for 10 seconds. That way our * time events elapse in bursts which has the advantage that * packet data can be aggregated better */ - + avahi_timeval_add(tv, (AvahiUsec) (jitter*1000.0*r/(RAND_MAX+1.0))); } - + return tv; } diff --git a/avahi-common/timeval.h b/avahi-common/timeval.h index a441c08..01819be 100644 --- a/avahi-common/timeval.h +++ b/avahi-common/timeval.h @@ -5,17 +5,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 diff --git a/avahi-common/utf8-test.c b/avahi-common/utf8-test.c index d8ffc1b..4fbc50a 100644 --- a/avahi-common/utf8-test.c +++ b/avahi-common/utf8-test.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 @@ -34,6 +34,6 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { assert(avahi_utf8_valid("hallo")); assert(!avahi_utf8_valid("üxknürz")); assert(avahi_utf8_valid("üxknürz")); - + return 0; } diff --git a/avahi-common/utf8.c b/avahi-common/utf8.c index f52ce55..0fe42d0 100644 --- a/avahi-common/utf8.c +++ b/avahi-common/utf8.c @@ -37,8 +37,8 @@ (((Char) & 0xFFFFF800) != 0xD800) && \ ((Char) < 0xFDD0 || (Char) > 0xFDEF) && \ ((Char) & 0xFFFE) != 0xFFFE) - - + + #define CONTINUATION_CHAR \ do { \ if ((*(const unsigned char *)p & 0xc0) != 0x80) /* 10xxxxxx */ \ @@ -60,10 +60,10 @@ avahi_utf8_valid (const char *str) { if (*(const unsigned char *)p < 128) /* done */; - else + else { const char *last; - + last = p; if ((*(const unsigned char *)p & 0xe0) == 0xc0) /* 110xxxxx */ { @@ -88,7 +88,7 @@ avahi_utf8_valid (const char *str) } else goto error; - + p++; CONTINUATION_CHAR; TWO_REMAINING: @@ -96,16 +96,16 @@ avahi_utf8_valid (const char *str) CONTINUATION_CHAR; p++; CONTINUATION_CHAR; - + if ( (val < min)) goto error; if ( (!UNICODE_VALID(val))) goto error; - } - + } + continue; - + error: return NULL; } diff --git a/avahi-common/utf8.h b/avahi-common/utf8.h index 93c9b59..aa2b17a 100644 --- a/avahi-common/utf8.h +++ b/avahi-common/utf8.h @@ -5,17 +5,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 diff --git a/avahi-common/watch-test.c b/avahi-common/watch-test.c index 870045d..da8e033 100644 --- a/avahi-common/watch-test.c +++ b/avahi-common/watch-test.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 @@ -48,7 +48,7 @@ static void callback(AvahiWatch *w, int fd, AvahiWatchEvent event, AVAHI_GCC_UNU if (event & AVAHI_WATCH_IN) { ssize_t r; char c; - + if ((r = read(fd, &c, 1)) <= 0) { fprintf(stderr, "read() failed: %s\n", r < 0 ? strerror(errno) : "EOF"); api->watch_free(w); @@ -91,7 +91,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { api = avahi_threaded_poll_get(threaded_poll); assert(api); #endif - + api->watch_new(api, 0, AVAHI_WATCH_IN, callback, NULL); avahi_elapse_time(&tv, 1000, 0); @@ -110,8 +110,8 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { fprintf(stderr, "... stupid stuff is done.\n"); avahi_threaded_poll_free(threaded_poll); - + #endif - + return 0; } diff --git a/avahi-common/watch.h b/avahi-common/watch.h index 31adad7..9b855d1 100644 --- a/avahi-common/watch.h +++ b/avahi-common/watch.h @@ -5,17 +5,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 @@ -62,7 +62,7 @@ typedef void (*AvahiTimeoutCallback)(AvahiTimeout *t, void *userdata); struct AvahiPoll { /** Some abstract user data usable by the provider of the API */ - void* userdata; + void* userdata; /** Create a new watch for the specified file descriptor and for * the specified events. The API will call the callback function @@ -88,7 +88,7 @@ struct AvahiPoll { /** Update the absolute expiration time for a timeout, If tv is * NULL, the timeout is disabled. It is safe to call this function from an AvahiTimeoutCallback */ void (*timeout_update)(AvahiTimeout *, const struct timeval *tv); - + /** Free a timeout. It is safe to call this function from an AvahiTimeoutCallback */ void (*timeout_free)(AvahiTimeout *t); }; -- cgit