From a97605e07ad7f44f2f65e15be64880e61a39ab43 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 25 Jun 2010 01:08:29 +0200 Subject: [PATCH] from now on we enforce a strict whitespace regime --- avahi-autoipd/iface-linux.c | 64 +++--- avahi-autoipd/iface.h | 6 +- avahi-autoipd/main.h | 6 +- avahi-client/browser.c | 106 ++++----- avahi-client/check-nss-test.c | 6 +- avahi-client/check-nss.c | 14 +- avahi-client/client-test.c | 30 +-- avahi-client/client.h | 10 +- avahi-client/entrygroup.c | 138 ++++++------ avahi-client/internal.h | 12 +- avahi-client/publish.h | 20 +- avahi-client/resolver.c | 112 +++++----- avahi-client/rr-test.c | 20 +- avahi-client/srv-test.c | 12 +- avahi-client/xdg-config-test.c | 8 +- avahi-client/xdg-config.h | 6 +- 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 +- avahi-compat-howl/address-test.c | 10 +- avahi-compat-howl/address.c | 26 +-- avahi-compat-howl/browse-domain-test.c | 14 +- avahi-compat-howl/compat.c | 208 +++++++++--------- avahi-compat-howl/include/corby/buffer.h | 40 ++-- avahi-compat-howl/include/corby/channel.h | 6 +- avahi-compat-howl/include/corby/corby.h | 6 +- avahi-compat-howl/include/corby/message.h | 4 +- avahi-compat-howl/include/corby/object.h | 4 +- avahi-compat-howl/include/corby/orb.h | 8 +- .../include/discovery/discovery.h | 18 +- .../include/discovery/text_record.h | 2 +- avahi-compat-howl/include/howl.h | 2 +- .../include/rendezvous/rendezvous.h | 2 +- .../include/rendezvous/text_record.h | 2 +- avahi-compat-howl/include/salt/address.h | 4 +- avahi-compat-howl/include/salt/debug.h | 4 +- avahi-compat-howl/include/salt/interface.h | 2 +- avahi-compat-howl/include/salt/platform.h | 14 +- avahi-compat-howl/include/salt/salt.h | 24 +- avahi-compat-howl/include/salt/signal.h | 6 +- avahi-compat-howl/include/salt/socket.h | 54 ++--- avahi-compat-howl/include/salt/time.h | 6 +- avahi-compat-howl/samples/browse.c | 4 +- avahi-compat-howl/samples/publish.c | 2 +- avahi-compat-howl/samples/query.c | 4 +- avahi-compat-howl/samples/resolve.c | 4 +- avahi-compat-howl/text-test.c | 10 +- avahi-compat-howl/text.c | 44 ++-- avahi-compat-howl/unsupported.c | 40 ++-- avahi-compat-howl/warn.c | 6 +- avahi-compat-howl/warn.h | 6 +- avahi-compat-libdns_sd/compat.c | 184 ++++++++-------- avahi-compat-libdns_sd/dns_sd.h | 66 +++--- avahi-compat-libdns_sd/null-test.c | 6 +- avahi-compat-libdns_sd/txt.c | 56 ++--- avahi-compat-libdns_sd/unsupported.c | 18 +- avahi-compat-libdns_sd/warn.c | 24 +- avahi-compat-libdns_sd/warn.h | 6 +- avahi-core/announce.c | 104 ++++----- avahi-core/announce.h | 6 +- avahi-core/avahi-reflector.c | 10 +- avahi-core/avahi-test.c | 40 ++-- avahi-core/browse-dns-server.c | 64 +++--- avahi-core/browse-domain.c | 58 ++--- avahi-core/browse-service-type.c | 28 +-- avahi-core/browse-service.c | 30 +-- avahi-core/browse.c | 98 ++++----- avahi-core/browse.h | 8 +- avahi-core/cache.c | 90 ++++---- avahi-core/cache.h | 14 +- avahi-core/conformance-test.c | 26 +-- avahi-core/core.h | 6 +- avahi-core/dns-spin-test.c | 6 +- avahi-core/dns-srv-rr.h | 8 +- avahi-core/dns-test.c | 14 +- avahi-core/dns.c | 168 +++++++------- avahi-core/dns.h | 6 +- avahi-core/domain-util.c | 26 +-- avahi-core/domain-util.h | 8 +- avahi-core/entry.c | 198 ++++++++--------- avahi-core/fdutil.c | 16 +- avahi-core/fdutil.h | 6 +- avahi-core/hashmap-test.c | 10 +- avahi-core/hashmap.c | 36 +-- avahi-core/hashmap.h | 6 +- avahi-core/iface-linux.c | 42 ++-- avahi-core/iface-linux.h | 10 +- avahi-core/iface-pfroute.c | 62 +++--- avahi-core/iface-pfroute.h | 6 +- avahi-core/iface.h | 16 +- avahi-core/internal.h | 28 +-- avahi-core/log.c | 10 +- avahi-core/log.h | 6 +- avahi-core/lookup.h | 10 +- avahi-core/multicast-lookup.c | 54 ++--- avahi-core/multicast-lookup.h | 6 +- avahi-core/netlink.c | 26 +-- avahi-core/netlink.h | 6 +- avahi-core/prioq-test.c | 12 +- avahi-core/prioq.c | 50 ++--- avahi-core/prioq.h | 6 +- avahi-core/probe-sched.c | 62 +++--- avahi-core/probe-sched.h | 6 +- avahi-core/publish.h | 22 +- avahi-core/querier-test.c | 20 +- avahi-core/querier.c | 44 ++-- avahi-core/querier.h | 6 +- avahi-core/query-sched.c | 68 +++--- avahi-core/query-sched.h | 6 +- avahi-core/resolve-address.c | 48 ++-- avahi-core/resolve-host-name.c | 56 ++--- avahi-core/resolve-service.c | 100 ++++----- avahi-core/response-sched.c | 66 +++--- avahi-core/response-sched.h | 6 +- avahi-core/rr-util.h | 6 +- avahi-core/rr.h | 22 +- avahi-core/rrlist.c | 30 +-- avahi-core/rrlist.h | 6 +- avahi-core/socket.h | 6 +- avahi-core/timeeventq-test.c | 6 +- avahi-core/timeeventq.c | 32 +-- avahi-core/timeeventq.h | 6 +- avahi-core/update-test.c | 16 +- avahi-core/util.c | 24 +- avahi-core/util.h | 6 +- avahi-core/wide-area.c | 110 ++++----- avahi-core/wide-area.h | 6 +- avahi-daemon/caps.c | 18 +- avahi-daemon/caps.h | 6 +- avahi-daemon/chroot.c | 68 +++--- avahi-daemon/chroot.h | 6 +- avahi-daemon/dbus-async-address-resolver.c | 28 +-- avahi-daemon/dbus-async-host-name-resolver.c | 26 +-- avahi-daemon/dbus-async-service-resolver.c | 36 +-- avahi-daemon/dbus-domain-browser.c | 28 +-- avahi-daemon/dbus-entry-group.c | 86 ++++---- avahi-daemon/dbus-internal.h | 14 +- avahi-daemon/dbus-protocol.c | 168 +++++++------- avahi-daemon/dbus-protocol.h | 6 +- avahi-daemon/dbus-record-browser.c | 38 ++-- avahi-daemon/dbus-service-browser.c | 34 +-- avahi-daemon/dbus-service-type-browser.c | 28 +-- avahi-daemon/dbus-sync-address-resolver.c | 10 +- avahi-daemon/dbus-sync-host-name-resolver.c | 10 +- avahi-daemon/dbus-sync-service-resolver.c | 26 +-- avahi-daemon/dbus-util.c | 90 ++++---- avahi-daemon/dbus-util.h | 6 +- avahi-daemon/ini-file-parser-test.c | 8 +- avahi-daemon/ini-file-parser.c | 36 +-- avahi-daemon/ini-file-parser.h | 6 +- avahi-daemon/main.h | 6 +- avahi-daemon/setproctitle.c | 18 +- avahi-daemon/setproctitle.h | 6 +- avahi-daemon/simple-protocol.h | 6 +- avahi-daemon/static-hosts.c | 28 +-- avahi-daemon/static-hosts.h | 6 +- avahi-daemon/static-services.h | 6 +- avahi-dnsconfd/main.c | 90 ++++---- avahi-glib/glib-malloc.c | 6 +- avahi-glib/glib-malloc.h | 6 +- avahi-glib/glib-watch-test.c | 12 +- avahi-glib/glib-watch.c | 58 ++--- avahi-glib/glib-watch.h | 6 +- avahi-qt/qt-watch.h | 6 +- avahi-utils/sigint.c | 18 +- avahi-utils/sigint.h | 6 +- avahi-utils/stdb.c | 26 +-- avahi-utils/stdb.h | 6 +- docs/socket-auto-port.c | 6 +- examples/client-browse-services.c | 28 +-- examples/core-browse-services.c | 38 ++-- examples/core-publish-service.c | 48 ++-- examples/glib-integration.c | 12 +- 201 files changed, 2792 insertions(+), 2792 deletions(-) diff --git a/avahi-autoipd/iface-linux.c b/avahi-autoipd/iface-linux.c index 5bc0300..b4abd6f 100644 --- a/avahi-autoipd/iface-linux.c +++ b/avahi-autoipd/iface-linux.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 @@ -67,7 +67,7 @@ AVAHI_LLIST_HEAD(Address, addresses) = NULL; int iface_init(int i) { struct sockaddr_nl addr; int on = 1; - + if ((fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE)) < 0) { daemon_log(LOG_ERR, "socket(PF_NETLINK): %s", strerror(errno)); goto fail; @@ -82,22 +82,22 @@ int iface_init(int i) { daemon_log(LOG_ERR, "bind(): %s", strerror(errno)); goto fail; } - + if (setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)) < 0) { daemon_log(LOG_ERR, "SO_PASSCRED: %s", strerror(errno)); goto fail; } ifindex = i; - + return fd; - + fail: if (fd >= 0) { close(fd); fd = -1; } - + return -1; } @@ -112,14 +112,14 @@ static int process_nlmsg(struct nlmsghdr *n) { if (ifi->ifi_family != AF_UNSPEC || (int) ifi->ifi_index != ifindex) return 0; - + if (n->nlmsg_type == RTM_DELLINK) { daemon_log(LOG_ERR, "Interface vanished."); return -1; } assert(n->nlmsg_type == RTM_NEWLINK); - + if ((ifi->ifi_flags & IFF_LOOPBACK) || (ifi->ifi_flags & IFF_NOARP) || ifi->ifi_type != ARPHRD_ETHER) { @@ -136,7 +136,7 @@ static int process_nlmsg(struct nlmsghdr *n) { int l; uint32_t address = 0; Address *i; - + ifa = NLMSG_DATA(n); if (ifa->ifa_family != AF_INET || (int) ifa->ifa_index != ifindex) @@ -154,7 +154,7 @@ static int process_nlmsg(struct nlmsghdr *n) { memcpy(&address, RTA_DATA(a), sizeof(uint32_t)); break; } - + a = RTA_NEXT(a, l); } @@ -180,7 +180,7 @@ static int process_nlmsg(struct nlmsghdr *n) { static int process_response(int wait_for_done, unsigned seq) { assert(fd >= 0); - + do { size_t bytes; ssize_t r; @@ -189,39 +189,39 @@ static int process_response(int wait_for_done, unsigned seq) { struct msghdr msghdr; struct cmsghdr *cmsghdr; struct ucred *ucred; - struct iovec iov; + struct iovec iov; struct nlmsghdr *p = (struct nlmsghdr *) replybuf; - + memset(&iov, 0, sizeof(iov)); - iov.iov_base = replybuf; + iov.iov_base = replybuf; iov.iov_len = sizeof(replybuf); memset(&msghdr, 0, sizeof(msghdr)); msghdr.msg_name = (void*) NULL; - msghdr.msg_namelen = 0; - msghdr.msg_iov = &iov; - msghdr.msg_iovlen = 1; - msghdr.msg_control = cred_msg; - msghdr.msg_controllen = sizeof(cred_msg); + msghdr.msg_namelen = 0; + msghdr.msg_iov = &iov; + msghdr.msg_iovlen = 1; + msghdr.msg_control = cred_msg; + msghdr.msg_controllen = sizeof(cred_msg); msghdr.msg_flags = 0; - + if ((r = recvmsg(fd, &msghdr, 0)) < 0) { daemon_log(LOG_ERR, "recvmsg() failed: %s", strerror(errno)); return -1; } if (!(cmsghdr = CMSG_FIRSTHDR(&msghdr)) || cmsghdr->cmsg_type != SCM_CREDENTIALS) { - daemon_log(LOG_WARNING, "No sender credentials received, ignoring data."); + daemon_log(LOG_WARNING, "No sender credentials received, ignoring data."); return -1; } ucred = (struct ucred*) CMSG_DATA(cmsghdr); - + if (ucred->uid != 0) return -1; bytes = (size_t) r; - + for (; bytes > 0; p = NLMSG_NEXT(p, bytes)) { if (!NLMSG_OK(p, bytes) || bytes < sizeof(struct nlmsghdr) || bytes < p->nlmsg_len) { @@ -258,7 +258,7 @@ int iface_get_initial_state(State *state) { assert(fd >= 0); assert(state); - + memset(&req, 0, sizeof(req)); n = (struct nlmsghdr*) req; n->nlmsg_len = NLMSG_LENGTH(sizeof(*ifi)); @@ -278,7 +278,7 @@ int iface_get_initial_state(State *state) { if (process_response(1, 0) < 0) return -1; - + n->nlmsg_type = RTM_GETADDR; n->nlmsg_len = NLMSG_LENGTH(sizeof(*ifa)); n->nlmsg_seq = ++seq; @@ -286,7 +286,7 @@ int iface_get_initial_state(State *state) { ifa = NLMSG_DATA(n); ifa->ifa_family = AF_INET; ifa->ifa_index = ifindex; - + if (send(fd, n, n->nlmsg_len, 0) < 0) { daemon_log(LOG_ERR, "send(): %s", strerror(errno)); return -1; @@ -296,7 +296,7 @@ int iface_get_initial_state(State *state) { return -1; *state = addresses ? STATE_SLEEPING : STATE_START; - + return 0; } @@ -305,7 +305,7 @@ int iface_process(Event *event) { assert(fd >= 0); b = !!addresses; - + if (process_response(0, 0) < 0) return -1; @@ -313,13 +313,13 @@ int iface_process(Event *event) { *event = EVENT_ROUTABLE_ADDR_UNCONFIGURED; else if (!b && addresses) *event = EVENT_ROUTABLE_ADDR_CONFIGURED; - + return 0; } void iface_done(void) { Address *a; - + if (fd >= 0) { close(fd); fd = -1; diff --git a/avahi-autoipd/iface.h b/avahi-autoipd/iface.h index e3f913e..7599b80 100644 --- a/avahi-autoipd/iface.h +++ b/avahi-autoipd/iface.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-autoipd/main.h b/avahi-autoipd/main.h index adadc99..1e2f627 100644 --- a/avahi-autoipd/main.h +++ b/avahi-autoipd/main.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-client/browser.c b/avahi-client/browser.c index 24393b8..1889694 100644 --- a/avahi-client/browser.c +++ b/avahi-client/browser.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,7 +44,7 @@ static void parse_environment(AvahiDomainBrowser *b) { char buf[AVAHI_DOMAIN_NAME_MAX*3], *e, *t, *p; assert(b); - + if (!(e = getenv("AVAHI_BROWSE_DOMAINS"))) return; @@ -60,17 +60,17 @@ static void parse_environment(AvahiDomainBrowser *b) { static void parse_domain_file(AvahiDomainBrowser *b) { FILE *f; char buf[AVAHI_DOMAIN_NAME_MAX]; - + assert(b); if (!(f = avahi_xdg_config_open("avahi/browse-domains"))) return; - - + + while (fgets(buf, sizeof(buf)-1, f)) { char domain[AVAHI_DOMAIN_NAME_MAX]; buf[strcspn(buf, "\n\r")] = 0; - + if (avahi_normalize_name(buf, domain, sizeof(domain))) b->static_browse_domains = avahi_string_list_add(b->static_browse_domains, domain); } @@ -112,7 +112,7 @@ AvahiDomainBrowser* avahi_domain_browser_new( AvahiLookupFlags flags, AvahiDomainBrowserCallback callback, void *userdata) { - + AvahiDomainBrowser *db = NULL; DBusMessage *message = NULL, *reply = NULL; DBusError error; @@ -156,7 +156,7 @@ AvahiDomainBrowser* avahi_domain_browser_new( } db->static_browse_domains = avahi_string_list_reverse(db->static_browse_domains); - + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "DomainBrowserNew"))) { avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; @@ -208,10 +208,10 @@ AvahiDomainBrowser* avahi_domain_browser_new( goto fail; } } - + dbus_message_unref(message); dbus_message_unref(reply); - + return db; fail: @@ -223,7 +223,7 @@ fail: if (db) avahi_domain_browser_free(db); - + if (message) dbus_message_unref(message); @@ -241,13 +241,13 @@ AvahiClient* avahi_domain_browser_get_client (AvahiDomainBrowser *b) { int avahi_domain_browser_free (AvahiDomainBrowser *b) { AvahiClient *client; int r = AVAHI_OK; - + assert(b); assert(b->ref >= 1); if (--(b->ref) >= 1) return AVAHI_OK; - + client = b->client; if (b->path && avahi_client_is_connected(b->client)) @@ -257,7 +257,7 @@ int avahi_domain_browser_free (AvahiDomainBrowser *b) { if (b->defer_timeout) b->client->poll_api->timeout_free(b->defer_timeout); - + avahi_string_list_free(b->static_browse_domains); avahi_free(b->path); avahi_free(b); @@ -276,7 +276,7 @@ DBusHandlerResult avahi_domain_browser_event (AvahiClient *client, AvahiBrowserE assert(client); assert(message); - + dbus_error_init (&error); if (!(path = dbus_message_get_path(message))) @@ -295,7 +295,7 @@ DBusHandlerResult avahi_domain_browser_event (AvahiClient *client, AvahiBrowserE switch (event) { case AVAHI_BROWSER_NEW: case AVAHI_BROWSER_REMOVE: - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_INT32, &interface, @@ -309,14 +309,14 @@ DBusHandlerResult avahi_domain_browser_event (AvahiClient *client, AvahiBrowserE } break; - + case AVAHI_BROWSER_CACHE_EXHAUSTED: case AVAHI_BROWSER_ALL_FOR_NOW: break; case AVAHI_BROWSER_FAILURE: { char *etxt; - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_STRING, &etxt, @@ -325,7 +325,7 @@ DBusHandlerResult avahi_domain_browser_event (AvahiClient *client, AvahiBrowserE fprintf(stderr, "Failed to parse browser event.\n"); goto fail; } - + avahi_client_set_errno(db->client, avahi_error_dbus_to_number(etxt)); break; } @@ -337,7 +337,7 @@ DBusHandlerResult avahi_domain_browser_event (AvahiClient *client, AvahiBrowserE /* We had this entry already in the static entries */ return DBUS_HANDLER_RESULT_HANDLED; } - + db->callback(db, (AvahiIfIndex) interface, (AvahiProtocol) protocol, event, domain, (AvahiLookupResultFlags) flags, db->userdata); return DBUS_HANDLER_RESULT_HANDLED; @@ -354,10 +354,10 @@ AvahiServiceTypeBrowser* avahi_service_type_browser_new( AvahiIfIndex interface, AvahiProtocol protocol, const char *domain, - AvahiLookupFlags flags, + AvahiLookupFlags flags, AvahiServiceTypeBrowserCallback callback, void *userdata) { - + AvahiServiceTypeBrowser *b = NULL; DBusMessage *message = NULL, *reply = NULL; DBusError error; @@ -398,12 +398,12 @@ AvahiServiceTypeBrowser* avahi_service_type_browser_new( avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "ServiceTypeBrowserNew"))) { avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; u_flags = (uint32_t) flags; @@ -446,7 +446,7 @@ AvahiServiceTypeBrowser* avahi_service_type_browser_new( return b; fail: - + if (dbus_error_is_set(&error)) { avahi_client_set_dbus_error(client, &error); dbus_error_free(&error); @@ -454,7 +454,7 @@ fail: if (b) avahi_service_type_browser_free(b); - + if (message) dbus_message_unref(message); @@ -497,7 +497,7 @@ DBusHandlerResult avahi_service_type_browser_event (AvahiClient *client, AvahiBr assert(client); assert(message); - + dbus_error_init (&error); if (!(path = dbus_message_get_path(message))) @@ -513,7 +513,7 @@ DBusHandlerResult avahi_service_type_browser_event (AvahiClient *client, AvahiBr domain = b->domain; interface = b->interface; protocol = b->protocol; - + switch (event) { case AVAHI_BROWSER_NEW: case AVAHI_BROWSER_REMOVE: @@ -530,14 +530,14 @@ DBusHandlerResult avahi_service_type_browser_event (AvahiClient *client, AvahiBr goto fail; } break; - + case AVAHI_BROWSER_CACHE_EXHAUSTED: case AVAHI_BROWSER_ALL_FOR_NOW: break; case AVAHI_BROWSER_FAILURE: { char *etxt; - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_STRING, &etxt, @@ -546,7 +546,7 @@ DBusHandlerResult avahi_service_type_browser_event (AvahiClient *client, AvahiBr fprintf(stderr, "Failed to parse browser event.\n"); goto fail; } - + avahi_client_set_errno(b->client, avahi_error_dbus_to_number(etxt)); break; } @@ -569,10 +569,10 @@ AvahiServiceBrowser* avahi_service_browser_new( AvahiProtocol protocol, const char *type, const char *domain, - AvahiLookupFlags flags, + AvahiLookupFlags flags, AvahiServiceBrowserCallback callback, void *userdata) { - + AvahiServiceBrowser *b = NULL; DBusMessage *message = NULL, *reply = NULL; DBusError error; @@ -598,7 +598,7 @@ AvahiServiceBrowser* avahi_service_browser_new( avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + b->client = client; b->callback = callback; b->userdata = userdata; @@ -613,13 +613,13 @@ AvahiServiceBrowser* avahi_service_browser_new( avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (domain && domain[0]) if (!(b->domain = avahi_strdup(domain))) { avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "ServiceBrowserNew"))) { avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; @@ -664,7 +664,7 @@ AvahiServiceBrowser* avahi_service_browser_new( dbus_message_unref(message); dbus_message_unref(reply); - + return b; fail: @@ -675,7 +675,7 @@ fail: if (b) avahi_service_browser_free(b); - + if (message) dbus_message_unref(message); @@ -737,7 +737,7 @@ DBusHandlerResult avahi_service_browser_event(AvahiClient *client, AvahiBrowserE switch (event) { case AVAHI_BROWSER_NEW: case AVAHI_BROWSER_REMOVE: - + if (!dbus_message_get_args ( message, &error, DBUS_TYPE_INT32, &interface, @@ -759,7 +759,7 @@ DBusHandlerResult avahi_service_browser_event(AvahiClient *client, AvahiBrowserE case AVAHI_BROWSER_FAILURE: { char *etxt; - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_STRING, &etxt, @@ -768,7 +768,7 @@ DBusHandlerResult avahi_service_browser_event(AvahiClient *client, AvahiBrowserE fprintf(stderr, "Failed to parse browser event.\n"); goto fail; } - + avahi_client_set_errno(b->client, avahi_error_dbus_to_number(etxt)); break; } @@ -795,7 +795,7 @@ AvahiRecordBrowser* avahi_record_browser_new( AvahiLookupFlags flags, AvahiRecordBrowserCallback callback, void *userdata) { - + AvahiRecordBrowser *b = NULL; DBusMessage *message = NULL, *reply = NULL; DBusError error; @@ -818,7 +818,7 @@ AvahiRecordBrowser* avahi_record_browser_new( avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + b->client = client; b->callback = callback; b->userdata = userdata; @@ -835,7 +835,7 @@ AvahiRecordBrowser* avahi_record_browser_new( avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "RecordBrowserNew"))) { avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; @@ -881,7 +881,7 @@ AvahiRecordBrowser* avahi_record_browser_new( dbus_message_unref(message); dbus_message_unref(reply); - + return b; fail: @@ -892,7 +892,7 @@ fail: if (b) avahi_record_browser_free(b); - + if (message) dbus_message_unref(message); @@ -978,7 +978,7 @@ DBusHandlerResult avahi_record_browser_event(AvahiClient *client, AvahiBrowserEv for (j = 0; j < 5; j++) dbus_message_iter_next(&iter); - + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY || dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_BYTE) goto fail; @@ -987,12 +987,12 @@ DBusHandlerResult avahi_record_browser_event(AvahiClient *client, AvahiBrowserEv dbus_message_iter_get_fixed_array(&sub, &rdata, &rdata_size); dbus_message_iter_next(&iter); - + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT32) goto fail; dbus_message_iter_get_basic(&iter, &flags); - + break; } @@ -1002,7 +1002,7 @@ DBusHandlerResult avahi_record_browser_event(AvahiClient *client, AvahiBrowserEv case AVAHI_BROWSER_FAILURE: { char *etxt; - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_STRING, &etxt, @@ -1011,7 +1011,7 @@ DBusHandlerResult avahi_record_browser_event(AvahiClient *client, AvahiBrowserEv fprintf(stderr, "Failed to parse browser event.\n"); goto fail; } - + avahi_client_set_errno(b->client, avahi_error_dbus_to_number(etxt)); break; } diff --git a/avahi-client/check-nss-test.c b/avahi-client/check-nss-test.c index 52aa81e..43d6a22 100644 --- a/avahi-client/check-nss-test.c +++ b/avahi-client/check-nss-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 diff --git a/avahi-client/check-nss.c b/avahi-client/check-nss.c index 0a933fa..69eefa5 100644 --- a/avahi-client/check-nss.c +++ b/avahi-client/check-nss.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 @@ -32,19 +32,19 @@ int avahi_nss_support(void) { int b = 0; - + #ifdef HAVE_DLOPEN static const char * const libs[] = { "libnss_mdns.so.2", "libnss_mdns4.so.2", "libnss_mdns6.so.2", NULL }; - + const char * const *l; - + for (l = libs; *l; l++) { void *dl; - + if ((dl = dlopen(*l, RTLD_LAZY))) { b = 1; dlclose(dl); diff --git a/avahi-client/client-test.c b/avahi-client/client-test.c index 7d30651..32e1487 100644 --- a/avahi-client/client-test.c +++ b/avahi-client/client-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 @@ -58,7 +58,7 @@ static void avahi_domain_browser_callback( const char *domain, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void *userdata) { - + printf ("DOMAIN-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, domain ? domain : "NULL", (char*)userdata); } @@ -76,7 +76,7 @@ static void avahi_service_resolver_callback( AvahiStringList *txt, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void *userdata) { - + char addr[64]; char *txtr; if (event == AVAHI_RESOLVER_FAILURE) { @@ -99,7 +99,7 @@ static void avahi_service_browser_callback ( const char *domain, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void *userdata) { - + AvahiServiceResolver *sr; printf ("SERVICE-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), name (%s), type (%s), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, name ? name : "NULL", type, domain ? domain : "NULL", (char*)userdata); @@ -120,7 +120,7 @@ static void avahi_service_type_browser_callback ( const char *domain, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void *userdata) { - + printf ("SERVICE-TYPE-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), type (%s), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, type ? type : "NULL", domain ? domain : "NULL", (char*)userdata); } @@ -133,7 +133,7 @@ static void avahi_address_resolver_callback ( const char *name, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void *userdata) { - + char addr[64]; if (event == AVAHI_RESOLVER_FAILURE) { printf ("ADDRESS-RESOLVER: Callback on AddressResolver, timed out.\n"); @@ -152,11 +152,11 @@ static void avahi_host_name_resolver_callback ( const AvahiAddress *a, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void *userdata) { - + AvahiClient *client; AvahiAddressResolver *ar; char addr[64]; - + if (event == AVAHI_RESOLVER_FAILURE) { printf ("HOST-NAME-RESOLVER: Callback on HostNameResolver, timed out.\n"); return; @@ -227,7 +227,7 @@ int main (AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { simple_poll = avahi_simple_poll_new(); poll_api = avahi_simple_poll_get(simple_poll); - + if (!(avahi = avahi_client_new(poll_api, 0, avahi_client_callback, "omghai2u", &error))) { fprintf(stderr, "Client failed: %s\n", avahi_strerror(error)); goto fail; @@ -246,7 +246,7 @@ int main (AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { ret = avahi_client_get_host_name_fqdn (avahi); printf("FQDN: %s (Error Return: %s)\n", ret, ret ? "OK" : avahi_strerror(avahi_client_errno(avahi))); - + cookie = avahi_client_get_local_service_cookie(avahi); printf("Local service cookie: %u (Error Return: %s)\n", cookie, cookie != AVAHI_SERVICE_COOKIE_INVALID ? "OK" : avahi_strerror(avahi_client_errno(avahi))); @@ -254,7 +254,7 @@ int main (AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { printf("Creating entry group: %s\n", group ? "OK" : avahi_strerror(avahi_client_errno (avahi))); assert(group); - + printf("Sucessfully created entry group %p\n", (void*) group); printf("%s\n", avahi_strerror(avahi_entry_group_add_service (group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "Lathiat's Site", "_http._tcp", NULL, NULL, 80, "foo=bar", NULL))); @@ -263,7 +263,7 @@ int main (AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { avahi_entry_group_commit (group); domain = avahi_domain_browser_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DOMAIN_BROWSER_BROWSE, 0, avahi_domain_browser_callback, "omghai3u"); - + if (domain == NULL) printf ("Failed to create domain browser object\n"); else @@ -317,7 +317,7 @@ int main (AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { avahi_simple_poll_loop(simple_poll); printf("terminating...\n"); - + fail: if (avahi) diff --git a/avahi-client/client.h b/avahi-client/client.h index 2f86d02..986afb3 100644 --- a/avahi-client/client.h +++ b/avahi-client/client.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 @@ -44,7 +44,7 @@ typedef enum { AVAHI_CLIENT_S_RUNNING = AVAHI_SERVER_RUNNING, /**< Server state: RUNNING */ AVAHI_CLIENT_S_COLLISION = AVAHI_SERVER_COLLISION, /**< Server state: COLLISION */ AVAHI_CLIENT_FAILURE = 100, /**< Some kind of error happened on the client side */ - AVAHI_CLIENT_CONNECTING = 101 /**< We're still connecting. This state is only entered when AVAHI_CLIENT_NO_FAIL has been passed to avahi_client_new() and the daemon is not yet available. */ + AVAHI_CLIENT_CONNECTING = 101 /**< We're still connecting. This state is only entered when AVAHI_CLIENT_NO_FAIL has been passed to avahi_client_new() and the daemon is not yet available. */ } AvahiClientState; typedef enum { @@ -93,7 +93,7 @@ const char* avahi_client_get_domain_name (AvahiClient*); const char* avahi_client_get_host_name_fqdn (AvahiClient*); /** Get state */ -AvahiClientState avahi_client_get_state(AvahiClient *client); +AvahiClientState avahi_client_get_state(AvahiClient *client); /** @{ \name Error Handling */ diff --git a/avahi-client/entrygroup.c b/avahi-client/entrygroup.c index e2fc3b9..cbe1882 100644 --- a/avahi-client/entrygroup.c +++ b/avahi-client/entrygroup.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 @@ -57,23 +57,23 @@ static int retrieve_state(AvahiEntryGroup *group) { int r = AVAHI_OK; int32_t state; AvahiClient *client; - + dbus_error_init(&error); assert(group); client = group->client; - + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "GetState"))) { r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); goto fail; } - + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); @@ -84,7 +84,7 @@ static int retrieve_state(AvahiEntryGroup *group) { dbus_message_unref(reply); return state; - + fail: if (dbus_error_is_set(&error)) { r = avahi_client_set_dbus_error(client, &error); @@ -120,14 +120,14 @@ AvahiEntryGroup* avahi_entry_group_new (AvahiClient *client, AvahiEntryGroupCall avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + group->client = client; group->callback = callback; group->userdata = userdata; group->state_valid = 0; group->path = NULL; AVAHI_LLIST_PREPEND(AvahiEntryGroup, groups, client->groups, group); - + if (!(message = dbus_message_new_method_call( AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, @@ -148,7 +148,7 @@ AvahiEntryGroup* avahi_entry_group_new (AvahiClient *client, AvahiEntryGroupCall avahi_client_set_errno (client, AVAHI_ERR_DBUS_ERROR); goto fail; } - + if (!(group->path = avahi_strdup (path))) { /* FIXME: We don't remove the object on the server side */ @@ -161,7 +161,7 @@ AvahiEntryGroup* avahi_entry_group_new (AvahiClient *client, AvahiEntryGroupCall avahi_client_set_errno(client, state); goto fail; } - + avahi_entry_group_set_state(group, (AvahiEntryGroupState) state); dbus_message_unref(message); @@ -177,13 +177,13 @@ fail: if (group) avahi_entry_group_free(group); - + if (message) dbus_message_unref(message); if (reply) dbus_message_unref(reply); - + return NULL; } @@ -192,23 +192,23 @@ static int entry_group_simple_method_call(AvahiEntryGroup *group, const char *me DBusError error; int r = AVAHI_OK; AvahiClient *client; - + dbus_error_init(&error); assert(group); client = group->client; - + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, method))) { r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); goto fail; } - + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); @@ -219,7 +219,7 @@ static int entry_group_simple_method_call(AvahiEntryGroup *group, const char *me dbus_message_unref(reply); return AVAHI_OK; - + fail: if (dbus_error_is_set(&error)) { r = avahi_client_set_dbus_error(client, &error); @@ -238,12 +238,12 @@ fail: int avahi_entry_group_free(AvahiEntryGroup *group) { AvahiClient *client = group->client; int r = AVAHI_OK; - + assert(group); - + if (group->path && avahi_client_is_connected(client)) r = entry_group_simple_method_call(group, "Free"); - + AVAHI_LLIST_REMOVE(AvahiEntryGroup, groups, client->groups, group); avahi_free(group->path); @@ -255,7 +255,7 @@ int avahi_entry_group_free(AvahiEntryGroup *group) { int avahi_entry_group_commit(AvahiEntryGroup *group) { int ret; assert(group); - + if (!group->path || !avahi_client_is_connected(group->client)) return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); @@ -269,13 +269,13 @@ int avahi_entry_group_commit(AvahiEntryGroup *group) { int avahi_entry_group_reset(AvahiEntryGroup *group) { int ret; assert(group); - + if (!group->path || !avahi_client_is_connected(group->client)) return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); if ((ret = entry_group_simple_method_call(group, "Reset")) < 0) return ret; - + group->state_valid = 0; return ret; } @@ -285,13 +285,13 @@ int avahi_entry_group_get_state (AvahiEntryGroup *group) { if (group->state_valid) return group->state; - + return retrieve_state(group); } AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup *group) { assert(group); - + return group->client; } @@ -301,7 +301,7 @@ int avahi_entry_group_is_empty (AvahiEntryGroup *group) { int r = AVAHI_OK; int b; AvahiClient *client; - + assert(group); client = group->client; @@ -309,18 +309,18 @@ int avahi_entry_group_is_empty (AvahiEntryGroup *group) { return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); dbus_error_init(&error); - + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "IsEmpty"))) { r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); goto fail; } - + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_BOOLEAN, &b, DBUS_TYPE_INVALID) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); @@ -331,7 +331,7 @@ int avahi_entry_group_is_empty (AvahiEntryGroup *group) { dbus_message_unref(reply); return !!b; - + fail: if (dbus_error_is_set(&error)) { r = avahi_client_set_dbus_error(client, &error); @@ -349,16 +349,16 @@ fail: static int append_rdata(DBusMessage *message, const void *rdata, size_t size) { DBusMessageIter iter, sub; - + assert(message); - + dbus_message_iter_init_append(message, &iter); - + if (!(dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &sub)) || !(dbus_message_iter_append_fixed_array(&sub, DBUS_TYPE_BYTE, &rdata, size)) || !(dbus_message_iter_close_container(&iter, &sub))) return -1; - + return 0; } @@ -373,7 +373,7 @@ static int append_string_list(DBusMessage *message, AvahiStringList *txt) { /* Reverse the string list, so that we can pass it in-order to the server */ txt = avahi_string_list_reverse(txt); - + if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "ay", &sub)) goto fail; @@ -381,7 +381,7 @@ static int append_string_list(DBusMessage *message, AvahiStringList *txt) { for (p = txt; p != NULL; p = p->next) { DBusMessageIter sub2; const uint8_t *data = p->text; - + if (!(dbus_message_iter_open_container(&sub, DBUS_TYPE_ARRAY, "y", &sub2)) || !(dbus_message_iter_append_fixed_array(&sub2, DBUS_TYPE_BYTE, &data, p->size)) || !(dbus_message_iter_close_container(&sub, &sub2))) @@ -412,7 +412,7 @@ int avahi_entry_group_add_service_strlst( const char *host, uint16_t port, AvahiStringList *txt) { - + DBusMessage *message = NULL, *reply = NULL; int r = AVAHI_OK; DBusError error; @@ -434,9 +434,9 @@ int avahi_entry_group_add_service_strlst( if (!host) host = ""; - + dbus_error_init(&error); - + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddService"))) { r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; @@ -461,13 +461,13 @@ int avahi_entry_group_add_service_strlst( r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); goto fail; } - + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); @@ -480,7 +480,7 @@ int avahi_entry_group_add_service_strlst( return AVAHI_OK; fail: - + if (dbus_error_is_set(&error)) { r = avahi_client_set_dbus_error(client, &error); dbus_error_free(&error); @@ -506,7 +506,7 @@ int avahi_entry_group_add_service( const char *host, uint16_t port, ...) { - + va_list va; int r; AvahiStringList *txt; @@ -552,7 +552,7 @@ int avahi_entry_group_add_service_subtype( domain = ""; dbus_error_init(&error); - + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddServiceSubtype"))) { r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; @@ -575,13 +575,13 @@ int avahi_entry_group_add_service_subtype( r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); goto fail; } - + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); @@ -594,7 +594,7 @@ int avahi_entry_group_add_service_subtype( return AVAHI_OK; fail: - + if (dbus_error_is_set(&error)) { r = avahi_client_set_dbus_error(client, &error); dbus_error_free(&error); @@ -615,9 +615,9 @@ int avahi_entry_group_update_service_txt( AvahiIfIndex interface, AvahiProtocol protocol, AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, + const char *name, + const char *type, + const char *domain, ...) { va_list va; @@ -637,9 +637,9 @@ int avahi_entry_group_update_service_txt_strlst( AvahiIfIndex interface, AvahiProtocol protocol, AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, + const char *name, + const char *type, + const char *domain, AvahiStringList *txt) { DBusMessage *message = NULL, *reply = NULL; @@ -660,9 +660,9 @@ int avahi_entry_group_update_service_txt_strlst( if (!domain) domain = ""; - + dbus_error_init(&error); - + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "UpdateServiceTxt"))) { r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; @@ -691,7 +691,7 @@ int avahi_entry_group_update_service_txt_strlst( r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); goto fail; } - + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); @@ -704,7 +704,7 @@ int avahi_entry_group_update_service_txt_strlst( return AVAHI_OK; fail: - + if (dbus_error_is_set(&error)) { r = avahi_client_set_dbus_error(client, &error); dbus_error_free(&error); @@ -745,7 +745,7 @@ int avahi_entry_group_add_address( return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); dbus_error_init(&error); - + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddAddress"))) { r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; @@ -754,7 +754,7 @@ int avahi_entry_group_add_address( i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; u_flags = (uint32_t) flags; - + if (!avahi_address_snprint (s_address, sizeof (s_address), a)) { r = avahi_client_set_errno(client, AVAHI_ERR_INVALID_ADDRESS); @@ -772,13 +772,13 @@ int avahi_entry_group_add_address( r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); goto fail; } - + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); @@ -791,7 +791,7 @@ int avahi_entry_group_add_address( return AVAHI_OK; fail: - + if (dbus_error_is_set(&error)) { r = avahi_client_set_dbus_error(client, &error); dbus_error_free(&error); @@ -834,7 +834,7 @@ int avahi_entry_group_add_record( return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); dbus_error_init(&error); - + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddRecord"))) { r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; @@ -843,7 +843,7 @@ int avahi_entry_group_add_record( i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; u_flags = (uint32_t) flags; - + if (!dbus_message_append_args( message, DBUS_TYPE_INT32, &i_interface, @@ -857,13 +857,13 @@ int avahi_entry_group_add_record( r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); goto fail; } - + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); @@ -876,7 +876,7 @@ int avahi_entry_group_add_record( return AVAHI_OK; fail: - + if (dbus_error_is_set(&error)) { r = avahi_client_set_dbus_error(client, &error); dbus_error_free(&error); diff --git a/avahi-client/internal.h b/avahi-client/internal.h index e49dd15..f4ff938 100644 --- a/avahi-client/internal.h +++ b/avahi-client/internal.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 @@ -39,10 +39,10 @@ struct AvahiClient { char *version_string, *host_name, *host_name_fqdn, *domain_name; uint32_t local_service_cookie; int local_service_cookie_valid; - + AvahiClientCallback callback; void *userdata; - + AVAHI_LLIST_HEAD(AvahiEntryGroup, groups); AVAHI_LLIST_HEAD(AvahiDomainBrowser, domain_browsers); AVAHI_LLIST_HEAD(AvahiServiceBrowser, service_browsers); @@ -65,7 +65,7 @@ struct AvahiEntryGroup { struct AvahiDomainBrowser { int ref; - + char *path; AvahiClient *client; AvahiDomainBrowserCallback callback; diff --git a/avahi-client/publish.h b/avahi-client/publish.h index 1efc85f..0884d3e 100644 --- a/avahi-client/publish.h +++ b/avahi-client/publish.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 @@ -92,7 +92,7 @@ int avahi_entry_group_add_service( AvahiPublishFlags flags /**< Usually 0, unless you know what you do */, const char *name /**< The name for the new service. Must be valid service name. i.e. a string shorter than 63 characters and valid UTF-8. May not be NULL. */, const char *type /**< The service type for the new service, such as _http._tcp. May not be NULL. */, - const char *domain /**< The domain to register this domain in. We recommend to pass NULL here, to let the daemon decide */, + const char *domain /**< The domain to register this domain in. We recommend to pass NULL here, to let the daemon decide */, const char *host /**< The host this services is residing on. We recommend to pass NULL here, the daemon will than automatically insert the local host name in that case */, uint16_t port /**< The IP port number of this service */, ...) AVAHI_GCC_SENTINEL; @@ -127,9 +127,9 @@ int avahi_entry_group_update_service_txt( AvahiIfIndex interface /**< The interface this service is announced on. This should match the value passed to the original avahi_entry_group_add_service() call. */, AvahiProtocol protocol /**< The protocol this service is announced with. This should match the value passed to the original avahi_entry_group_add_service() call. */, AvahiPublishFlags flags /**< Only != 0 if you really know what you do */, - const char *name /**< The name of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, - const char *type /**< The type of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, - const char *domain /**< The domain this service resides is, as passed to avahi_entry_group_add_service(). May be NULL. */, + const char *name /**< The name of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, + const char *type /**< The type of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, + const char *domain /**< The domain this service resides is, as passed to avahi_entry_group_add_service(). May be NULL. */, ...) AVAHI_GCC_SENTINEL; /** Update a TXT record for an existing service. Similar to avahi_entry_group_update_service_txt() but takes an AvahiStringList for the TXT strings, instead of a NULL terminated list of arguments. */ @@ -138,9 +138,9 @@ int avahi_entry_group_update_service_txt_strlst( AvahiIfIndex interface, AvahiProtocol protocol, AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, + const char *name, + const char *type, + const char *domain, AvahiStringList *strlst); /** \cond fulldocs */ diff --git a/avahi-client/resolver.c b/avahi-client/resolver.c index 4403a12..c1ace37 100644 --- a/avahi-client/resolver.c +++ b/avahi-client/resolver.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 @@ DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolv assert(client); assert(message); - + dbus_error_init (&error); if (!(path = dbus_message_get_path(message))) @@ -70,7 +70,7 @@ DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolv uint16_t port; DBusMessageIter iter, sub; AvahiAddress a; - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_INT32, &interface, @@ -84,48 +84,48 @@ DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolv DBUS_TYPE_UINT16, &port, DBUS_TYPE_INVALID) || dbus_error_is_set (&error)) { - + fprintf(stderr, "Failed to parse resolver event.\n"); goto fail; } - + dbus_message_iter_init(message, &iter); - + for (j = 0; j < 9; j++) dbus_message_iter_next(&iter); - + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY || dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_ARRAY) { fprintf(stderr, "Error parsing service resolving message\n"); goto fail; } - + strlst = NULL; dbus_message_iter_recurse(&iter, &sub); - + for (;;) { DBusMessageIter sub2; int at; const uint8_t *k; int n; - + if ((at = dbus_message_iter_get_arg_type(&sub)) == DBUS_TYPE_INVALID) break; - + assert(at == DBUS_TYPE_ARRAY); - + if (dbus_message_iter_get_element_type(&sub) != DBUS_TYPE_BYTE) { fprintf(stderr, "Error parsing service resolving message\n"); goto fail; } - + dbus_message_iter_recurse(&sub, &sub2); k = NULL; n = 0; dbus_message_iter_get_fixed_array(&sub2, &k, &n); if (k && n > 0) strlst = avahi_string_list_add_arbitrary(strlst, k, n); - + dbus_message_iter_next(&sub); } @@ -137,23 +137,23 @@ DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolv } dbus_message_iter_get_basic(&iter, &flags); - + assert(address); if (address[0] == 0) address = NULL; else avahi_address_parse(address, (AvahiProtocol) aprotocol, &a); - + r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, type, domain, host, address ? &a : NULL, port, strlst, (AvahiLookupResultFlags) flags, r->userdata); - + avahi_string_list_free(strlst); break; } - + case AVAHI_RESOLVER_FAILURE: { char *etxt; - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_STRING, &etxt, @@ -162,7 +162,7 @@ DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolv fprintf(stderr, "Failed to parse resolver event.\n"); goto fail; } - + avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt)); r->callback(r, r->interface, r->protocol, event, r->name, r->type, r->domain, NULL, NULL, 0, NULL, 0, r->userdata); break; @@ -171,7 +171,7 @@ DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolv return DBUS_HANDLER_RESULT_HANDLED; - + fail: dbus_error_free (&error); avahi_string_list_free(strlst); @@ -196,7 +196,7 @@ AvahiServiceResolver * avahi_service_resolver_new( int32_t i_interface, i_protocol, i_aprotocol; uint32_t u_flags; char *path; - + assert(client); assert(type); @@ -205,7 +205,7 @@ AvahiServiceResolver * avahi_service_resolver_new( if (!name) name = ""; - + dbus_error_init (&error); if (!avahi_client_is_connected(client)) { @@ -225,7 +225,7 @@ AvahiServiceResolver * avahi_service_resolver_new( r->name = r->type = r->domain = NULL; r->interface = interface; r->protocol = protocol; - + AVAHI_LLIST_PREPEND(AvahiServiceResolver, service_resolvers, client->service_resolvers, r); if (name && name[0]) @@ -244,8 +244,8 @@ AvahiServiceResolver * avahi_service_resolver_new( avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - - + + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "ServiceResolverNew"))) { avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; @@ -290,13 +290,13 @@ AvahiServiceResolver * avahi_service_resolver_new( avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + dbus_message_unref(message); dbus_message_unref(reply); return r; - + fail: if (dbus_error_is_set(&error)) { @@ -306,13 +306,13 @@ fail: if (r) avahi_service_resolver_free(r); - + if (message) dbus_message_unref(message); if (reply) dbus_message_unref(reply); - + return NULL; } @@ -353,7 +353,7 @@ DBusHandlerResult avahi_host_name_resolver_event (AvahiClient *client, AvahiReso assert(client); assert(message); - + dbus_error_init (&error); if (!(path = dbus_message_get_path(message))) @@ -372,7 +372,7 @@ DBusHandlerResult avahi_host_name_resolver_event (AvahiClient *client, AvahiReso uint32_t flags; char *name, *address; AvahiAddress a; - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_INT32, &interface, @@ -386,20 +386,20 @@ DBusHandlerResult avahi_host_name_resolver_event (AvahiClient *client, AvahiReso fprintf(stderr, "Failed to parse resolver event.\n"); goto fail; } - + assert(address); if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) { fprintf(stderr, "Failed to parse address\n"); goto fail; } - + r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, &a, (AvahiLookupResultFlags) flags, r->userdata); break; } - + case AVAHI_RESOLVER_FAILURE: { char *etxt; - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_STRING, &etxt, @@ -408,7 +408,7 @@ DBusHandlerResult avahi_host_name_resolver_event (AvahiClient *client, AvahiReso fprintf(stderr, "Failed to parse resolver event.\n"); goto fail; } - + avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt)); r->callback(r, r->interface, r->protocol, event, r->host_name, NULL, 0, r->userdata); break; @@ -416,7 +416,7 @@ DBusHandlerResult avahi_host_name_resolver_event (AvahiClient *client, AvahiReso } return DBUS_HANDLER_RESULT_HANDLED; - + fail: dbus_error_free (&error); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; @@ -439,7 +439,7 @@ AvahiHostNameResolver * avahi_host_name_resolver_new( int32_t i_interface, i_protocol, i_aprotocol; uint32_t u_flags; char *path; - + assert(client); assert(name); @@ -462,7 +462,7 @@ AvahiHostNameResolver * avahi_host_name_resolver_new( r->interface = interface; r->protocol = protocol; r->host_name = NULL; - + AVAHI_LLIST_PREPEND(AvahiHostNameResolver, host_name_resolvers, client->host_name_resolvers, r); if (!(r->host_name = avahi_strdup(name))) { @@ -517,7 +517,7 @@ AvahiHostNameResolver * avahi_host_name_resolver_new( dbus_message_unref(reply); return r; - + fail: if (dbus_error_is_set(&error)) { @@ -527,7 +527,7 @@ fail: if (r) avahi_host_name_resolver_free(r); - + if (message) dbus_message_unref(message); @@ -572,7 +572,7 @@ DBusHandlerResult avahi_address_resolver_event (AvahiClient *client, AvahiResolv assert(client); assert(message); - + dbus_error_init (&error); if (!(path = dbus_message_get_path(message))) @@ -591,7 +591,7 @@ DBusHandlerResult avahi_address_resolver_event (AvahiClient *client, AvahiResolv uint32_t flags; char *name, *address; AvahiAddress a; - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_INT32, &interface, @@ -605,20 +605,20 @@ DBusHandlerResult avahi_address_resolver_event (AvahiClient *client, AvahiResolv fprintf(stderr, "Failed to parse resolver event.\n"); goto fail; } - + assert(address); if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) { fprintf(stderr, "Failed to parse address\n"); goto fail; } - + r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, &a, name, (AvahiLookupResultFlags) flags, r->userdata); break; } case AVAHI_RESOLVER_FAILURE: { char *etxt; - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_STRING, &etxt, @@ -627,7 +627,7 @@ DBusHandlerResult avahi_address_resolver_event (AvahiClient *client, AvahiResolv fprintf(stderr, "Failed to parse resolver event.\n"); goto fail; } - + avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt)); r->callback(r, r->interface, r->protocol, event, &r->address, NULL, 0, r->userdata); break; @@ -635,7 +635,7 @@ DBusHandlerResult avahi_address_resolver_event (AvahiClient *client, AvahiResolv } return DBUS_HANDLER_RESULT_HANDLED; - + fail: dbus_error_free (&error); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; @@ -646,7 +646,7 @@ AvahiAddressResolver * avahi_address_resolver_new( AvahiIfIndex interface, AvahiProtocol protocol, const AvahiAddress *a, - AvahiLookupFlags flags, + AvahiLookupFlags flags, AvahiAddressResolverCallback callback, void *userdata) { @@ -685,7 +685,7 @@ AvahiAddressResolver * avahi_address_resolver_new( r->interface = interface; r->protocol = protocol; r->address = *a; - + AVAHI_LLIST_PREPEND(AvahiAddressResolver, address_resolvers, client->address_resolvers, r); if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "AddressResolverNew"))) { @@ -720,7 +720,7 @@ AvahiAddressResolver * avahi_address_resolver_new( avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); goto fail; } - + if (!(r->path = avahi_strdup(path))) { /* FIXME: We don't remove the object on the server side */ @@ -733,7 +733,7 @@ AvahiAddressResolver * avahi_address_resolver_new( dbus_message_unref(reply); return r; - + fail: if (dbus_error_is_set(&error)) { @@ -743,7 +743,7 @@ fail: if (r) avahi_address_resolver_free(r); - + if (message) dbus_message_unref(message); diff --git a/avahi-client/rr-test.c b/avahi-client/rr-test.c index 9fffa5d..2a5d64a 100644 --- a/avahi-client/rr-test.c +++ b/avahi-client/rr-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 @@ -37,11 +37,11 @@ static void hexdump(const void* p, size_t size) { assert(p); printf("Dumping %lu bytes from %p:\n", (unsigned long) size, p); - + while (size > 0) { unsigned i; - for (i = 0; i < 16; i++) { + for (i = 0; i < 16; i++) { if (i < size) printf("%02x ", c[i]); else @@ -54,14 +54,14 @@ static void hexdump(const void* p, size_t size) { else printf(" "); } - + printf("\n"); c += 16; if (size <= 16) break; - + size -= 16; } } @@ -91,13 +91,13 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { const AvahiPoll *poll_api; AvahiClient *client; AvahiRecordBrowser *r; - + simple_poll = avahi_simple_poll_new(); assert(simple_poll); - + poll_api = avahi_simple_poll_get(simple_poll); assert(poll_api); - + client = avahi_client_new(poll_api, 0, NULL, NULL, NULL); assert(client); diff --git a/avahi-client/srv-test.c b/avahi-client/srv-test.c index 5242947..5f5e1de 100644 --- a/avahi-client/srv-test.c +++ b/avahi-client/srv-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 @@ -56,13 +56,13 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { const AvahiPoll *poll_api; AvahiClient *client; AvahiServiceResolver *r; - + simple_poll = avahi_simple_poll_new(); assert(simple_poll); - + poll_api = avahi_simple_poll_get(simple_poll); assert(poll_api); - + client = avahi_client_new(poll_api, 0, NULL, NULL, NULL); assert(client); diff --git a/avahi-client/xdg-config-test.c b/avahi-client/xdg-config-test.c index 2e1c88f..35ed25c 100644 --- a/avahi-client/xdg-config-test.c +++ b/avahi-client/xdg-config-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 @@ -32,7 +32,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { FILE *f; f = avahi_xdg_config_open("foo"); - + if (f) fclose(f); diff --git a/avahi-client/xdg-config.h b/avahi-client/xdg-config.h index 88f66a8..9948580 100644 --- a/avahi-client/xdg-config.h +++ b/avahi-client/xdg-config.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/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); }; diff --git a/avahi-compat-howl/address-test.c b/avahi-compat-howl/address-test.c index 05276aa..cdb6a6e 100644 --- a/avahi-compat-howl/address-test.c +++ b/avahi-compat-howl/address-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 @@ -41,13 +41,13 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { ASSERT_SW_OKAY(sw_ipv4_address_init_from_name(&a, "heise.de")); ASSERT_NOT_NULL(sw_ipv4_address_name(a, t, sizeof(t))); printf("%s\n", t); - + ASSERT_SW_OKAY(sw_ipv4_address_init_from_this_host(&a)); ASSERT_NOT_NULL(sw_ipv4_address_name(a, t, sizeof(t))); printf("%s\n", t); ASSERT_SW_OKAY(sw_ipv4_address_decompose(a, &a1, &a2, &a3, &a4)); printf("%i.%i.%i.%i\n", a1, a2, a3, a4); - + return 0; } diff --git a/avahi-compat-howl/address.c b/avahi-compat-howl/address.c index 1d9fbbe..3805a61 100644 --- a/avahi-compat-howl/address.c +++ b/avahi-compat-howl/address.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 @@ -85,10 +85,10 @@ sw_result sw_ipv4_address_init_from_name( assert(name); AVAHI_WARN_LINKAGE; - + if (!(he = gethostbyname(name))) return SW_E_UNKNOWN; - + self->m_addr = *(uint32_t*) he->h_addr; return SW_OKAY; } @@ -113,7 +113,7 @@ sw_result sw_ipv4_address_init_from_this_host(sw_ipv4_address *self) { assert(self); AVAHI_WARN_LINKAGE; - + /* This is so fucked up ... */ memset(&sa, 0, sizeof(sa)); @@ -135,7 +135,7 @@ sw_result sw_ipv4_address_init_from_this_host(sw_ipv4_address *self) { close(fd); self->m_addr = sa.sin_addr.s_addr; - + return SW_OKAY; } @@ -144,7 +144,7 @@ sw_result sw_ipv4_address_fina(AVAHI_GCC_UNUSED sw_ipv4_address self) { AVAHI_WARN_LINKAGE; /* This is ridiculous ... */ - + return SW_OKAY; } @@ -170,10 +170,10 @@ sw_string sw_ipv4_address_name( if (len < INET_ADDRSTRLEN) return NULL; - + if (!(inet_ntop(AF_INET, &self.m_addr, name, len))) return NULL; - + return name; } @@ -187,9 +187,9 @@ sw_result sw_ipv4_address_decompose( uint32_t a; AVAHI_WARN_LINKAGE; - + a = ntohl(self.m_addr); - + assert(a1); assert(a2); assert(a3); @@ -199,7 +199,7 @@ sw_result sw_ipv4_address_decompose( *a2 = (uint8_t) (a >> 16); *a3 = (uint8_t) (a >> 8); *a4 = (uint8_t) (a); - + return SW_OKAY; } diff --git a/avahi-compat-howl/browse-domain-test.c b/avahi-compat-howl/browse-domain-test.c index be99d92..6dac23c 100644 --- a/avahi-compat-howl/browse-domain-test.c +++ b/avahi-compat-howl/browse-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 @@ -54,7 +54,7 @@ static sw_result reply( case SW_DISCOVERY_BROWSE_INVALID: fprintf(stderr, "some kind of failure happened: %s\n", domain); break; - + default: abort(); } @@ -65,12 +65,12 @@ static sw_result reply( int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { sw_discovery discovery; sw_discovery_oid oid; - + ASSERT_SW_OKAY(sw_discovery_init(&discovery)); ASSERT_SW_OKAY(sw_discovery_browse_domains(discovery, 0, reply, NULL, &oid)); - + ASSERT_SW_OKAY(sw_discovery_run(discovery)); - + return 0; } diff --git a/avahi-compat-howl/compat.c b/avahi-compat-howl/compat.c index e436208..12a82fa 100644 --- a/avahi-compat-howl/compat.c +++ b/avahi-compat-howl/compat.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 @@ -87,7 +87,7 @@ struct _sw_discovery { sw_discovery_oid oid_index; int thread_fd, main_fd; - + pthread_t thread; int thread_running; @@ -121,7 +121,7 @@ static sw_result map_error(int error) { switch (error) { case AVAHI_OK: return SW_OKAY; - + case AVAHI_ERR_NO_MEMORY: return SW_E_MEM; } @@ -134,7 +134,7 @@ static int read_command(int fd) { char command; assert(fd >= 0); - + if ((r = read(fd, &command, 1)) != 1) { fprintf(stderr, __FILE__": read() failed: %s\n", r < 0 ? strerror(errno) : "EOF"); return -1; @@ -157,9 +157,9 @@ static int write_command(int fd, char reply) { static int poll_func(struct pollfd *ufds, unsigned int nfds, int timeout, void *userdata) { sw_discovery self = userdata; int ret; - + assert(self); - + ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex)); ret = poll(ufds, nfds, timeout); ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex)); @@ -173,7 +173,7 @@ static void * thread_func(void *data) { sigfillset(&mask); pthread_sigmask(SIG_BLOCK, &mask, NULL); - + self->thread = pthread_self(); self->thread_running = 1; @@ -184,7 +184,7 @@ static void * thread_func(void *data) { break; /* fprintf(stderr, "Command: %c\n", command); */ - + switch (command) { case COMMAND_POLL: { @@ -194,30 +194,30 @@ static void * thread_func(void *data) { for (;;) { errno = 0; - + if ((ret = avahi_simple_poll_run(self->simple_poll)) < 0) { - + if (errno == EINTR) continue; - + fprintf(stderr, __FILE__": avahi_simple_poll_run() failed: %s\n", strerror(errno)); } break; } - + ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex)); - + if (write_command(self->thread_fd, ret < 0 ? COMMAND_POLL_FAILED : COMMAND_POLL_DONE) < 0) break; - + break; } case COMMAND_QUIT: return NULL; } - + } return NULL; @@ -231,13 +231,13 @@ static int oid_alloc(sw_discovery self, oid_type type) { while (self->oid_index >= OID_MAX) self->oid_index -= OID_MAX; - + if (self->oid_table[self->oid_index].type == OID_UNUSED) { self->oid_table[self->oid_index].type = type; self->oid_table[self->oid_index].discovery = self; assert(OID_GET_INDEX(&self->oid_table[self->oid_index]) == self->oid_index); - + return self->oid_index ++; } @@ -245,7 +245,7 @@ static int oid_alloc(sw_discovery self, oid_type type) { } /* No free entry found */ - + return (sw_discovery_oid) -1; } @@ -271,22 +271,22 @@ static oid_data* oid_get(sw_discovery self, sw_discovery_oid oid) { if (self->oid_table[oid].type == OID_UNUSED) return NULL; - + return &self->oid_table[oid]; } static service_data* service_data_new(sw_discovery self) { service_data *sdata; - + assert(self); if (!(sdata = avahi_new0(service_data, 1))) return NULL; AVAHI_LLIST_PREPEND(service_data, services, self->services, sdata); - + return sdata; - + } static void service_data_free(sw_discovery self, service_data* sdata) { @@ -294,7 +294,7 @@ static void service_data_free(sw_discovery self, service_data* sdata) { assert(sdata); AVAHI_LLIST_REMOVE(service_data, services, self->services, sdata); - + avahi_free(sdata->name); avahi_free(sdata->regtype); avahi_free(sdata->domain); @@ -308,12 +308,12 @@ static void reg_client_callback(oid_data *data, AvahiClientState state); static void client_callback(AvahiClient *s, AvahiClientState state, void* userdata) { sw_discovery self = userdata; sw_discovery_oid oid; - + assert(s); assert(self); discovery_ref(self); - + for (oid = 0; oid < OID_MAX; oid++) { switch (self->oid_table[oid].type) { @@ -341,16 +341,16 @@ sw_result sw_discovery_init(sw_discovery * self) { sw_result result = SW_E_UNKNOWN; pthread_mutexattr_t mutex_attr; int error; - + assert(self); - + AVAHI_WARN_LINKAGE; *self = NULL; if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0) goto fail; - + if (!(*self = avahi_new(struct _sw_discovery, 1))) { result = SW_E_MEM; goto fail; @@ -365,7 +365,7 @@ sw_result sw_discovery_init(sw_discovery * self) { memset((*self)->oid_table, 0, sizeof((*self)->oid_table)); (*self)->oid_index = 0; - + (*self)->thread_running = 0; AVAHI_LLIST_HEAD_INIT(service_info, (*self)->services); @@ -384,7 +384,7 @@ sw_result sw_discovery_init(sw_discovery * self) { result = map_error(error); goto fail; } - + /* Start simple poll */ if (avahi_simple_poll_prepare((*self)->simple_poll, -1) < 0) goto fail; @@ -392,12 +392,12 @@ sw_result sw_discovery_init(sw_discovery * self) { /* Queue an initial POLL command for the thread */ if (write_command((*self)->main_fd, COMMAND_POLL) < 0) goto fail; - + if (pthread_create(&(*self)->thread, NULL, thread_func, *self) != 0) goto fail; (*self)->thread_running = 1; - + return SW_OKAY; fail: @@ -416,9 +416,9 @@ static int stop_thread(sw_discovery self) { if (write_command(self->main_fd, COMMAND_QUIT) < 0) return -1; - + avahi_simple_poll_wakeup(self->simple_poll); - + ASSERT_SUCCESS(pthread_join(self->thread, NULL)); self->thread_running = 0; return 0; @@ -459,24 +459,24 @@ static void discovery_unref(sw_discovery self) { while (self->services) service_data_free(self, self->services); - + avahi_free(self); } sw_result sw_discovery_fina(sw_discovery self) { assert(self); - + AVAHI_WARN_LINKAGE; stop_thread(self); discovery_unref(self); - + return SW_OKAY; } sw_result sw_discovery_run(sw_discovery self) { assert(self); - + AVAHI_WARN_LINKAGE; return sw_salt_run((sw_salt) self); @@ -484,7 +484,7 @@ sw_result sw_discovery_run(sw_discovery self) { sw_result sw_discovery_stop_run(sw_discovery self) { assert(self); - + AVAHI_WARN_LINKAGE; return sw_salt_stop_run((sw_salt) self); @@ -492,7 +492,7 @@ sw_result sw_discovery_stop_run(sw_discovery self) { int sw_discovery_socket(sw_discovery self) { assert(self); - + AVAHI_WARN_LINKAGE; return self->main_fd; @@ -500,17 +500,17 @@ int sw_discovery_socket(sw_discovery self) { sw_result sw_discovery_read_socket(sw_discovery self) { sw_result result = SW_E_UNKNOWN; - + assert(self); discovery_ref(self); ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex)); - + /* Cleanup notification socket */ if (read_command(self->main_fd) != COMMAND_POLL_DONE) goto finish; - + if (avahi_simple_poll_dispatch(self->simple_poll) < 0) goto finish; @@ -525,26 +525,26 @@ sw_result sw_discovery_read_socket(sw_discovery self) { /* Request the poll */ if (write_command(self->main_fd, COMMAND_POLL) < 0) goto finish; - + result = SW_OKAY; - + finish: ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex)); discovery_unref(self); - + return result; } sw_result sw_discovery_salt(sw_discovery self, sw_salt *salt) { assert(self); assert(salt); - + AVAHI_WARN_LINKAGE; *salt = (sw_salt) self; - + return SW_OKAY; } @@ -557,34 +557,34 @@ sw_result sw_salt_step(sw_salt self, sw_uint32 * msec) { if (!((sw_discovery) self)->thread_running) return SW_E_UNKNOWN; - + memset(&p, 0, sizeof(p)); p.fd = ((sw_discovery) self)->main_fd; p.events = POLLIN; if ((r = poll(&p, 1, msec ? (int) *msec : -1)) < 0) { - + /* Don't treat EINTR as error */ if (errno == EINTR) return SW_OKAY; - + return SW_E_UNKNOWN; - + } else if (r == 0) { - + /* Timeoout */ return SW_OKAY; } else { /* Success */ - + if (p.revents != POLLIN) return SW_E_UNKNOWN; if ((result = sw_discovery_read_socket((sw_discovery) self)) != SW_OKAY) return result; } - + return SW_OKAY; } @@ -594,7 +594,7 @@ sw_result sw_salt_run(sw_salt self) { AVAHI_WARN_LINKAGE; assert(self); - + for (;;) if ((ret = sw_salt_step(self, NULL)) != SW_OKAY) return ret; @@ -622,7 +622,7 @@ sw_result sw_salt_lock(sw_salt self) { sw_result sw_salt_unlock(sw_salt self) { assert(self); - + AVAHI_WARN_LINKAGE; ASSERT_SUCCESS(pthread_mutex_unlock(&((sw_discovery) self)->salt_mutex)); @@ -634,9 +634,9 @@ static void reg_report_status(oid_data *data, sw_discovery_publish_status status sw_discovery_publish_reply reply; assert(data); - + reply = (sw_discovery_publish_reply) data->reply; - + reply(data->discovery, OID_GET_INDEX(data), status, @@ -646,11 +646,11 @@ static void reg_report_status(oid_data *data, sw_discovery_publish_status status static int reg_create_service(oid_data *data) { int ret; const char *real_type; - + assert(data); real_type = avahi_get_type_from_subtype(data->service_data->regtype); - + if ((ret = avahi_entry_group_add_service_strlst( data->object, data->service_data->interface, @@ -663,7 +663,7 @@ static int reg_create_service(oid_data *data) { data->service_data->port, data->service_data->txt)) < 0) return ret; - + if (real_type) { /* Create a subtype entry */ @@ -692,12 +692,12 @@ static void reg_client_callback(oid_data *data, AvahiClientState state) { /* We've not been setup completely */ if (!data->object) return; - + switch (state) { case AVAHI_CLIENT_FAILURE: reg_report_status(data, SW_DISCOVERY_PUBLISH_INVALID); break; - + case AVAHI_CLIENT_S_RUNNING: { int ret; @@ -706,10 +706,10 @@ static void reg_client_callback(oid_data *data, AvahiClientState state) { reg_report_status(data, SW_DISCOVERY_PUBLISH_INVALID); return; } - + break; } - + case AVAHI_CLIENT_S_COLLISION: case AVAHI_CLIENT_S_REGISTERING: @@ -749,7 +749,7 @@ static void reg_entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState st case AVAHI_ENTRY_GROUP_FAILURE: reg_report_status(data, SW_DISCOVERY_PUBLISH_INVALID); break; - + } } @@ -771,13 +771,13 @@ sw_result sw_discovery_publish( sw_result result = SW_E_UNKNOWN; service_data *sdata; AvahiStringList *txt = NULL; - + assert(self); assert(name); assert(type); assert(reply); assert(oid); - + AVAHI_WARN_LINKAGE; if (text_record && text_record_len > 0) @@ -820,7 +820,7 @@ sw_result sw_discovery_publish( if (avahi_client_get_state(self->client) == AVAHI_CLIENT_S_RUNNING) { int error; - + if ((error = reg_create_service(data)) < 0) { result = map_error(error); goto finish; @@ -832,8 +832,8 @@ sw_result sw_discovery_publish( finish: ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex)); - - if (result != SW_OKAY) + + if (result != SW_OKAY) if (*oid != (sw_discovery_oid) -1) sw_discovery_cancel(self, *oid); @@ -872,7 +872,7 @@ static void domain_browser_callback( case AVAHI_BROWSER_FAILURE: reply(data->discovery, OID_GET_INDEX(data), SW_DISCOVERY_BROWSE_INVALID, interface, NULL, NULL, domain, data->extra); break; - + case AVAHI_BROWSER_CACHE_EXHAUSTED: case AVAHI_BROWSER_ALL_FOR_NOW: break; @@ -885,15 +885,15 @@ sw_result sw_discovery_browse_domains( sw_discovery_browse_reply reply, sw_opaque extra, sw_discovery_oid * oid) { - + oid_data *data; AvahiIfIndex ifindex; sw_result result = SW_E_UNKNOWN; - + assert(self); assert(reply); assert(oid); - + AVAHI_WARN_LINKAGE; if ((*oid = oid_alloc(self, OID_DOMAIN_BROWSER)) == (sw_discovery_oid) -1) @@ -903,11 +903,11 @@ sw_result sw_discovery_browse_domains( assert(data); data->reply = (sw_result (*)(void)) reply; data->extra = extra; - + ifindex = interface_index == 0 ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface_index; ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex)); - + if (!(data->object = avahi_domain_browser_new(self->client, ifindex, AVAHI_PROTO_INET, NULL, AVAHI_DOMAIN_BROWSER_BROWSE, 0, domain_browser_callback, data))) { result = map_error(avahi_client_errno(self->client)); goto finish; @@ -918,7 +918,7 @@ sw_result sw_discovery_browse_domains( finish: ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex)); - + if (result != SW_OKAY) if (*oid != (sw_discovery_oid) -1) sw_discovery_cancel(self, *oid); @@ -943,7 +943,7 @@ static void service_resolver_callback( oid_data* data = userdata; sw_discovery_resolve_reply reply; - + assert(r); assert(data); @@ -960,7 +960,7 @@ static void service_resolver_callback( sw_ipv4_address_init_from_saddr(&addr, a->data.ipv4.address); host_name = add_trailing_dot(host_name, host_name_fixed, sizeof(host_name_fixed)); - + if ((p = avahi_new0(uint8_t, (l = avahi_string_list_serialize(txt, NULL, 0))+1))) avahi_string_list_serialize(txt, p, l); @@ -973,7 +973,7 @@ static void service_resolver_callback( case AVAHI_RESOLVER_FAILURE: /* Apparently there is no way in HOWL to inform about failed resolvings ... */ - + avahi_warn("A service failed to resolve in the HOWL compatiblity layer of Avahi which is used by '%s'. " "Since the HOWL API doesn't offer any means to inform the application about this, we have to ignore the failure. " "Please fix your application to use the native API of Avahi!", @@ -996,13 +996,13 @@ sw_result sw_discovery_resolve( oid_data *data; AvahiIfIndex ifindex; sw_result result = SW_E_UNKNOWN; - + assert(self); assert(name); assert(type); assert(reply); assert(oid); - + AVAHI_WARN_LINKAGE; if ((*oid = oid_alloc(self, OID_SERVICE_RESOLVER)) == (sw_discovery_oid) -1) @@ -1012,22 +1012,22 @@ sw_result sw_discovery_resolve( assert(data); data->reply = (sw_result (*)(void)) reply; data->extra = extra; - + ifindex = interface_index == 0 ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface_index; ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex)); - + if (!(data->object = avahi_service_resolver_new(self->client, ifindex, AVAHI_PROTO_INET, name, type, domain, AVAHI_PROTO_INET, 0, service_resolver_callback, data))) { result = map_error(avahi_client_errno(self->client)); goto finish; } result = SW_OKAY; - + finish: ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex)); - + if (result != SW_OKAY) if (*oid != (sw_discovery_oid) -1) sw_discovery_cancel(self, *oid); @@ -1049,7 +1049,7 @@ static void service_browser_callback( oid_data* data = userdata; char type_fixed[AVAHI_DOMAIN_NAME_MAX], domain_fixed[AVAHI_DOMAIN_NAME_MAX]; sw_discovery_browse_reply reply; - + assert(b); assert(data); @@ -1070,7 +1070,7 @@ static void service_browser_callback( case AVAHI_BROWSER_FAILURE: reply(data->discovery, OID_GET_INDEX(data), SW_DISCOVERY_BROWSE_INVALID, interface, name, type, domain, data->extra); break; - + case AVAHI_BROWSER_CACHE_EXHAUSTED: case AVAHI_BROWSER_ALL_FOR_NOW: break; @@ -1089,12 +1089,12 @@ sw_result sw_discovery_browse( oid_data *data; AvahiIfIndex ifindex; sw_result result = SW_E_UNKNOWN; - + assert(self); assert(type); assert(reply); assert(oid); - + AVAHI_WARN_LINKAGE; if ((*oid = oid_alloc(self, OID_SERVICE_BROWSER)) == (sw_discovery_oid) -1) @@ -1104,22 +1104,22 @@ sw_result sw_discovery_browse( assert(data); data->reply = (sw_result (*)(void)) reply; data->extra = extra; - + ifindex = interface_index == 0 ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface_index; ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex)); - + if (!(data->object = avahi_service_browser_new(self->client, ifindex, AVAHI_PROTO_INET, type, domain, 0, service_browser_callback, data))) { result = map_error(avahi_client_errno(self->client)); goto finish; } result = SW_OKAY; - + finish: ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex)); - + if (result != SW_OKAY) if (*oid != (sw_discovery_oid) -1) sw_discovery_cancel(self, *oid); @@ -1129,7 +1129,7 @@ finish: sw_result sw_discovery_cancel(sw_discovery self, sw_discovery_oid oid) { oid_data *data; - assert(self); + assert(self); AVAHI_WARN_LINKAGE; @@ -1141,19 +1141,19 @@ sw_result sw_discovery_cancel(sw_discovery self, sw_discovery_oid oid) { case OID_SERVICE_BROWSER: avahi_service_browser_free(data->object); break; - + case OID_SERVICE_RESOLVER: avahi_service_resolver_free(data->object); break; - + case OID_DOMAIN_BROWSER: avahi_domain_browser_free(data->object); break; - + case OID_ENTRY_GROUP: avahi_entry_group_free(data->object); break; - + case OID_UNUSED: ; } @@ -1165,7 +1165,7 @@ sw_result sw_discovery_cancel(sw_discovery self, sw_discovery_oid oid) { } oid_release(self, oid); - + return SW_OKAY; } diff --git a/avahi-compat-howl/include/corby/buffer.h b/avahi-compat-howl/include/corby/buffer.h index 017ad5d..3c4416e 100644 --- a/avahi-compat-howl/include/corby/buffer.h +++ b/avahi-compat-howl/include/corby/buffer.h @@ -8,7 +8,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. @@ -36,7 +36,7 @@ #ifdef __cplusplus extern "C" { -#endif +#endif struct _sw_corby_buffer; @@ -128,7 +128,7 @@ sw_corby_buffer_fina( void HOWL_API sw_corby_buffer_reset( sw_corby_buffer self); - + sw_result HOWL_API sw_corby_buffer_set_octets( @@ -136,21 +136,21 @@ sw_corby_buffer_set_octets( sw_octets octets, sw_size_t size); - + sw_octets HOWL_API sw_corby_buffer_octets( sw_corby_buffer self); - - + + sw_size_t HOWL_API sw_corby_buffer_bytes_used( sw_corby_buffer self); - + sw_size_t HOWL_API sw_corby_buffer_size( sw_corby_buffer self); - + sw_result HOWL_API sw_corby_buffer_put_int8( @@ -193,14 +193,14 @@ sw_corby_buffer_put_octets( sw_corby_buffer self, sw_const_octets val, sw_size_t size); - + sw_result HOWL_API sw_corby_buffer_put_sized_octets( sw_corby_buffer self, sw_const_octets val, sw_uint32 len); - + sw_result HOWL_API sw_corby_buffer_put_cstring( @@ -218,7 +218,7 @@ sw_result HOWL_API sw_corby_buffer_put_pad( sw_corby_buffer self, sw_corby_buffer_pad pad); - + sw_result HOWL_API sw_corby_buffer_get_int8( @@ -273,7 +273,7 @@ sw_corby_buffer_allocate_and_get_sized_octets( sw_octets * val, sw_uint32 * size, sw_uint8 endian); - + sw_result HOWL_API sw_corby_buffer_get_zerocopy_sized_octets( @@ -281,7 +281,7 @@ sw_corby_buffer_get_zerocopy_sized_octets( sw_octets * val, sw_uint32 * size, sw_uint8 endian); - + sw_result HOWL_API sw_corby_buffer_get_sized_octets( @@ -297,15 +297,15 @@ sw_corby_buffer_allocate_and_get_cstring( sw_string * val, sw_uint32 * len, sw_uint8 endian); - - + + sw_result HOWL_API sw_corby_buffer_get_zerocopy_cstring( sw_corby_buffer self, sw_string * val, sw_uint32 * len, sw_uint8 endian); - + sw_result HOWL_API sw_corby_buffer_get_cstring( @@ -313,18 +313,18 @@ sw_corby_buffer_get_cstring( sw_string val, sw_uint32 * len, sw_uint8 endian); - - + + sw_result HOWL_API sw_corby_buffer_get_object( sw_corby_buffer self, struct _sw_corby_object ** object, sw_uint8 endian); - + #ifdef __cplusplus } -#endif +#endif #endif diff --git a/avahi-compat-howl/include/corby/channel.h b/avahi-compat-howl/include/corby/channel.h index 823e027..9c91fbb 100644 --- a/avahi-compat-howl/include/corby/channel.h +++ b/avahi-compat-howl/include/corby/channel.h @@ -8,7 +8,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. @@ -38,7 +38,7 @@ #ifdef __cplusplus extern "C" { -#endif +#endif struct _sw_corby_channel; typedef struct _sw_corby_channel * sw_corby_channel; @@ -180,7 +180,7 @@ sw_corby_channel_fina( #ifdef __cplusplus } -#endif +#endif #endif diff --git a/avahi-compat-howl/include/corby/corby.h b/avahi-compat-howl/include/corby/corby.h index 7d68138..5e069ff 100644 --- a/avahi-compat-howl/include/corby/corby.h +++ b/avahi-compat-howl/include/corby/corby.h @@ -8,7 +8,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. @@ -38,9 +38,9 @@ /* - * protocol tags. the only standard one is TAG_INTERNET_IIOP. + * protocol tags. the only standard one is TAG_INTERNET_IIOP. * the others are proprietary pandora corby protocols. - */ + */ #define SW_TAG_INTERNET_IOP 0 #define SW_TAG_UIOP 250 #define SW_TAG_MIOP 251 diff --git a/avahi-compat-howl/include/corby/message.h b/avahi-compat-howl/include/corby/message.h index 406b9b9..a06c358 100644 --- a/avahi-compat-howl/include/corby/message.h +++ b/avahi-compat-howl/include/corby/message.h @@ -8,7 +8,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. @@ -54,7 +54,7 @@ sw_corby_message_fina( #ifdef __cplusplus } -#endif +#endif #endif diff --git a/avahi-compat-howl/include/corby/object.h b/avahi-compat-howl/include/corby/object.h index 1bc7407..1cfd516 100644 --- a/avahi-compat-howl/include/corby/object.h +++ b/avahi-compat-howl/include/corby/object.h @@ -8,7 +8,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. @@ -64,7 +64,7 @@ sw_corby_object_init_from_url( sw_result HOWL_API sw_corby_object_fina( sw_corby_object self); - + sw_result HOWL_API sw_corby_object_start_request( diff --git a/avahi-compat-howl/include/corby/orb.h b/avahi-compat-howl/include/corby/orb.h index a674082..76af578 100644 --- a/avahi-compat-howl/include/corby/orb.h +++ b/avahi-compat-howl/include/corby/orb.h @@ -8,7 +8,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. @@ -38,7 +38,7 @@ #ifdef __cplusplus extern "C" { -#endif +#endif struct _sw_corby_orb; @@ -165,7 +165,7 @@ sw_corby_orb_protocol_to_address( sw_const_string tag, sw_string addr, sw_port * port); - + sw_result HOWL_API sw_corby_orb_protocol_to_url( @@ -193,7 +193,7 @@ sw_corby_orb_dispatch_message( #ifdef __cplusplus } -#endif +#endif #endif diff --git a/avahi-compat-howl/include/discovery/discovery.h b/avahi-compat-howl/include/discovery/discovery.h index 1e8a7d5..082373d 100644 --- a/avahi-compat-howl/include/discovery/discovery.h +++ b/avahi-compat-howl/include/discovery/discovery.h @@ -8,7 +8,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. @@ -52,7 +52,7 @@ typedef sw_uint32 sw_discovery_oid; /* * For backwards compatibility */ -#define sw_discovery_publish_host_id sw_discovery_oid +#define sw_discovery_publish_host_id sw_discovery_oid #define sw_discovery_publish_id sw_discovery_oid #define sw_discovery_browse_id sw_discovery_oid #define sw_discovery_resolve_id sw_discovery_oid @@ -107,7 +107,7 @@ typedef sw_result sw_discovery_publish_status status, sw_opaque extra); -typedef sw_result +typedef sw_result (HOWL_API *sw_discovery_browse_reply)( sw_discovery session, sw_discovery_oid oid, @@ -142,10 +142,10 @@ typedef sw_result sw_const_string fullname, sw_uint16 rrtype, sw_uint16 rrclass, - sw_uint16 rrdatalen, + sw_uint16 rrdatalen, sw_const_octets rrdata, sw_uint32 ttl, - sw_opaque extra); + sw_opaque extra); /* @@ -254,7 +254,7 @@ sw_discovery_query_record( sw_const_string fullname, sw_uint16 rrtype, sw_uint16 rrclass, - sw_discovery_query_record_reply reply, + sw_discovery_query_record_reply reply, sw_opaque extra, sw_discovery_oid * oid); @@ -263,7 +263,7 @@ sw_result HOWL_API sw_discovery_cancel( sw_discovery self, sw_discovery_oid oid); - + /* ---------------------------------------------------------- @@ -272,7 +272,7 @@ sw_discovery_cancel( * * ---------------------------------------------------------- */ - + sw_result HOWL_API sw_discovery_run( @@ -282,7 +282,7 @@ sw_discovery_run( sw_result HOWL_API sw_discovery_stop_run( sw_discovery self); - + int HOWL_API sw_discovery_socket( diff --git a/avahi-compat-howl/include/discovery/text_record.h b/avahi-compat-howl/include/discovery/text_record.h index 91f16d7..a5ee802 100644 --- a/avahi-compat-howl/include/discovery/text_record.h +++ b/avahi-compat-howl/include/discovery/text_record.h @@ -8,7 +8,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. diff --git a/avahi-compat-howl/include/howl.h b/avahi-compat-howl/include/howl.h index 80a1775..dac6d43 100644 --- a/avahi-compat-howl/include/howl.h +++ b/avahi-compat-howl/include/howl.h @@ -8,7 +8,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. diff --git a/avahi-compat-howl/include/rendezvous/rendezvous.h b/avahi-compat-howl/include/rendezvous/rendezvous.h index 1d26b4a..12c85e8 100644 --- a/avahi-compat-howl/include/rendezvous/rendezvous.h +++ b/avahi-compat-howl/include/rendezvous/rendezvous.h @@ -8,7 +8,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. diff --git a/avahi-compat-howl/include/rendezvous/text_record.h b/avahi-compat-howl/include/rendezvous/text_record.h index cf8b845..3e2bfc2 100644 --- a/avahi-compat-howl/include/rendezvous/text_record.h +++ b/avahi-compat-howl/include/rendezvous/text_record.h @@ -8,7 +8,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. diff --git a/avahi-compat-howl/include/salt/address.h b/avahi-compat-howl/include/salt/address.h index b18a4af..ea83f8d 100644 --- a/avahi-compat-howl/include/salt/address.h +++ b/avahi-compat-howl/include/salt/address.h @@ -8,7 +8,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. @@ -91,7 +91,7 @@ sw_ipv4_address_fina( sw_bool HOWL_API sw_ipv4_address_is_any( sw_ipv4_address self); - + sw_saddr HOWL_API sw_ipv4_address_saddr( diff --git a/avahi-compat-howl/include/salt/debug.h b/avahi-compat-howl/include/salt/debug.h index 03bd453..c53977b 100644 --- a/avahi-compat-howl/include/salt/debug.h +++ b/avahi-compat-howl/include/salt/debug.h @@ -8,7 +8,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. @@ -36,7 +36,7 @@ #ifdef __cplusplus extern "C" { -#endif +#endif #define SW_LOG_WARNING 1 << 0 diff --git a/avahi-compat-howl/include/salt/interface.h b/avahi-compat-howl/include/salt/interface.h index 5356398..a4b1b1d 100644 --- a/avahi-compat-howl/include/salt/interface.h +++ b/avahi-compat-howl/include/salt/interface.h @@ -8,7 +8,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. diff --git a/avahi-compat-howl/include/salt/platform.h b/avahi-compat-howl/include/salt/platform.h index fda0c77..6bb9dcc 100644 --- a/avahi-compat-howl/include/salt/platform.h +++ b/avahi-compat-howl/include/salt/platform.h @@ -8,7 +8,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. @@ -33,7 +33,7 @@ #ifdef __cplusplus extern "C" { -#endif +#endif #if defined(__VXWORKS__) @@ -119,7 +119,7 @@ typedef int sw_result; * for little endian platforms. * * The macro WORDS_BIGENDIAN will be defined - * by autoconf. If you are using Howl on + * by autoconf. If you are using Howl on * a platform that doesn't have autoconf, define * SW_ENDIAN directly * -------------------------------------------------------- @@ -185,19 +185,19 @@ extern sw_int32 sw_strcasecmp( sw_const_string arg1, sw_const_string arg2); - + extern sw_int32 sw_strncasecmp( sw_const_string arg1, sw_const_string arg2, sw_len n); - + extern sw_string sw_strtok_r( sw_string arg1, sw_const_string arg2, sw_string * lasts); - + # define sw_memset(ARG1, ARG2, ARG3) memset((char*) ARG1, ARG2, ARG3) # define sw_memcpy(ARG1, ARG2, ARG3) memcpy((char*) ARG1, (char*) ARG2, ARG3) # define sw_memcmp(ARG1, ARG2, ARG3) memcmp((char*) ARG1, ARG2, ARG3) @@ -413,7 +413,7 @@ sw_strerror(); /* * Obsolete types and macros. - * + * * These are here for backwards compatibility, but will * be removed in the future */ diff --git a/avahi-compat-howl/include/salt/salt.h b/avahi-compat-howl/include/salt/salt.h index 88ac0d9..ddb289b 100644 --- a/avahi-compat-howl/include/salt/salt.h +++ b/avahi-compat-howl/include/salt/salt.h @@ -8,7 +8,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. @@ -36,14 +36,14 @@ #ifdef __cplusplus extern "C" { -#endif +#endif typedef enum _sw_socket_event { SW_SOCKET_READ = (1 << 0), SW_SOCKET_WRITE = (1 << 1), - SW_SOCKET_OOB = (1 << 2) + SW_SOCKET_OOB = (1 << 2) } sw_socket_event; @@ -80,7 +80,7 @@ typedef sw_result sw_salt salt, struct _sw_network_interface * netif, sw_opaque extra); - + typedef sw_opaque sw_signal_handler; typedef sw_result (HOWL_API *sw_signal_handler_func)( @@ -95,13 +95,13 @@ sw_salt_init( sw_salt * self, int argc, char ** argv); - - + + sw_result HOWL_API sw_salt_fina( sw_salt self); - + sw_result HOWL_API sw_salt_register_socket( sw_salt self, @@ -116,8 +116,8 @@ sw_result HOWL_API sw_salt_unregister_socket( sw_salt self, struct _sw_socket * socket); - - + + sw_result HOWL_API sw_salt_register_timer( sw_salt self, @@ -126,8 +126,8 @@ sw_salt_register_timer( sw_timer_handler handler, sw_timer_handler_func func, sw_opaque extra); - - + + sw_result HOWL_API sw_salt_unregister_timer( sw_salt self, @@ -187,7 +187,7 @@ sw_salt_run( sw_result HOWL_API sw_salt_stop_run( sw_salt self); - + #define SW_FALSE 0 #define SW_TRUE 1 diff --git a/avahi-compat-howl/include/salt/signal.h b/avahi-compat-howl/include/salt/signal.h index 2ae5bb3..b36e02f 100644 --- a/avahi-compat-howl/include/salt/signal.h +++ b/avahi-compat-howl/include/salt/signal.h @@ -8,7 +8,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. @@ -35,7 +35,7 @@ #ifdef __cplusplus extern "C" { -#endif +#endif struct _sw_signal; @@ -55,7 +55,7 @@ sw_signal_fina( #ifdef __cplusplus } -#endif +#endif #endif diff --git a/avahi-compat-howl/include/salt/socket.h b/avahi-compat-howl/include/salt/socket.h index 88773e4..9eaa102 100644 --- a/avahi-compat-howl/include/salt/socket.h +++ b/avahi-compat-howl/include/salt/socket.h @@ -8,7 +8,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. @@ -36,7 +36,7 @@ #ifdef __cplusplus extern "C" { -#endif +#endif struct _sw_socket; @@ -66,8 +66,8 @@ sw_udp_socket_init( sw_result HOWL_API sw_multicast_socket_init( sw_socket * self); - - + + sw_result HOWL_API sw_socket_fina( sw_socket self); @@ -97,21 +97,21 @@ sw_result HOWL_API sw_socket_listen( sw_socket self, int qsize); - - + + sw_result HOWL_API sw_socket_connect( sw_socket self, sw_ipv4_address address, sw_port port); - - + + sw_result HOWL_API sw_socket_accept( sw_socket self, sw_socket * socket); - - + + sw_result HOWL_API sw_socket_send( sw_socket self, @@ -129,7 +129,7 @@ sw_socket_sendto( sw_ipv4_address to, sw_port port); - + sw_result HOWL_API sw_socket_recv( sw_socket self, @@ -154,13 +154,13 @@ sw_result HOWL_API sw_socket_set_blocking_mode( sw_socket self, sw_bool blocking_mode); - - + + sw_result HOWL_API sw_socket_set_options( sw_socket self, sw_socket_options options); - + sw_ipv4_address HOWL_API sw_socket_ipv4_address( @@ -185,31 +185,31 @@ sw_socket_close( sw_result HOWL_API sw_socket_options_init( sw_socket_options * self); - + sw_result HOWL_API sw_socket_options_fina( sw_socket_options self); - + sw_result HOWL_API sw_socket_options_set_debug( sw_socket_options self, sw_bool val); - + sw_result HOWL_API sw_socket_options_set_nodelay( sw_socket_options self, sw_bool val); - - + + sw_result HOWL_API sw_socket_options_set_dontroute( sw_socket_options self, sw_bool val); - - + + sw_result HOWL_API sw_socket_options_set_keepalive( sw_socket_options self, @@ -221,8 +221,8 @@ sw_socket_options_set_linger( sw_socket_options self, sw_bool onoff, sw_uint32 linger); - - + + sw_result HOWL_API sw_socket_options_set_reuseaddr( sw_socket_options self, @@ -233,8 +233,8 @@ sw_result HOWL_API sw_socket_options_set_rcvbuf( sw_socket_options self, sw_uint32 val); - - + + sw_result HOWL_API sw_socket_options_set_sndbuf( sw_socket_options self, @@ -242,7 +242,7 @@ sw_socket_options_set_sndbuf( int -sw_socket_error_code(void); +sw_socket_error_code(void); #define SW_E_SOCKET_BASE 0x80000200 @@ -257,7 +257,7 @@ sw_socket_error_code(void); #ifdef __cplusplus } -#endif +#endif #endif diff --git a/avahi-compat-howl/include/salt/time.h b/avahi-compat-howl/include/salt/time.h index b3ec226..8789b3a 100644 --- a/avahi-compat-howl/include/salt/time.h +++ b/avahi-compat-howl/include/salt/time.h @@ -8,7 +8,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. @@ -35,7 +35,7 @@ #ifdef __cplusplus extern "C" { -#endif +#endif struct _sw_timer; @@ -94,7 +94,7 @@ sw_time_cmp( #ifdef __cplusplus } -#endif +#endif #endif diff --git a/avahi-compat-howl/samples/browse.c b/avahi-compat-howl/samples/browse.c index b4a8cf3..f55b1cf 100644 --- a/avahi-compat-howl/samples/browse.c +++ b/avahi-compat-howl/samples/browse.c @@ -5,7 +5,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. @@ -54,7 +54,7 @@ my_resolver( sw_result err = SW_OKAY; sw_discovery_cancel(discovery, oid); - + fprintf(stderr, "resolve reply: 0x%x %s %s %s %s %d\n", interface_index, name, type, domain, sw_ipv4_address_name(address, name_buf, 16), port); if ((text_record_len > 0) && (text_record) && (*text_record != '\0')) diff --git a/avahi-compat-howl/samples/publish.c b/avahi-compat-howl/samples/publish.c index cca6040..931e786 100644 --- a/avahi-compat-howl/samples/publish.c +++ b/avahi-compat-howl/samples/publish.c @@ -5,7 +5,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. diff --git a/avahi-compat-howl/samples/query.c b/avahi-compat-howl/samples/query.c index a74a81c..b1c30eb 100644 --- a/avahi-compat-howl/samples/query.c +++ b/avahi-compat-howl/samples/query.c @@ -5,7 +5,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. @@ -40,7 +40,7 @@ query_record_reply( sw_const_string fullname, sw_uint16 rrtype, sw_uint16 rrclass, - sw_uint16 rrdatalen, + sw_uint16 rrdatalen, sw_const_octets rrdata, sw_uint32 ttl, sw_opaque extra) diff --git a/avahi-compat-howl/samples/resolve.c b/avahi-compat-howl/samples/resolve.c index b921c27..1790849 100644 --- a/avahi-compat-howl/samples/resolve.c +++ b/avahi-compat-howl/samples/resolve.c @@ -5,7 +5,7 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. @@ -54,7 +54,7 @@ my_resolver( sw_result err = SW_OKAY; sw_discovery_cancel(discovery, oid); - + fprintf(stderr, "resolve reply: 0x%x %s %s %s %s %d\n", interface_index, name, type, domain, sw_ipv4_address_name(address, name_buf, 16), port); if ((text_record_len > 0) && (text_record) && (*text_record != '\0')) diff --git a/avahi-compat-howl/text-test.c b/avahi-compat-howl/text-test.c index fea653c..e0d6f2c 100644 --- a/avahi-compat-howl/text-test.c +++ b/avahi-compat-howl/text-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 @@ -72,7 +72,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { char key[255]; uint8_t val[255]; sw_ulong val_len; - + ASSERT_SW_OKAY(sw_text_record_init(&r)); ASSERT_SW_OKAY(sw_text_record_add_string(r, "foo=bar")); ASSERT_SW_OKAY(sw_text_record_add_string(r, "waldo=baz")); @@ -92,7 +92,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { - + ASSERT_SW_OKAY(sw_text_record_fina(r)); return 0; diff --git a/avahi-compat-howl/text.c b/avahi-compat-howl/text.c index 3b717be..178ca73 100644 --- a/avahi-compat-howl/text.c +++ b/avahi-compat-howl/text.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,12 +44,12 @@ struct _sw_text_record { 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); } @@ -59,17 +59,17 @@ sw_result sw_text_record_init(sw_text_record *self) { assert(self); AVAHI_WARN_LINKAGE; - + if (!(*self = avahi_new(struct _sw_text_record, 1))) { *self = NULL; return SW_E_UNKNOWN; } - + (*self)->strlst = NULL; (*self)->buffer = NULL; (*self)->buffer_size = 0; (*self)->buffer_valid = 0; - + return SW_OKAY; } @@ -89,12 +89,12 @@ sw_result sw_text_record_add_string( sw_const_string string) { AvahiStringList *n; - + assert(self); assert(string); AVAHI_WARN_LINKAGE; - + if (!(n = avahi_string_list_add(self->strlst, string))) return SW_E_UNKNOWN; @@ -112,7 +112,7 @@ sw_result sw_text_record_add_key_and_string_value( assert(self); assert(key); - + AVAHI_WARN_LINKAGE; if (!(n = avahi_string_list_add_pair(self->strlst, key, val))) @@ -134,7 +134,7 @@ sw_result sw_text_record_add_key_and_binary_value( assert(self); assert(key); assert(len || !val); - + AVAHI_WARN_LINKAGE; if (!(n = avahi_string_list_add_pair_arbitrary(self->strlst, key, val, len))) @@ -152,10 +152,10 @@ static int rebuild(sw_text_record self) { return 0; self->buffer_size = avahi_string_list_serialize(self->strlst, NULL, 0); - + if (!(self->buffer = avahi_realloc(self->buffer, self->buffer_size + 1))) return -1; - + avahi_string_list_serialize(self->strlst, self->buffer, self->buffer_size); self->buffer_valid = 1; @@ -177,7 +177,7 @@ sw_uint32 sw_text_record_len(sw_text_record self) { assert(self); AVAHI_WARN_LINKAGE; - + if (rebuild(self) < 0) return (uint32_t) -1; @@ -186,7 +186,7 @@ sw_uint32 sw_text_record_len(sw_text_record self) { struct _sw_text_record_iterator { AvahiStringList *strlst, *index; - + }; sw_result sw_text_record_iterator_init( @@ -198,7 +198,7 @@ sw_result sw_text_record_iterator_init( assert(self); AVAHI_WARN_LINKAGE; - + if (!(*self = avahi_new(struct _sw_text_record_iterator, 1))) { *self = NULL; return SW_E_UNKNOWN; @@ -211,7 +211,7 @@ sw_result sw_text_record_iterator_init( } (*self)->index = (*self)->strlst = avahi_string_list_reverse(txt); - + return SW_OKAY; } @@ -222,7 +222,7 @@ sw_result sw_text_record_iterator_fina(sw_text_record_iterator self) { avahi_string_list_free(self->strlst); avahi_free(self); - + return SW_OKAY; } @@ -234,10 +234,10 @@ sw_result sw_text_record_iterator_next( char *mkey = NULL, *mvalue = NULL; size_t msize = 0; - + assert(self); assert(key); - + AVAHI_WARN_LINKAGE; if (!self->index) @@ -250,7 +250,7 @@ sw_result sw_text_record_iterator_next( memset(val, 0, SW_TEXT_RECORD_MAX_LEN); memcpy(val, mvalue, msize); *val_len = msize; - + avahi_free(mkey); avahi_free(mvalue); diff --git a/avahi-compat-howl/unsupported.c b/avahi-compat-howl/unsupported.c index 800b3c3..ba9fc3b 100644 --- a/avahi-compat-howl/unsupported.c +++ b/avahi-compat-howl/unsupported.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 @@ -97,14 +97,14 @@ sw_time sw_time_add( AVAHI_WARN_UNSUPPORTED_ABORT; } -AVAHI_GCC_NORETURN +AVAHI_GCC_NORETURN sw_time sw_time_sub( AVAHI_GCC_UNUSED sw_time self, AVAHI_GCC_UNUSED sw_time y) { AVAHI_WARN_UNSUPPORTED_ABORT; } -AVAHI_GCC_NORETURN +AVAHI_GCC_NORETURN sw_int32 sw_time_cmp( AVAHI_GCC_UNUSED sw_time self, AVAHI_GCC_UNUSED sw_time y) { @@ -338,17 +338,17 @@ sw_result sw_socket_set_options( return SW_E_NO_IMPL; } -AVAHI_GCC_NORETURN +AVAHI_GCC_NORETURN sw_ipv4_address sw_socket_ipv4_address(AVAHI_GCC_UNUSED sw_socket self) { AVAHI_WARN_UNSUPPORTED_ABORT; } -AVAHI_GCC_NORETURN +AVAHI_GCC_NORETURN sw_port sw_socket_port(AVAHI_GCC_UNUSED sw_socket self) { AVAHI_WARN_UNSUPPORTED_ABORT; } -AVAHI_GCC_NORETURN +AVAHI_GCC_NORETURN sw_sockdesc_t sw_socket_desc(AVAHI_GCC_UNUSED sw_socket self) { AVAHI_WARN_UNSUPPORTED_ABORT; } @@ -425,7 +425,7 @@ sw_result sw_socket_options_set_sndbuf( return SW_E_NO_IMPL; } -AVAHI_GCC_NORETURN +AVAHI_GCC_NORETURN int sw_socket_error_code(void) { AVAHI_WARN_UNSUPPORTED_ABORT; } @@ -478,7 +478,7 @@ sw_result sw_corby_orb_register_channel( return SW_E_NO_IMPL; } -AVAHI_GCC_NORETURN +AVAHI_GCC_NORETURN sw_corby_orb_delegate sw_corby_orb_get_delegate(AVAHI_GCC_UNUSED sw_corby_orb self) { AVAHI_WARN_UNSUPPORTED_ABORT; } @@ -581,7 +581,7 @@ sw_result sw_corby_buffer_init_with_size_and_delegate( sw_result sw_corby_buffer_fina(AVAHI_GCC_UNUSED sw_corby_buffer self) { AVAHI_WARN_UNSUPPORTED; return SW_E_NO_IMPL; -} +} void sw_corby_buffer_reset(AVAHI_GCC_UNUSED sw_corby_buffer self) { AVAHI_WARN_UNSUPPORTED; @@ -667,7 +667,7 @@ sw_result sw_corby_buffer_put_sized_octets( AVAHI_WARN_UNSUPPORTED; return SW_E_NO_IMPL; } - + sw_result sw_corby_buffer_put_cstring( AVAHI_GCC_UNUSED sw_corby_buffer self, AVAHI_GCC_UNUSED sw_const_string val) { @@ -710,7 +710,7 @@ sw_result sw_corby_buffer_get_int16( AVAHI_WARN_UNSUPPORTED; return SW_E_NO_IMPL; } - + sw_result sw_corby_buffer_get_uint16( AVAHI_GCC_UNUSED sw_corby_buffer self, AVAHI_GCC_UNUSED sw_uint16 * val, @@ -718,7 +718,7 @@ sw_result sw_corby_buffer_get_uint16( AVAHI_WARN_UNSUPPORTED; return SW_E_NO_IMPL; } - + sw_result sw_corby_buffer_get_int32( AVAHI_GCC_UNUSED sw_corby_buffer self, AVAHI_GCC_UNUSED sw_int32 * val, @@ -815,7 +815,7 @@ sw_result sw_corby_channel_start_request( AVAHI_WARN_UNSUPPORTED; return SW_E_NO_IMPL; } - + sw_result sw_corby_channel_start_reply( AVAHI_GCC_UNUSED sw_corby_channel self, AVAHI_GCC_UNUSED struct _sw_corby_buffer ** buffer, @@ -879,9 +879,9 @@ sw_result sw_corby_channel_set_delegate( AVAHI_GCC_UNUSED sw_corby_channel_delegate delegate) { AVAHI_WARN_UNSUPPORTED; return SW_E_NO_IMPL; -} +} -AVAHI_GCC_NORETURN +AVAHI_GCC_NORETURN sw_corby_channel_delegate sw_corby_channel_get_delegate( AVAHI_GCC_UNUSED sw_corby_channel self) { AVAHI_WARN_UNSUPPORTED_ABORT; @@ -893,7 +893,7 @@ void sw_corby_channel_set_app_data( AVAHI_WARN_UNSUPPORTED; } -AVAHI_GCC_NORETURN +AVAHI_GCC_NORETURN sw_opaque sw_corby_channel_get_app_data(AVAHI_GCC_UNUSED sw_corby_channel self) { AVAHI_WARN_UNSUPPORTED_ABORT; } @@ -938,7 +938,7 @@ sw_result sw_corby_object_send( AVAHI_WARN_UNSUPPORTED; return SW_E_NO_IMPL; } - + sw_result sw_corby_object_recv( AVAHI_GCC_UNUSED sw_corby_object self, AVAHI_GCC_UNUSED sw_corby_message * message, @@ -1010,7 +1010,7 @@ sw_result sw_text_record_string_iterator_fina( AVAHI_GCC_UNUSED sw_text_record_string_iterator self) { AVAHI_WARN_UNSUPPORTED; return SW_E_NO_IMPL; -} +} sw_result sw_text_record_string_iterator_next( AVAHI_GCC_UNUSED sw_text_record_string_iterator self, diff --git a/avahi-compat-howl/warn.c b/avahi-compat-howl/warn.c index 4bff7ee..6e1715f 100644 --- a/avahi-compat-howl/warn.c +++ b/avahi-compat-howl/warn.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 diff --git a/avahi-compat-howl/warn.h b/avahi-compat-howl/warn.h index 785dba4..2e30eaf 100644 --- a/avahi-compat-howl/warn.h +++ b/avahi-compat-howl/warn.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-compat-libdns_sd/compat.c b/avahi-compat-libdns_sd/compat.c index 7c2686a..819b770 100644 --- a/avahi-compat-libdns_sd/compat.c +++ b/avahi-compat-libdns_sd/compat.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 @@ -64,7 +64,7 @@ struct type_info { struct _DNSServiceRef_t { int n_ref; - + AvahiSimplePoll *simple_poll; int thread_fd, main_fd; @@ -73,7 +73,7 @@ struct _DNSServiceRef_t { int thread_running; pthread_mutex_t mutex; - + void *context; DNSServiceBrowseReply service_browser_callback; DNSServiceResolveReply service_resolver_callback; @@ -100,10 +100,10 @@ static DNSServiceErrorType map_error(int error) { switch (error) { case AVAHI_OK : return kDNSServiceErr_NoError; - + case AVAHI_ERR_BAD_STATE : return kDNSServiceErr_BadState; - + case AVAHI_ERR_INVALID_HOST_NAME: case AVAHI_ERR_INVALID_DOMAIN_NAME: case AVAHI_ERR_INVALID_TTL: @@ -137,13 +137,13 @@ static DNSServiceErrorType map_error(int error) { case AVAHI_ERR_INVALID_INTERFACE: case AVAHI_ERR_INVALID_PROTOCOL: return kDNSServiceErr_BadInterfaceIndex; - + case AVAHI_ERR_INVALID_FLAGS: return kDNSServiceErr_BadFlags; - + case AVAHI_ERR_NOT_FOUND: return kDNSServiceErr_NoSuchName; - + case AVAHI_ERR_VERSION_MISMATCH: return kDNSServiceErr_Incompatible; @@ -179,7 +179,7 @@ static void type_info_free(struct type_info *i) { static int type_info_parse(struct type_info *i, const char *t) { char *token = NULL; - + assert(i); assert(t); @@ -190,12 +190,12 @@ static int type_info_parse(struct type_info *i, const char *t) { if (*t == 0) break; - + l = strcspn(t, ","); if (l <= 0) goto fail; - + token = avahi_strndup(t, l); if (!token) @@ -211,7 +211,7 @@ static int type_info_parse(struct type_info *i, const char *t) { token = NULL; } else { char *fst; - + /* This is not the first token, hence a subtype */ if (!(fst = avahi_strdup_printf("%s._sub.%s", token, i->type))) @@ -239,7 +239,7 @@ static int type_info_parse(struct type_info *i, const char *t) { if (i->type) return 0; - + fail: type_info_free(i); avahi_free(token); @@ -265,7 +265,7 @@ static int read_command(int fd) { char command; assert(fd >= 0); - + if ((r = read(fd, &command, 1)) != 1) { fprintf(stderr, __FILE__": read() failed: %s\n", r < 0 ? strerror(errno) : "EOF"); return -1; @@ -288,15 +288,15 @@ static int write_command(int fd, char reply) { static int poll_func(struct pollfd *ufds, unsigned int nfds, int timeout, void *userdata) { DNSServiceRef sdref = userdata; int ret; - + assert(sdref); - + ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex)); /* fprintf(stderr, "pre-syscall\n"); */ ret = poll(ufds, nfds, timeout); /* fprintf(stderr, "post-syscall\n"); */ - + ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex)); return ret; @@ -308,7 +308,7 @@ static void * thread_func(void *data) { sigfillset(&mask); pthread_sigmask(SIG_BLOCK, &mask, NULL); - + sdref->thread = pthread_self(); sdref->thread_running = 1; @@ -319,7 +319,7 @@ static void * thread_func(void *data) { break; /* fprintf(stderr, "Command: %c\n", command); */ - + switch (command) { case COMMAND_POLL: { @@ -329,12 +329,12 @@ static void * thread_func(void *data) { for (;;) { errno = 0; - + if ((ret = avahi_simple_poll_run(sdref->simple_poll)) < 0) { if (errno == EINTR) continue; - + fprintf(stderr, __FILE__": avahi_simple_poll_run() failed: %s\n", strerror(errno)); } @@ -345,14 +345,14 @@ static void * thread_func(void *data) { if (write_command(sdref->thread_fd, ret < 0 ? COMMAND_POLL_FAILED : COMMAND_POLL_DONE) < 0) break; - + break; } case COMMAND_QUIT: return NULL; } - + } return NULL; @@ -402,12 +402,12 @@ static DNSServiceRef sdref_new(void) { /* Queue an initial POLL command for the thread */ if (write_command(sdref->main_fd, COMMAND_POLL) < 0) goto fail; - + if (pthread_create(&sdref->thread, NULL, thread_func, sdref) != 0) goto fail; sdref->thread_running = 1; - + return sdref; fail: @@ -420,7 +420,7 @@ fail: static void sdref_free(DNSServiceRef sdref) { assert(sdref); - + if (sdref->thread_running) { ASSERT_SUCCESS(write_command(sdref->main_fd, COMMAND_QUIT)); avahi_simple_poll_wakeup(sdref->simple_poll); @@ -447,9 +447,9 @@ static void sdref_free(DNSServiceRef sdref) { avahi_free(sdref->service_host); type_info_free(&sdref->type_info); - + avahi_string_list_free(sdref->service_txt); - + avahi_free(sdref); } @@ -471,7 +471,7 @@ static void sdref_unref(DNSServiceRef sdref) { int DNSSD_API DNSServiceRefSockFD(DNSServiceRef sdref) { AVAHI_WARN_LINKAGE; - + if (!sdref || sdref->n_ref <= 0) return -1; @@ -485,15 +485,15 @@ DNSServiceErrorType DNSSD_API DNSServiceProcessResult(DNSServiceRef sdref) { if (!sdref || sdref->n_ref <= 0) return kDNSServiceErr_BadParam; - + sdref_ref(sdref); ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex)); - + /* Cleanup notification socket */ if (read_command(sdref->main_fd) != COMMAND_POLL_DONE) goto finish; - + if (avahi_simple_poll_dispatch(sdref->simple_poll) < 0) goto finish; @@ -508,13 +508,13 @@ DNSServiceErrorType DNSSD_API DNSServiceProcessResult(DNSServiceRef sdref) { /* Request the poll */ if (write_command(sdref->main_fd, COMMAND_POLL) < 0) goto finish; - + ret = kDNSServiceErr_NoError; - + finish: ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex)); - + sdref_unref(sdref); return ret; @@ -546,7 +546,7 @@ static void service_browser_callback( type = add_trailing_dot(type, type_fixed, sizeof(type_fixed)); domain = add_trailing_dot(domain, domain_fixed, sizeof(domain_fixed)); - + switch (event) { case AVAHI_BROWSER_NEW: sdref->service_browser_callback(sdref, kDNSServiceFlagsAdd, interface, kDNSServiceErr_NoError, name, type, domain, sdref->context); @@ -559,7 +559,7 @@ static void service_browser_callback( case AVAHI_BROWSER_FAILURE: sdref->service_browser_callback(sdref, 0, interface, map_error(avahi_client_errno(sdref->client)), NULL, NULL, NULL, sdref->context); break; - + case AVAHI_BROWSER_CACHE_EXHAUSTED: case AVAHI_BROWSER_ALL_FOR_NOW: break; @@ -569,7 +569,7 @@ static void service_browser_callback( static void generic_client_callback(AvahiClient *s, AvahiClientState state, void* userdata) { DNSServiceRef sdref = userdata; int error = kDNSServiceErr_Unknown; - + assert(s); assert(sdref); assert(sdref->n_ref >= 1); @@ -609,7 +609,7 @@ DNSServiceErrorType DNSSD_API DNSServiceBrowse( DNSServiceRef sdref = NULL; AvahiIfIndex ifindex; struct type_info type_info; - + AVAHI_WARN_LINKAGE; if (!ret_sdref || !regtype) @@ -622,7 +622,7 @@ DNSServiceErrorType DNSSD_API DNSServiceBrowse( } type_info_init(&type_info); - + if (type_info_parse(&type_info, regtype) < 0 || type_info.n_subtypes > 1) { type_info_free(&type_info); @@ -630,7 +630,7 @@ DNSServiceErrorType DNSSD_API DNSServiceBrowse( return kDNSServiceErr_Unsupported; } else regtype = type_info.subtypes ? (char*) type_info.subtypes->text : type_info.type; - + if (!(sdref = sdref_new())) { type_info_free(&type_info); return kDNSServiceErr_Unknown; @@ -640,26 +640,26 @@ DNSServiceErrorType DNSSD_API DNSServiceBrowse( sdref->service_browser_callback = callback; ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex)); - + if (!(sdref->client = avahi_client_new(avahi_simple_poll_get(sdref->simple_poll), 0, generic_client_callback, sdref, &error))) { ret = map_error(error); goto finish; } ifindex = interface == kDNSServiceInterfaceIndexAny ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface; - + if (!(sdref->service_browser = avahi_service_browser_new(sdref->client, ifindex, AVAHI_PROTO_UNSPEC, regtype, domain, 0, service_browser_callback, sdref))) { ret = map_error(avahi_client_errno(sdref->client)); goto finish; } - + ret = kDNSServiceErr_NoError; *ret_sdref = sdref; - + finish: ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex)); - + if (ret != kDNSServiceErr_NoError) DNSServiceRefDeallocate(sdref); @@ -707,7 +707,7 @@ static void service_resolver_callback( assert(ret == AVAHI_OK); strcat(full_name, "."); - + sdref->service_resolver_callback(sdref, 0, interface, kDNSServiceErr_NoError, full_name, host_name, htons(port), l, (unsigned char*) p, sdref->context); avahi_free(p); @@ -753,27 +753,27 @@ DNSServiceErrorType DNSSD_API DNSServiceResolve( sdref->service_resolver_callback = callback; ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex)); - + if (!(sdref->client = avahi_client_new(avahi_simple_poll_get(sdref->simple_poll), 0, generic_client_callback, sdref, &error))) { ret = map_error(error); goto finish; } ifindex = interface == kDNSServiceInterfaceIndexAny ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface; - + if (!(sdref->service_resolver = avahi_service_resolver_new(sdref->client, ifindex, AVAHI_PROTO_UNSPEC, name, regtype, domain, AVAHI_PROTO_UNSPEC, 0, service_resolver_callback, sdref))) { ret = map_error(avahi_client_errno(sdref->client)); goto finish; } - + ret = kDNSServiceErr_NoError; *ret_sdref = sdref; - + finish: ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex)); - + if (ret != kDNSServiceErr_NoError) DNSServiceRefDeallocate(sdref); @@ -782,7 +782,7 @@ finish: int DNSSD_API DNSServiceConstructFullName ( char *fullName, - const char *service, + const char *service, const char *regtype, const char *domain) { @@ -793,7 +793,7 @@ int DNSSD_API DNSServiceConstructFullName ( if (avahi_service_name_join(fullName, kDNSServiceMaxDomainName, service, regtype, domain) < 0) return -1; - + return 0; } @@ -827,7 +827,7 @@ static void domain_browser_callback( case AVAHI_BROWSER_FAILURE: sdref->domain_browser_callback(sdref, 0, interface, map_error(avahi_client_errno(sdref->client)), domain, sdref->context); break; - + case AVAHI_BROWSER_CACHE_EXHAUSTED: case AVAHI_BROWSER_ALL_FOR_NOW: break; @@ -865,28 +865,28 @@ DNSServiceErrorType DNSSD_API DNSServiceEnumerateDomains( sdref->domain_browser_callback = callback; ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex)); - + if (!(sdref->client = avahi_client_new(avahi_simple_poll_get(sdref->simple_poll), 0, generic_client_callback, sdref, &error))) { ret = map_error(error); goto finish; } ifindex = interface == kDNSServiceInterfaceIndexAny ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface; - + if (!(sdref->domain_browser = avahi_domain_browser_new(sdref->client, ifindex, AVAHI_PROTO_UNSPEC, "local", flags == kDNSServiceFlagsRegistrationDomains ? AVAHI_DOMAIN_BROWSER_REGISTER : AVAHI_DOMAIN_BROWSER_BROWSE, 0, domain_browser_callback, sdref))) { ret = map_error(avahi_client_errno(sdref->client)); goto finish; } - + ret = kDNSServiceErr_NoError; *ret_sdref = sdref; - + finish: ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex)); - + if (ret != kDNSServiceErr_NoError) DNSServiceRefDeallocate(sdref); @@ -904,7 +904,7 @@ static void reg_report_error(DNSServiceRef sdref, DNSServiceErrorType error) { regtype = add_trailing_dot(sdref->type_info.type, regtype_fixed, sizeof(regtype_fixed)); domain = add_trailing_dot(sdref->service_domain, domain_fixed, sizeof(domain_fixed)); - + sdref->service_register_callback( sdref, 0, error, sdref->service_name_chosen ? sdref->service_name_chosen : sdref->service_name, @@ -916,7 +916,7 @@ static void reg_report_error(DNSServiceRef sdref, DNSServiceErrorType error) { static int reg_create_service(DNSServiceRef sdref) { int ret; AvahiStringList *l; - + assert(sdref); assert(sdref->n_ref >= 1); @@ -964,7 +964,7 @@ static void reg_client_callback(AvahiClient *s, AvahiClientState state, void* us /* We've not been setup completely */ if (!sdref->entry_group) return; - + switch (state) { case AVAHI_CLIENT_FAILURE: reg_report_error(sdref, kDNSServiceErr_Unknown); @@ -994,29 +994,29 @@ static void reg_client_callback(AvahiClient *s, AvahiClientState state, void* us if (!sdref->service_name_chosen) { assert(sdref->service_name); - + if (!(sdref->service_name_chosen = avahi_strdup(sdref->service_name))) { reg_report_error(sdref, kDNSServiceErr_NoMemory); return; } } - + /* Register the service */ if ((ret = reg_create_service(sdref)) < 0) { reg_report_error(sdref, map_error(ret)); return; } - + break; } - + case AVAHI_CLIENT_S_COLLISION: case AVAHI_CLIENT_S_REGISTERING: /* Remove our entry */ avahi_entry_group_reset(sdref->entry_group); - + break; case AVAHI_CLIENT_CONNECTING: @@ -1042,7 +1042,7 @@ static void reg_entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState st case AVAHI_ENTRY_GROUP_COLLISION: { char *n; int ret; - + /* Remove our entry */ avahi_entry_group_reset(sdref->entry_group); @@ -1061,7 +1061,7 @@ static void reg_entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState st reg_report_error(sdref, map_error(ret)); return; } - + break; } @@ -1074,7 +1074,7 @@ static void reg_entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState st /* Inform the user */ reg_report_error(sdref, map_error(avahi_client_errno(sdref->client))); break; - + } } @@ -1082,14 +1082,14 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister ( DNSServiceRef *ret_sdref, DNSServiceFlags flags, uint32_t interface, - const char *name, + const char *name, const char *regtype, - const char *domain, - const char *host, + const char *domain, + const char *host, uint16_t port, uint16_t txtLen, - const void *txtRecord, - DNSServiceRegisterReply callback, + const void *txtRecord, + DNSServiceRegisterReply callback, void *context) { DNSServiceErrorType ret = kDNSServiceErr_Unknown; @@ -1103,7 +1103,7 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister ( if (!ret_sdref || !regtype) return kDNSServiceErr_BadParam; *ret_sdref = NULL; - + if (!txtRecord) { txtLen = 1; txtRecord = ""; @@ -1114,7 +1114,7 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister ( return kDNSServiceErr_Unsupported; } - if (txtLen > 0) + if (txtLen > 0) if (avahi_string_list_parse(txtRecord, txtLen, &txt) < 0) return kDNSServiceErr_Invalid; @@ -1122,7 +1122,7 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister ( avahi_string_list_free(txt); return kDNSServiceErr_Invalid; } - + if (!(sdref = sdref_new())) { avahi_string_list_free(txt); type_info_free(&type_info); @@ -1141,9 +1141,9 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister ( sdref->service_txt = txt; /* Some OOM checking would be cool here */ - + ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex)); - + if (!(sdref->client = avahi_client_new(avahi_simple_poll_get(sdref->simple_poll), 0, reg_client_callback, sdref, &error))) { ret = map_error(error); goto finish; @@ -1185,20 +1185,20 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister ( goto finish; } - + if ((error = reg_create_service(sdref)) < 0) { ret = map_error(error); goto finish; } } - + ret = kDNSServiceErr_NoError; *ret_sdref = sdref; - + finish: ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex)); - + if (ret != kDNSServiceErr_NoError) DNSServiceRefDeallocate(sdref); @@ -1207,7 +1207,7 @@ finish: DNSServiceErrorType DNSSD_API DNSServiceUpdateRecord( DNSServiceRef sdref, - DNSRecordRef rref, + DNSRecordRef rref, DNSServiceFlags flags, uint16_t rdlen, const void *rdata, @@ -1226,7 +1226,7 @@ DNSServiceErrorType DNSSD_API DNSServiceUpdateRecord( return kDNSServiceErr_Unsupported; } - if (rdlen > 0) + if (rdlen > 0) if (avahi_string_list_parse(rdata, rdlen, &txt) < 0) return kDNSServiceErr_Invalid; @@ -1251,7 +1251,7 @@ DNSServiceErrorType DNSSD_API DNSServiceUpdateRecord( sdref->type_info.type, sdref->service_domain, sdref->service_txt) < 0) { - + ret = map_error(avahi_client_errno(sdref->client)); goto finish; } @@ -1260,10 +1260,10 @@ DNSServiceErrorType DNSSD_API DNSServiceUpdateRecord( avahi_string_list_free(txt); ret = kDNSServiceErr_NoError; - + finish: ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex)); - + return ret; } diff --git a/avahi-compat-libdns_sd/dns_sd.h b/avahi-compat-libdns_sd/dns_sd.h index b7eb8a2..66e494e 100644 --- a/avahi-compat-libdns_sd/dns_sd.h +++ b/avahi-compat-libdns_sd/dns_sd.h @@ -2,27 +2,27 @@ * * Copyright (c) 2003-2004, Apple Computer, Inc. All rights reserved. * - * Redistribution and use in source and binary forms, with or without + * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ @@ -150,7 +150,7 @@ enum /* Flag for signifying that a query or registration should be performed exclusively via multicast DNS, * even for a name in a domain (e.g. foo.apple.com.) that would normally imply unicast DNS. */ - + kDNSServiceFlagsReturnCNAME = 0x800 /* Flag for returning CNAME records in the DNSServiceQueryRecord call. CNAME records are * normally followed without indicating to the client that there was a CNAME record. @@ -316,23 +316,23 @@ enum */ -/* +/* * Constants for specifying an interface index * * Specific interface indexes are identified via a 32-bit unsigned integer returned * by the if_nametoindex() family of calls. - * + * * If the client passes 0 for interface index, that means "do the right thing", * which (at present) means, "if the name is in an mDNS local multicast domain * (e.g. 'local.', '254.169.in-addr.arpa.', '{8,9,A,B}.E.F.ip6.arpa.') then multicast * on all applicable interfaces, otherwise send via unicast to the appropriate * DNS server." Normally, most clients will use 0 for interface index to * automatically get the default sensible behaviour. - * + * * If the client passes a positive interface index, then for multicast names that * indicates to do the operation only on that one interface. For unicast names the * interface index is ignored unless kDNSServiceFlagsForceMulticast is also set. - * + * * If the client passes kDNSServiceInterfaceIndexLocalOnly when registering * a service, then that service will be found *only* by other local clients * on the same machine that are browsing using kDNSServiceInterfaceIndexLocalOnly @@ -341,7 +341,7 @@ enum * running on the same machine, this allows the client to advertise that service * in a way such that it does not inadvertently appear in service lists on * all the other machines on the network. - * + * * If the client passes kDNSServiceInterfaceIndexLocalOnly when browsing * then it will find *all* records registered on that same local machine. * Clients explicitly wishing to discover *only* LocalOnly services can @@ -494,7 +494,7 @@ typedef void (DNSSD_API *DNSServiceDomainEnumReply) /* DNSServiceEnumerateDomains() Parameters: * * - * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds + * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds * then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError, * and the enumeration operation will run indefinitely until the client * terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate(). @@ -578,7 +578,7 @@ typedef void (DNSSD_API *DNSServiceRegisterReply) /* DNSServiceRegister() Parameters: * - * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds + * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds * then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError, * and the registration will remain active indefinitely until the client * terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate(). @@ -843,7 +843,7 @@ typedef void (DNSSD_API *DNSServiceBrowseReply) /* DNSServiceBrowse() Parameters: * - * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds + * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds * then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError, * and the browse operation will run indefinitely until the client * terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate(). @@ -964,7 +964,7 @@ typedef void (DNSSD_API *DNSServiceResolveReply) /* DNSServiceResolve() Parameters * - * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds + * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds * then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError, * and the resolve operation will run indefinitely until the client * terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate(). @@ -1190,7 +1190,7 @@ typedef void (DNSSD_API *DNSServiceQueryRecordReply) /* DNSServiceQueryRecord() Parameters: * - * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds + * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds * then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError, * and the query operation will run indefinitely until the client * terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate(). @@ -1683,7 +1683,7 @@ DNSServiceErrorType DNSSD_API TXTRecordGetItemAtIndex * calls by this user that do not specify an explicit domain will browse and * register in this wide-area domain in addition to .local. In addition, this * domain will be returned as a Browse domain via domain enumeration calls. - * + * * * Parameters: * @@ -1700,8 +1700,8 @@ DNSServiceErrorType DNSSD_API DNSServiceSetDefaultDomainForUser ( DNSServiceFlags flags, const char *domain - ); - + ); + #endif //__APPLE_API_PRIVATE // Some C compiler cleverness. We can make the compiler check certain things for us, diff --git a/avahi-compat-libdns_sd/null-test.c b/avahi-compat-libdns_sd/null-test.c index a6c03df..8accc13 100644 --- a/avahi-compat-libdns_sd/null-test.c +++ b/avahi-compat-libdns_sd/null-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 diff --git a/avahi-compat-libdns_sd/txt.c b/avahi-compat-libdns_sd/txt.c index 2b539e6..74f8a5f 100644 --- a/avahi-compat-libdns_sd/txt.c +++ b/avahi-compat-libdns_sd/txt.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 @@ -51,7 +51,7 @@ void DNSSD_API TXTRecordCreate( AVAHI_WARN_LINKAGE; assert(txtref); - + /* Apple's API design is flawed in so many ways, including the * fact that it isn't compatible with 64 bit processors. To work * around this we need some magic here which involves allocating @@ -75,7 +75,7 @@ void DNSSD_API TXTRecordDeallocate(TXTRecordRef *txtref) { TXTRecordInternal *t; AVAHI_WARN_LINKAGE; - + assert(txtref); t = INTERNAL_PTR(txtref); if (!t) @@ -91,7 +91,7 @@ void DNSSD_API TXTRecordDeallocate(TXTRecordRef *txtref) { static int make_sure_fits_in(TXTRecordInternal *t, size_t size) { uint8_t *n; size_t nsize; - + assert(t); if (t->size + size <= t->max_size) @@ -101,13 +101,13 @@ static int make_sure_fits_in(TXTRecordInternal *t, size_t size) { if (nsize > 0xFFFF) return -1; - + if (!(n = avahi_realloc(t->malloc_buffer, nsize))) return -1; if (!t->malloc_buffer && t->size) memcpy(n, t->buffer, t->size); - + t->buffer = t->malloc_buffer = n; t->max_size = nsize; @@ -134,7 +134,7 @@ static int remove_key(TXTRecordInternal *t, const char *key) { /* Key longer than buffer */ if (key_len > t->size - i - 1) break; - + if (key_len <= *p && strncmp(key, (char*) p+1, key_len) == 0 && (key_len == *p || p[1+key_len] == '=')) { @@ -150,7 +150,7 @@ static int remove_key(TXTRecordInternal *t, const char *key) { found = 1; } else { /* Skip to next */ - + i += *p +1; p += *p +1; } @@ -162,7 +162,7 @@ static int remove_key(TXTRecordInternal *t, const char *key) { DNSServiceErrorType DNSSD_API TXTRecordSetValue( TXTRecordRef *txtref, const char *key, - uint8_t length, + uint8_t length, const void *value) { TXTRecordInternal *t; @@ -186,7 +186,7 @@ DNSServiceErrorType DNSSD_API TXTRecordSetValue( if (n > 0xFF) return kDNSServiceErr_Invalid; - + if (make_sure_fits_in(t, 1 + n) < 0) return kDNSServiceErr_NoMemory; @@ -196,7 +196,7 @@ DNSServiceErrorType DNSSD_API TXTRecordSetValue( *(p++) = (uint8_t) n; t->size ++; - + memcpy(p, key, l); p += l; t->size += l; @@ -267,7 +267,7 @@ static const uint8_t *find_key(const uint8_t *buffer, size_t size, const char *k key_len = strlen(key); assert(key_len <= 0xFF); - + p = buffer; i = 0; @@ -280,7 +280,7 @@ static const uint8_t *find_key(const uint8_t *buffer, size_t size, const char *k /* Key longer than buffer */ if (key_len > size - i - 1) return NULL; - + if (key_len <= *p && strncmp(key, (const char*) p+1, key_len) == 0 && (key_len == *p || p[1+key_len] == '=')) { @@ -288,7 +288,7 @@ static const uint8_t *find_key(const uint8_t *buffer, size_t size, const char *k /* Key matches, so let's return it */ return p; - } + } /* Skip to next */ i += *p +1; @@ -326,7 +326,7 @@ const void * DNSSD_API TXTRecordGetValuePtr( const uint8_t *p; size_t n, l; - + AVAHI_WARN_LINKAGE; assert(key); @@ -336,7 +336,7 @@ const void * DNSSD_API TXTRecordGetValuePtr( if (*key == 0 || strchr(key, '=') || strlen(key) > 0xFF) /* Empty or invalid key */ return NULL; - + assert(buffer); if (!(p = find_key(buffer, size, key))) @@ -351,20 +351,20 @@ const void * DNSSD_API TXTRecordGetValuePtr( if (n <= 0) goto fail; - + assert(*p == '='); p++; n--; if (value_len) *value_len = n; - + return p; fail: if (value_len) *value_len = 0; - + return NULL; } @@ -381,12 +381,12 @@ uint16_t DNSSD_API TXTRecordGetCount( if (!size) return 0; - + assert(buffer); - + p = buffer; i = 0; - + while (i < size) { /* Does the item fit in? */ @@ -418,7 +418,7 @@ DNSServiceErrorType DNSSD_API TXTRecordGetItemAtIndex( size_t i; unsigned n = 0; DNSServiceErrorType ret = kDNSServiceErr_Invalid; - + AVAHI_WARN_LINKAGE; if (!size) @@ -428,7 +428,7 @@ DNSServiceErrorType DNSSD_API TXTRecordGetItemAtIndex( p = buffer; i = 0; - + while (i < size) { /* Does the item fit in? */ @@ -451,7 +451,7 @@ DNSServiceErrorType DNSSD_API TXTRecordGetItemAtIndex( strncpy(key, (const char*) p + 1, l); key[l] = 0; - + if (d) { if (value_len) *value_len = *p - l - 1; @@ -486,6 +486,6 @@ fail: if (value_len) *value_len = 0; - return ret; + return ret; } diff --git a/avahi-compat-libdns_sd/unsupported.c b/avahi-compat-libdns_sd/unsupported.c index a460b41..2a23aed 100644 --- a/avahi-compat-libdns_sd/unsupported.c +++ b/avahi-compat-libdns_sd/unsupported.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,7 +43,7 @@ DNSServiceErrorType DNSSD_API DNSServiceRegisterRecord ( AVAHI_GCC_UNUSED void *context) { AVAHI_WARN_UNSUPPORTED; - + return kDNSServiceErr_Unsupported; } @@ -58,7 +58,7 @@ DNSServiceErrorType DNSSD_API DNSServiceQueryRecord ( AVAHI_GCC_UNUSED void *context) { AVAHI_WARN_UNSUPPORTED; - + return kDNSServiceErr_Unsupported; } @@ -72,13 +72,13 @@ DNSServiceErrorType DNSSD_API DNSServiceReconfirmRecord ( AVAHI_GCC_UNUSED const void *rdata) { AVAHI_WARN_UNSUPPORTED; - + return kDNSServiceErr_Unsupported; } DNSServiceErrorType DNSSD_API DNSServiceCreateConnection(AVAHI_GCC_UNUSED DNSServiceRef *sdRef) { AVAHI_WARN_UNSUPPORTED; - + return kDNSServiceErr_Unsupported; } @@ -92,7 +92,7 @@ DNSServiceErrorType DNSSD_API DNSServiceAddRecord( AVAHI_GCC_UNUSED uint32_t ttl) { AVAHI_WARN_UNSUPPORTED; - + return kDNSServiceErr_Unsupported; } @@ -102,7 +102,7 @@ DNSServiceErrorType DNSSD_API DNSServiceRemoveRecord( AVAHI_GCC_UNUSED DNSServiceFlags flags) { AVAHI_WARN_UNSUPPORTED; - + return kDNSServiceErr_Unsupported; } diff --git a/avahi-compat-libdns_sd/warn.c b/avahi-compat-libdns_sd/warn.c index d3389c1..94aa535 100644 --- a/avahi-compat-libdns_sd/warn.c +++ b/avahi-compat-libdns_sd/warn.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 @@ -55,25 +55,25 @@ const char *avahi_exe_name(void) { /* Yes, I know, this is not portable. But who cares? It's for * cosmetics only, anyway. */ - + pthread_mutex_lock(&mutex); if (exe_name[0] == 0) { int k; - + if ((k = readlink("/proc/self/exe", exe_name, sizeof(exe_name)-1)) < 0) snprintf(exe_name, sizeof(exe_name), "(unknown)"); else { char *slash; - + assert((size_t) k <= sizeof(exe_name)-1); exe_name[k] = 0; - + if ((slash = strrchr(exe_name, '/'))) memmove(exe_name, slash+1, strlen(slash)+1); } } - + pthread_mutex_unlock(&mutex); return exe_name; @@ -89,14 +89,14 @@ void avahi_warn(const char *fmt, ...) { char msg[512] = "*** WARNING *** "; va_list ap; size_t n; - + assert(fmt); - + va_start(ap, fmt); n = strlen(msg); vsnprintf(msg + n, sizeof(msg) - n, fmt, ap); va_end(ap); - + fprintf(stderr, "%s\n", msg); openlog(avahi_exe_name(), LOG_PID, LOG_USER); @@ -106,7 +106,7 @@ void avahi_warn(const char *fmt, ...) { void avahi_warn_linkage(void) { int w; - + pthread_mutex_lock(&linkage_mutex); w = linkage_warning; linkage_warning = 1; diff --git a/avahi-compat-libdns_sd/warn.h b/avahi-compat-libdns_sd/warn.h index da64fab..6bd8478 100644 --- a/avahi-compat-libdns_sd/warn.h +++ b/avahi-compat-libdns_sd/warn.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-core/announce.c b/avahi-core/announce.c index d0fd598..5a35045 100644 --- a/avahi-core/announce.c +++ b/avahi-core/announce.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 @@ -45,7 +45,7 @@ static void remove_announcer(AvahiServer *s, AvahiAnnouncer *a) { AVAHI_LLIST_REMOVE(AvahiAnnouncer, by_interface, a->interface->announcers, a); AVAHI_LLIST_REMOVE(AvahiAnnouncer, by_entry, a->entry->announcers, a); - + avahi_free(a); } @@ -61,7 +61,7 @@ static void set_timeout(AvahiAnnouncer *a, const struct timeval *tv) { } } else { - if (a->time_event) + if (a->time_event) avahi_time_event_update(a->time_event, tv); else a->time_event = avahi_time_event_new(a->server->time_event_queue, tv, elapse_announce, a); @@ -76,28 +76,28 @@ void avahi_s_entry_group_check_probed(AvahiSEntryGroup *g, int immediately) { assert(!g->dead); /* Check whether all group members have been probed */ - - if (g->state != AVAHI_ENTRY_GROUP_REGISTERING || g->n_probing > 0) + + if (g->state != AVAHI_ENTRY_GROUP_REGISTERING || g->n_probing > 0) return; avahi_s_entry_group_change_state(g, AVAHI_ENTRY_GROUP_ESTABLISHED); if (g->dead) return; - + for (e = g->entries; e; e = e->by_group_next) { AvahiAnnouncer *a; - + for (a = e->announcers; a; a = a->by_entry_next) { - + if (a->state != AVAHI_WAITING) continue; - + a->state = AVAHI_ANNOUNCING; if (immediately) { /* Shortcut */ - + a->n_iteration = 1; next_state(a); } else { @@ -118,17 +118,17 @@ static void next_state(AvahiAnnouncer *a) { assert(a->entry->group); avahi_s_entry_group_check_probed(a->entry->group, 1); - + } else if (a->state == AVAHI_PROBING) { if (a->n_iteration >= 4) { /* Probing done */ - + if (a->entry->group) { assert(a->entry->group->n_probing); a->entry->group->n_probing--; } - + if (a->entry->group && a->entry->group->state == AVAHI_ENTRY_GROUP_REGISTERING) a->state = AVAHI_WAITING; else { @@ -142,10 +142,10 @@ static void next_state(AvahiAnnouncer *a) { struct timeval tv; avahi_interface_post_probe(a->interface, a->entry->record, 0); - + avahi_elapse_time(&tv, AVAHI_PROBE_INTERVAL_MSEC, 0); set_timeout(a, &tv); - + a->n_iteration++; } @@ -168,10 +168,10 @@ static void next_state(AvahiAnnouncer *a) { } else { struct timeval tv; avahi_elapse_time(&tv, a->sec_delay*1000, AVAHI_ANNOUNCEMENT_JITTER_MSEC); - + if (a->n_iteration < 10) a->sec_delay *= 2; - + set_timeout(a, &tv); } } @@ -185,7 +185,7 @@ static void elapse_announce(AvahiTimeEvent *e, void *userdata) { static AvahiAnnouncer *get_announcer(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) { AvahiAnnouncer *a; - + assert(s); assert(e); assert(i); @@ -200,7 +200,7 @@ static AvahiAnnouncer *get_announcer(AvahiServer *s, AvahiEntry *e, AvahiInterfa static void go_to_initial_state(AvahiAnnouncer *a) { AvahiEntry *e; struct timeval tv; - + assert(a); e = a->entry; @@ -212,7 +212,7 @@ static void go_to_initial_state(AvahiAnnouncer *a) { a->state = AVAHI_ANNOUNCING; else a->state = AVAHI_WAITING; - + } else a->state = AVAHI_ESTABLISHED; @@ -222,9 +222,9 @@ static void go_to_initial_state(AvahiAnnouncer *a) { if (a->state == AVAHI_PROBING && e->group) e->group->n_probing++; - if (a->state == AVAHI_PROBING) + if (a->state == AVAHI_PROBING) set_timeout(a, avahi_elapse_time(&tv, 0, AVAHI_PROBE_JITTER_MSEC)); - else if (a->state == AVAHI_ANNOUNCING) + else if (a->state == AVAHI_ANNOUNCING) set_timeout(a, avahi_elapse_time(&tv, 0, AVAHI_ANNOUNCEMENT_JITTER_MSEC)); else set_timeout(a, NULL); @@ -243,13 +243,13 @@ static void new_announcer(AvahiServer *s, AvahiInterface *i, AvahiEntry *e) { /* We don't want duplicate announcers */ if (get_announcer(s, e, i)) - return; + return; if ((!(a = avahi_new(AvahiAnnouncer, 1)))) { avahi_log_error(__FILE__": Out of memory."); return; } - + a->server = s; a->interface = i; a->entry = e; @@ -263,7 +263,7 @@ static void new_announcer(AvahiServer *s, AvahiInterface *i, AvahiEntry *e) { void avahi_announce_interface(AvahiServer *s, AvahiInterface *i) { AvahiEntry *e; - + assert(s); assert(i); @@ -277,7 +277,7 @@ void avahi_announce_interface(AvahiServer *s, AvahiInterface *i) { static void announce_walk_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata) { AvahiEntry *e = userdata; - + assert(m); assert(i); assert(e); @@ -296,7 +296,7 @@ void avahi_announce_entry(AvahiServer *s, AvahiEntry *e) { void avahi_announce_group(AvahiServer *s, AvahiSEntryGroup *g) { AvahiEntry *e; - + assert(s); assert(g); @@ -315,7 +315,7 @@ int avahi_entry_is_registered(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) if (!(a = get_announcer(s, e, i))) return 0; - + return a->state == AVAHI_ANNOUNCING || a->state == AVAHI_ESTABLISHED || @@ -332,7 +332,7 @@ int avahi_entry_is_probing(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) { if (!(a = get_announcer(s, e, i))) return 0; - + return a->state == AVAHI_PROBING || (a->state == AVAHI_WAITING && (e->flags & AVAHI_PUBLISH_UNIQUE)); @@ -340,7 +340,7 @@ int avahi_entry_is_probing(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) { void avahi_entry_return_to_initial_state(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) { AvahiAnnouncer *a; - + assert(s); assert(e); assert(i); @@ -356,12 +356,12 @@ void avahi_entry_return_to_initial_state(AvahiServer *s, AvahiEntry *e, AvahiInt static AvahiRecord *make_goodbye_record(AvahiRecord *r) { AvahiRecord *g; - + assert(r); if (!(g = avahi_record_copy(r))) return NULL; /* OOM */ - + assert(g->ref == 1); g->ttl = 0; @@ -370,7 +370,7 @@ static AvahiRecord *make_goodbye_record(AvahiRecord *r) { static int is_duplicate_entry(AvahiServer *s, AvahiEntry *e) { AvahiEntry *i; - + assert(s); assert(e); @@ -381,7 +381,7 @@ static int is_duplicate_entry(AvahiServer *s, AvahiEntry *e) { if (!avahi_record_equal_no_ttl(i->record, e->record)) continue; - + return 1; } @@ -391,7 +391,7 @@ static int is_duplicate_entry(AvahiServer *s, AvahiEntry *e) { static void send_goodbye_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata) { AvahiEntry *e = userdata; AvahiRecord *g; - + assert(m); assert(i); assert(e); @@ -408,10 +408,10 @@ static void send_goodbye_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, v if (is_duplicate_entry(m->server, e)) return; - + if (!(g = make_goodbye_record(e->record))) return; /* OOM */ - + avahi_interface_post_response(i, g, e->flags & AVAHI_PUBLISH_UNIQUE, NULL, 1); avahi_record_unref(g); } @@ -419,7 +419,7 @@ static void send_goodbye_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, v static void reannounce(AvahiAnnouncer *a) { AvahiEntry *e; struct timeval tv; - + assert(a); e = a->entry; @@ -430,12 +430,12 @@ static void reannounce(AvahiAnnouncer *a) { /* Because we might change state we decrease the probing counter first */ if (a->state == AVAHI_PROBING && a->entry->group) a->entry->group->n_probing--; - + if (a->state == AVAHI_PROBING || (a->state == AVAHI_WAITING && (e->flags & AVAHI_PUBLISH_UNIQUE) && !(e->flags & AVAHI_PUBLISH_NO_PROBE))) /* We were probing or waiting after probe, so we restart probing from the beginning here */ - + a->state = AVAHI_PROBING; else if (a->state == AVAHI_WAITING) @@ -443,26 +443,26 @@ static void reannounce(AvahiAnnouncer *a) { a->state = AVAHI_WAITING; else if (e->flags & AVAHI_PUBLISH_NO_ANNOUNCE) - + /* No announcer needed */ a->state = AVAHI_ESTABLISHED; else { - + /* Ok, let's restart announcing */ a->state = AVAHI_ANNOUNCING; - } - + } + /* Now let's increase the probing counter again */ if (a->state == AVAHI_PROBING && e->group) e->group->n_probing++; - + a->n_iteration = 1; a->sec_delay = 1; if (a->state == AVAHI_PROBING) set_timeout(a, avahi_elapse_time(&tv, 0, AVAHI_PROBE_JITTER_MSEC)); - else if (a->state == AVAHI_ANNOUNCING) + else if (a->state == AVAHI_ANNOUNCING) set_timeout(a, avahi_elapse_time(&tv, 0, AVAHI_ANNOUNCEMENT_JITTER_MSEC)); else set_timeout(a, NULL); @@ -472,7 +472,7 @@ static void reannounce(AvahiAnnouncer *a) { static void reannounce_walk_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata) { AvahiEntry *e = userdata; AvahiAnnouncer *a; - + assert(m); assert(i); assert(e); @@ -492,7 +492,7 @@ void avahi_reannounce_entry(AvahiServer *s, AvahiEntry *e) { avahi_interface_monitor_walk(s->monitor, e->interface, e->protocol, reannounce_walk_callback, e); } - + void avahi_goodbye_interface(AvahiServer *s, AvahiInterface *i, int send_goodbye, int remove) { assert(s); assert(i); @@ -500,7 +500,7 @@ void avahi_goodbye_interface(AvahiServer *s, AvahiInterface *i, int send_goodbye if (send_goodbye) if (i->announcing) { AvahiEntry *e; - + for (e = s->entries; e; e = e->entries_next) if (!e->dead) send_goodbye_callback(s->monitor, i, e); @@ -514,7 +514,7 @@ void avahi_goodbye_interface(AvahiServer *s, AvahiInterface *i, int send_goodbye void avahi_goodbye_entry(AvahiServer *s, AvahiEntry *e, int send_goodbye, int remove) { assert(s); assert(e); - + if (send_goodbye) if (!e->dead) avahi_interface_monitor_walk(s->monitor, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, send_goodbye_callback, e); diff --git a/avahi-core/announce.h b/avahi-core/announce.h index 3a8bcf3..d50ca63 100644 --- a/avahi-core/announce.h +++ b/avahi-core/announce.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-core/avahi-reflector.c b/avahi-core/avahi-reflector.c index df5539f..fa178f0 100644 --- a/avahi-core/avahi-reflector.c +++ b/avahi-core/avahi-reflector.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 @@ -40,7 +40,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char*argv[]) { AvahiSimplePoll *simple_poll; simple_poll = avahi_simple_poll_new(); - + avahi_server_config_init(&config); config.publish_hinfo = 0; config.publish_addresses = 0; @@ -48,7 +48,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char*argv[]) { config.publish_domain = 0; config.use_ipv6 = 0; config.enable_reflector = 1; - + server = avahi_server_new(avahi_simple_poll_get(simple_poll), &config, NULL, NULL, &error); avahi_server_config_free(&config); diff --git a/avahi-core/avahi-test.c b/avahi-core/avahi-test.c index cb7b97e..8d2d61b 100644 --- a/avahi-core/avahi-test.c +++ b/avahi-core/avahi-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 @@ -61,7 +61,7 @@ static void dump_line(const char *text, AVAHI_GCC_UNUSED void* userdata) { static void dump_timeout_callback(AvahiTimeout *timeout, void* userdata) { struct timeval tv; - + AvahiServer *avahi = userdata; avahi_server_dump(avahi, dump_line, NULL); @@ -98,7 +98,7 @@ static void record_browser_callback( AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, AVAHI_GCC_UNUSED void* userdata) { char *t; - + assert(r); if (record) { @@ -113,7 +113,7 @@ static void remove_entries(void); static void create_entries(int new_name); static void entry_group_callback(AVAHI_GCC_UNUSED AvahiServer *s, AVAHI_GCC_UNUSED AvahiSEntryGroup *g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void* userdata) { - avahi_log_debug("entry group state: %i", state); + avahi_log_debug("entry group state: %i", state); if (state == AVAHI_ENTRY_GROUP_COLLISION) { remove_entries(); @@ -127,8 +127,8 @@ static void entry_group_callback(AVAHI_GCC_UNUSED AvahiServer *s, AVAHI_GCC_UNUS static void server_callback(AvahiServer *s, AvahiServerState state, AVAHI_GCC_UNUSED void* userdata) { server = s; - avahi_log_debug("server state: %i", state); - + avahi_log_debug("server state: %i", state); + if (state == AVAHI_SERVER_RUNNING) { avahi_log_debug("Server startup complete. Host name is <%s>. Service cookie is %u", avahi_server_get_host_name_fqdn(s), avahi_server_get_local_service_cookie(s)); create_entries(0); @@ -155,11 +155,11 @@ static void create_entries(int new_name) { remove_entries(); - if (!group) + if (!group) group = avahi_s_entry_group_new(server, entry_group_callback, NULL); assert(avahi_s_entry_group_is_empty(group)); - + if (!service_name) service_name = avahi_strdup("Test Service"); else if (new_name) { @@ -167,7 +167,7 @@ static void create_entries(int new_name) { avahi_free(service_name); service_name = n; } - + if (avahi_server_add_service(server, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, service_name, "_http._tcp", NULL, NULL, 80, "foo", NULL) < 0) { avahi_log_error("Failed to add HTTP service"); goto fail; @@ -190,7 +190,7 @@ static void create_entries(int new_name) { r = avahi_record_new_full("cname.local", AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_CNAME, AVAHI_DEFAULT_TTL); r->data.cname.name = avahi_strdup("cocaine.local"); - + if (avahi_server_add(server, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, r) < 0) { avahi_record_unref(r); avahi_log_error("Failed to add CNAME record"); @@ -291,14 +291,14 @@ static void sr_callback( const AvahiAddress *a, uint16_t port, AvahiStringList *txt, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, + AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, AVAHI_GCC_UNUSED void* userdata) { if (event != AVAHI_RESOLVER_FOUND) avahi_log_debug("SR: (%i.%i) <%s> as %s in <%s> [%s]", iface, protocol, name, service_type, domain_name, resolver_event_to_string(event)); else { char t[AVAHI_ADDRESS_STR_MAX], *s; - + avahi_address_snprint(t, sizeof(t), a); s = avahi_string_list_to_string(txt); @@ -317,9 +317,9 @@ static void dsb_callback( uint16_t port, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, AVAHI_GCC_UNUSED void* userdata) { - + char t[AVAHI_ADDRESS_STR_MAX] = "n/a"; - + if (a) avahi_address_snprint(t, sizeof(t), a); @@ -344,7 +344,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { simple_poll = avahi_simple_poll_new(); poll_api = avahi_simple_poll_get(simple_poll); - + avahi_server_config_init(&config); avahi_address_parse("192.168.50.1", AVAHI_PROTO_UNSPEC, &config.wide_area_servers[0]); @@ -353,7 +353,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { server = avahi_server_new(poll_api, &config, server_callback, NULL, &error); avahi_server_config_free(&config); - + k = avahi_key_new("_http._tcp.0pointer.de", AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR); r = avahi_s_record_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, k, 0, record_browser_callback, NULL); avahi_key_unref(k); @@ -389,7 +389,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { avahi_s_dns_server_browser_free(dsb); if (group) - avahi_s_entry_group_free(group); + avahi_s_entry_group_free(group); if (server) avahi_server_free(server); @@ -398,6 +398,6 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { avahi_simple_poll_free(simple_poll); avahi_free(service_name); - + return 0; } diff --git a/avahi-core/browse-dns-server.c b/avahi-core/browse-dns-server.c index 48d23ad..49bb5e5 100644 --- a/avahi-core/browse-dns-server.c +++ b/avahi-core/browse-dns-server.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 @@ struct AvahiDNSServerInfo { AvahiSHostNameResolver *host_name_resolver; AvahiAddress address; AvahiLookupResultFlags flags; - + AVAHI_LLIST_FIELDS(AvahiDNSServerInfo, info); }; struct AvahiSDNSServerBrowser { AvahiServer *server; - + AvahiSRecordBrowser *record_browser; AvahiSDNSServerBrowserCallback callback; void* userdata; @@ -58,14 +58,14 @@ struct AvahiSDNSServerBrowser { AvahiLookupFlags user_flags; unsigned n_info; - + AVAHI_LLIST_FIELDS(AvahiSDNSServerBrowser, browser); AVAHI_LLIST_HEAD(AvahiDNSServerInfo, info); }; static AvahiDNSServerInfo* get_server_info(AvahiSDNSServerBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiRecord *r) { AvahiDNSServerInfo *i; - + assert(b); assert(r); @@ -85,12 +85,12 @@ static void server_info_free(AvahiSDNSServerBrowser *b, AvahiDNSServerInfo *i) { avahi_record_unref(i->srv_record); if (i->host_name_resolver) avahi_s_host_name_resolver_free(i->host_name_resolver); - + AVAHI_LLIST_REMOVE(AvahiDNSServerInfo, info, b->info, i); assert(b->n_info >= 1); b->n_info--; - + avahi_free(i); } @@ -103,9 +103,9 @@ static void host_name_resolver_callback( const AvahiAddress *a, AvahiLookupResultFlags flags, void* userdata) { - + AvahiDNSServerInfo *i = userdata; - + assert(r); assert(host_name); assert(i); @@ -113,7 +113,7 @@ static void host_name_resolver_callback( switch (event) { case AVAHI_RESOLVER_FOUND: { i->address = *a; - + i->browser->callback( i->browser, i->interface, @@ -145,7 +145,7 @@ static void record_browser_callback( AvahiRecord *record, AvahiLookupResultFlags flags, void* userdata) { - + AvahiSDNSServerBrowser *b = userdata; assert(rr); @@ -157,19 +157,19 @@ static void record_browser_callback( switch (event) { case AVAHI_BROWSER_NEW: { AvahiDNSServerInfo *i; - + assert(record); assert(record->key->type == AVAHI_DNS_TYPE_SRV); if (get_server_info(b, interface, protocol, record)) return; - + if (b->n_info >= 10) return; - + if (!(i = avahi_new(AvahiDNSServerInfo, 1))) return; /* OOM */ - + i->browser = b; i->interface = interface; i->protocol = protocol; @@ -182,22 +182,22 @@ static void record_browser_callback( b->user_flags, host_name_resolver_callback, i); i->flags = flags; - + AVAHI_LLIST_PREPEND(AvahiDNSServerInfo, info, b->info, i); - + b->n_info++; break; } case AVAHI_BROWSER_REMOVE: { AvahiDNSServerInfo *i; - + assert(record); assert(record->key->type == AVAHI_DNS_TYPE_SRV); if (!(i = get_server_info(b, interface, protocol, record))) return; - + if (!i->host_name_resolver) b->callback( b, @@ -209,7 +209,7 @@ static void record_browser_callback( i->srv_record->data.srv.port, i->flags | flags, b->userdata); - + server_info_free(b, i); break; } @@ -228,7 +228,7 @@ static void record_browser_callback( 0, flags, b->userdata); - + break; } } @@ -248,12 +248,12 @@ AvahiSDNSServerBrowser *avahi_s_dns_server_browser_new( "_domain._udp", "_dns-update._udp" }; - + AvahiSDNSServerBrowser *b; AvahiKey *k = NULL; char n[AVAHI_DOMAIN_NAME_MAX]; int r; - + assert(server); assert(callback); @@ -271,12 +271,12 @@ AvahiSDNSServerBrowser *avahi_s_dns_server_browser_new( avahi_server_set_errno(server, r); return NULL; } - + if (!(b = avahi_new(AvahiSDNSServerBrowser, 1))) { avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY); return NULL; } - + b->server = server; b->callback = callback; b->userdata = userdata; @@ -286,15 +286,15 @@ AvahiSDNSServerBrowser *avahi_s_dns_server_browser_new( AVAHI_LLIST_HEAD_INIT(AvahiDNSServerInfo, b->info); AVAHI_LLIST_PREPEND(AvahiSDNSServerBrowser, browser, server->dns_server_browsers, b); - + if (!(k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV))) { avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(b->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b))) goto fail; - + avahi_key_unref(k); return b; @@ -303,7 +303,7 @@ fail: if (k) avahi_key_unref(k); - + avahi_s_dns_server_browser_free(b); return NULL; } @@ -313,7 +313,7 @@ void avahi_s_dns_server_browser_free(AvahiSDNSServerBrowser *b) { while (b->info) server_info_free(b, b->info); - + AVAHI_LLIST_REMOVE(AvahiSDNSServerBrowser, browser, b->server->dns_server_browsers, b); if (b->record_browser) diff --git a/avahi-core/browse-domain.c b/avahi-core/browse-domain.c index 0043806..465f85f 100644 --- a/avahi-core/browse-domain.c +++ b/avahi-core/browse-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 @@ -34,9 +34,9 @@ struct AvahiSDomainBrowser { int ref; - + AvahiServer *server; - + AvahiSRecordBrowser *record_browser; AvahiDomainBrowserType type; @@ -46,7 +46,7 @@ struct AvahiSDomainBrowser { AvahiTimeEvent *defer_event; int all_for_now_scheduled; - + AVAHI_LLIST_FIELDS(AvahiSDomainBrowser, browser); }; @@ -65,7 +65,7 @@ static void record_browser_callback( AvahiRecord *record, AvahiLookupResultFlags flags, void* userdata) { - + AvahiSDomainBrowser *b = userdata; char *n = NULL; @@ -78,7 +78,7 @@ static void record_browser_callback( b->all_for_now_scheduled = 1; return; } - + /* Filter flags */ flags &= AVAHI_LOOKUP_RESULT_CACHED | AVAHI_LOOKUP_RESULT_MULTICAST | AVAHI_LOOKUP_RESULT_WIDE_AREA; @@ -90,21 +90,21 @@ static void record_browser_callback( AvahiStringList *l; /* Filter out entries defined statically */ - + for (l = b->server->config.browse_domains; l; l = l->next) if (avahi_domain_equal((char*) l->text, n)) return; } - + } - + b->callback(b, interface, protocol, event, n, flags, b->userdata); } static void defer_callback(AvahiTimeEvent *e, void *userdata) { AvahiSDomainBrowser *b = userdata; AvahiStringList *l; - + assert(e); assert(b); @@ -117,22 +117,22 @@ static void defer_callback(AvahiTimeEvent *e, void *userdata) { inc_ref(b); for (l = b->server->config.browse_domains; l; l = l->next) { - + /* Check whether this object still exists outside our own * stack frame */ if (b->ref <= 1) break; - + b->callback(b, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_BROWSER_NEW, (char*) l->text, AVAHI_LOOKUP_RESULT_STATIC, b->userdata); } if (b->ref > 1) { /* If the ALL_FOR_NOW event has already been scheduled, execute it now */ - - if (b->all_for_now_scheduled) + + if (b->all_for_now_scheduled) b->callback(b, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_BROWSER_ALL_FOR_NOW, NULL, 0, b->userdata); } - + /* Decrease ref counter */ avahi_s_domain_browser_free(b); } @@ -154,12 +154,12 @@ AvahiSDomainBrowser *avahi_s_domain_browser_new( "dr", "lb" }; - + AvahiSDomainBrowser *b; AvahiKey *k = NULL; char n[AVAHI_DOMAIN_NAME_MAX]; int r; - + assert(server); assert(callback); @@ -176,7 +176,7 @@ AvahiSDomainBrowser *avahi_s_domain_browser_new( avahi_server_set_errno(server, r); return NULL; } - + if (!(b = avahi_new(AvahiSDomainBrowser, 1))) { avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY); return NULL; @@ -197,24 +197,24 @@ AvahiSDomainBrowser *avahi_s_domain_browser_new( avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(b->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b))) goto fail; - + avahi_key_unref(k); if (type == AVAHI_DOMAIN_BROWSER_BROWSE && b->server->config.browse_domains) b->defer_event = avahi_time_event_new(server->time_event_queue, NULL, defer_callback, b); - + return b; - + fail: - + if (k) avahi_key_unref(k); - + avahi_s_domain_browser_free(b); - + return NULL; } @@ -224,7 +224,7 @@ void avahi_s_domain_browser_free(AvahiSDomainBrowser *b) { assert(b->ref >= 1); if (--b->ref > 0) return; - + AVAHI_LLIST_REMOVE(AvahiSDomainBrowser, browser, b->server->domain_browsers, b); if (b->record_browser) @@ -232,6 +232,6 @@ void avahi_s_domain_browser_free(AvahiSDomainBrowser *b) { if (b->defer_event) avahi_time_event_free(b->defer_event); - + avahi_free(b); } diff --git a/avahi-core/browse-service-type.c b/avahi-core/browse-service-type.c index 252e3cb..408d0b7 100644 --- a/avahi-core/browse-service-type.c +++ b/avahi-core/browse-service-type.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 @@ -52,7 +52,7 @@ static void record_browser_callback( AvahiRecord *record, AvahiLookupResultFlags flags, void* userdata) { - + AvahiSServiceTypeBrowser *b = userdata; assert(rr); @@ -63,7 +63,7 @@ static void record_browser_callback( if (record) { char type[AVAHI_DOMAIN_NAME_MAX], domain[AVAHI_DOMAIN_NAME_MAX]; - + assert(record->key->type == AVAHI_DNS_TYPE_PTR); if (avahi_service_name_split(record->data.ptr.name, NULL, 0, type, sizeof(type), domain, sizeof(domain)) < 0) { @@ -84,12 +84,12 @@ AvahiSServiceTypeBrowser *avahi_s_service_type_browser_new( AvahiLookupFlags flags, AvahiSServiceTypeBrowserCallback callback, void* userdata) { - + AvahiSServiceTypeBrowser *b; AvahiKey *k = NULL; char n[AVAHI_DOMAIN_NAME_MAX]; int r; - + assert(server); assert(callback); @@ -105,32 +105,32 @@ AvahiSServiceTypeBrowser *avahi_s_service_type_browser_new( avahi_server_set_errno(server, r); return NULL; } - + if (!(b = avahi_new(AvahiSServiceTypeBrowser, 1))) { avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY); return NULL; } - + b->server = server; b->callback = callback; b->userdata = userdata; b->record_browser = NULL; - + AVAHI_LLIST_PREPEND(AvahiSServiceTypeBrowser, browser, server->service_type_browsers, b); if (!(b->domain_name = avahi_normalize_name_strdup(domain))) { avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR))) { avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(b->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b))) goto fail; - + avahi_key_unref(k); return b; @@ -140,7 +140,7 @@ fail: avahi_key_unref(k); avahi_s_service_type_browser_free(b); - + return NULL; } diff --git a/avahi-core/browse-service.c b/avahi-core/browse-service.c index 43778dd..87d2690 100644 --- a/avahi-core/browse-service.c +++ b/avahi-core/browse-service.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,7 +36,7 @@ struct AvahiSServiceBrowser { AvahiServer *server; char *domain_name; char *service_type; - + AvahiSRecordBrowser *record_browser; AvahiSServiceBrowserCallback callback; @@ -53,7 +53,7 @@ static void record_browser_callback( AvahiRecord *record, AvahiLookupResultFlags flags, void* userdata) { - + AvahiSServiceBrowser *b = userdata; assert(rr); @@ -61,7 +61,7 @@ static void record_browser_callback( /* Filter flags */ flags &= AVAHI_LOOKUP_RESULT_CACHED | AVAHI_LOOKUP_RESULT_MULTICAST | AVAHI_LOOKUP_RESULT_WIDE_AREA; - + if (record) { char service[AVAHI_LABEL_MAX], type[AVAHI_DOMAIN_NAME_MAX], domain[AVAHI_DOMAIN_NAME_MAX]; @@ -76,7 +76,7 @@ static void record_browser_callback( } b->callback(b, interface, protocol, event, service, type, domain, flags, b->userdata); - + } else b->callback(b, interface, protocol, event, NULL, b->service_type, b->domain_name, flags, b->userdata); @@ -96,7 +96,7 @@ AvahiSServiceBrowser *avahi_s_service_browser_new( AvahiKey *k = NULL; char n[AVAHI_DOMAIN_NAME_MAX]; int r; - + assert(server); assert(callback); assert(service_type); @@ -114,18 +114,18 @@ AvahiSServiceBrowser *avahi_s_service_browser_new( avahi_server_set_errno(server, r); return NULL; } - + if (!(b = avahi_new(AvahiSServiceBrowser, 1))) { avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY); return NULL; } - + b->server = server; b->domain_name = b->service_type = NULL; b->callback = callback; b->userdata = userdata; b->record_browser = NULL; - + AVAHI_LLIST_PREPEND(AvahiSServiceBrowser, browser, server->service_browsers, b); if (!(b->domain_name = avahi_normalize_name_strdup(domain)) || @@ -133,12 +133,12 @@ AvahiSServiceBrowser *avahi_s_service_browser_new( avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR))) { avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(b->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b))) goto fail; @@ -150,7 +150,7 @@ fail: if (k) avahi_key_unref(k); - + avahi_s_service_browser_free(b); return NULL; } @@ -162,7 +162,7 @@ void avahi_s_service_browser_free(AvahiSServiceBrowser *b) { if (b->record_browser) avahi_s_record_browser_free(b->record_browser); - + avahi_free(b->domain_name); avahi_free(b->service_type); avahi_free(b); diff --git a/avahi-core/browse.c b/avahi-core/browse.c index 16d8954..f56203f 100644 --- a/avahi-core/browse.c +++ b/avahi-core/browse.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,20 +42,20 @@ struct AvahiSRBLookup { AvahiSRecordBrowser *record_browser; - + unsigned ref; AvahiIfIndex interface; AvahiProtocol protocol; AvahiLookupFlags flags; - + AvahiKey *key; AvahiWideAreaLookup *wide_area; AvahiMulticastLookup *multicast; AvahiRList *cname_lookups; - + AVAHI_LLIST_FIELDS(AvahiSRBLookup, lookups); }; @@ -89,7 +89,7 @@ static AvahiSRBLookup* lookup_new( AvahiKey *key) { AvahiSRBLookup *l; - + assert(b); assert(AVAHI_IF_VALID(interface)); assert(AVAHI_PROTO_VALID(protocol)); @@ -97,10 +97,10 @@ static AvahiSRBLookup* lookup_new( if (b->n_lookups >= AVAHI_LOOKUPS_PER_BROWSER_MAX) /* We don't like cyclic CNAMEs */ return NULL; - + if (!(l = avahi_new(AvahiSRBLookup, 1))) return NULL; - + l->ref = 1; l->record_browser = b; l->interface = interface; @@ -112,11 +112,11 @@ static AvahiSRBLookup* lookup_new( l->flags = flags; transport_flags_from_domain(b->server, &l->flags, key->name); - + AVAHI_LLIST_PREPEND(AvahiSRBLookup, lookups, b->lookups, l); b->n_lookups ++; - + return l; } @@ -134,7 +134,7 @@ static void lookup_unref(AvahiSRBLookup *l) { avahi_wide_area_lookup_free(l->wide_area); l->wide_area = NULL; } - + if (l->multicast) { avahi_multicast_lookup_free(l->multicast); l->multicast = NULL; @@ -144,7 +144,7 @@ static void lookup_unref(AvahiSRBLookup *l) { lookup_unref(l->cname_lookups->data); l->cname_lookups = avahi_rlist_remove_by_link(l->cname_lookups, l->cname_lookups); } - + avahi_key_unref(l->key); avahi_free(l); } @@ -163,9 +163,9 @@ static AvahiSRBLookup *lookup_find( AvahiProtocol protocol, AvahiLookupFlags flags, AvahiKey *key) { - + AvahiSRBLookup *l; - + assert(b); for (l = b->lookups; l; l = l->lookups_next) { @@ -201,7 +201,7 @@ static void lookup_wide_area_callback( AvahiLookupResultFlags flags, AvahiRecord *r, void *userdata) { - + AvahiSRBLookup *l = userdata; AvahiSRecordBrowser *b; @@ -215,11 +215,11 @@ static void lookup_wide_area_callback( return; lookup_ref(l); - + switch (event) { case AVAHI_BROWSER_NEW: assert(r); - + if (r->key->clazz == AVAHI_DNS_CLASS_IN && r->key->type == AVAHI_DNS_TYPE_CNAME) /* It's a CNAME record, so let's follow it. We only follow it on wide area DNS! */ @@ -259,7 +259,7 @@ static void lookup_multicast_callback( AvahiSRBLookup *l = userdata; AvahiSRecordBrowser *b; - + assert(e); assert(l); @@ -269,11 +269,11 @@ static void lookup_multicast_callback( return; lookup_ref(l); - + switch (event) { case AVAHI_BROWSER_NEW: assert(r); - + if (r->key->clazz == AVAHI_DNS_CLASS_IN && r->key->type == AVAHI_DNS_TYPE_CNAME) /* It's a CNAME record, so let's follow it. We allow browsing on both multicast and wide area. */ @@ -283,7 +283,7 @@ static void lookup_multicast_callback( if (avahi_server_is_record_local(b->server, interface, protocol, r)) flags |= AVAHI_LOOKUP_RESULT_LOCAL; - + b->callback(b, interface, protocol, event, r, flags, b->userdata); } break; @@ -323,12 +323,12 @@ static int lookup_start(AvahiSRBLookup *l) { assert(!(l->flags & AVAHI_LOOKUP_USE_WIDE_AREA) != !(l->flags & AVAHI_LOOKUP_USE_MULTICAST)); assert(!l->wide_area && !l->multicast); - + if (l->flags & AVAHI_LOOKUP_USE_WIDE_AREA) { if (!(l->wide_area = avahi_wide_area_lookup_new(l->record_browser->server->wide_area_lookup_engine, l->key, lookup_wide_area_callback, l))) return -1; - + } else { assert(l->flags & AVAHI_LOOKUP_USE_MULTICAST); @@ -341,15 +341,15 @@ static int lookup_start(AvahiSRBLookup *l) { static int lookup_scan_cache(AvahiSRBLookup *l) { int n = 0; - + assert(l); assert(!(l->flags & AVAHI_LOOKUP_USE_WIDE_AREA) != !(l->flags & AVAHI_LOOKUP_USE_MULTICAST)); - + if (l->flags & AVAHI_LOOKUP_USE_WIDE_AREA) { n = (int) avahi_wide_area_scan_cache(l->record_browser->server->wide_area_lookup_engine, l->key, lookup_wide_area_callback, l); - + } else { assert(l->flags & AVAHI_LOOKUP_USE_MULTICAST); n = (int) avahi_multicast_lookup_engine_scan_cache(l->record_browser->server->multicast_lookup_engine, l->interface, l->protocol, l->key, lookup_multicast_callback, l); @@ -360,7 +360,7 @@ static int lookup_scan_cache(AvahiSRBLookup *l) { static AvahiSRBLookup* lookup_add(AvahiSRecordBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiLookupFlags flags, AvahiKey *key) { AvahiSRBLookup *l; - + assert(b); assert(!b->dead); @@ -379,9 +379,9 @@ static int lookup_go(AvahiSRBLookup *l) { if (l->record_browser->dead) return 0; - + lookup_ref(l); - + /* Browse the cache for the root request */ n = lookup_scan_cache(l); @@ -390,7 +390,7 @@ static int lookup_go(AvahiSRBLookup *l) { if ((l->flags & AVAHI_LOOKUP_USE_MULTICAST) || n == 0) /* We do no start a query if the cache contained entries and we're on wide area */ - + if (lookup_start(l) < 0) n = -1; } @@ -403,7 +403,7 @@ static int lookup_go(AvahiSRBLookup *l) { static void lookup_handle_cname(AvahiSRBLookup *l, AvahiIfIndex interface, AvahiProtocol protocol, AvahiLookupFlags flags, AvahiRecord *r) { AvahiKey *k; AvahiSRBLookup *n; - + assert(l); assert(r); @@ -411,7 +411,7 @@ static void lookup_handle_cname(AvahiSRBLookup *l, AvahiIfIndex interface, Avahi assert(r->key->type == AVAHI_DNS_TYPE_CNAME); k = avahi_key_new(r->data.ptr.name, l->record_browser->key->clazz, l->record_browser->key->type); - n = lookup_add(l->record_browser, interface, protocol, flags, k); + n = lookup_add(l->record_browser, interface, protocol, flags, k); avahi_key_unref(k); if (!n) { @@ -446,7 +446,7 @@ static void lookup_drop_cname(AvahiSRBLookup *l, AvahiIfIndex interface, AvahiPr avahi_key_equal(n->key, k)) break; } - + avahi_key_unref(k); if (rl) { @@ -487,11 +487,11 @@ static void defer_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void *userdata) { b, b->interface, b->protocol, AVAHI_BROWSER_FAILURE, NULL, b->flags & AVAHI_LOOKUP_USE_WIDE_AREA ? AVAHI_LOOKUP_RESULT_WIDE_AREA : AVAHI_LOOKUP_RESULT_MULTICAST, b->userdata); - + browser_cancel(b); return; } - + /* Tell the client that we're done with the cache */ b->callback( b, b->interface, b->protocol, AVAHI_BROWSER_CACHE_EXHAUSTED, NULL, @@ -503,7 +503,7 @@ static void defer_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void *userdata) { /* If we do wide area lookups and the the cache contained * entries, we assume that it is complete, and tell the user * so by firing ALL_FOR_NOW. */ - + b->callback(b, b->interface, b->protocol, AVAHI_BROWSER_ALL_FOR_NOW, NULL, AVAHI_LOOKUP_RESULT_WIDE_AREA, b->userdata); } } @@ -529,7 +529,7 @@ AvahiSRecordBrowser *avahi_s_record_browser_new( AvahiLookupFlags flags, AvahiSRecordBrowserCallback callback, void* userdata) { - + AvahiSRecordBrowser *b; assert(server); @@ -541,13 +541,13 @@ AvahiSRecordBrowser *avahi_s_record_browser_new( AVAHI_CHECK_VALIDITY_RETURN_NULL(server, !avahi_key_is_pattern(key), AVAHI_ERR_IS_PATTERN); AVAHI_CHECK_VALIDITY_RETURN_NULL(server, avahi_key_is_valid(key), AVAHI_ERR_INVALID_KEY); AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS); - AVAHI_CHECK_VALIDITY_RETURN_NULL(server, !(flags & AVAHI_LOOKUP_USE_WIDE_AREA) || !(flags & AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS); - + AVAHI_CHECK_VALIDITY_RETURN_NULL(server, !(flags & AVAHI_LOOKUP_USE_WIDE_AREA) || !(flags & AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS); + if (!(b = avahi_new(AvahiSRecordBrowser, 1))) { avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY); return NULL; } - + b->dead = 0; b->server = server; b->interface = interface; @@ -559,13 +559,13 @@ AvahiSRecordBrowser *avahi_s_record_browser_new( b->n_lookups = 0; AVAHI_LLIST_HEAD_INIT(AvahiSRBLookup, b->lookups); b->root_lookup = NULL; - + AVAHI_LLIST_PREPEND(AvahiSRecordBrowser, browser, server->record_browsers, b); /* The currently cached entries are scanned a bit later, and than we will start querying, too */ b->defer_time_event = avahi_time_event_new(server->time_event_queue, NULL, defer_callback, b); assert(b->defer_time_event); - + return b; } @@ -583,30 +583,30 @@ void avahi_s_record_browser_destroy(AvahiSRecordBrowser *b) { assert(b); browser_cancel(b); - + AVAHI_LLIST_REMOVE(AvahiSRecordBrowser, browser, b->server->record_browsers, b); avahi_key_unref(b->key); - + avahi_free(b); } void avahi_browser_cleanup(AvahiServer *server) { AvahiSRecordBrowser *b; AvahiSRecordBrowser *n; - + assert(server); while (server->need_browser_cleanup) { server->need_browser_cleanup = 0; - + for (b = server->record_browsers; b; b = n) { n = b->browser_next; - + if (b->dead) avahi_s_record_browser_destroy(b); } - } + } if (server->wide_area_lookup_engine) avahi_wide_area_cleanup(server->wide_area_lookup_engine); diff --git a/avahi-core/browse.h b/avahi-core/browse.h index 36d4e2e..771e593 100644 --- a/avahi-core/browse.h +++ b/avahi-core/browse.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 @@ -41,7 +41,7 @@ struct AvahiSRecordBrowser { AvahiIfIndex interface; AvahiProtocol protocol; AvahiLookupFlags flags; - + AvahiTimeEvent *defer_time_event; AvahiSRecordBrowserCallback callback; diff --git a/avahi-core/cache.c b/avahi-core/cache.c index 2786f74..3042ff6 100644 --- a/avahi-core/cache.c +++ b/avahi-core/cache.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 @@ -54,14 +54,14 @@ static void remove_entry(AvahiCache *c, AvahiCacheEntry *e) { /* Remove from linked list */ AVAHI_LLIST_REMOVE(AvahiCacheEntry, entry, c->entries, e); - + if (e->time_event) avahi_time_event_free(e->time_event); avahi_multicast_lookup_engine_notify(c->server->multicast_lookup_engine, c->interface, e->record, AVAHI_BROWSER_REMOVE); - + avahi_record_unref(e->record); - + avahi_free(e); assert(c->n_entries >= 1); @@ -76,7 +76,7 @@ AvahiCache *avahi_cache_new(AvahiServer *server, AvahiInterface *iface) { avahi_log_error(__FILE__": Out of memory."); return NULL; /* OOM */ } - + c->server = server; c->interface = iface; @@ -90,7 +90,7 @@ AvahiCache *avahi_cache_new(AvahiServer *server, AvahiInterface *iface) { c->n_entries = 0; c->last_rand_timestamp = 0; - + return c; } @@ -100,9 +100,9 @@ void avahi_cache_free(AvahiCache *c) { while (c->entries) remove_entry(c, c->entries); assert(c->n_entries == 0); - + avahi_hashmap_free(c->hashmap); - + avahi_free(c); } @@ -111,34 +111,34 @@ static AvahiCacheEntry *lookup_key(AvahiCache *c, AvahiKey *k) { assert(k); assert(!avahi_key_is_pattern(k)); - + return avahi_hashmap_lookup(c->hashmap, k); } void* avahi_cache_walk(AvahiCache *c, AvahiKey *pattern, AvahiCacheWalkCallback cb, void* userdata) { void* ret; - + assert(c); assert(pattern); assert(cb); - + if (avahi_key_is_pattern(pattern)) { AvahiCacheEntry *e, *n; - + for (e = c->entries; e; e = n) { n = e->entry_next; - + if (avahi_key_pattern_match(pattern, e->record->key)) if ((ret = cb(c, pattern, e, userdata))) return ret; } - + } else { AvahiCacheEntry *e, *n; for (e = lookup_key(c, pattern); e; e = n) { n = e->by_key_next; - + if ((ret = cb(c, pattern, e, userdata))) return ret; } @@ -171,7 +171,7 @@ static void elapse_func(AvahiTimeEvent *t, void *userdata) { AvahiCacheEntry *e = userdata; /* char *txt; */ unsigned percent = 0; - + assert(t); assert(e); @@ -185,17 +185,17 @@ static void elapse_func(AvahiTimeEvent *t, void *userdata) { case AVAHI_CACHE_REPLACE_FINAL: remove_entry(e->cache, e); - + e = NULL; /* avahi_log_debug("Removing entry from cache due to expiration (%s)", txt); */ break; - + case AVAHI_CACHE_VALID: case AVAHI_CACHE_POOF: e->state = AVAHI_CACHE_EXPIRY1; percent = 85; break; - + case AVAHI_CACHE_EXPIRY1: e->state = AVAHI_CACHE_EXPIRY2; percent = 90; @@ -204,7 +204,7 @@ static void elapse_func(AvahiTimeEvent *t, void *userdata) { e->state = AVAHI_CACHE_EXPIRY3; percent = 95; break; - + case AVAHI_CACHE_EXPIRY3: e->state = AVAHI_CACHE_EXPIRY_FINAL; percent = 100; @@ -218,10 +218,10 @@ static void elapse_func(AvahiTimeEvent *t, void *userdata) { /* Request a cache update if we are subscribed to this entry */ if (avahi_querier_shall_refresh_cache(e->cache->interface, e->record->key)) avahi_interface_post_query(e->cache->interface, e->record->key, 0, NULL); - + /* Check again later */ next_expiry(e->cache, e, percent); - + } /* avahi_free(txt); */ @@ -230,7 +230,7 @@ static void elapse_func(AvahiTimeEvent *t, void *userdata) { static void update_time_event(AvahiCache *c, AvahiCacheEntry *e) { assert(c); assert(e); - + if (e->time_event) avahi_time_event_update(e->time_event, &e->expiry); else @@ -240,11 +240,11 @@ static void update_time_event(AvahiCache *c, AvahiCacheEntry *e) { static void next_expiry(AvahiCache *c, AvahiCacheEntry *e, unsigned percent) { AvahiUsec usec, left, right; time_t now; - + assert(c); assert(e); assert(percent > 0 && percent <= 100); - + usec = (AvahiUsec) e->record->ttl * 10000; left = usec * percent; @@ -258,19 +258,19 @@ static void next_expiry(AvahiCache *c, AvahiCacheEntry *e, unsigned percent) { } usec = left + (AvahiUsec) ((double) (right-left) * c->last_rand / (RAND_MAX+1.0)); - + e->expiry = e->timestamp; avahi_timeval_add(&e->expiry, usec); - + /* g_message("wake up in +%lu seconds", e->expiry.tv_sec - e->timestamp.tv_sec); */ - + update_time_event(c, e); } static void expire_in_one_second(AvahiCache *c, AvahiCacheEntry *e, AvahiCacheEntryState state) { assert(c); assert(e); - + e->state = state; gettimeofday(&e->expiry, NULL); avahi_timeval_add(&e->expiry, 1000000); /* 1s */ @@ -279,7 +279,7 @@ static void expire_in_one_second(AvahiCache *c, AvahiCacheEntry *e, AvahiCacheEn void avahi_cache_update(AvahiCache *c, AvahiRecord *r, int cache_flush, const AvahiAddress *a) { /* char *txt; */ - + assert(c); assert(r && r->ref >= 1); @@ -302,7 +302,7 @@ void avahi_cache_update(AvahiCache *c, AvahiRecord *r, int cache_flush, const Av /* This is an update request */ if ((first = lookup_key(c, r->key))) { - + if (cache_flush) { /* For unique entries drop all entries older than one second */ @@ -315,31 +315,31 @@ void avahi_cache_update(AvahiCache *c, AvahiRecord *r, int cache_flush, const Av expire_in_one_second(c, e, AVAHI_CACHE_REPLACE_FINAL); } } - + /* Look for exactly the same entry */ for (e = first; e; e = e->by_key_next) if (avahi_record_equal_no_ttl(e->record, r)) break; } - + if (e) { - + /* avahi_log_debug("found matching cache entry"); */ /* We need to update the hash table key if we replace the * record */ if (e->by_key_prev == NULL) avahi_hashmap_replace(c->hashmap, r->key, e); - + /* Update the record */ avahi_record_unref(e->record); e->record = avahi_record_ref(r); /* avahi_log_debug("cache: updating %s", txt); */ - + } else { /* No entry found, therefore we create a new one */ - + /* avahi_log_debug("cache: couldn't find matching cache entry for %s", txt); */ if (c->n_entries >= AVAHI_CACHE_ENTRIES_MAX) @@ -365,8 +365,8 @@ void avahi_cache_update(AvahiCache *c, AvahiRecord *r, int cache_flush, const Av /* Notify subscribers */ avahi_multicast_lookup_engine_notify(c->server->multicast_lookup_engine, c->interface, e->record, AVAHI_BROWSER_NEW); - } - + } + e->origin = *a; e->timestamp = now; next_expiry(c, e, 80); @@ -396,7 +396,7 @@ static void dump_callback(void* key, void* data, void* userdata) { if (!(t = avahi_record_to_string(e->record))) continue; /* OOM */ - + dump_data->callback(t, dump_data->userdata); avahi_free(t); } @@ -421,7 +421,7 @@ int avahi_cache_dump(AvahiCache *c, AvahiDumpCallback callback, void* userdata) int avahi_cache_entry_half_ttl(AvahiCache *c, AvahiCacheEntry *e) { struct timeval now; unsigned age; - + assert(c); assert(e); @@ -430,7 +430,7 @@ int avahi_cache_entry_half_ttl(AvahiCache *c, AvahiCacheEntry *e) { age = (unsigned) (avahi_timeval_diff(&now, &e->timestamp)/1000000); /* avahi_log_debug("age: %lli, ttl/2: %u", age, e->record->ttl); */ - + return age >= e->record->ttl/2; } @@ -484,7 +484,7 @@ static void* start_poof_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEnt default: ; } - + return NULL; } diff --git a/avahi-core/cache.h b/avahi-core/cache.h index fd74005..7477a5b 100644 --- a/avahi-core/cache.h +++ b/avahi-core/cache.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 @@ -52,7 +52,7 @@ struct AvahiCacheEntry { struct timeval expiry; int cache_flush; int poof_num; - + AvahiAddress origin; AvahiCacheEntryState state; @@ -66,9 +66,9 @@ struct AvahiCacheEntry { struct AvahiCache { AvahiServer *server; - + AvahiInterface *interface; - + AvahiHashmap *hashmap; AVAHI_LLIST_HEAD(AvahiCacheEntry, entries); @@ -95,7 +95,7 @@ int avahi_cache_entry_half_ttl(AvahiCache *c, AvahiCacheEntry *e); * records of the specified key. The specified address is */ void avahi_cache_start_poof(AvahiCache *c, AvahiKey *key, const AvahiAddress *a); -/* Stop a previously started POOF algorithm for a record. (Used for response suppresions records */ +/* Stop a previously started POOF algorithm for a record. (Used for response suppresions records */ void avahi_cache_stop_poof(AvahiCache *c, AvahiRecord *record, const AvahiAddress *a); void avahi_cache_flush(AvahiCache *c); diff --git a/avahi-core/conformance-test.c b/avahi-core/conformance-test.c index dc3c864..30e299d 100644 --- a/avahi-core/conformance-test.c +++ b/avahi-core/conformance-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 @@ -55,7 +55,7 @@ static void dump_line(const char *text, AVAHI_GCC_UNUSED void* userdata) { static void dump_timeout_callback(AvahiTimeout *timeout, AVAHI_GCC_UNUSED void* userdata) { struct timeval tv; - + avahi_server_dump(avahi, dump_line, NULL); avahi_elapse_time(&tv, 5000, 0); @@ -77,8 +77,8 @@ static void create_service(const char *t) { avahi_s_entry_group_reset(group); else group = avahi_s_entry_group_new(avahi, entry_group_callback, NULL); - - avahi_server_add_service(avahi, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, name, "_http._tcp", NULL, NULL, 80, "foo", NULL); + + avahi_server_add_service(avahi, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, name, "_http._tcp", NULL, NULL, 80, "foo", NULL); avahi_s_entry_group_commit(group); try++; @@ -86,8 +86,8 @@ static void create_service(const char *t) { static void rename_timeout_callback(AvahiTimeout *timeout, AVAHI_GCC_UNUSED void *userdata) { struct timeval tv; - - if (access("flag", F_OK) == 0) { + + if (access("flag", F_OK) == 0) { create_service("New - Bonjour Service Name"); return; } @@ -112,7 +112,7 @@ static void server_callback(AvahiServer *s, AvahiServerState state, AVAHI_GCC_UN avahi_server_dump(avahi, dump_line, NULL); } else if (state == AVAHI_SERVER_COLLISION) { char *n; - + n = avahi_alternative_host_name(avahi_server_get_host_name(s)); avahi_log_warn("Host name conflict, retrying with <%s>", n); avahi_server_set_host_name(s, n); @@ -147,14 +147,14 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { /* Evil, but the conformace test requires that*/ create_service("gurke"); - + avahi_simple_poll_loop(simple_poll); - + if (group) - avahi_s_entry_group_free(group); + avahi_s_entry_group_free(group); avahi_server_free(avahi); avahi_simple_poll_free(simple_poll); - + return 0; } diff --git a/avahi-core/core.h b/avahi-core/core.h index 94d1970..f3aea9d 100644 --- a/avahi-core/core.h +++ b/avahi-core/core.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-core/dns-spin-test.c b/avahi-core/dns-spin-test.c index d93e508..8621f9f 100644 --- a/avahi-core/dns-spin-test.c +++ b/avahi-core/dns-spin-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 diff --git a/avahi-core/dns-srv-rr.h b/avahi-core/dns-srv-rr.h index 1a7f95f..b936195 100644 --- a/avahi-core/dns-srv-rr.h +++ b/avahi-core/dns-srv-rr.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 @@ -76,7 +76,7 @@ AvahiSDNSServerBrowser *avahi_s_dns_server_browser_new( AvahiProtocol protocol, const char *domain, AvahiDNSServerType type, - AvahiProtocol aprotocol, /**< Address protocol for the DNS server */ + AvahiProtocol aprotocol, /**< Address protocol for the DNS server */ AvahiLookupFlags flags, /**< Lookup flags. */ AvahiSDNSServerBrowserCallback callback, void* userdata); diff --git a/avahi-core/dns-test.c b/avahi-core/dns-test.c index ae2343d..4c47c3e 100644 --- a/avahi-core/dns-test.c +++ b/avahi-core/dns-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 @@ -57,7 +57,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { assert(avahi_dns_packet_consume_name(p, t, sizeof(t)) == 0); avahi_log_debug(">%s<", t); assert(avahi_domain_equal(a, t)); - + assert(avahi_dns_packet_consume_name(p, t, sizeof(t)) == 0); avahi_log_debug(">%s<", t); assert(avahi_domain_equal(b, t)); @@ -69,11 +69,11 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { assert(avahi_dns_packet_consume_name(p, t, sizeof(t)) == 0); avahi_log_debug(">%s<", t); assert(avahi_domain_equal(d, t)); - + avahi_dns_packet_free(p); /* RDATA PARSING AND SERIALIZATION */ - + /* Create an AvahiRecord with some usful data */ r = avahi_record_new_full("foobar.local", AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_HINFO, AVAHI_DEFAULT_TTL); assert(r); @@ -110,6 +110,6 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { avahi_free(m); avahi_record_unref(r); - + return 0; } diff --git a/avahi-core/dns.c b/avahi-core/dns.c index 41ccc8f..0228fcb 100644 --- a/avahi-core/dns.c +++ b/avahi-core/dns.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 @@ -51,10 +51,10 @@ AvahiDnsPacket* avahi_dns_packet_new(unsigned mtu) { if (max_size < AVAHI_DNS_PACKET_HEADER_SIZE) max_size = AVAHI_DNS_PACKET_HEADER_SIZE; - + if (!(p = avahi_malloc(sizeof(AvahiDnsPacket) + max_size))) return p; - + p->size = p->rindex = AVAHI_DNS_PACKET_HEADER_SIZE; p->max_size = max_size; p->name_table = NULL; @@ -69,7 +69,7 @@ AvahiDnsPacket* avahi_dns_packet_new_query(unsigned mtu) { if (!(p = avahi_dns_packet_new(mtu))) return NULL; - + avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_FLAGS, AVAHI_DNS_FLAGS(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)); return p; } @@ -79,7 +79,7 @@ AvahiDnsPacket* avahi_dns_packet_new_response(unsigned mtu, int aa) { if (!(p = avahi_dns_packet_new(mtu))) return NULL; - + avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_FLAGS, AVAHI_DNS_FLAGS(1, 0, aa, 0, 0, 0, 0, 0, 0, 0)); return p; } @@ -97,7 +97,7 @@ AvahiDnsPacket* avahi_dns_packet_new_reply(AvahiDnsPacket* p, unsigned mtu, int saved_rindex = p->rindex; p->rindex = AVAHI_DNS_PACKET_HEADER_SIZE; - + for (n = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_QDCOUNT); n > 0; n--) { AvahiKey *k; int unicast_response; @@ -120,7 +120,7 @@ AvahiDnsPacket* avahi_dns_packet_new_reply(AvahiDnsPacket* p, unsigned mtu, int (avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS) & AVAHI_DNS_FLAG_OPCODE)); return r; -} +} void avahi_dns_packet_free(AvahiDnsPacket *p) { @@ -128,14 +128,14 @@ void avahi_dns_packet_free(AvahiDnsPacket *p) { if (p->name_table) avahi_hashmap_free(p->name_table); - + avahi_free(p); } void avahi_dns_packet_set_field(AvahiDnsPacket *p, unsigned idx, uint16_t v) { assert(p); assert(idx < AVAHI_DNS_PACKET_HEADER_SIZE); - + ((uint16_t*) AVAHI_DNS_PACKET_DATA(p))[idx] = htons(v); } @@ -151,12 +151,12 @@ void avahi_dns_packet_inc_field(AvahiDnsPacket *p, unsigned idx) { assert(idx < AVAHI_DNS_PACKET_HEADER_SIZE); avahi_dns_packet_set_field(p, idx, avahi_dns_packet_get_field(p, idx) + 1); -} +} static void name_table_cleanup(void *key, void *value, void *user_data) { AvahiDnsPacket *p = user_data; - + if ((uint8_t*) value >= AVAHI_DNS_PACKET_DATA(p) + p->size) avahi_hashmap_remove(p->name_table, key); } @@ -169,23 +169,23 @@ void avahi_dns_packet_cleanup_name_table(AvahiDnsPacket *p) { uint8_t* avahi_dns_packet_append_name(AvahiDnsPacket *p, const char *name) { uint8_t *d, *saved_ptr = NULL; size_t saved_size; - + assert(p); assert(name); saved_size = p->size; saved_ptr = avahi_dns_packet_extend(p, 0); - + while (*name) { uint8_t* prev; const char *pname; char label[64], *u; - + /* Check whether we can compress this name. */ if (p->name_table && (prev = avahi_hashmap_lookup(p->name_table, name))) { unsigned idx; - + assert(prev >= AVAHI_DNS_PACKET_DATA(p)); idx = (unsigned) (prev - AVAHI_DNS_PACKET_DATA(p)); @@ -203,7 +203,7 @@ uint8_t* avahi_dns_packet_append_name(AvahiDnsPacket *p, const char *name) { } pname = name; - + if (!(avahi_unescape_label(&name, label, sizeof(label)))) goto fail; @@ -222,7 +222,7 @@ uint8_t* avahi_dns_packet_append_name(AvahiDnsPacket *p, const char *name) { if (!(d = avahi_dns_packet_extend(p, 1))) goto fail; - + *d = 0; return saved_ptr; @@ -237,10 +237,10 @@ fail: uint8_t* avahi_dns_packet_append_uint16(AvahiDnsPacket *p, uint16_t v) { uint8_t *d; assert(p); - + if (!(d = avahi_dns_packet_extend(p, sizeof(uint16_t)))) return NULL; - + d[0] = (uint8_t) (v >> 8); d[1] = (uint8_t) v; return d; @@ -252,7 +252,7 @@ uint8_t *avahi_dns_packet_append_uint32(AvahiDnsPacket *p, uint32_t v) { if (!(d = avahi_dns_packet_extend(p, sizeof(uint32_t)))) return NULL; - + d[0] = (uint8_t) (v >> 24); d[1] = (uint8_t) (v >> 16); d[2] = (uint8_t) (v >> 8); @@ -278,13 +278,13 @@ uint8_t *avahi_dns_packet_append_bytes(AvahiDnsPacket *p, const void *b, size_t uint8_t* avahi_dns_packet_append_string(AvahiDnsPacket *p, const char *s) { uint8_t* d; size_t k; - + assert(p); assert(s); if ((k = strlen(s)) >= 255) k = 255; - + if (!(d = avahi_dns_packet_extend(p, k+1))) return NULL; @@ -296,15 +296,15 @@ uint8_t* avahi_dns_packet_append_string(AvahiDnsPacket *p, const char *s) { uint8_t *avahi_dns_packet_extend(AvahiDnsPacket *p, size_t l) { uint8_t *d; - + assert(p); if (p->size+l > p->max_size) return NULL; - + d = AVAHI_DNS_PACKET_DATA(p) + p->size; p->size += l; - + return d; } @@ -316,7 +316,7 @@ int avahi_dns_packet_check_valid(AvahiDnsPacket *p) { return -1; flags = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS); - + if (flags & AVAHI_DNS_FLAG_OPCODE) return -1; @@ -329,9 +329,9 @@ int avahi_dns_packet_check_valid_multicast(AvahiDnsPacket *p) { if (avahi_dns_packet_check_valid(p) < 0) return -1; - + flags = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS); - + if (flags & AVAHI_DNS_FLAG_RCODE) return -1; @@ -340,7 +340,7 @@ int avahi_dns_packet_check_valid_multicast(AvahiDnsPacket *p) { int avahi_dns_packet_is_query(AvahiDnsPacket *p) { assert(p); - + return !(avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS) & AVAHI_DNS_FLAG_QR); } @@ -351,7 +351,7 @@ static int consume_labels(AvahiDnsPacket *p, unsigned idx, char *ret_name, size_ unsigned label_ptr; int i; assert(p && ret_name && l); - + for (i = 0; i < AVAHI_DNS_LABELS_MAX; i++) { uint8_t n; @@ -368,15 +368,15 @@ static int consume_labels(AvahiDnsPacket *p, unsigned idx, char *ret_name, size_ if (l < 1) return -1; *ret_name = 0; - + return ret; - + } else if (n <= 63) { /* Uncompressed label */ idx++; if (!compressed) ret++; - + if (idx + n > p->size) return -1; @@ -393,7 +393,7 @@ static int consume_labels(AvahiDnsPacket *p, unsigned idx, char *ret_name, size_ return -1; idx += n; - + if (!compressed) ret += n; } else if ((n & 0xC0) == 0xC0) { @@ -411,7 +411,7 @@ static int consume_labels(AvahiDnsPacket *p, unsigned idx, char *ret_name, size_ if (!compressed) ret += 2; - + compressed = 1; } else return -1; @@ -422,7 +422,7 @@ static int consume_labels(AvahiDnsPacket *p, unsigned idx, char *ret_name, size_ int avahi_dns_packet_consume_name(AvahiDnsPacket *p, char *ret_name, size_t l) { int r; - + if ((r = consume_labels(p, p->rindex, ret_name, l)) < 0) return -1; @@ -458,7 +458,7 @@ int avahi_dns_packet_consume_uint32(AvahiDnsPacket *p, uint32_t *ret_v) { d = (uint8_t*) (AVAHI_DNS_PACKET_DATA(p) + p->rindex); *ret_v = (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | d[3]; p->rindex += sizeof(uint32_t); - + return 0; } @@ -466,7 +466,7 @@ int avahi_dns_packet_consume_bytes(AvahiDnsPacket *p, void * ret_data, size_t l) assert(p); assert(ret_data); assert(l > 0); - + if (p->rindex + l > p->size) return -1; @@ -478,7 +478,7 @@ int avahi_dns_packet_consume_bytes(AvahiDnsPacket *p, void * ret_data, size_t l) int avahi_dns_packet_consume_string(AvahiDnsPacket *p, char *ret_string, size_t l) { size_t k; - + assert(p); assert(ret_string); assert(l > 0); @@ -496,7 +496,7 @@ int avahi_dns_packet_consume_string(AvahiDnsPacket *p, char *ret_string, size_t memcpy(ret_string, AVAHI_DNS_PACKET_DATA(p)+p->rindex+1, l-1); ret_string[l-1] = 0; - + p->rindex += 1+k; return 0; @@ -504,7 +504,7 @@ int avahi_dns_packet_consume_string(AvahiDnsPacket *p, char *ret_string, size_t const void* avahi_dns_packet_get_rptr(AvahiDnsPacket *p) { assert(p); - + if (p->rindex > p->size) return NULL; @@ -524,32 +524,32 @@ int avahi_dns_packet_skip(AvahiDnsPacket *p, size_t length) { static int parse_rdata(AvahiDnsPacket *p, AvahiRecord *r, uint16_t rdlength) { char buf[AVAHI_DOMAIN_NAME_MAX]; const void* start; - + assert(p); assert(r); start = avahi_dns_packet_get_rptr(p); - + switch (r->key->type) { case AVAHI_DNS_TYPE_PTR: case AVAHI_DNS_TYPE_CNAME: case AVAHI_DNS_TYPE_NS: - + if (avahi_dns_packet_consume_name(p, buf, sizeof(buf)) < 0) return -1; r->data.ptr.name = avahi_strdup(buf); break; - + case AVAHI_DNS_TYPE_SRV: - + if (avahi_dns_packet_consume_uint16(p, &r->data.srv.priority) < 0 || avahi_dns_packet_consume_uint16(p, &r->data.srv.weight) < 0 || avahi_dns_packet_consume_uint16(p, &r->data.srv.port) < 0 || avahi_dns_packet_consume_name(p, buf, sizeof(buf)) < 0) return -1; - + r->data.srv.name = avahi_strdup(buf); break; @@ -557,12 +557,12 @@ static int parse_rdata(AvahiDnsPacket *p, AvahiRecord *r, uint16_t rdlength) { if (avahi_dns_packet_consume_string(p, buf, sizeof(buf)) < 0) return -1; - + r->data.hinfo.cpu = avahi_strdup(buf); - + if (avahi_dns_packet_consume_string(p, buf, sizeof(buf)) < 0) return -1; - + r->data.hinfo.os = avahi_strdup(buf); break; @@ -571,12 +571,12 @@ static int parse_rdata(AvahiDnsPacket *p, AvahiRecord *r, uint16_t rdlength) { if (rdlength > 0) { if (avahi_string_list_parse(avahi_dns_packet_get_rptr(p), rdlength, &r->data.txt.string_list) < 0) return -1; - + if (avahi_dns_packet_skip(p, rdlength) < 0) return -1; } else r->data.txt.string_list = NULL; - + break; case AVAHI_DNS_TYPE_A: @@ -585,27 +585,27 @@ static int parse_rdata(AvahiDnsPacket *p, AvahiRecord *r, uint16_t rdlength) { if (avahi_dns_packet_consume_bytes(p, &r->data.a.address, sizeof(AvahiIPv4Address)) < 0) return -1; - + break; case AVAHI_DNS_TYPE_AAAA: /* avahi_log_debug("aaaa"); */ - + if (avahi_dns_packet_consume_bytes(p, &r->data.aaaa.address, sizeof(AvahiIPv6Address)) < 0) return -1; - + break; - + default: /* avahi_log_debug("generic"); */ - + if (rdlength > 0) { r->data.generic.data = avahi_memdup(avahi_dns_packet_get_rptr(p), rdlength); - r->data.generic.size = rdlength; - + r->data.generic.size = rdlength; + if (avahi_dns_packet_skip(p, rdlength) < 0) return -1; } @@ -616,7 +616,7 @@ static int parse_rdata(AvahiDnsPacket *p, AvahiRecord *r, uint16_t rdlength) { /* Check if we read enough data */ if ((const uint8_t*) avahi_dns_packet_get_rptr(p) - (const uint8_t*) start != rdlength) return -1; - + return 0; } @@ -640,16 +640,16 @@ AvahiRecord* avahi_dns_packet_consume_record(AvahiDnsPacket *p, int *ret_cache_f if (ret_cache_flush) *ret_cache_flush = !!(class & AVAHI_DNS_CACHE_FLUSH); class &= ~AVAHI_DNS_CACHE_FLUSH; - + if (!(r = avahi_record_new_full(name, class, type, ttl))) goto fail; - + if (parse_rdata(p, r, rdlength) < 0) goto fail; if (!avahi_record_is_valid(r)) goto fail; - + return r; fail: @@ -675,7 +675,7 @@ AvahiKey* avahi_dns_packet_consume_key(AvahiDnsPacket *p, int *ret_unicast_respo *ret_unicast_response = !!(class & AVAHI_DNS_UNICAST_RESPONSE); class &= ~AVAHI_DNS_UNICAST_RESPONSE; - + if (!(k = avahi_key_new(name, class, type))) return NULL; @@ -690,12 +690,12 @@ AvahiKey* avahi_dns_packet_consume_key(AvahiDnsPacket *p, int *ret_unicast_respo uint8_t* avahi_dns_packet_append_key(AvahiDnsPacket *p, AvahiKey *k, int unicast_response) { uint8_t *t; size_t size; - + assert(p); assert(k); size = p->size; - + if (!(t = avahi_dns_packet_append_name(p, k->name)) || !avahi_dns_packet_append_uint16(p, k->type) || !avahi_dns_packet_append_uint16(p, k->clazz | (unicast_response ? AVAHI_DNS_UNICAST_RESPONSE : 0))) { @@ -711,16 +711,16 @@ uint8_t* avahi_dns_packet_append_key(AvahiDnsPacket *p, AvahiKey *k, int unicast static int append_rdata(AvahiDnsPacket *p, AvahiRecord *r) { assert(p); assert(r); - + switch (r->key->type) { - + case AVAHI_DNS_TYPE_PTR: case AVAHI_DNS_TYPE_CNAME: case AVAHI_DNS_TYPE_NS: - + if (!(avahi_dns_packet_append_name(p, r->data.ptr.name))) return -1; - + break; case AVAHI_DNS_TYPE_SRV: @@ -759,16 +759,16 @@ static int append_rdata(AvahiDnsPacket *p, AvahiRecord *r) { if (!avahi_dns_packet_append_bytes(p, &r->data.a.address, sizeof(r->data.a.address))) return -1; - + break; case AVAHI_DNS_TYPE_AAAA: - + if (!avahi_dns_packet_append_bytes(p, &r->data.aaaa.address, sizeof(r->data.aaaa.address))) return -1; - + break; - + default: if (r->data.generic.size) @@ -802,7 +802,7 @@ uint8_t* avahi_dns_packet_append_record(AvahiDnsPacket *p, AvahiRecord *r, int c if (append_rdata(p, r) < 0) goto fail; - + size = avahi_dns_packet_extend(p, 0) - start; assert(size <= AVAHI_DNS_RDATA_MAX); @@ -810,7 +810,7 @@ uint8_t* avahi_dns_packet_append_record(AvahiDnsPacket *p, AvahiRecord *r, int c l[0] = (uint8_t) ((uint16_t) size >> 8); l[1] = (uint8_t) ((uint16_t) size); - + return t; @@ -831,17 +831,17 @@ size_t avahi_dns_packet_space(AvahiDnsPacket *p) { assert(p); assert(p->size <= p->max_size); - + return p->max_size - p->size; } int avahi_rdata_parse(AvahiRecord *record, const void* rdata, size_t size) { int ret; AvahiDnsPacket p; - + assert(record); assert(rdata); - + p.data = (void*) rdata; p.max_size = p.size = size; p.rindex = 0; @@ -850,14 +850,14 @@ int avahi_rdata_parse(AvahiRecord *record, const void* rdata, size_t size) { ret = parse_rdata(&p, record, size); assert(!p.name_table); - + return ret; } size_t avahi_rdata_serialize(AvahiRecord *record, void *rdata, size_t max_size) { int ret; AvahiDnsPacket p; - + assert(record); assert(rdata); assert(max_size > 0); @@ -874,6 +874,6 @@ size_t avahi_rdata_serialize(AvahiRecord *record, void *rdata, size_t max_size) if (ret < 0) return (size_t) -1; - + return p.size; } diff --git a/avahi-core/dns.h b/avahi-core/dns.h index 7ec9935..39fb291 100644 --- a/avahi-core/dns.h +++ b/avahi-core/dns.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-core/domain-util.c b/avahi-core/domain-util.c index 777a064..36d68bb 100644 --- a/avahi-core/domain-util.c +++ b/avahi-core/domain-util.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,8 +41,8 @@ static void strip_bad_chars(char *s) { char *p, *d; s[strcspn(s, ".")] = 0; - - for (p = s, d = s; *p; p++) + + for (p = s, d = s; *p; p++) if ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z') || (*p >= '0' && *p <= '9') || @@ -55,7 +55,7 @@ static void strip_bad_chars(char *s) { #ifdef __linux__ static int load_lsb_distrib_id(char *ret_s, size_t size) { FILE *f; - + assert(ret_s); assert(size > 0); @@ -100,7 +100,7 @@ char *avahi_get_host_name(char *ret_s, size_t size) { *ret_s = 0; avahi_log_warn("System host name is set to 'localhost'. This is not a suitable mDNS host name, looking for alternatives."); } - + if (*ret_s == 0) { /* No hostname was set, so let's take the OS name */ @@ -118,7 +118,7 @@ char *avahi_get_host_name(char *ret_s, size_t size) { { /* Try uname() second */ struct utsname utsname; - + if (uname(&utsname) >= 0) { snprintf(ret_s, size, "%s", utsname.sysname); strip_bad_chars(ret_s); @@ -132,8 +132,8 @@ char *avahi_get_host_name(char *ret_s, size_t size) { } if (size >= AVAHI_LABEL_MAX) - ret_s[AVAHI_LABEL_MAX-1] = 0; - + ret_s[AVAHI_LABEL_MAX-1] = 0; + return ret_s; } @@ -164,7 +164,7 @@ int avahi_binary_domain_cmp(const char *a, const char *b) { if ((r = strcmp(ca, cb))) return r; - + if (!*a && !*b) return 0; } @@ -179,12 +179,12 @@ int avahi_domain_ends_with(const char *domain, const char *suffix) { if (*domain == 0) return 0; - + if (avahi_domain_equal(domain, suffix)) return 1; r = avahi_unescape_label(&domain, dummy, sizeof(dummy)); assert(r); - } + } } diff --git a/avahi-core/domain-util.h b/avahi-core/domain-util.h index 01233d8..213bb71 100644 --- a/avahi-core/domain-util.h +++ b/avahi-core/domain-util.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 @@ -31,7 +31,7 @@ AVAHI_C_DECL_BEGIN /** Return the local host name. */ -char *avahi_get_host_name(char *ret_s, size_t size); +char *avahi_get_host_name(char *ret_s, size_t size); /** Return the local host name. avahi_free() the result! */ char *avahi_get_host_name_strdup(void); diff --git a/avahi-core/entry.c b/avahi-core/entry.c index 749fae5..6287033 100644 --- a/avahi-core/entry.c +++ b/avahi-core/entry.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 @@ -107,7 +107,7 @@ void avahi_entry_group_free(AvahiServer *s, AvahiSEntryGroup *g) { if (g->register_time_event) avahi_time_event_free(g->register_time_event); - + AVAHI_LLIST_REMOVE(AvahiSEntryGroup, groups, s->groups, g); avahi_free(g); } @@ -117,10 +117,10 @@ void avahi_cleanup_dead_entries(AvahiServer *s) { if (s->need_group_cleanup) { AvahiSEntryGroup *g, *next; - + for (g = s->groups; g; g = next) { next = g->groups_next; - + if (g->dead) avahi_entry_group_free(s, g); } @@ -130,10 +130,10 @@ void avahi_cleanup_dead_entries(AvahiServer *s) { if (s->need_entry_cleanup) { AvahiEntry *e, *next; - + for (e = s->entries; e; e = next) { next = e->entries_next; - + if (e->dead) avahi_entry_free(s, e); } @@ -147,7 +147,7 @@ void avahi_cleanup_dead_entries(AvahiServer *s) { static int check_record_conflict(AvahiServer *s, AvahiIfIndex interface, AvahiProtocol protocol, AvahiRecord *r, AvahiPublishFlags flags) { AvahiEntry *e; - + assert(s); assert(r); @@ -157,7 +157,7 @@ static int check_record_conflict(AvahiServer *s, AvahiIfIndex interface, AvahiPr if (!(flags & AVAHI_PUBLISH_UNIQUE) && !(e->flags & AVAHI_PUBLISH_UNIQUE)) continue; - + if ((flags & AVAHI_PUBLISH_ALLOW_MULTIPLE) && (e->flags & AVAHI_PUBLISH_ALLOW_MULTIPLE) ) continue; @@ -188,7 +188,7 @@ static AvahiEntry * server_add_internal( AvahiRecord *r) { AvahiEntry *e; - + assert(s); assert(r); @@ -225,11 +225,11 @@ static AvahiEntry * server_add_internal( !g || (g->state != AVAHI_ENTRY_GROUP_ESTABLISHED && g->state != AVAHI_ENTRY_GROUP_REGISTERING) || (flags & AVAHI_PUBLISH_UPDATE), AVAHI_ERR_BAD_STATE); - + if (flags & AVAHI_PUBLISH_UPDATE) { AvahiRecord *old_record; int is_first = 1; - + /* Update and existing record */ /* Find the first matching entry */ @@ -265,14 +265,14 @@ static AvahiEntry * server_add_internal( /* If we were the first entry in the list, we need to update the key */ if (is_first) avahi_hashmap_replace(s->entries_by_key, e->record->key, e); - + avahi_record_unref(old_record); } else { AvahiEntry *t; /* Add a new record */ - + if (check_record_conflict(s, interface, protocol, r, flags) < 0) { avahi_server_set_errno(s, AVAHI_ERR_COLLISION); return NULL; @@ -282,7 +282,7 @@ static AvahiEntry * server_add_internal( avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY); return NULL; } - + e->server = s; e->record = avahi_record_ref(r); e->group = g; @@ -290,20 +290,20 @@ static AvahiEntry * server_add_internal( e->protocol = protocol; e->flags = flags; e->dead = 0; - + AVAHI_LLIST_HEAD_INIT(AvahiAnnouncer, e->announcers); - + AVAHI_LLIST_PREPEND(AvahiEntry, entries, s->entries, e); - + /* Insert into hash table indexed by name */ t = avahi_hashmap_lookup(s->entries_by_key, e->record->key); AVAHI_LLIST_PREPEND(AvahiEntry, by_key, t, e); avahi_hashmap_replace(s->entries_by_key, e->record->key, t); - + /* Insert into group list */ if (g) - AVAHI_LLIST_PREPEND(AvahiEntry, by_group, g->entries, e); - + AVAHI_LLIST_PREPEND(AvahiEntry, by_group, g->entries, e); + avahi_announce_entry(s, e); } @@ -331,10 +331,10 @@ const AvahiRecord *avahi_server_iterate(AvahiServer *s, AvahiSEntryGroup *g, voi if (!*e) *e = g ? g->entries : s->entries; - + while (*e && (*e)->dead) *e = g ? (*e)->by_group_next : (*e)->entries_next; - + if (!*e) return NULL; @@ -343,7 +343,7 @@ const AvahiRecord *avahi_server_iterate(AvahiServer *s, AvahiSEntryGroup *g, voi int avahi_server_dump(AvahiServer *s, AvahiDumpCallback callback, void* userdata) { AvahiEntry *e; - + assert(s); assert(callback); @@ -355,10 +355,10 @@ int avahi_server_dump(AvahiServer *s, AvahiDumpCallback callback, void* userdata if (e->dead) continue; - + if (!(t = avahi_record_to_string(e->record))) return avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY); - + snprintf(ln, sizeof(ln), "%s ; iface=%i proto=%i", t, e->interface, e->protocol); avahi_free(t); @@ -384,7 +384,7 @@ static AvahiEntry *server_add_ptr_internal( AvahiRecord *r; AvahiEntry *e; - + assert(s); assert(dest); @@ -398,13 +398,13 @@ static AvahiEntry *server_add_ptr_internal( avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY); return NULL; } - + r->data.ptr.name = avahi_normalize_name_strdup(dest); e = server_add_internal(s, g, interface, protocol, flags, r); avahi_record_unref(r); return e; } - + int avahi_server_add_ptr( AvahiServer *s, AvahiSEntryGroup *g, @@ -438,7 +438,7 @@ int avahi_server_add_address( int ret = AVAHI_OK; AvahiEntry *entry = NULL, *reverse = NULL; AvahiRecord *r; - + assert(s); assert(a); @@ -454,7 +454,7 @@ int avahi_server_add_address( AVAHI_CHECK_VALIDITY(s, !name || avahi_is_valid_fqdn(name), AVAHI_ERR_INVALID_HOST_NAME); /* Prepare the host naem */ - + if (!name) name = s->host_name_fqdn; else { @@ -464,29 +464,29 @@ int avahi_server_add_address( transport_flags_from_domain(s, &flags, name); AVAHI_CHECK_VALIDITY(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED); - + /* Create the A/AAAA record */ - + if (a->proto == AVAHI_PROTO_INET) { if (!(r = avahi_record_new_full(name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_A, AVAHI_DEFAULT_TTL_HOST_NAME))) { ret = avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY); goto finish; } - + r->data.a.address = a->data.ipv4; - + } else { assert(a->proto == AVAHI_PROTO_INET6); - + if (!(r = avahi_record_new_full(name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_AAAA, AVAHI_DEFAULT_TTL_HOST_NAME))) { ret = avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY); goto finish; } - + r->data.aaaa.address = a->data.ipv6; } - + entry = server_add_internal(s, g, interface, protocol, (flags & ~ AVAHI_PUBLISH_NO_REVERSE) | AVAHI_PUBLISH_UNIQUE | AVAHI_PUBLISH_ALLOW_MULTIPLE, r); avahi_record_unref(r); @@ -496,17 +496,17 @@ int avahi_server_add_address( } /* Create the reverse lookup entry */ - + if (!(flags & AVAHI_PUBLISH_NO_REVERSE)) { char reverse_n[AVAHI_DOMAIN_NAME_MAX]; avahi_reverse_lookup_name(a, reverse_n, sizeof(reverse_n)); - + if (!(reverse = server_add_ptr_internal(s, g, interface, protocol, flags | AVAHI_PUBLISH_UNIQUE, AVAHI_DEFAULT_TTL_HOST_NAME, reverse_n, name))) { ret = avahi_server_errno(s); goto finish; } } - + finish: if (ret != AVAHI_OK && !(flags & AVAHI_PUBLISH_UPDATE)) { @@ -531,7 +531,7 @@ static AvahiEntry *server_add_txt_strlst_nocopy( AvahiRecord *r; AvahiEntry *e; - + assert(s); if (!(r = avahi_record_new_full(name ? name : s->host_name_fqdn, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_TXT, ttl))) { @@ -539,7 +539,7 @@ static AvahiEntry *server_add_txt_strlst_nocopy( avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY); return NULL; } - + r->data.txt.string_list = strlst; e = server_add_internal(s, g, interface, protocol, flags, r); avahi_record_unref(r); @@ -580,7 +580,7 @@ static int server_add_service_strlst_nocopy( AvahiRecord *r = NULL; int ret = AVAHI_OK; AvahiEntry *srv_entry = NULL, *txt_entry = NULL, *ptr_entry = NULL, *enum_entry = NULL; - + assert(s); assert(type); assert(name); @@ -605,7 +605,7 @@ static int server_add_service_strlst_nocopy( transport_flags_from_domain(s, &flags, domain); AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED); - + if (!(h = avahi_normalize_name_strdup(host))) { ret = avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY); goto fail; @@ -619,19 +619,19 @@ static int server_add_service_strlst_nocopy( } /* Add service enumeration PTR record */ - + if (!(ptr_entry = server_add_ptr_internal(s, g, interface, protocol, 0, AVAHI_DEFAULT_TTL, ptr_name, svc_name))) { ret = avahi_server_errno(s); goto fail; } /* Add SRV record */ - + if (!(r = avahi_record_new_full(svc_name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV, AVAHI_DEFAULT_TTL_HOST_NAME))) { ret = avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY); goto fail; } - + r->data.srv.priority = 0; r->data.srv.weight = 0; r->data.srv.port = port; @@ -649,7 +649,7 @@ static int server_add_service_strlst_nocopy( if (!(flags & AVAHI_PUBLISH_NO_COOKIE)) strlst = add_magic_cookie(s, strlst); - + txt_entry = server_add_txt_strlst_nocopy(s, g, interface, protocol, AVAHI_PUBLISH_UNIQUE, AVAHI_DEFAULT_TTL, svc_name, strlst); strlst = NULL; @@ -659,7 +659,7 @@ static int server_add_service_strlst_nocopy( } /* Add service type enumeration record */ - + if (!(enum_entry = server_add_ptr_internal(s, g, interface, protocol, 0, AVAHI_DEFAULT_TTL, enum_ptr, ptr_name))) { ret = avahi_server_errno(s); goto fail; @@ -676,10 +676,10 @@ fail: if (enum_entry) avahi_entry_free(s, enum_entry); } - + avahi_string_list_free(strlst); avahi_free(h); - + return ret; } @@ -718,11 +718,11 @@ int avahi_server_add_service( va_list va; int ret; - + va_start(va, port); ret = server_add_service_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, host, port, avahi_string_list_new_va(va)); va_end(va); - + return ret; } @@ -732,15 +732,15 @@ static int server_update_service_txt_strlst_nocopy( AvahiIfIndex interface, AvahiProtocol protocol, AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, + const char *name, + const char *type, + const char *domain, AvahiStringList *strlst) { char svc_name[AVAHI_DOMAIN_NAME_MAX]; int ret = AVAHI_OK; AvahiEntry *e; - + assert(s); assert(type); assert(name); @@ -769,17 +769,17 @@ static int server_update_service_txt_strlst_nocopy( /* Add TXT record */ if (!(flags & AVAHI_PUBLISH_NO_COOKIE)) strlst = add_magic_cookie(s, strlst); - + e = server_add_txt_strlst_nocopy(s, g, interface, protocol, AVAHI_PUBLISH_UNIQUE | AVAHI_PUBLISH_UPDATE, AVAHI_DEFAULT_TTL, svc_name, strlst); strlst = NULL; if (!e) ret = avahi_server_errno(s); - + fail: - + avahi_string_list_free(strlst); - + return ret; } @@ -789,9 +789,9 @@ int avahi_server_update_service_txt_strlst( AvahiIfIndex interface, AvahiProtocol protocol, AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, + const char *name, + const char *type, + const char *domain, AvahiStringList *strlst) { return server_update_service_txt_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, avahi_string_list_copy(strlst)); @@ -804,18 +804,18 @@ int avahi_server_update_service_txt( AvahiIfIndex interface, AvahiProtocol protocol, AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, + const char *name, + const char *type, + const char *domain, ...) { va_list va; int ret; - + va_start(va, domain); ret = server_update_service_txt_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, avahi_string_list_new_va(va)); va_end(va); - + return ret; } @@ -825,14 +825,14 @@ int avahi_server_add_service_subtype( AvahiIfIndex interface, AvahiProtocol protocol, AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, + const char *name, + const char *type, + const char *domain, const char *subtype) { int ret = AVAHI_OK; char svc_name[AVAHI_DOMAIN_NAME_MAX], ptr_name[AVAHI_DOMAIN_NAME_MAX]; - + assert(name); assert(type); assert(subtype); @@ -861,7 +861,7 @@ int avahi_server_add_service_subtype( goto fail; fail: - + return ret; } @@ -877,7 +877,7 @@ static void hexstring(char *s, size_t sl, const void *p, size_t pl) { k++; pl--; } - + b = !b; sl--; @@ -900,9 +900,9 @@ static AvahiEntry *server_add_dns_server_name( AvahiEntry *e; char t[AVAHI_DOMAIN_NAME_MAX], normalized_d[AVAHI_DOMAIN_NAME_MAX], *n; - + AvahiRecord *r; - + assert(s); assert(name); @@ -911,7 +911,7 @@ static AvahiEntry *server_add_dns_server_name( AVAHI_CHECK_VALIDITY_RETURN_NULL(s, port != 0, AVAHI_ERR_INVALID_PORT); AVAHI_CHECK_VALIDITY_RETURN_NULL(s, avahi_is_valid_fqdn(name), AVAHI_ERR_INVALID_HOST_NAME); AVAHI_CHECK_VALIDITY_RETURN_NULL(s, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME); - + if (!domain) domain = s->domain_name; @@ -922,17 +922,17 @@ static AvahiEntry *server_add_dns_server_name( avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY); return NULL; } - + AVAHI_ASSERT_TRUE(avahi_normalize_name(domain, normalized_d, sizeof(normalized_d))); snprintf(t, sizeof(t), "%s.%s", type == AVAHI_DNS_SERVER_RESOLVE ? "_domain._udp" : "_dns-update._udp", normalized_d); - + if (!(r = avahi_record_new_full(t, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV, AVAHI_DEFAULT_TTL_HOST_NAME))) { avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY); avahi_free(n); return NULL; } - + r->data.srv.priority = 0; r->data.srv.weight = 0; r->data.srv.port = port; @@ -973,7 +973,7 @@ int avahi_server_add_dns_server_address( transport_flags_from_domain(s, &flags, domain); AVAHI_CHECK_VALIDITY(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED); - + if (address->proto == AVAHI_PROTO_INET) { hexstring(h, sizeof(h), &address->data, sizeof(AvahiIPv4Address)); snprintf(n, sizeof(n), "ip-%s.%s", h, domain); @@ -988,13 +988,13 @@ int avahi_server_add_dns_server_address( if (!r) return avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY); - + a_entry = server_add_internal(s, g, interface, protocol, AVAHI_PUBLISH_UNIQUE | AVAHI_PUBLISH_ALLOW_MULTIPLE, r); avahi_record_unref(r); if (!a_entry) return avahi_server_errno(s); - + if (!(s_entry = server_add_dns_server_name(s, g, interface, protocol, flags, domain, type, n, port))) { if (!(flags & AVAHI_PUBLISH_UPDATE)) avahi_entry_free(s, a_entry); @@ -1016,7 +1016,7 @@ void avahi_s_entry_group_change_state(AvahiSEntryGroup *g, AvahiEntryGroupState /* If the entry group was established for a time longer then * 5s, reset the establishment trial counter */ - + if (avahi_age(&g->established_at) > 5000000) g->n_register_try = 0; } else if (g->state == AVAHI_ENTRY_GROUP_REGISTERING) { @@ -1025,30 +1025,30 @@ void avahi_s_entry_group_change_state(AvahiSEntryGroup *g, AvahiEntryGroupState g->register_time_event = NULL; } } - + if (state == AVAHI_ENTRY_GROUP_ESTABLISHED) /* If the entry group is now established, remember the time * this happened */ - + gettimeofday(&g->established_at, NULL); - + g->state = state; - + if (g->callback) g->callback(g->server, g, state, g->userdata); } AvahiSEntryGroup *avahi_s_entry_group_new(AvahiServer *s, AvahiSEntryGroupCallback callback, void* userdata) { AvahiSEntryGroup *g; - + assert(s); if (!(g = avahi_new(AvahiSEntryGroup, 1))) { avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY); return NULL; } - + g->server = s; g->callback = callback; g->userdata = userdata; @@ -1067,7 +1067,7 @@ AvahiSEntryGroup *avahi_s_entry_group_new(AvahiServer *s, AvahiSEntryGroupCallba void avahi_s_entry_group_free(AvahiSEntryGroup *g) { AvahiEntry *e; - + assert(g); assert(g->server); @@ -1084,7 +1084,7 @@ void avahi_s_entry_group_free(AvahiSEntryGroup *g) { } g->dead = 1; - + g->server->need_group_cleanup = 1; g->server->need_entry_cleanup = 1; @@ -1111,14 +1111,14 @@ static void entry_group_register_time_event_callback(AVAHI_GCC_UNUSED AvahiTimeE avahi_time_event_free(g->register_time_event); g->register_time_event = NULL; - + /* Holdoff time passed, so let's start probing */ entry_group_commit_real(g); } int avahi_s_entry_group_commit(AvahiSEntryGroup *g) { struct timeval now; - + assert(g); assert(!g->dead); @@ -1146,7 +1146,7 @@ int avahi_s_entry_group_commit(AvahiSEntryGroup *g) { /* Holdoff time has not yet passed, so let's wait */ assert(!g->register_time_event); g->register_time_event = avahi_time_event_new(g->server->time_event_queue, &g->register_time, entry_group_register_time_event_callback, g); - + avahi_s_entry_group_change_state(g, AVAHI_ENTRY_GROUP_REGISTERING); } @@ -1156,7 +1156,7 @@ int avahi_s_entry_group_commit(AvahiSEntryGroup *g) { void avahi_s_entry_group_reset(AvahiSEntryGroup *g) { AvahiEntry *e; assert(g); - + for (e = g->entries; e; e = e->by_group_next) { if (!e->dead) { avahi_goodbye_entry(g->server, e, 1, 1); diff --git a/avahi-core/fdutil.c b/avahi-core/fdutil.c index e35016d..4beb03d 100644 --- a/avahi-core/fdutil.c +++ b/avahi-core/fdutil.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,7 +34,7 @@ int avahi_set_cloexec(int fd) { int n; assert(fd >= 0); - + if ((n = fcntl(fd, F_GETFD)) < 0) return -1; @@ -46,7 +46,7 @@ int avahi_set_cloexec(int fd) { int avahi_set_nonblock(int fd) { int n; - + assert(fd >= 0); if ((n = fcntl(fd, F_GETFL)) < 0) @@ -61,13 +61,13 @@ int avahi_set_nonblock(int fd) { int avahi_wait_for_write(int fd) { fd_set fds; int r; - + FD_ZERO(&fds); FD_SET(fd, &fds); - + if ((r = select(fd+1, NULL, &fds, NULL, NULL)) < 0) return -1; - + assert(r > 0); return 0; diff --git a/avahi-core/fdutil.h b/avahi-core/fdutil.h index 047b9bb..ea1471d 100644 --- a/avahi-core/fdutil.h +++ b/avahi-core/fdutil.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-core/hashmap-test.c b/avahi-core/hashmap-test.c index 9826d53..2d731ee 100644 --- a/avahi-core/hashmap-test.c +++ b/avahi-core/hashmap-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 @@ -46,7 +46,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { for (n = 0; n < 1000; n ++) avahi_hashmap_insert(m, avahi_strdup_printf("key %u", n), avahi_strdup_printf("value %u", n)); - + printf("%s\n", (const char*) avahi_hashmap_lookup(m, "bla")); avahi_hashmap_replace(m, avahi_strdup("bla"), avahi_strdup("#3")); @@ -57,7 +57,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { t = (const char*) avahi_hashmap_lookup(m, "bla"); printf("%s\n", t ? t : "(null)"); - + avahi_hashmap_free(m); return 0; diff --git a/avahi-core/hashmap.c b/avahi-core/hashmap.c index 07bd707..32c9c4a 100644 --- a/avahi-core/hashmap.c +++ b/avahi-core/hashmap.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 @@ -49,7 +49,7 @@ struct AvahiHashmap { AvahiHashFunc hash_func; AvahiEqualFunc equal_func; AvahiFreeFunc key_free_func, value_free_func; - + Entry *entries[HASH_MAP_SIZE]; AVAHI_LLIST_HEAD(Entry, entries_list); }; @@ -59,7 +59,7 @@ static Entry* entry_get(AvahiHashmap *m, const void *key) { Entry *e; idx = m->hash_func(key) % HASH_MAP_SIZE; - + for (e = m->entries[idx]; e; e = e->bucket_next) if (m->equal_func(key, e->key)) return e; @@ -87,7 +87,7 @@ static void entry_free(AvahiHashmap *m, Entry *e, int stolen) { AvahiHashmap* avahi_hashmap_new(AvahiHashFunc hash_func, AvahiEqualFunc equal_func, AvahiFreeFunc key_free_func, AvahiFreeFunc value_free_func) { AvahiHashmap *m; - + assert(hash_func); assert(equal_func); @@ -100,7 +100,7 @@ AvahiHashmap* avahi_hashmap_new(AvahiHashFunc hash_func, AvahiEqualFunc equal_fu m->value_free_func = value_free_func; AVAHI_LLIST_HEAD_INIT(Entry, m->entries_list); - + return m; } @@ -109,13 +109,13 @@ void avahi_hashmap_free(AvahiHashmap *m) { while (m->entries_list) entry_free(m, m->entries_list, 0); - + avahi_free(m); } void* avahi_hashmap_lookup(AvahiHashmap *m, const void *key) { Entry *e; - + assert(m); if (!(e = entry_get(m, key))) @@ -135,7 +135,7 @@ int avahi_hashmap_insert(AvahiHashmap *m, void *key, void *value) { m->key_free_func(key); if (m->value_free_func) m->value_free_func(value); - + return 1; } @@ -150,7 +150,7 @@ int avahi_hashmap_insert(AvahiHashmap *m, void *key, void *value) { idx = m->hash_func(key) % HASH_MAP_SIZE; AVAHI_LLIST_PREPEND(Entry, bucket, m->entries[idx], e); - + return 0; } @@ -169,7 +169,7 @@ int avahi_hashmap_replace(AvahiHashmap *m, void *key, void *value) { e->key = key; e->value = value; - + return 1; } @@ -184,13 +184,13 @@ int avahi_hashmap_replace(AvahiHashmap *m, void *key, void *value) { idx = m->hash_func(key) % HASH_MAP_SIZE; AVAHI_LLIST_PREPEND(Entry, bucket, m->entries[idx], e); - + return 0; } void avahi_hashmap_remove(AvahiHashmap *m, const void *key) { Entry *e; - + assert(m); if (!(e = entry_get(m, key))) @@ -216,7 +216,7 @@ unsigned avahi_string_hash(const void *data) { unsigned hash = 0; assert(p); - + for (; *p; p++) hash = 31 * hash + *p; @@ -228,7 +228,7 @@ int avahi_string_equal(const void *a, const void *b) { assert(p); assert(q); - + return strcmp(p, q) == 0; } @@ -236,7 +236,7 @@ unsigned avahi_int_hash(const void *data) { const int *i = data; assert(i); - + return (unsigned) *i; } @@ -245,6 +245,6 @@ int avahi_int_equal(const void *a, const void *b) { assert(_a); assert(_b); - + return *_a == *_b; } diff --git a/avahi-core/hashmap.h b/avahi-core/hashmap.h index 120cf30..95efa56 100644 --- a/avahi-core/hashmap.h +++ b/avahi-core/hashmap.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-core/iface-linux.c b/avahi-core/iface-linux.c index c8ed9e0..98fdea5 100644 --- a/avahi-core/iface-linux.c +++ b/avahi-core/iface-linux.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 @@ -50,7 +50,7 @@ static int netlink_list_items(AvahiNetlink *nl, uint16_t type, unsigned *ret_seq uint8_t req[1024]; /* Issue a wild dump NETLINK request */ - + memset(&req, 0, sizeof(req)); n = (struct nlmsghdr*) req; n->nlmsg_len = NLMSG_LENGTH(sizeof(struct rtgenmsg)); @@ -69,7 +69,7 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat AvahiInterfaceMonitor *m = userdata; /* This routine is called for every RTNETLINK response packet */ - + assert(m); assert(n); assert(m->osdep.netlink == nl); @@ -77,7 +77,7 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat if (n->nlmsg_type == RTM_NEWLINK) { /* A new interface appeared or an existing one has been modified */ - + struct ifinfomsg *ifinfomsg = NLMSG_DATA(n); AvahiHwInterface *hw; struct rtattr *a = NULL; @@ -93,7 +93,7 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat * interface appears, but when it changes, too */ if (!(hw = avahi_interface_monitor_get_hw_interface(m, ifinfomsg->ifi_index))) - + /* No object found, so let's create a new * one. avahi_hw_interface_new() will call * avahi_interface_new() internally twice for IPv4 and @@ -136,10 +136,10 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat hw->mac_address_size = RTA_PAYLOAD(a); if (hw->mac_address_size > AVAHI_MAC_ADDRESS_MAX) hw->mac_address_size = AVAHI_MAC_ADDRESS_MAX; - + memcpy(hw->mac_address, RTA_DATA(a), hw->mac_address_size); break; - + default: ; } @@ -156,7 +156,7 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat /* Update any associated RRs of this interface. (i.e. the * _workstation._tcp record containing the MAC address) */ avahi_hw_interface_update_rrs(hw, 0); - + } else if (n->nlmsg_type == RTM_DELLINK) { /* An interface has been removed */ @@ -174,11 +174,11 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat /* Free our object */ avahi_hw_interface_free(hw, 0); - + } else if (n->nlmsg_type == RTM_NEWADDR || n->nlmsg_type == RTM_DELADDR) { /* An address has been added, modified or removed */ - + struct ifaddrmsg *ifaddrmsg = NLMSG_DATA(n); AvahiInterface *i; struct rtattr *a = NULL; @@ -207,7 +207,7 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat switch(a->rta_type) { case IFA_ADDRESS: /* Fill in address data */ - + if ((raddr.proto == AVAHI_PROTO_INET6 && RTA_PAYLOAD(a) != 16) || (raddr.proto == AVAHI_PROTO_INET && RTA_PAYLOAD(a) != 4)) return; @@ -220,7 +220,7 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat default: ; } - + a = RTA_NEXT(a, l); } @@ -260,16 +260,16 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat /* Update any associated RRs, like A or AAAA for our new/removed address */ avahi_interface_update_rrs(i, 0); - + } else if (n->nlmsg_type == NLMSG_DONE) { /* This wild dump request ended, so let's see what we do next */ - + if (m->osdep.list == LIST_IFACE) { /* Mmmm, interfaces have been wild dumped already, so * let's go on with wild dumping the addresses */ - + if (netlink_list_items(m->osdep.netlink, RTM_GETADDR, &m->osdep.query_addr_seq) < 0) { avahi_log_warn("NETLINK: Failed to list addrs: %s", strerror(errno)); m->osdep.list = LIST_DONE; @@ -300,14 +300,14 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat /* Tell the user that the wild dump is complete */ avahi_log_info("Network interface enumeration completed."); } - + } else if (n->nlmsg_type == NLMSG_ERROR && (n->nlmsg_seq == m->osdep.query_link_seq || n->nlmsg_seq == m->osdep.query_addr_seq)) { struct nlmsgerr *e = NLMSG_DATA (n); /* Some kind of error happened. Let's just tell the user and * ignore it otherwise */ - + if (e->error) avahi_log_warn("NETLINK: Failed to browse: %s", strerror(-e->error)); } @@ -317,7 +317,7 @@ int avahi_interface_monitor_init_osdep(AvahiInterfaceMonitor *m) { assert(m); /* Initialize our own data */ - + m->osdep.netlink = NULL; m->osdep.query_addr_seq = m->osdep.query_link_seq = 0; @@ -361,7 +361,7 @@ void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m) { /* Let's handle netlink events until we are done with wild * dumping */ - + while (!m->list_complete) if (!avahi_netlink_work(m->osdep.netlink, 1) == 0) break; diff --git a/avahi-core/iface-linux.h b/avahi-core/iface-linux.h index eed648c..5878089 100644 --- a/avahi-core/iface-linux.h +++ b/avahi-core/iface-linux.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 @@ -28,9 +28,9 @@ typedef struct AvahiInterfaceMonitorOSDep AvahiInterfaceMonitorOSDep; struct AvahiInterfaceMonitorOSDep { AvahiNetlink *netlink; - + unsigned query_addr_seq, query_link_seq; - + enum { LIST_IFACE, LIST_ADDR, diff --git a/avahi-core/iface-pfroute.c b/avahi-core/iface-pfroute.c index 391081e..bd91e92 100644 --- a/avahi-core/iface-pfroute.c +++ b/avahi-core/iface-pfroute.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,8 +48,8 @@ #include "iface-pfroute.h" #include "util.h" -static int bitcount (unsigned int n) -{ +static int bitcount (unsigned int n) +{ int count=0 ; while (n) { @@ -64,39 +64,39 @@ static void rtm_info(struct rt_msghdr *rtm, AvahiInterfaceMonitor *m) AvahiHwInterface *hw; struct if_msghdr *ifm = (struct if_msghdr *)rtm; struct sockaddr_dl *sdl = (struct sockaddr_dl *)(ifm + 1); - + if (sdl->sdl_family != AF_LINK) return; - + if (ifm->ifm_addrs == 0 && ifm->ifm_index > 0) { if (!(hw = avahi_interface_monitor_get_hw_interface(m, (AvahiIfIndex) ifm->ifm_index))) return; avahi_hw_interface_free(hw, 0); return; } - + if (!(hw = avahi_interface_monitor_get_hw_interface(m, ifm->ifm_index))) if (!(hw = avahi_hw_interface_new(m, (AvahiIfIndex) ifm->ifm_index))) return; /* OOM */ - + hw->flags_ok = (ifm->ifm_flags & IFF_UP) && (!m->server->config.use_iff_running || (ifm->ifm_flags & IFF_RUNNING)) && !(ifm->ifm_flags & IFF_LOOPBACK) && (ifm->ifm_flags & IFF_MULTICAST) && (m->server->config.allow_point_to_point || !(ifm->ifm_flags & IFF_POINTOPOINT)); - + avahi_free(hw->name); hw->name = avahi_strndup(sdl->sdl_data, sdl->sdl_nlen); - + hw->mtu = ifm->ifm_data.ifi_mtu; - + hw->mac_address_size = sdl->sdl_alen; if (hw->mac_address_size > AVAHI_MAC_ADDRESS_MAX) hw->mac_address_size = AVAHI_MAC_ADDRESS_MAX; - + memcpy(hw->mac_address, sdl->sdl_data + sdl->sdl_nlen, hw->mac_address_size); - + /* { */ /* char mac[256]; */ /* avahi_log_debug("======\n name: %s\n index:%d\n mtu:%d\n mac:%s\n flags_ok:%d\n======", */ @@ -105,7 +105,7 @@ static void rtm_info(struct rt_msghdr *rtm, AvahiInterfaceMonitor *m) /* avahi_format_mac_address(mac, sizeof(mac), hw->mac_address, hw->mac_address_size), */ /* hw->flags_ok); */ /* } */ - + avahi_hw_interface_check_relevant(hw); avahi_hw_interface_update_rrs(hw, 0); } @@ -155,14 +155,14 @@ static void rtm_addr(struct rt_msghdr *rtm, AvahiInterfaceMonitor *m) return; raddr.proto = avahi_af_to_proto(sa->sa_family); - + for(cp = cp0, i = 0; i < RTAX_MAX; i++) { if (!(ifam->ifam_addrs & (1<sa_len == 0) + if (sa->sa_len == 0) continue; #endif switch(sa->sa_family) { @@ -231,7 +231,7 @@ static void rtm_addr(struct rt_msghdr *rtm, AvahiInterfaceMonitor *m) return; avahi_interface_address_free(addriface); } - + avahi_interface_check_relevant(iface); avahi_interface_update_rrs(iface, 0); } @@ -240,7 +240,7 @@ static void parse_rtmsg(struct rt_msghdr *rtm, AvahiInterfaceMonitor *m) { assert(m); assert(rtm); - + if (rtm->rtm_version != RTM_VERSION) { avahi_log_warn("routing message version %d not understood", rtm->rtm_version); @@ -301,15 +301,15 @@ int avahi_interface_monitor_init_osdep(AvahiInterfaceMonitor *m) { } m->osdep.pfroute->fd = fd; - if (!(m->osdep.pfroute->watch = m->server->poll_api->watch_new(m->server->poll_api, - m->osdep.pfroute->fd, - AVAHI_WATCH_IN, - socket_event, + if (!(m->osdep.pfroute->watch = m->server->poll_api->watch_new(m->server->poll_api, + m->osdep.pfroute->fd, + AVAHI_WATCH_IN, + socket_event, m))) { avahi_log_error(__FILE__": Failed to create watch."); goto fail; } - + return 0; fail: @@ -317,10 +317,10 @@ fail: if (m->osdep.pfroute) { if (m->osdep.pfroute->watch) m->server->poll_api->watch_free(m->osdep.pfroute->watch); - + if (fd >= 0) close(fd); - + m->osdep.pfroute = NULL; } @@ -333,7 +333,7 @@ void avahi_interface_monitor_free_osdep(AvahiInterfaceMonitor *m) { if (m->osdep.pfroute) { if (m->osdep.pfroute->watch) m->server->poll_api->watch_free(m->osdep.pfroute->watch); - + if (m->osdep.pfroute->fd >= 0) close(m->osdep.pfroute->fd); @@ -423,7 +423,7 @@ static void if_add_interface(struct lifreq *lifreq, AvahiInterfaceMonitor *m, in index = if_nametoindex(lifreq->lifr_name); if (!(hw = avahi_interface_monitor_get_hw_interface(m, (AvahiIfIndex) index))) { - if (!(hw = avahi_hw_interface_new(m, (AvahiIfIndex) index))) + if (!(hw = avahi_hw_interface_new(m, (AvahiIfIndex) index))) return; /* OOM */ hw->flags_ok = @@ -445,7 +445,7 @@ static void if_add_interface(struct lifreq *lifreq, AvahiInterfaceMonitor *m, in return; /* OOM */ addriface->global_scope = 1; - + avahi_hw_interface_check_relevant(hw); avahi_hw_interface_update_rrs(hw, 0); } @@ -459,7 +459,7 @@ void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m) { struct rt_msghdr *rtm; assert(m); - + retry2: mib[0] = CTL_NET; mib[1] = PF_ROUTE; @@ -492,7 +492,7 @@ void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m) { rtm = (struct rt_msghdr *)next; parse_rtmsg(rtm, m); } - + m->list_complete = 1; avahi_interface_monitor_check_relevant(m); avahi_interface_monitor_update_rrs(m, 0); diff --git a/avahi-core/iface-pfroute.h b/avahi-core/iface-pfroute.h index 34098da..e5dab53 100644 --- a/avahi-core/iface-pfroute.h +++ b/avahi-core/iface-pfroute.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-core/iface.h b/avahi-core/iface.h index 4106ea7..9e5dc62 100644 --- a/avahi-core/iface.h +++ b/avahi-core/iface.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 @@ -47,9 +47,9 @@ typedef struct AvahiHwInterface AvahiHwInterface; #else typedef struct AvahiInterfaceMonitorOSDep AvahiInterfaceMonitorOSDep; struct AvahiInterfaceMonitorOSDep { - + unsigned query_addr_seq, query_link_seq; - + enum { LIST_IFACE, LIST_ADDR, @@ -79,7 +79,7 @@ struct AvahiHwInterface { char *name; AvahiIfIndex index; int flags_ok; - + unsigned mtu; uint8_t mac_address[AVAHI_MAC_ADDRESS_MAX]; @@ -96,7 +96,7 @@ struct AvahiInterface { AVAHI_LLIST_FIELDS(AvahiInterface, interface); AVAHI_LLIST_FIELDS(AvahiInterface, by_hardware); - + AvahiProtocol protocol; int announcing; AvahiAddress local_mcast_address; @@ -125,7 +125,7 @@ struct AvahiInterfaceAddress { unsigned prefix_len; int global_scope; - + AvahiSEntryGroup *entry_group; }; diff --git a/avahi-core/internal.h b/avahi-core/internal.h index d0a10d6..958890f 100644 --- a/avahi-core/internal.h +++ b/avahi-core/internal.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 @@ -53,7 +53,7 @@ typedef struct AvahiLegacyUnicastReflectSlot AvahiLegacyUnicastReflectSlot; struct AvahiLegacyUnicastReflectSlot { AvahiServer *server; - + uint16_t id, original_id; AvahiAddress address; uint16_t port; @@ -67,7 +67,7 @@ struct AvahiEntry { AvahiSEntryGroup *group; int dead; - + AvahiPublishFlags flags; AvahiRecord *record; AvahiIfIndex interface; @@ -76,7 +76,7 @@ struct AvahiEntry { AVAHI_LLIST_FIELDS(AvahiEntry, entries); AVAHI_LLIST_FIELDS(AvahiEntry, by_key); AVAHI_LLIST_FIELDS(AvahiEntry, by_group); - + AVAHI_LLIST_HEAD(AvahiAnnouncer, announcers); }; @@ -89,20 +89,20 @@ struct AvahiSEntryGroup { AvahiSEntryGroupCallback callback; unsigned n_probing; - + unsigned n_register_try; struct timeval register_time; AvahiTimeEvent *register_time_event; struct timeval established_at; - + AVAHI_LLIST_FIELDS(AvahiSEntryGroup, groups); AVAHI_LLIST_HEAD(AvahiEntry, entries); }; struct AvahiServer { const AvahiPoll *poll_api; - + AvahiInterfaceMonitor *monitor; AvahiServerConfig config; @@ -110,7 +110,7 @@ struct AvahiServer { AvahiHashmap *entries_by_key; AVAHI_LLIST_HEAD(AvahiSEntryGroup, groups); - + AVAHI_LLIST_HEAD(AvahiSRecordBrowser, record_browsers); AvahiHashmap *record_browser_hashmap; AVAHI_LLIST_HEAD(AvahiSHostNameResolver, host_name_resolvers); @@ -122,9 +122,9 @@ struct AvahiServer { AVAHI_LLIST_HEAD(AvahiSDNSServerBrowser, dns_server_browsers); int need_entry_cleanup, need_group_cleanup, need_browser_cleanup; - + AvahiTimeEventQueue *time_event_queue; - + char *host_name, *host_name_fqdn, *domain_name; int fd_ipv4, fd_ipv6, @@ -189,8 +189,8 @@ int avahi_server_add_ptr( AvahiIfIndex interface, AvahiProtocol protocol, AvahiPublishFlags flags, - uint32_t ttl, - const char *name, + uint32_t ttl, + const char *name, const char *dest); #define AVAHI_CHECK_VALIDITY(server, expression, error) { \ diff --git a/avahi-core/log.c b/avahi-core/log.c index bfd4021..63ed5b5 100644 --- a/avahi-core/log.c +++ b/avahi-core/log.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,9 +36,9 @@ void avahi_set_log_function(AvahiLogFunction function) { void avahi_log_ap(AvahiLogLevel level, const char*format, va_list ap) { char txt[256]; - + vsnprintf(txt, sizeof(txt), format, ap); - + if (log_function) log_function(level, txt); else diff --git a/avahi-core/log.h b/avahi-core/log.h index 25e3940..3a1711a 100644 --- a/avahi-core/log.h +++ b/avahi-core/log.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-core/lookup.h b/avahi-core/lookup.h index 0ce6fe8..435d554 100644 --- a/avahi-core/lookup.h +++ b/avahi-core/lookup.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 @@ -80,7 +80,7 @@ void avahi_s_record_browser_free(AvahiSRecordBrowser *b); /** Callback prototype for AvahiSHostNameResolver events */ typedef void (*AvahiSHostNameResolverCallback)( AvahiSHostNameResolver *r, - AvahiIfIndex interface, + AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, /**< Resolving event */ const char *host_name, /**< Host name which should be resolved. May differ in case from the query */ @@ -108,7 +108,7 @@ typedef void (*AvahiSAddressResolverCallback)( AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, - const AvahiAddress *a, + const AvahiAddress *a, const char *host_name, /**< A host name for the specified address, if one was found, i.e. event == AVAHI_RESOLVER_FOUND */ AvahiLookupResultFlags flags, /**< Lookup flags */ void* userdata); diff --git a/avahi-core/multicast-lookup.c b/avahi-core/multicast-lookup.c index c3afcb0..75e01f1 100644 --- a/avahi-core/multicast-lookup.c +++ b/avahi-core/multicast-lookup.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,17 +41,17 @@ struct AvahiMulticastLookup { int dead; AvahiKey *key, *cname_key; - + AvahiMulticastLookupCallback callback; void *userdata; AvahiIfIndex interface; AvahiProtocol protocol; - + int queriers_added; AvahiTimeEvent *all_for_now_event; - + AVAHI_LLIST_FIELDS(AvahiMulticastLookup, lookups); AVAHI_LLIST_FIELDS(AvahiMulticastLookup, by_key); }; @@ -85,10 +85,10 @@ AvahiMulticastLookup *avahi_multicast_lookup_new( AvahiKey *key, AvahiMulticastLookupCallback callback, void *userdata) { - + AvahiMulticastLookup *l, *t; struct timeval tv; - + assert(e); assert(AVAHI_IF_VALID(interface)); assert(AVAHI_PROTO_VALID(protocol)); @@ -121,7 +121,7 @@ AvahiMulticastLookup *avahi_multicast_lookup_new( /* Issue the ALL_FOR_NOW event one second after the querier was initially created */ l->all_for_now_event = avahi_time_event_new(e->server->time_event_queue, &tv, all_for_now_callback, l); - + return l; } @@ -146,7 +146,7 @@ static void lookup_destroy(AvahiMulticastLookup *l) { assert(l); lookup_stop(l); - + t = avahi_hashmap_lookup(l->engine->lookups_by_key, l->key); AVAHI_LLIST_REMOVE(AvahiMulticastLookup, by_key, t, l); if (t) @@ -161,7 +161,7 @@ static void lookup_destroy(AvahiMulticastLookup *l) { if (l->cname_key) avahi_key_unref(l->cname_key); - + avahi_free(l); } @@ -179,13 +179,13 @@ void avahi_multicast_lookup_free(AvahiMulticastLookup *l) { void avahi_multicast_lookup_engine_cleanup(AvahiMulticastLookupEngine *e) { AvahiMulticastLookup *l, *n; assert(e); - + while (e->cleanup_dead) { e->cleanup_dead = 0; - + for (l = e->lookups; l; l = n) { n = l->lookups_next; - + if (l->dead) lookup_destroy(l); } @@ -219,7 +219,7 @@ static void* scan_cache_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEnt cbdata->userdata); cbdata->n_found ++; - + return NULL; } @@ -231,12 +231,12 @@ static void scan_interface_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, assert(cbdata); cbdata->interface = i; - + avahi_cache_walk(i->cache, cbdata->key, scan_cache_callback, cbdata); if (cbdata->cname_key) avahi_cache_walk(i->cache, cbdata->cname_key, scan_cache_callback, cbdata); - + cbdata->interface = NULL; } @@ -247,9 +247,9 @@ unsigned avahi_multicast_lookup_engine_scan_cache( AvahiKey *key, AvahiMulticastLookupCallback callback, void *userdata) { - + struct cbdata cbdata; - + assert(e); assert(key); assert(callback); @@ -264,9 +264,9 @@ unsigned avahi_multicast_lookup_engine_scan_cache( cbdata.userdata = userdata; cbdata.interface = NULL; cbdata.n_found = 0; - + avahi_interface_monitor_walk(e->server->monitor, interface, protocol, scan_interface_callback, &cbdata); - + if (cbdata.cname_key) avahi_key_unref(cbdata.cname_key); @@ -275,12 +275,12 @@ unsigned avahi_multicast_lookup_engine_scan_cache( void avahi_multicast_lookup_engine_new_interface(AvahiMulticastLookupEngine *e, AvahiInterface *i) { AvahiMulticastLookup *l; - + assert(e); assert(i); for (l = e->lookups; l; l = l->lookups_next) { - + if (l->dead || !l->callback) continue; @@ -291,7 +291,7 @@ void avahi_multicast_lookup_engine_new_interface(AvahiMulticastLookupEngine *e, void avahi_multicast_lookup_engine_notify(AvahiMulticastLookupEngine *e, AvahiInterface *i, AvahiRecord *record, AvahiBrowserEvent event) { AvahiMulticastLookup *l; - + assert(e); assert(record); assert(i); @@ -313,7 +313,7 @@ void avahi_multicast_lookup_engine_notify(AvahiMulticastLookupEngine *e, AvahiIn if (l->dead || !l->callback) continue; - + if ((key = avahi_key_new_cname(l->key))) { if (avahi_key_equal(record->key, key)) l->callback(e, i->hardware->index, i->protocol, event, AVAHI_LOOKUP_RESULT_MULTICAST, record, l->userdata); @@ -326,9 +326,9 @@ void avahi_multicast_lookup_engine_notify(AvahiMulticastLookupEngine *e, AvahiIn AvahiMulticastLookupEngine *avahi_multicast_lookup_engine_new(AvahiServer *s) { AvahiMulticastLookupEngine *e; - + assert(s); - + e = avahi_new(AvahiMulticastLookupEngine, 1); e->server = s; e->cleanup_dead = 0; diff --git a/avahi-core/multicast-lookup.h b/avahi-core/multicast-lookup.h index 43e240d..e3e6a85 100644 --- a/avahi-core/multicast-lookup.h +++ b/avahi-core/multicast-lookup.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-core/netlink.c b/avahi-core/netlink.c index 5050801..d109358 100644 --- a/avahi-core/netlink.c +++ b/avahi-core/netlink.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 @@ -53,7 +53,7 @@ int avahi_netlink_work(AvahiNetlink *nl, int block) { struct iovec iov; struct nlmsghdr *p; char cred_msg[CMSG_SPACE(sizeof(struct ucred))]; - + assert(nl); iov.iov_base = nl->buffer; @@ -70,7 +70,7 @@ int avahi_netlink_work(AvahiNetlink *nl, int block) { if ((bytes = recvmsg(nl->fd, &smsg, 0)) < 0) { if (errno == EAGAIN || errno == EINTR) return 0; - + avahi_log_error(__FILE__": recvmsg() failed: %s", strerror(errno)); return -1; } @@ -88,18 +88,18 @@ int avahi_netlink_work(AvahiNetlink *nl, int block) { return -1; p = (struct nlmsghdr *) nl->buffer; - + assert(nl->callback); - + for (; bytes > 0; p = NLMSG_NEXT(p, bytes)) { if (!NLMSG_OK(p, (size_t) bytes)) { avahi_log_warn(__FILE__": packet truncated"); return -1; } - + nl->callback(nl, p, nl->userdata); } - + return 0; } @@ -126,7 +126,7 @@ AvahiNetlink *avahi_netlink_new(const AvahiPoll *poll_api, uint32_t groups, void avahi_log_error(__FILE__": socket(PF_NETLINK): %s", strerror(errno)); return NULL; } - + memset(&addr, 0, sizeof(addr)); addr.nl_family = AF_NETLINK; addr.nl_groups = groups; @@ -162,7 +162,7 @@ AvahiNetlink *avahi_netlink_new(const AvahiPoll *poll_api, uint32_t groups, void avahi_log_error(__FILE__": Failed to create watch."); goto fail; } - + return nl; fail: @@ -186,7 +186,7 @@ void avahi_netlink_free(AvahiNetlink *nl) { if (nl->fd >= 0) close(nl->fd); - + avahi_free(nl->buffer); avahi_free(nl); } @@ -194,7 +194,7 @@ void avahi_netlink_free(AvahiNetlink *nl) { int avahi_netlink_send(AvahiNetlink *nl, struct nlmsghdr *m, unsigned *ret_seq) { assert(nl); assert(m); - + m->nlmsg_seq = nl->seq++; m->nlmsg_flags |= NLM_F_ACK; diff --git a/avahi-core/netlink.h b/avahi-core/netlink.h index 8f2f8cb..0d0b8a2 100644 --- a/avahi-core/netlink.h +++ b/avahi-core/netlink.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-core/prioq-test.c b/avahi-core/prioq-test.c index d85a222..3d85b78 100644 --- a/avahi-core/prioq-test.c +++ b/avahi-core/prioq-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 @@ -69,7 +69,7 @@ static void rec(AvahiPrioQueueNode *n) { assert(n->parent->right == NULL); } - + if (n->parent) { int a = POINTER_TO_INT(n->parent->data), b = POINTER_TO_INT(n->data); if (a > b) { @@ -101,12 +101,12 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { assert(q->n_nodes == q2->n_nodes); printf("%i\n", POINTER_TO_INT(((AvahiPrioQueueNode*)q2->root->data)->data)); - + avahi_prio_queue_remove(q, q2->root->data); avahi_prio_queue_remove(q2, q2->root); } - + /* prev = 0; */ /* while (q->root) { */ /* int v = GPOINTER_TO_INT(q->root->data); */ diff --git a/avahi-core/prioq.c b/avahi-core/prioq.c index 8d91d87..243a410 100644 --- a/avahi-core/prioq.c +++ b/avahi-core/prioq.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,11 +36,11 @@ AvahiPrioQueue* avahi_prio_queue_new(AvahiPQCompareFunc compare) { if (!(q = avahi_new(AvahiPrioQueue, 1))) return NULL; /* OOM */ - + q->root = q->last = NULL; q->n_nodes = 0; q->compare = compare; - + return q; } @@ -64,7 +64,7 @@ static AvahiPrioQueueNode* get_node_at_xy(AvahiPrioQueue *q, unsigned x, unsigne for (r = 0; r < y; r++) { assert(n); - + if ((x >> (y-r-1)) & 1) n = n->right; else @@ -91,7 +91,7 @@ static void exchange_nodes(AvahiPrioQueue *q, AvahiPrioQueueNode *a, AvahiPrioQu if (a->parent == b) { /* B is parent of A */ - + p = b->parent; b->parent = a; @@ -113,7 +113,7 @@ static void exchange_nodes(AvahiPrioQueue *q, AvahiPrioQueueNode *a, AvahiPrioQu a->right->parent = a; if ((b->right = r)) b->right->parent = b; - + } else { if ((b->right = a->right)) b->right->parent = b; @@ -127,7 +127,7 @@ static void exchange_nodes(AvahiPrioQueue *q, AvahiPrioQueueNode *a, AvahiPrioQu } } else if (b->parent == a) { /* A ist parent of B */ - + p = a->parent; a->parent = b; @@ -162,7 +162,7 @@ static void exchange_nodes(AvahiPrioQueue *q, AvahiPrioQueueNode *a, AvahiPrioQu } } else { AvahiPrioQueueNode *apl = NULL, *bpl = NULL; - + /* Swap parents */ ap = a->parent; bp = b->parent; @@ -171,15 +171,15 @@ static void exchange_nodes(AvahiPrioQueue *q, AvahiPrioQueueNode *a, AvahiPrioQu apl = ap->left; if (bp) bpl = bp->left; - + if ((a->parent = bp)) { if (bpl == b) bp->left = a; - else + else bp->right = a; } else q->root = a; - + if ((b->parent = ap)) { if (apl == a) ap->left = b; @@ -189,8 +189,8 @@ static void exchange_nodes(AvahiPrioQueue *q, AvahiPrioQueueNode *a, AvahiPrioQu q->root = b; /* Swap children */ - l = a->left; - r = a->right; + l = a->left; + r = a->right; if ((a->left = b->left)) a->left->parent = a; @@ -204,7 +204,7 @@ static void exchange_nodes(AvahiPrioQueue *q, AvahiPrioQueueNode *a, AvahiPrioQu if ((b->right = r)) b->right->parent = b; } - + /* Swap siblings */ ap = a->prev; an = a->next; bp = b->prev; bn = b->next; @@ -221,7 +221,7 @@ static void exchange_nodes(AvahiPrioQueue *q, AvahiPrioQueueNode *a, AvahiPrioQu if ((b->prev = ap)) b->prev->next = b; - + } else if (b->next == a) { /* B is predecessor of A */ a->next = b; @@ -240,15 +240,15 @@ static void exchange_nodes(AvahiPrioQueue *q, AvahiPrioQueueNode *a, AvahiPrioQu if ((a->prev = bp)) a->prev->next = a; - + if ((a->next = bn)) a->next->prev = a; else q->last = a; - + if ((b->prev = ap)) b->prev->next = b; - + if ((b->next = an)) b->next->prev = b; else @@ -295,14 +295,14 @@ AvahiPrioQueueNode* avahi_prio_queue_put(AvahiPrioQueue *q, void* data) { if (!(n = avahi_new(AvahiPrioQueueNode, 1))) return NULL; /* OOM */ - + n->queue = q; n->data = data; if (q->last) { assert(q->root); assert(q->n_nodes); - + n->y = q->last->y; n->x = q->last->x+1; @@ -313,7 +313,7 @@ AvahiPrioQueueNode* avahi_prio_queue_put(AvahiPrioQueue *q, void* data) { q->last->next = n; n->prev = q->last; - + assert(n->y > 0); n->parent = get_node_at_xy(q, n->x/2, n->y-1); @@ -324,7 +324,7 @@ AvahiPrioQueueNode* avahi_prio_queue_put(AvahiPrioQueue *q, void* data) { } else { assert(!q->root); assert(!q->n_nodes); - + n->y = n->x = 0; q->root = n; n->prev = n->parent = NULL; @@ -358,7 +358,7 @@ void avahi_prio_queue_remove(AvahiPrioQueue *q, AvahiPrioQueueNode *n) { assert(!n->right); q->last = n->prev; - + if (n->prev) { n->prev->next = NULL; assert(n->parent); diff --git a/avahi-core/prioq.h b/avahi-core/prioq.h index ace92f6..bf122fb 100644 --- a/avahi-core/prioq.h +++ b/avahi-core/prioq.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-core/probe-sched.c b/avahi-core/probe-sched.c index 106bb81..15bc6a6 100644 --- a/avahi-core/probe-sched.c +++ b/avahi-core/probe-sched.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,13 +41,13 @@ typedef struct AvahiProbeJob AvahiProbeJob; struct AvahiProbeJob { AvahiProbeScheduler *scheduler; AvahiTimeEvent *time_event; - + int chosen; /* Use for packet assembling */ int done; struct timeval delivery; AvahiRecord *record; - + AVAHI_LLIST_FIELDS(AvahiProbeJob, jobs); }; @@ -61,7 +61,7 @@ struct AvahiProbeScheduler { static AvahiProbeJob* job_new(AvahiProbeScheduler *s, AvahiRecord *record, int done) { AvahiProbeJob *pj; - + assert(s); assert(record); @@ -69,7 +69,7 @@ static AvahiProbeJob* job_new(AvahiProbeScheduler *s, AvahiRecord *record, int d avahi_log_error(__FILE__": Out of memory"); return NULL; /* OOM */ } - + pj->scheduler = s; pj->record = avahi_record_ref(record); pj->time_event = NULL; @@ -138,13 +138,13 @@ AvahiProbeScheduler *avahi_probe_scheduler_new(AvahiInterface *i) { avahi_log_error(__FILE__": Out of memory"); return NULL; } - + s->interface = i; s->time_event_queue = i->monitor->server->time_event_queue; AVAHI_LLIST_HEAD_INIT(AvahiProbeJob, s->jobs); AVAHI_LLIST_HEAD_INIT(AvahiProbeJob, s->history); - + return s; } @@ -157,13 +157,13 @@ void avahi_probe_scheduler_free(AvahiProbeScheduler *s) { void avahi_probe_scheduler_clear(AvahiProbeScheduler *s) { assert(s); - + while (s->jobs) job_free(s, s->jobs); while (s->history) job_free(s, s->history); } - + static int packet_add_probe_query(AvahiProbeScheduler *s, AvahiDnsPacket *p, AvahiProbeJob *pj) { size_t size; AvahiKey *k; @@ -174,7 +174,7 @@ static int packet_add_probe_query(AvahiProbeScheduler *s, AvahiDnsPacket *p, Ava assert(pj); assert(!pj->chosen); - + /* Estimate the size for this record */ size = avahi_key_get_estimate_size(pj->record->key) + @@ -187,7 +187,7 @@ static int packet_add_probe_query(AvahiProbeScheduler *s, AvahiDnsPacket *p, Ava /* Create the probe query */ if (!(k = avahi_key_new(pj->record->key->name, pj->record->key->clazz, AVAHI_DNS_TYPE_ANY))) return 0; /* OOM */ - + b = !!avahi_dns_packet_append_key(p, k, 0); assert(b); @@ -202,7 +202,7 @@ static int packet_add_probe_query(AvahiProbeScheduler *s, AvahiDnsPacket *p, Ava /* Does the record match the probe? */ if (k->clazz != pj->record->key->clazz || !avahi_domain_equal(k->name, pj->record->key->name)) continue; - + /* This job wouldn't fit in */ if (avahi_record_get_estimate_size(pj->record) > avahi_dns_packet_space(p)) break; @@ -212,7 +212,7 @@ static int packet_add_probe_query(AvahiProbeScheduler *s, AvahiDnsPacket *p, Ava } avahi_key_unref(k); - + return 1; } @@ -234,7 +234,7 @@ static void elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* data) { if (!(p = avahi_dns_packet_new_query(s->interface->hardware->mtu))) return; /* OOM */ n = 1; - + /* Add the import probe */ if (!packet_add_probe_query(s, p, pj)) { size_t size; @@ -249,7 +249,7 @@ static void elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* data) { avahi_key_get_estimate_size(pj->record->key) + avahi_record_get_estimate_size(pj->record) + AVAHI_DNS_PACKET_HEADER_SIZE; - + if (!(p = avahi_dns_packet_new_query(size + AVAHI_DNS_PACKET_EXTRA_SIZE))) return; /* OOM */ @@ -257,7 +257,7 @@ static void elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* data) { avahi_dns_packet_free(p); return; /* OOM */ } - + b = avahi_dns_packet_append_key(p, k, 0) && avahi_dns_packet_append_record(p, pj->record, 0, 0); avahi_key_unref(k); @@ -266,8 +266,8 @@ static void elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* data) { avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_QDCOUNT, 1); avahi_interface_send_packet(s->interface, p); } else - avahi_log_warn("Probe record too large, cannot send"); - + avahi_log_warn("Probe record too large, cannot send"); + avahi_dns_packet_free(p); job_mark_done(s, pj); @@ -279,10 +279,10 @@ static void elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* data) { if (pj->chosen) continue; - + if (!packet_add_probe_query(s, p, pj)) break; - + n++; } @@ -304,15 +304,15 @@ static void elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* data) { /* Unmark all following jobs */ for (; pj; pj = pj->jobs_next) pj->chosen = 0; - + break; } job_mark_done(s, pj); - + n ++; } - + avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_NSCOUNT, n); /* Send it now */ @@ -328,7 +328,7 @@ static AvahiProbeJob* find_scheduled_job(AvahiProbeScheduler *s, AvahiRecord *re for (pj = s->jobs; pj; pj = pj->jobs_next) { assert(!pj->done); - + if (avahi_record_equal_no_ttl(pj->record, record)) return pj; } @@ -338,7 +338,7 @@ static AvahiProbeJob* find_scheduled_job(AvahiProbeScheduler *s, AvahiRecord *re static AvahiProbeJob* find_history_job(AvahiProbeScheduler *s, AvahiRecord *record) { AvahiProbeJob *pj; - + assert(s); assert(record); @@ -353,7 +353,7 @@ static AvahiProbeJob* find_history_job(AvahiProbeScheduler *s, AvahiRecord *reco job_free(s, pj); return NULL; } - + return pj; } } @@ -364,7 +364,7 @@ static AvahiProbeJob* find_history_job(AvahiProbeScheduler *s, AvahiRecord *reco int avahi_probe_scheduler_post(AvahiProbeScheduler *s, AvahiRecord *record, int immediately) { AvahiProbeJob *pj; struct timeval tv; - + assert(s); assert(record); assert(!avahi_key_is_pattern(record->key)); @@ -387,11 +387,11 @@ int avahi_probe_scheduler_post(AvahiProbeScheduler *s, AvahiRecord *record, int /* Create a new job and schedule it */ if (!(pj = job_new(s, record, 0))) return 0; /* OOM */ - + pj->delivery = tv; pj->time_event = avahi_time_event_new(s->time_event_queue, &pj->delivery, elapse_callback, pj); - + /* avahi_log_debug("Accepted new probe job."); */ return 1; diff --git a/avahi-core/probe-sched.h b/avahi-core/probe-sched.h index 3af1319..bb43399 100644 --- a/avahi-core/probe-sched.h +++ b/avahi-core/probe-sched.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-core/publish.h b/avahi-core/publish.h index 77c49af..fde8653 100644 --- a/avahi-core/publish.h +++ b/avahi-core/publish.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 @@ -83,7 +83,7 @@ int avahi_server_add( AvahiProtocol protocol, /**< A protocol family to attach this record to. One of the AVAHI_PROTO_xxx constants. Use AVAHI_PROTO_UNSPEC to make this record available on all protocols (wich means on both IPv4 and IPv6). */ AvahiPublishFlags flags, /**< Special flags for this record */ AvahiRecord *r /**< The record to add. This function increases the reference counter of this object. */); - + /** Add an IP address mapping to the server. This will add both the * host-name-to-address and the reverse mapping to the server. See * avahi_server_add() for more information. If adding one of the RRs @@ -114,7 +114,7 @@ int avahi_server_add_service( AvahiPublishFlags flags, const char *name, /**< Service name, e.g. "Lennart's Files" */ const char *type, /**< DNS-SD type, e.g. "_http._tcp" */ - const char *domain, + const char *domain, const char *host, /**< Host name where this servcie resides, or NULL if on the local host */ uint16_t port, /**< Port number of the service */ ... /**< Text records, terminated by NULL */) AVAHI_GCC_SENTINEL; @@ -152,9 +152,9 @@ int avahi_server_update_service_txt_strlst( AvahiIfIndex interface, AvahiProtocol protocol, AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, + const char *name, + const char *type, + const char *domain, AvahiStringList *strlst); /** Update the TXT record for a service with the NULL termonate list of strings */ @@ -164,9 +164,9 @@ int avahi_server_update_service_txt( AvahiIfIndex interface, AvahiProtocol protocol, AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, + const char *name, + const char *type, + const char *domain, ...) AVAHI_GCC_SENTINEL; /** Check if there is a service locally defined and return the entry group it is attached to. Returns NULL if the service isn't local*/ diff --git a/avahi-core/querier-test.c b/avahi-core/querier-test.c index 1c28ea0..21fb9ed 100644 --- a/avahi-core/querier-test.c +++ b/avahi-core/querier-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 @@ -73,7 +73,7 @@ static void create_second_service_browser(AvahiTimeout *timeout, AVAHI_GCC_UNUSE service_browser2 = avahi_s_service_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, SERVICE_TYPE, DOMAIN, 0, sb_callback, NULL); assert(service_browser2); - + poll_api->timeout_free(timeout); } @@ -84,10 +84,10 @@ static void quit(AVAHI_GCC_UNUSED AvahiTimeout *timeout, AVAHI_GCC_UNUSED void * int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { struct timeval tv; AvahiServerConfig config; - + simple_poll = avahi_simple_poll_new(); assert(simple_poll); - + poll_api = avahi_simple_poll_get(simple_poll); assert(poll_api); @@ -100,25 +100,25 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { avahi_address_parse("192.168.50.1", AVAHI_PROTO_UNSPEC, &config.wide_area_servers[0]); config.n_wide_area_servers = 1; config.enable_wide_area = 1; - + server = avahi_server_new(poll_api, &config, NULL, NULL, NULL); assert(server); avahi_server_config_free(&config); service_browser1 = avahi_s_service_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, SERVICE_TYPE, DOMAIN, 0, sb_callback, NULL); assert(service_browser1); - + poll_api->timeout_new(poll_api, avahi_elapse_time(&tv, 10000, 0), create_second_service_browser, NULL); poll_api->timeout_new(poll_api, avahi_elapse_time(&tv, 60000, 0), quit, NULL); - + for (;;) if (avahi_simple_poll_iterate(simple_poll, -1) != 0) break; avahi_server_free(server); avahi_simple_poll_free(simple_poll); - + return 0; } diff --git a/avahi-core/querier.c b/avahi-core/querier.c index 8a230cd..90eca37 100644 --- a/avahi-core/querier.c +++ b/avahi-core/querier.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 @@ -47,7 +47,7 @@ struct AvahiQuerier { unsigned post_id; int post_id_valid; - + AVAHI_LLIST_FIELDS(AvahiQuerier, queriers); }; @@ -59,14 +59,14 @@ void avahi_querier_free(AvahiQuerier *q) { avahi_key_unref(q->key); avahi_time_event_free(q->time_event); - + avahi_free(q); } static void querier_elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void *userdata) { AvahiQuerier *q = userdata; struct timeval tv; - + assert(q); if (q->n_used <= 0) { @@ -84,15 +84,15 @@ static void querier_elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void *us /* The queue accepted our query. We store the query id here, * that allows us to drop the query at a later point if the * query is very short-lived. */ - + q->post_id_valid = 1; } q->sec_delay *= 2; - + if (q->sec_delay >= 60*60) /* 1h */ q->sec_delay = 60*60; - + avahi_elapse_time(&tv, q->sec_delay*1000, 0); avahi_time_event_update(q->time_event, &tv); } @@ -100,12 +100,12 @@ static void querier_elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void *us void avahi_querier_add(AvahiInterface *i, AvahiKey *key, struct timeval *ret_ctime) { AvahiQuerier *q; struct timeval tv; - + assert(i); assert(key); - + if ((q = avahi_hashmap_lookup(i->queriers_by_key, key))) { - + /* Someone is already browsing for records of this RR key */ q->n_used++; @@ -120,7 +120,7 @@ void avahi_querier_add(AvahiInterface *i, AvahiKey *key, struct timeval *ret_cti /* No one is browsing for this RR key, so we add a new querier */ if (!(q = avahi_new(AvahiQuerier, 1))) return; /* OOM */ - + q->key = avahi_key_ref(key); q->interface = i; q->n_used = 1; @@ -185,7 +185,7 @@ static void remove_querier_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, void avahi_querier_remove_for_all(AvahiServer *s, AvahiIfIndex idx, AvahiProtocol protocol, AvahiKey *key) { assert(s); assert(key); - + avahi_interface_monitor_walk(s->monitor, idx, protocol, remove_querier_callback, key); } @@ -196,7 +196,7 @@ struct cbdata { static void add_querier_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata) { struct cbdata *cbdata = userdata; - + assert(m); assert(i); assert(cbdata); @@ -212,7 +212,7 @@ static void add_querier_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, vo void avahi_querier_add_for_all(AvahiServer *s, AvahiIfIndex idx, AvahiProtocol protocol, AvahiKey *key, struct timeval *ret_ctime) { struct cbdata cbdata; - + assert(s); assert(key); @@ -221,13 +221,13 @@ void avahi_querier_add_for_all(AvahiServer *s, AvahiIfIndex idx, AvahiProtocol p if (ret_ctime) ret_ctime->tv_sec = ret_ctime->tv_usec = 0; - + avahi_interface_monitor_walk(s->monitor, idx, protocol, add_querier_callback, &cbdata); } int avahi_querier_shall_refresh_cache(AvahiInterface *i, AvahiKey *key) { AvahiQuerier *q; - + assert(i); assert(key); @@ -237,19 +237,19 @@ int avahi_querier_shall_refresh_cache(AvahiInterface *i, AvahiKey *key) { /* This key is currently not subscribed at all, so no cache * refresh is needed */ return 0; - + if (q->n_used <= 0) { /* If this is an entry nobody references right now, don't * consider it "existing". */ - + /* Remove this querier since it is referenced by nobody * and the cached data will soon be out of date */ avahi_querier_free(q); /* Tell the cache that no refresh is needed */ return 0; - + } else { struct timeval tv; @@ -266,6 +266,6 @@ int avahi_querier_shall_refresh_cache(AvahiInterface *i, AvahiKey *key) { void avahi_querier_free_all(AvahiInterface *i) { assert(i); - while (i->queriers) + while (i->queriers) avahi_querier_free(i->queriers); } diff --git a/avahi-core/querier.h b/avahi-core/querier.h index 3f4eead..c942aef 100644 --- a/avahi-core/querier.h +++ b/avahi-core/querier.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-core/query-sched.c b/avahi-core/query-sched.c index 0319b02..5cad11b 100644 --- a/avahi-core/query-sched.c +++ b/avahi-core/query-sched.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 @@ -40,10 +40,10 @@ typedef struct AvahiKnownAnswer AvahiKnownAnswer; struct AvahiQueryJob { unsigned id; int n_posted; - + AvahiQueryScheduler *scheduler; AvahiTimeEvent *time_event; - + int done; struct timeval delivery; @@ -56,7 +56,7 @@ struct AvahiQueryJob { * entries) most of the time, but this might be a wrong * assumption, especially on setups where traffic reflection is * involved. */ - + AVAHI_LLIST_FIELDS(AvahiQueryJob, jobs); }; @@ -80,7 +80,7 @@ struct AvahiQueryScheduler { static AvahiQueryJob* job_new(AvahiQueryScheduler *s, AvahiKey *key, int done) { AvahiQueryJob *qj; - + assert(s); assert(key); @@ -88,14 +88,14 @@ static AvahiQueryJob* job_new(AvahiQueryScheduler *s, AvahiKey *key, int done) { avahi_log_error(__FILE__": Out of memory"); return NULL; } - + qj->scheduler = s; qj->key = avahi_key_ref(key); qj->time_event = NULL; qj->n_posted = 1; qj->id = s->next_id++; - - if ((qj->done = done)) + + if ((qj->done = done)) AVAHI_LLIST_PREPEND(AvahiQueryJob, jobs, s->history, qj); else AVAHI_LLIST_PREPEND(AvahiQueryJob, jobs, s->jobs, qj); @@ -158,11 +158,11 @@ AvahiQueryScheduler *avahi_query_scheduler_new(AvahiInterface *i) { avahi_log_error(__FILE__": Out of memory"); return NULL; /* OOM */ } - + s->interface = i; s->time_event_queue = i->monitor->server->time_event_queue; s->next_id = 0; - + AVAHI_LLIST_HEAD_INIT(AvahiQueryJob, s->jobs); AVAHI_LLIST_HEAD_INIT(AvahiQueryJob, s->history); AVAHI_LLIST_HEAD_INIT(AvahiKnownAnswer, s->known_answers); @@ -180,7 +180,7 @@ void avahi_query_scheduler_free(AvahiQueryScheduler *s) { void avahi_query_scheduler_clear(AvahiQueryScheduler *s) { assert(s); - + while (s->jobs) job_free(s, s->jobs); while (s->history) @@ -190,7 +190,7 @@ void avahi_query_scheduler_clear(AvahiQueryScheduler *s) { static void* known_answer_walk_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEntry *e, void* userdata) { AvahiQueryScheduler *s = userdata; AvahiKnownAnswer *ka; - + assert(c); assert(pattern); assert(e); @@ -198,12 +198,12 @@ static void* known_answer_walk_callback(AvahiCache *c, AvahiKey *pattern, AvahiC if (avahi_cache_entry_half_ttl(c, e)) return NULL; - + if (!(ka = avahi_new0(AvahiKnownAnswer, 1))) { avahi_log_error(__FILE__": Out of memory"); return NULL; } - + ka->scheduler = s; ka->record = avahi_record_ref(e->record); @@ -221,7 +221,7 @@ static int packet_add_query_job(AvahiQueryScheduler *s, AvahiDnsPacket *p, Avahi /* Add all matching known answers to the list */ avahi_cache_walk(s->interface->cache, qj->key, known_answer_walk_callback, s); - + job_mark_done(s, qj); return 1; @@ -234,7 +234,7 @@ static void append_known_answers_and_send(AvahiQueryScheduler *s, AvahiDnsPacket assert(p); n = 0; - + while ((ka = s->known_answers)) { int too_large = 0; @@ -266,7 +266,7 @@ static void append_known_answers_and_send(AvahiQueryScheduler *s, AvahiDnsPacket if (!too_large) n++; } - + avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_ANCOUNT, n); avahi_interface_send_packet(s->interface, p); avahi_dns_packet_free(p); @@ -289,10 +289,10 @@ static void elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* data) { } assert(!s->known_answers); - + if (!(p = avahi_dns_packet_new_query(s->interface->hardware->mtu))) return; /* OOM */ - + b = packet_add_query_job(s, p, qj); assert(b); /* An query must always fit in */ n = 1; @@ -320,7 +320,7 @@ static AvahiQueryJob* find_scheduled_job(AvahiQueryScheduler *s, AvahiKey *key) for (qj = s->jobs; qj; qj = qj->jobs_next) { assert(!qj->done); - + if (avahi_key_equal(qj->key, key)) return qj; } @@ -330,7 +330,7 @@ static AvahiQueryJob* find_scheduled_job(AvahiQueryScheduler *s, AvahiKey *key) static AvahiQueryJob* find_history_job(AvahiQueryScheduler *s, AvahiKey *key) { AvahiQueryJob *qj; - + assert(s); assert(key); @@ -345,7 +345,7 @@ static AvahiQueryJob* find_history_job(AvahiQueryScheduler *s, AvahiKey *key) { job_free(s, qj); return NULL; } - + return qj; } } @@ -356,13 +356,13 @@ static AvahiQueryJob* find_history_job(AvahiQueryScheduler *s, AvahiKey *key) { int avahi_query_scheduler_post(AvahiQueryScheduler *s, AvahiKey *key, int immediately, unsigned *ret_id) { struct timeval tv; AvahiQueryJob *qj; - + assert(s); assert(key); if ((qj = find_history_job(s, key))) return 0; - + avahi_elapse_time(&tv, immediately ? 0 : AVAHI_QUERY_DEFER_MSEC, 0); if ((qj = find_scheduled_job(s, key))) { @@ -376,25 +376,25 @@ int avahi_query_scheduler_post(AvahiQueryScheduler *s, AvahiKey *key, int immedi } qj->n_posted++; - + } else { if (!(qj = job_new(s, key, 0))) return 0; /* OOM */ - + qj->delivery = tv; qj->time_event = avahi_time_event_new(s->time_event_queue, &qj->delivery, elapse_callback, qj); } if (ret_id) *ret_id = qj->id; - + return 1; } void avahi_query_scheduler_incoming(AvahiQueryScheduler *s, AvahiKey *key) { AvahiQueryJob *qj; - + assert(s); assert(key); @@ -412,14 +412,14 @@ void avahi_query_scheduler_incoming(AvahiQueryScheduler *s, AvahiKey *key) { if (!(qj = find_history_job(s, key))) if (!(qj = job_new(s, key, 1))) return; /* OOM */ - + gettimeofday(&qj->delivery, NULL); job_set_elapse_time(s, qj, AVAHI_QUERY_HISTORY_MSEC, 0); } int avahi_query_scheduler_withdraw_by_id(AvahiQueryScheduler *s, unsigned id) { AvahiQueryJob *qj; - + assert(s); /* Very short lived queries can withdraw an already scheduled item @@ -428,7 +428,7 @@ int avahi_query_scheduler_withdraw_by_id(AvahiQueryScheduler *s, unsigned id) { for (qj = s->jobs; qj; qj = qj->jobs_next) { assert(!qj->done); - + if (qj->id == id) { /* Entry found */ @@ -441,7 +441,7 @@ int avahi_query_scheduler_withdraw_by_id(AvahiQueryScheduler *s, unsigned id) { * case since there should exist only one querier per * key, but there are exceptions, notably reflected * traffic.) */ - + job_free(s, qj); return 1; } diff --git a/avahi-core/query-sched.h b/avahi-core/query-sched.h index 5238558..1accc05 100644 --- a/avahi-core/query-sched.h +++ b/avahi-core/query-sched.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-core/resolve-address.c b/avahi-core/resolve-address.c index 25d21ac..140fc3c 100644 --- a/avahi-core/resolve-address.c +++ b/avahi-core/resolve-address.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,7 +37,7 @@ struct AvahiSAddressResolver { AvahiServer *server; AvahiAddress address; - + AvahiSRecordBrowser *record_browser; AvahiSAddressResolverCallback callback; @@ -58,7 +58,7 @@ struct AvahiSAddressResolver { static void finish(AvahiSAddressResolver *r, AvahiResolverEvent event) { assert(r); - + if (r->time_event) { avahi_time_event_free(r->time_event); r->time_event = NULL; @@ -78,7 +78,7 @@ static void finish(AvahiSAddressResolver *r, AvahiResolverEvent event) { static void time_event_callback(AvahiTimeEvent *e, void *userdata) { AvahiSAddressResolver *r = userdata; - + assert(e); assert(r); @@ -105,53 +105,53 @@ static void record_browser_callback( AvahiRecord *record, AvahiLookupResultFlags flags, void* userdata) { - + AvahiSAddressResolver *r = userdata; assert(rr); assert(r); switch (event) { - case AVAHI_BROWSER_NEW: + case AVAHI_BROWSER_NEW: assert(record); assert(record->key->type == AVAHI_DNS_TYPE_PTR); - + if (r->interface > 0 && interface != r->interface) return; - + if (r->protocol != AVAHI_PROTO_UNSPEC && protocol != r->protocol) return; - + if (r->interface <= 0) r->interface = interface; - + if (r->protocol == AVAHI_PROTO_UNSPEC) r->protocol = protocol; - + if (!r->ptr_record) { r->ptr_record = avahi_record_ref(record); r->flags = flags; - + finish(r, AVAHI_RESOLVER_FOUND); } break; - + case AVAHI_BROWSER_REMOVE: assert(record); assert(record->key->type == AVAHI_DNS_TYPE_PTR); - + if (r->ptr_record && avahi_record_equal_no_ttl(record, r->ptr_record)) { avahi_record_unref(r->ptr_record); r->ptr_record = NULL; r->flags = flags; - + /** Look for a replacement */ avahi_s_record_browser_restart(r->record_browser); start_timeout(r); } break; - + case AVAHI_BROWSER_CACHE_EXHAUSTED: case AVAHI_BROWSER_ALL_FOR_NOW: break; @@ -184,7 +184,7 @@ AvahiSAddressResolver *avahi_s_address_resolver_new( AvahiLookupFlags flags, AvahiSAddressResolverCallback callback, void* userdata) { - + AvahiSAddressResolver *r; AvahiKey *k; char n[AVAHI_DOMAIN_NAME_MAX]; @@ -197,7 +197,7 @@ AvahiSAddressResolver *avahi_s_address_resolver_new( AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL); AVAHI_CHECK_VALIDITY_RETURN_NULL(server, address->proto == AVAHI_PROTO_INET || address->proto == AVAHI_PROTO_INET6, AVAHI_ERR_INVALID_PROTOCOL); AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS); - + avahi_reverse_lookup_name(address, n, sizeof(n)); if (!(k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR))) { @@ -210,7 +210,7 @@ AvahiSAddressResolver *avahi_s_address_resolver_new( avahi_key_unref(k); return NULL; } - + r->server = server; r->address = *address; r->callback = callback; @@ -236,7 +236,7 @@ AvahiSAddressResolver *avahi_s_address_resolver_new( r->retry_with_multicast = 1; } } - + r->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, r); if (!r->record_browser) { @@ -245,7 +245,7 @@ AvahiSAddressResolver *avahi_s_address_resolver_new( } start_timeout(r); - + return r; } @@ -265,6 +265,6 @@ void avahi_s_address_resolver_free(AvahiSAddressResolver *r) { if (r->key) avahi_key_unref(r->key); - + avahi_free(r); } diff --git a/avahi-core/resolve-host-name.c b/avahi-core/resolve-host-name.c index 59dc3cf..30857c8 100644 --- a/avahi-core/resolve-host-name.c +++ b/avahi-core/resolve-host-name.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 @@ struct AvahiSHostNameResolver { AvahiServer *server; char *host_name; - + AvahiSRecordBrowser *record_browser_a; AvahiSRecordBrowser *record_browser_aaaa; @@ -66,20 +66,20 @@ static void finish(AvahiSHostNameResolver *r, AvahiResolverEvent event) { switch (event) { case AVAHI_RESOLVER_FOUND: { AvahiAddress a; - + assert(r->address_record); - + switch (r->address_record->key->type) { case AVAHI_DNS_TYPE_A: a.proto = AVAHI_PROTO_INET; a.data.ipv4 = r->address_record->data.a.address; break; - + case AVAHI_DNS_TYPE_AAAA: a.proto = AVAHI_PROTO_INET6; a.data.ipv6 = r->address_record->data.aaaa.address; break; - + default: abort(); } @@ -88,9 +88,9 @@ static void finish(AvahiSHostNameResolver *r, AvahiResolverEvent event) { break; } - + case AVAHI_RESOLVER_FAILURE: - + r->callback(r, r->interface, r->protocol, event, r->host_name, NULL, r->flags, r->userdata); break; } @@ -98,7 +98,7 @@ static void finish(AvahiSHostNameResolver *r, AvahiResolverEvent event) { static void time_event_callback(AvahiTimeEvent *e, void *userdata) { AvahiSHostNameResolver *r = userdata; - + assert(e); assert(r); @@ -126,9 +126,9 @@ static void record_browser_callback( AvahiRecord *record, AvahiLookupResultFlags flags, void* userdata) { - + AvahiSHostNameResolver *r = userdata; - + assert(rr); assert(r); @@ -140,20 +140,20 @@ static void record_browser_callback( if (r->interface > 0 && interface != r->interface) return; - + if (r->protocol != AVAHI_PROTO_UNSPEC && protocol != r->protocol) return; - + if (r->interface <= 0) r->interface = interface; - + if (r->protocol == AVAHI_PROTO_UNSPEC) r->protocol = protocol; - + if (!r->address_record) { r->address_record = avahi_record_ref(record); r->flags = flags; - + finish(r, AVAHI_RESOLVER_FOUND); } @@ -169,13 +169,13 @@ static void record_browser_callback( r->flags = flags; - + /** Look for a replacement */ if (r->record_browser_aaaa) avahi_s_record_browser_restart(r->record_browser_aaaa); if (r->record_browser_a) avahi_s_record_browser_restart(r->record_browser_a); - + start_timeout(r); } @@ -189,7 +189,7 @@ static void record_browser_callback( case AVAHI_BROWSER_FAILURE: /* Stop browsers */ - + if (r->record_browser_aaaa) avahi_s_record_browser_free(r->record_browser_aaaa); if (r->record_browser_a) @@ -197,7 +197,7 @@ static void record_browser_callback( r->record_browser_a = r->record_browser_aaaa = NULL; r->flags = flags; - + finish(r, AVAHI_RESOLVER_FAILURE); break; } @@ -212,10 +212,10 @@ AvahiSHostNameResolver *avahi_s_host_name_resolver_new( AvahiLookupFlags flags, AvahiSHostNameResolverCallback callback, void* userdata) { - + AvahiSHostNameResolver *r; AvahiKey *k; - + assert(server); assert(host_name); assert(callback); @@ -230,7 +230,7 @@ AvahiSHostNameResolver *avahi_s_host_name_resolver_new( avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY); return NULL; } - + r->server = server; r->host_name = avahi_normalize_name_strdup(host_name); r->callback = callback; @@ -255,7 +255,7 @@ AvahiSHostNameResolver *avahi_s_host_name_resolver_new( if (!r->record_browser_a) goto fail; - } + } if (aprotocol == AVAHI_PROTO_INET6 || aprotocol == AVAHI_PROTO_UNSPEC) { k = avahi_key_new(host_name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_AAAA); @@ -269,7 +269,7 @@ AvahiSHostNameResolver *avahi_s_host_name_resolver_new( assert(r->record_browser_aaaa || r->record_browser_a); start_timeout(r); - + return r; fail: @@ -293,7 +293,7 @@ void avahi_s_host_name_resolver_free(AvahiSHostNameResolver *r) { if (r->address_record) avahi_record_unref(r->address_record); - + avahi_free(r->host_name); avahi_free(r); } diff --git a/avahi-core/resolve-service.c b/avahi-core/resolve-service.c index 1ad6078..48a6012 100644 --- a/avahi-core/resolve-service.c +++ b/avahi-core/resolve-service.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 @@ -54,7 +54,7 @@ struct AvahiSServiceResolver { AvahiRecord *srv_record, *txt_record, *address_record; AvahiLookupResultFlags srv_flags, txt_flags, address_flags; - + AvahiSServiceResolverCallback callback; void* userdata; AvahiLookupFlags user_flags; @@ -66,7 +66,7 @@ struct AvahiSServiceResolver { static void finish(AvahiSServiceResolver *r, AvahiResolverEvent event) { AvahiLookupResultFlags flags; - + assert(r); if (r->time_event) { @@ -78,10 +78,10 @@ static void finish(AvahiSServiceResolver *r, AvahiResolverEvent event) { r->txt_flags | r->srv_flags | r->address_flags; - + switch (event) { case AVAHI_RESOLVER_FAILURE: - + r->callback( r, r->interface, @@ -101,9 +101,9 @@ static void finish(AvahiSServiceResolver *r, AvahiResolverEvent event) { case AVAHI_RESOLVER_FOUND: { AvahiAddress a; - + assert(event == AVAHI_RESOLVER_FOUND); - + assert(r->srv_record); if (r->address_record) { @@ -112,17 +112,17 @@ static void finish(AvahiSServiceResolver *r, AvahiResolverEvent event) { a.proto = AVAHI_PROTO_INET; a.data.ipv4 = r->address_record->data.a.address; break; - + case AVAHI_DNS_TYPE_AAAA: a.proto = AVAHI_PROTO_INET6; a.data.ipv6 = r->address_record->data.aaaa.address; break; - + default: assert(0); } } - + r->callback( r, r->interface, @@ -145,7 +145,7 @@ static void finish(AvahiSServiceResolver *r, AvahiResolverEvent event) { static void time_event_callback(AvahiTimeEvent *e, void *userdata) { AvahiSServiceResolver *r = userdata; - + assert(e); assert(r); @@ -173,7 +173,7 @@ static void record_browser_callback( AvahiRecord *record, AvahiLookupResultFlags flags, void* userdata) { - + AvahiSServiceResolver *r = userdata; assert(rr); @@ -191,30 +191,30 @@ static void record_browser_callback( case AVAHI_BROWSER_NEW: { int changed = 0; assert(record); - + if (r->interface > 0 && interface > 0 && interface != r->interface) return; - + if (r->protocol != AVAHI_PROTO_UNSPEC && protocol != AVAHI_PROTO_UNSPEC && protocol != r->protocol) return; - + if (r->interface <= 0) r->interface = interface; - + if (r->protocol == AVAHI_PROTO_UNSPEC) r->protocol = protocol; - + switch (record->key->type) { case AVAHI_DNS_TYPE_SRV: if (!r->srv_record) { r->srv_record = avahi_record_ref(record); changed = 1; - + if (r->record_browser_a) { avahi_s_record_browser_free(r->record_browser_a); r->record_browser_a = NULL; } - + if (r->record_browser_aaaa) { avahi_s_record_browser_free(r->record_browser_aaaa); r->record_browser_aaaa = NULL; @@ -226,8 +226,8 @@ static void record_browser_callback( AvahiKey *k = avahi_key_new(r->srv_record->data.srv.name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_A); r->record_browser_a = avahi_s_record_browser_new(r->server, r->interface, r->protocol, k, r->user_flags & ~(AVAHI_LOOKUP_NO_TXT|AVAHI_LOOKUP_NO_ADDRESS), record_browser_callback, r); avahi_key_unref(k); - } - + } + if (r->address_protocol == AVAHI_PROTO_INET6 || r->address_protocol == AVAHI_PROTO_UNSPEC) { AvahiKey *k = avahi_key_new(r->srv_record->data.srv.name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_AAAA); r->record_browser_aaaa = avahi_s_record_browser_new(r->server, r->interface, r->protocol, k, r->user_flags & ~(AVAHI_LOOKUP_NO_TXT|AVAHI_LOOKUP_NO_ADDRESS), record_browser_callback, r); @@ -236,7 +236,7 @@ static void record_browser_callback( } } break; - + case AVAHI_DNS_TYPE_TXT: assert(!(r->user_flags & AVAHI_LOOKUP_NO_TXT)); @@ -246,7 +246,7 @@ static void record_browser_callback( changed = 1; } break; - + case AVAHI_DNS_TYPE_A: case AVAHI_DNS_TYPE_AAAA: @@ -257,7 +257,7 @@ static void record_browser_callback( changed = 1; } break; - + default: abort(); } @@ -272,14 +272,14 @@ static void record_browser_callback( break; } - + case AVAHI_BROWSER_REMOVE: assert(record); switch (record->key->type) { case AVAHI_DNS_TYPE_SRV: - + if (r->srv_record && avahi_record_equal_no_ttl(record, r->srv_record)) { avahi_record_unref(r->srv_record); r->srv_record = NULL; @@ -288,42 +288,42 @@ static void record_browser_callback( avahi_s_record_browser_free(r->record_browser_a); r->record_browser_a = NULL; } - + if (r->record_browser_aaaa) { avahi_s_record_browser_free(r->record_browser_aaaa); r->record_browser_aaaa = NULL; } - + /** Look for a replacement */ avahi_s_record_browser_restart(r->record_browser_srv); start_timeout(r); } - + break; - + case AVAHI_DNS_TYPE_TXT: - + assert(!(r->user_flags & AVAHI_LOOKUP_NO_TXT)); - + if (r->txt_record && avahi_record_equal_no_ttl(record, r->txt_record)) { avahi_record_unref(r->txt_record); r->txt_record = NULL; - + /** Look for a replacement */ avahi_s_record_browser_restart(r->record_browser_txt); start_timeout(r); } break; - + case AVAHI_DNS_TYPE_A: case AVAHI_DNS_TYPE_AAAA: - + assert(!(r->user_flags & AVAHI_LOOKUP_NO_ADDRESS)); - + if (r->address_record && avahi_record_equal_no_ttl(record, r->address_record)) { avahi_record_unref(r->address_record); r->address_record = NULL; - + /** Look for a replacement */ if (r->record_browser_aaaa) avahi_s_record_browser_restart(r->record_browser_aaaa); @@ -332,7 +332,7 @@ static void record_browser_callback( start_timeout(r); } break; - + default: abort(); } @@ -344,7 +344,7 @@ static void record_browser_callback( break; case AVAHI_BROWSER_FAILURE: - + if (rr == r->record_browser_a && r->record_browser_aaaa) { /* We were looking for both AAAA and A, and the other query is still living, so we'll not die */ avahi_s_record_browser_free(r->record_browser_a); @@ -360,7 +360,7 @@ static void record_browser_callback( } /* Hmm, everything's lost, tell the user */ - + if (r->record_browser_srv) avahi_s_record_browser_free(r->record_browser_srv); if (r->record_browser_txt) @@ -388,12 +388,12 @@ AvahiSServiceResolver *avahi_s_service_resolver_new( AvahiLookupFlags flags, AvahiSServiceResolverCallback callback, void* userdata) { - + AvahiSServiceResolver *r; AvahiKey *k; char n[AVAHI_DOMAIN_NAME_MAX]; int ret; - + assert(server); assert(type); assert(callback); @@ -413,12 +413,12 @@ AvahiSServiceResolver *avahi_s_service_resolver_new( avahi_server_set_errno(server, ret); return NULL; } - + if (!(r = avahi_new(AvahiSServiceResolver, 1))) { avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY); return NULL; } - + r->server = server; r->service_name = avahi_strdup(name); r->service_type = avahi_normalize_name_strdup(type); @@ -448,7 +448,7 @@ AvahiSServiceResolver *avahi_s_service_resolver_new( k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_TXT); r->record_browser_txt = avahi_s_record_browser_new(server, interface, protocol, k, flags & ~(AVAHI_LOOKUP_NO_TXT|AVAHI_LOOKUP_NO_ADDRESS), record_browser_callback, r); avahi_key_unref(k); - + if (!r->record_browser_txt) { avahi_s_service_resolver_free(r); return NULL; @@ -456,7 +456,7 @@ AvahiSServiceResolver *avahi_s_service_resolver_new( } start_timeout(r); - + return r; } @@ -467,7 +467,7 @@ void avahi_s_service_resolver_free(AvahiSServiceResolver *r) { if (r->time_event) avahi_time_event_free(r->time_event); - + if (r->record_browser_srv) avahi_s_record_browser_free(r->record_browser_srv); if (r->record_browser_txt) @@ -483,7 +483,7 @@ void avahi_s_service_resolver_free(AvahiSServiceResolver *r) { avahi_record_unref(r->txt_record); if (r->address_record) avahi_record_unref(r->address_record); - + avahi_free(r->service_name); avahi_free(r->service_type); avahi_free(r->domain_name); diff --git a/avahi-core/response-sched.c b/avahi-core/response-sched.c index b194ef3..74bb7b0 100644 --- a/avahi-core/response-sched.c +++ b/avahi-core/response-sched.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 @@ -55,7 +55,7 @@ typedef enum { struct AvahiResponseJob { AvahiResponseScheduler *scheduler; AvahiTimeEvent *time_event; - + AvahiResponseJobState state; struct timeval delivery; @@ -63,7 +63,7 @@ struct AvahiResponseJob { int flush_cache; AvahiAddress querier; int querier_valid; - + AVAHI_LLIST_FIELDS(AvahiResponseJob, jobs); }; @@ -78,7 +78,7 @@ struct AvahiResponseScheduler { static AvahiResponseJob* job_new(AvahiResponseScheduler *s, AvahiRecord *record, AvahiResponseJobState state) { AvahiResponseJob *rj; - + assert(s); assert(record); @@ -86,14 +86,14 @@ static AvahiResponseJob* job_new(AvahiResponseScheduler *s, AvahiRecord *record, avahi_log_error(__FILE__": Out of memory"); return NULL; } - + rj->scheduler = s; rj->record = avahi_record_ref(record); rj->time_event = NULL; rj->flush_cache = 0; rj->querier_valid = 0; - - if ((rj->state = state) == AVAHI_SCHEDULED) + + if ((rj->state = state) == AVAHI_SCHEDULED) AVAHI_LLIST_PREPEND(AvahiResponseJob, jobs, s->jobs, rj); else if (rj->state == AVAHI_DONE) AVAHI_LLIST_PREPEND(AvahiResponseJob, jobs, s->history, rj); @@ -161,10 +161,10 @@ AvahiResponseScheduler *avahi_response_scheduler_new(AvahiInterface *i) { avahi_log_error(__FILE__": Out of memory"); return NULL; } - + s->interface = i; s->time_event_queue = i->monitor->server->time_event_queue; - + AVAHI_LLIST_HEAD_INIT(AvahiResponseJob, s->jobs); AVAHI_LLIST_HEAD_INIT(AvahiResponseJob, s->history); AVAHI_LLIST_HEAD_INIT(AvahiResponseJob, s->suppressed); @@ -181,7 +181,7 @@ void avahi_response_scheduler_free(AvahiResponseScheduler *s) { void avahi_response_scheduler_clear(AvahiResponseScheduler *s) { assert(s); - + while (s->jobs) job_free(s, s->jobs); while (s->history) @@ -192,7 +192,7 @@ void avahi_response_scheduler_clear(AvahiResponseScheduler *s) { static void enumerate_aux_records_callback(AVAHI_GCC_UNUSED AvahiServer *s, AvahiRecord *r, int flush_cache, void* userdata) { AvahiResponseJob *rj = userdata; - + assert(r); assert(rj); @@ -212,7 +212,7 @@ static int packet_add_response_job(AvahiResponseScheduler *s, AvahiDnsPacket *p, * auxilliary packets, too */ avahi_server_enumerate_aux_records(s->interface->monitor->server, s->interface, rj->record, enumerate_aux_records_callback, rj); job_mark_done(s, rj); - + return 1; } @@ -232,16 +232,16 @@ static void send_response_packet(AvahiResponseScheduler *s, AvahiResponseJob *rj /* Try to fill up packet with more responses, if available */ while (s->jobs) { - + if (!packet_add_response_job(s, p, s->jobs)) break; - + n++; } - + } else { size_t size; - + avahi_dns_packet_free(p); /* OK, the packet was too small, so create one that fits */ @@ -269,7 +269,7 @@ static void elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* data) { assert(rj); - if (rj->state == AVAHI_DONE || rj->state == AVAHI_SUPPRESSED) + if (rj->state == AVAHI_DONE || rj->state == AVAHI_SUPPRESSED) job_free(rj->scheduler, rj); /* Lets drop this entry */ else send_response_packet(rj->scheduler, rj); @@ -283,7 +283,7 @@ static AvahiResponseJob* find_scheduled_job(AvahiResponseScheduler *s, AvahiReco for (rj = s->jobs; rj; rj = rj->jobs_next) { assert(rj->state == AVAHI_SCHEDULED); - + if (avahi_record_equal_no_ttl(rj->record, record)) return rj; } @@ -293,7 +293,7 @@ static AvahiResponseJob* find_scheduled_job(AvahiResponseScheduler *s, AvahiReco static AvahiResponseJob* find_history_job(AvahiResponseScheduler *s, AvahiRecord *record) { AvahiResponseJob *rj; - + assert(s); assert(record); @@ -304,13 +304,13 @@ static AvahiResponseJob* find_history_job(AvahiResponseScheduler *s, AvahiRecord /* Check whether this entry is outdated */ /* avahi_log_debug("history age: %u", (unsigned) (avahi_age(&rj->delivery)/1000)); */ - + if (avahi_age(&rj->delivery)/1000 > AVAHI_RESPONSE_HISTORY_MSEC) { /* it is outdated, so let's remove it */ job_free(s, rj); return NULL; } - + return rj; } } @@ -320,7 +320,7 @@ static AvahiResponseJob* find_history_job(AvahiResponseScheduler *s, AvahiRecord static AvahiResponseJob* find_suppressed_job(AvahiResponseScheduler *s, AvahiRecord *record, const AvahiAddress *querier) { AvahiResponseJob *rj; - + assert(s); assert(record); assert(querier); @@ -328,7 +328,7 @@ static AvahiResponseJob* find_suppressed_job(AvahiResponseScheduler *s, AvahiRec for (rj = s->suppressed; rj; rj = rj->jobs_next) { assert(rj->state == AVAHI_SUPPRESSED); assert(rj->querier_valid); - + if (avahi_record_equal_no_ttl(rj->record, record) && avahi_address_cmp(&rj->querier, querier) == 0) { /* Check whether this entry is outdated */ @@ -350,7 +350,7 @@ int avahi_response_scheduler_post(AvahiResponseScheduler *s, AvahiRecord *record AvahiResponseJob *rj; struct timeval tv; /* char *t; */ - + assert(s); assert(record); @@ -385,7 +385,7 @@ int avahi_response_scheduler_post(AvahiResponseScheduler *s, AvahiRecord *record } avahi_elapse_time(&tv, immediately ? 0 : AVAHI_RESPONSE_DEFER_MSEC, immediately ? 0 : AVAHI_RESPONSE_JITTER_MSEC); - + if ((rj = find_scheduled_job(s, record))) { /* avahi_log_debug("Response suppressed by local duplicate suppression (scheduled)"); */ @@ -416,7 +416,7 @@ int avahi_response_scheduler_post(AvahiResponseScheduler *s, AvahiRecord *record /* Create a new job and schedule it */ if (!(rj = job_new(s, record, AVAHI_SCHEDULED))) return 0; /* OOM */ - + rj->delivery = tv; rj->time_event = avahi_time_event_new(s->time_event_queue, &rj->delivery, elapse_callback, rj); rj->flush_cache = flush_cache; @@ -435,7 +435,7 @@ void avahi_response_scheduler_incoming(AvahiResponseScheduler *s, AvahiRecord *r /* This function is called whenever an incoming response was * receieved. We drop scheduled responses which match here. The * keyword is "DUPLICATE ANSWER SUPPRESION". */ - + if ((rj = find_scheduled_job(s, record))) { if ((!rj->flush_cache || flush_cache) && /* flush cache bit was set correctly */ @@ -461,20 +461,20 @@ void avahi_response_scheduler_incoming(AvahiResponseScheduler *s, AvahiRecord *r rj->flush_cache = flush_cache; rj->querier_valid = 0; - + gettimeofday(&rj->delivery, NULL); job_set_elapse_time(s, rj, AVAHI_RESPONSE_HISTORY_MSEC, 0); } void avahi_response_scheduler_suppress(AvahiResponseScheduler *s, AvahiRecord *record, const AvahiAddress *querier) { AvahiResponseJob *rj; - + assert(s); assert(record); assert(querier); if ((rj = find_scheduled_job(s, record))) { - + if (rj->querier_valid && avahi_address_cmp(querier, &rj->querier) == 0 && /* same originator */ avahi_record_is_goodbye(record) == avahi_record_is_goodbye(rj->record) && /* both goodbye packets, or both not */ record->ttl >= rj->record->ttl/2) { /* sensible TTL */ @@ -490,7 +490,7 @@ void avahi_response_scheduler_suppress(AvahiResponseScheduler *s, AvahiRecord *r /* Let's update the old entry */ avahi_record_unref(rj->record); rj->record = avahi_record_ref(record); - + } else { /* Create a new entry */ diff --git a/avahi-core/response-sched.h b/avahi-core/response-sched.h index 68c4a9d..0fe6acc 100644 --- a/avahi-core/response-sched.h +++ b/avahi-core/response-sched.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-core/rr-util.h b/avahi-core/rr-util.h index b3c35b4..0fbcf98 100644 --- a/avahi-core/rr-util.h +++ b/avahi-core/rr-util.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-core/rr.h b/avahi-core/rr.h index 2160507..94126a6 100644 --- a/avahi-core/rr.h +++ b/avahi-core/rr.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 @@ -37,8 +37,8 @@ AVAHI_C_DECL_BEGIN enum { AVAHI_DNS_TYPE_ANY = 0xFF, /**< Special query type for requesting all records */ AVAHI_DNS_TYPE_OPT = 41, /**< EDNS0 option */ - AVAHI_DNS_TYPE_TKEY = 249, - AVAHI_DNS_TYPE_TSIG = 250, + AVAHI_DNS_TYPE_TKEY = 249, + AVAHI_DNS_TYPE_TSIG = 250, AVAHI_DNS_TYPE_IXFR = 251, AVAHI_DNS_TYPE_AXFR = 252 }; @@ -67,16 +67,16 @@ typedef struct AvahiKey { typedef struct AvahiRecord { int ref; /**< Reference counter */ AvahiKey *key; /**< Reference to the query key of this record */ - + uint32_t ttl; /**< DNS TTL of this record */ union { - + struct { void* data; uint16_t size; } generic; /**< Generic record data for unknown types */ - + struct { uint16_t priority; uint16_t weight; @@ -106,7 +106,7 @@ typedef struct AvahiRecord { } aaaa; /**< Data for AAAA records */ } data; /**< Record data */ - + } AvahiRecord; /** Create a new AvahiKey object. The reference counter will be set to 1. */ @@ -121,7 +121,7 @@ void avahi_key_unref(AvahiKey *k); /** Check whether two AvahiKey object contain the same * data. AVAHI_DNS_CLASS_ANY/AVAHI_DNS_TYPE_ANY are treated like any * other class/type. */ -int avahi_key_equal(const AvahiKey *a, const AvahiKey *b); +int avahi_key_equal(const AvahiKey *a, const AvahiKey *b); /** Return a numeric hash value for a key for usage in hash tables. */ unsigned avahi_key_hash(const AvahiKey *k); @@ -152,7 +152,7 @@ char *avahi_key_to_string(const AvahiKey *k); /** Create a textual representation of the specified record, similar * in style to BIND zone file data. avahi_free() the result! */ -char *avahi_record_to_string(const AvahiRecord *r); +char *avahi_record_to_string(const AvahiRecord *r); /** Check whether two records are equal (regardless of the TTL */ int avahi_record_equal_no_ttl(const AvahiRecord *a, const AvahiRecord *b); diff --git a/avahi-core/rrlist.c b/avahi-core/rrlist.c index 915ecbb..308ecd1 100644 --- a/avahi-core/rrlist.c +++ b/avahi-core/rrlist.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 @@ -57,7 +57,7 @@ AvahiRecordList *avahi_record_list_new(void) { avahi_log_error("avahi_new() failed."); return NULL; } - + AVAHI_LLIST_HEAD_INIT(AvahiRecordListItem, l->read); AVAHI_LLIST_HEAD_INIT(AvahiRecordListItem, l->unread); @@ -76,18 +76,18 @@ static void item_free(AvahiRecordList *l, AvahiRecordListItem *i) { assert(l); assert(i); - if (i->read) + if (i->read) AVAHI_LLIST_REMOVE(AvahiRecordListItem, items, l->read, i); else AVAHI_LLIST_REMOVE(AvahiRecordListItem, items, l->unread, i); - + avahi_record_unref(i->record); avahi_free(i); } void avahi_record_list_flush(AvahiRecordList *l) { assert(l); - + while (l->read) item_free(l, l->read); while (l->unread) @@ -104,7 +104,7 @@ AvahiRecord* avahi_record_list_next(AvahiRecordList *l, int *ret_flush_cache, in return NULL; assert(!i->read); - + r = avahi_record_ref(i->record); if (ret_unicast_response) *ret_unicast_response = i->unicast_response; @@ -117,7 +117,7 @@ AvahiRecord* avahi_record_list_next(AvahiRecordList *l, int *ret_flush_cache, in AVAHI_LLIST_PREPEND(AvahiRecordListItem, items, l->read, i); i->read = 1; - + return r; } @@ -126,7 +126,7 @@ static AvahiRecordListItem *get(AvahiRecordList *l, AvahiRecord *r) { assert(l); assert(r); - + for (i = l->read; i; i = i->items_next) if (avahi_record_equal_no_ttl(i->record, r)) return i; @@ -140,7 +140,7 @@ static AvahiRecordListItem *get(AvahiRecordList *l, AvahiRecord *r) { void avahi_record_list_push(AvahiRecordList *l, AvahiRecord *r, int flush_cache, int unicast_response, int auxiliary) { AvahiRecordListItem *i; - + assert(l); assert(r); @@ -151,7 +151,7 @@ void avahi_record_list_push(AvahiRecordList *l, AvahiRecord *r, int flush_cache, avahi_log_error("avahi_new() failed."); return; } - + i->unicast_response = unicast_response; i->flush_cache = flush_cache; i->auxiliary = auxiliary; @@ -159,7 +159,7 @@ void avahi_record_list_push(AvahiRecordList *l, AvahiRecord *r, int flush_cache, i->read = 0; l->all_flush_cache = l->all_flush_cache && flush_cache; - + AVAHI_LLIST_PREPEND(AvahiRecordListItem, items, l->unread, i); } @@ -177,7 +177,7 @@ void avahi_record_list_drop(AvahiRecordList *l, AvahiRecord *r) { int avahi_record_list_is_empty(AvahiRecordList *l) { assert(l); - + return !l->unread && !l->read; } @@ -185,6 +185,6 @@ int avahi_record_list_all_flush_cache(AvahiRecordList *l) { assert(l); /* Return TRUE if all entries in this list have flush_cache set */ - + return l->all_flush_cache; } diff --git a/avahi-core/rrlist.h b/avahi-core/rrlist.h index 9c07ecd..89bd138 100644 --- a/avahi-core/rrlist.h +++ b/avahi-core/rrlist.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-core/socket.h b/avahi-core/socket.h index 237b534..596ab50 100644 --- a/avahi-core/socket.h +++ b/avahi-core/socket.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-core/timeeventq-test.c b/avahi-core/timeeventq-test.c index c66a55a..e02a685 100644 --- a/avahi-core/timeeventq-test.c +++ b/avahi-core/timeeventq-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 diff --git a/avahi-core/timeeventq.c b/avahi-core/timeeventq.c index 17334ee..6502a59 100644 --- a/avahi-core/timeeventq.c +++ b/avahi-core/timeeventq.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 @@ -83,7 +83,7 @@ static void expiration_event(AVAHI_GCC_UNUSED AvahiTimeout *timeout, void *userd struct timeval now; gettimeofday(&now, NULL); - + /* Check if expired */ if (avahi_timeval_compare(&now, &e->expiry) >= 0) { @@ -97,7 +97,7 @@ static void expiration_event(AVAHI_GCC_UNUSED AvahiTimeout *timeout, void *userd update_timeout(q); return; - } + } } avahi_log_debug(__FILE__": Strange, expiration_event() called, but nothing really happened."); @@ -129,9 +129,9 @@ AvahiTimeEventQueue* avahi_time_event_queue_new(const AvahiPoll *poll_api) { if (!(q->prioq = avahi_prio_queue_new(compare))) goto oom; - if (!(q->timeout = poll_api->timeout_new(poll_api, NULL, expiration_event, q))) + if (!(q->timeout = poll_api->timeout_new(poll_api, NULL, expiration_event, q))) goto oom; - + return q; oom: @@ -142,13 +142,13 @@ oom: if (q->prioq) avahi_prio_queue_free(q->prioq); } - + return NULL; } void avahi_time_event_queue_free(AvahiTimeEventQueue *q) { AvahiTimeEvent *e; - + assert(q); while ((e = time_event_queue_root(q))) @@ -156,7 +156,7 @@ void avahi_time_event_queue_free(AvahiTimeEventQueue *q) { avahi_prio_queue_free(q->prioq); q->poll_api->timeout_free(q->timeout); - + avahi_free(q); } @@ -165,9 +165,9 @@ AvahiTimeEvent* avahi_time_event_new( const struct timeval *timeval, AvahiTimeEventCallback callback, void* userdata) { - + AvahiTimeEvent *e; - + assert(q); assert(callback); assert(userdata); @@ -176,7 +176,7 @@ AvahiTimeEvent* avahi_time_event_new( avahi_log_error(__FILE__": Out of memory"); return NULL; /* OOM */ } - + e->queue = q; e->callback = callback; e->userdata = userdata; @@ -187,9 +187,9 @@ AvahiTimeEvent* avahi_time_event_new( e->expiry.tv_sec = 0; e->expiry.tv_usec = 0; } - + fix_expiry_time(e); - + e->last_run.tv_sec = 0; e->last_run.tv_usec = 0; @@ -221,7 +221,7 @@ void avahi_time_event_update(AvahiTimeEvent *e, const struct timeval *timeval) { e->expiry = *timeval; fix_expiry_time(e); avahi_prio_queue_shuffle(e->queue->prioq, e->node); - + update_timeout(e->queue); } diff --git a/avahi-core/timeeventq.h b/avahi-core/timeeventq.h index cdfa5e6..05cfe8b 100644 --- a/avahi-core/timeeventq.h +++ b/avahi-core/timeeventq.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-core/update-test.c b/avahi-core/update-test.c index 6b92900..e623967 100644 --- a/avahi-core/update-test.c +++ b/avahi-core/update-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 @@ -42,11 +42,11 @@ static AvahiSEntryGroup *group = NULL; static void server_callback(AvahiServer *s, AvahiServerState state, AVAHI_GCC_UNUSED void* userdata) { - avahi_log_debug("server state: %i", state); - + avahi_log_debug("server state: %i", state); + if (state == AVAHI_SERVER_RUNNING) { int ret; - + group = avahi_s_entry_group_new(s, NULL, NULL); assert(group); @@ -62,7 +62,7 @@ static void modify_txt_callback(AVAHI_GCC_UNUSED AvahiTimeout *e, void *userdata AvahiServer *s = userdata; avahi_log_debug("modifying"); - + ret = avahi_server_update_service_txt(s, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "foo", "_http._tcp", NULL, "test2", NULL); assert(ret == AVAHI_OK); } @@ -76,7 +76,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { simple_poll = avahi_simple_poll_new(); assert(simple_poll); - + poll_api = avahi_simple_poll_get(simple_poll); assert(poll_api); diff --git a/avahi-core/util.c b/avahi-core/util.c index b1925f0..09f35f2 100644 --- a/avahi-core/util.c +++ b/avahi-core/util.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,11 +37,11 @@ void avahi_hexdump(const void* p, size_t size) { assert(p); printf("Dumping %lu bytes from %p:\n", (unsigned long) size, p); - + while (size > 0) { unsigned i; - for (i = 0; i < 16; i++) { + for (i = 0; i < 16; i++) { if (i < size) printf("%02x ", c[i]); else @@ -54,14 +54,14 @@ void avahi_hexdump(const void* p, size_t size) { else printf(" "); } - + printf("\n"); c += 16; if (size <= 16) break; - + size -= 16; } } @@ -74,22 +74,22 @@ char *avahi_format_mac_address(char *r, size_t l, const uint8_t* mac, size_t siz assert(r); assert(l > 0); assert(mac); - + if (size <= 0) { *r = 0; return r; } - + for (i = 0; i < size; i++) { if (l < 3) break; - + *(t++) = hex[*mac >> 4]; *(t++) = hex[*mac & 0xF]; *(t++) = ':'; l -= 3; - + mac++; } @@ -97,7 +97,7 @@ char *avahi_format_mac_address(char *r, size_t l, const uint8_t* mac, size_t siz *(t-1) = 0; else *r = 0; - + return r; } diff --git a/avahi-core/util.h b/avahi-core/util.h index 8d2caee..8e8ad44 100644 --- a/avahi-core/util.h +++ b/avahi-core/util.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-core/wide-area.c b/avahi-core/wide-area.c index add81c7..5997d84 100644 --- a/avahi-core/wide-area.c +++ b/avahi-core/wide-area.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,13 +48,13 @@ typedef struct AvahiWideAreaCacheEntry AvahiWideAreaCacheEntry; struct AvahiWideAreaCacheEntry { AvahiWideAreaLookupEngine *engine; - + AvahiRecord *record; struct timeval timestamp; struct timeval expiry; AvahiTimeEvent *time_event; - + AVAHI_LLIST_FIELDS(AvahiWideAreaCacheEntry, by_key); AVAHI_LLIST_FIELDS(AvahiWideAreaCacheEntry, cache); }; @@ -62,12 +62,12 @@ struct AvahiWideAreaCacheEntry { struct AvahiWideAreaLookup { AvahiWideAreaLookupEngine *engine; int dead; - + uint32_t id; /* effectively just an uint16_t, but we need it as an index for a hash table */ AvahiTimeEvent *time_event; AvahiKey *key, *cname_key; - + int n_send; AvahiDnsPacket *packet; @@ -87,7 +87,7 @@ struct AvahiWideAreaLookupEngine { AvahiWatch *watch_ipv4, *watch_ipv6; uint16_t next_id; - + /* Cache */ AVAHI_LLIST_HEAD(AvahiWideAreaCacheEntry, cache); AvahiHashmap *cache_by_key; @@ -108,23 +108,23 @@ struct AvahiWideAreaLookupEngine { static AvahiWideAreaLookup* find_lookup(AvahiWideAreaLookupEngine *e, uint16_t id) { AvahiWideAreaLookup *l; int i = (int) id; - + assert(e); if (!(l = avahi_hashmap_lookup(e->lookups_by_id, &i))) return NULL; - + assert(l->id == id); if (l->dead) return NULL; - + return l; } static int send_to_dns_server(AvahiWideAreaLookup *l, AvahiDnsPacket *p) { AvahiAddress *a; - + assert(l); assert(p); @@ -135,20 +135,20 @@ static int send_to_dns_server(AvahiWideAreaLookup *l, AvahiDnsPacket *p) { a = &l->engine->dns_servers[l->engine->current_dns_server]; l->dns_server_used = *a; - + if (a->proto == AVAHI_PROTO_INET) { if (l->engine->fd_ipv4 < 0) return -1; - + return avahi_send_dns_packet_ipv4(l->engine->fd_ipv4, AVAHI_IF_UNSPEC, p, NULL, &a->data.ipv4, AVAHI_DNS_PORT); - + } else { assert(a->proto == AVAHI_PROTO_INET6); if (l->engine->fd_ipv6 < 0) return -1; - + return avahi_send_dns_packet_ipv6(l->engine->fd_ipv6, AVAHI_IF_UNSPEC, p, NULL, &a->data.ipv6, AVAHI_DNS_PORT); } } @@ -164,7 +164,7 @@ static void next_dns_server(AvahiWideAreaLookupEngine *e) { static void lookup_stop(AvahiWideAreaLookup *l) { assert(l); - + l->callback = NULL; if (l->time_event) { @@ -187,7 +187,7 @@ static void sender_timeout_callback(AvahiTimeEvent *e, void *userdata) { /* There is no other DNS server, fail */ l->n_send = 1000; } - + if (l->n_send >= 6) { avahi_log_warn(__FILE__": Query timed out."); avahi_server_set_errno(l->engine->server, AVAHI_ERR_TIMEOUT); @@ -208,7 +208,7 @@ AvahiWideAreaLookup *avahi_wide_area_lookup_new( AvahiKey *key, AvahiWideAreaLookupCallback callback, void *userdata) { - + struct timeval tv; AvahiWideAreaLookup *l, *t; uint8_t *p; @@ -234,7 +234,7 @@ AvahiWideAreaLookup *avahi_wide_area_lookup_new( break; /* This ID is not yet used. */ l->id = e->next_id++; - + /* We keep the packet around in case we need to repeat our query */ l->packet = avahi_dns_packet_new(0); @@ -243,7 +243,7 @@ AvahiWideAreaLookup *avahi_wide_area_lookup_new( p = avahi_dns_packet_append_key(l->packet, key, 0); assert(p); - + avahi_dns_packet_set_field(l->packet, AVAHI_DNS_FIELD_QDCOUNT, 1); if (send_to_dns_server(l, l->packet) < 0) { @@ -257,7 +257,7 @@ AvahiWideAreaLookup *avahi_wide_area_lookup_new( } l->n_send = 1; - + l->time_event = avahi_time_event_new(e->server->time_event_queue, avahi_elapse_time(&tv, 500, 0), sender_timeout_callback, l); avahi_hashmap_insert(e->lookups_by_id, &l->id, l); @@ -267,14 +267,14 @@ AvahiWideAreaLookup *avahi_wide_area_lookup_new( avahi_hashmap_replace(e->lookups_by_key, avahi_key_ref(l->key), t); AVAHI_LLIST_PREPEND(AvahiWideAreaLookup, lookups, e->lookups, l); - + return l; } static void lookup_destroy(AvahiWideAreaLookup *l) { AvahiWideAreaLookup *t; assert(l); - + lookup_stop(l); t = avahi_hashmap_lookup(l->engine->lookups_by_key, l->key); @@ -285,7 +285,7 @@ static void lookup_destroy(AvahiWideAreaLookup *l) { avahi_hashmap_remove(l->engine->lookups_by_key, l->key); AVAHI_LLIST_REMOVE(AvahiWideAreaLookup, lookups, l->engine->lookups, l); - + avahi_hashmap_remove(l->engine->lookups_by_id, &l->id); avahi_dns_packet_free(l->packet); @@ -294,7 +294,7 @@ static void lookup_destroy(AvahiWideAreaLookup *l) { if (l->cname_key) avahi_key_unref(l->cname_key); - + avahi_free(l); } @@ -315,10 +315,10 @@ void avahi_wide_area_cleanup(AvahiWideAreaLookupEngine *e) { while (e->cleanup_dead) { e->cleanup_dead = 0; - + for (l = e->lookups; l; l = n) { n = l->lookups_next; - + if (l->dead) lookup_destroy(l); } @@ -349,7 +349,7 @@ static void cache_entry_free(AvahiWideAreaCacheEntry *c) { static void expiry_event(AvahiTimeEvent *te, void *userdata) { AvahiWideAreaCacheEntry *e = userdata; - + assert(te); assert(e); @@ -358,7 +358,7 @@ static void expiry_event(AvahiTimeEvent *te, void *userdata) { static AvahiWideAreaCacheEntry* find_record_in_cache(AvahiWideAreaLookupEngine *e, AvahiRecord *r) { AvahiWideAreaCacheEntry *c; - + assert(e); assert(r); @@ -371,17 +371,17 @@ static AvahiWideAreaCacheEntry* find_record_in_cache(AvahiWideAreaLookupEngine * static void run_callbacks(AvahiWideAreaLookupEngine *e, AvahiRecord *r) { AvahiWideAreaLookup *l; - + assert(e); assert(r); for (l = avahi_hashmap_lookup(e->lookups_by_key, r->key); l; l = l->by_key_next) { if (l->dead || !l->callback) continue; - + l->callback(e, AVAHI_BROWSER_NEW, AVAHI_LOOKUP_RESULT_WIDE_AREA, r, l->userdata); } - + if (r->key->clazz == AVAHI_DNS_CLASS_IN && r->key->type == AVAHI_DNS_TYPE_CNAME) { /* It's a CNAME record, so we have to scan the all lookups to see if one matches */ @@ -390,7 +390,7 @@ static void run_callbacks(AvahiWideAreaLookupEngine *e, AvahiRecord *r) { if (l->dead || !l->callback) continue; - + if ((key = avahi_key_new_cname(l->key))) { if (avahi_key_equal(r->key, key)) l->callback(e, AVAHI_BROWSER_NEW, AVAHI_LOOKUP_RESULT_WIDE_AREA, r, l->userdata); @@ -404,7 +404,7 @@ static void run_callbacks(AvahiWideAreaLookupEngine *e, AvahiRecord *r) { static void add_to_cache(AvahiWideAreaLookupEngine *e, AvahiRecord *r) { AvahiWideAreaCacheEntry *c; int is_new; - + assert(e); assert(r); @@ -422,7 +422,7 @@ static void add_to_cache(AvahiWideAreaLookupEngine *e, AvahiRecord *r) { if (e->cache_n_entries >= CACHE_ENTRIES_MAX) /* Eventually we should improve the caching algorithm here */ goto finish; - + c = avahi_new(AvahiWideAreaCacheEntry, 1); c->engine = e; c->time_event = NULL; @@ -438,7 +438,7 @@ static void add_to_cache(AvahiWideAreaLookupEngine *e, AvahiRecord *r) { } c->record = avahi_record_ref(r); - + gettimeofday(&c->timestamp, NULL); c->expiry = c->timestamp; avahi_timeval_add(&c->expiry, r->ttl * 1000000); @@ -449,7 +449,7 @@ static void add_to_cache(AvahiWideAreaLookupEngine *e, AvahiRecord *r) { c->time_event = avahi_time_event_new(e->server->time_event_queue, &c->expiry, expiry_event, c); finish: - + if (is_new) run_callbacks(e, r); } @@ -484,7 +484,7 @@ static void handle_packet(AvahiWideAreaLookupEngine *e, AvahiDnsPacket *p) { int i, r; AvahiBrowserEvent final_event = AVAHI_BROWSER_ALL_FOR_NOW; - + assert(e); assert(p); @@ -513,7 +513,7 @@ static void handle_packet(AvahiWideAreaLookupEngine *e, AvahiDnsPacket *p) { /* Skip over the question */ for (i = (int) avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_QDCOUNT); i > 0; i--) { AvahiKey *k; - + if (!(k = avahi_dns_packet_consume_key(p, NULL))) { avahi_log_warn(__FILE__": Wide area response packet too short or invalid while reading question key. (Maybe a UTF-8 problem?)"); avahi_server_set_errno(e->server, AVAHI_ERR_INVALID_PACKET); @@ -543,7 +543,7 @@ static void handle_packet(AvahiWideAreaLookupEngine *e, AvahiDnsPacket *p) { } finish: - + if (l && !l->dead) { if (l->callback) l->callback(e, final_event, AVAHI_LOOKUP_RESULT_WIDE_AREA, NULL, l->userdata); @@ -555,7 +555,7 @@ finish: static void socket_event(AVAHI_GCC_UNUSED AvahiWatch *w, int fd, AVAHI_GCC_UNUSED AvahiWatchEvent events, void *userdata) { AvahiWideAreaLookupEngine *e = userdata; AvahiDnsPacket *p = NULL; - + if (fd == e->fd_ipv4) p = avahi_recv_dns_packet_ipv4(e->fd_ipv4, NULL, NULL, NULL, NULL, NULL); else { @@ -571,7 +571,7 @@ static void socket_event(AVAHI_GCC_UNUSED AvahiWatch *w, int fd, AVAHI_GCC_UNUSE AvahiWideAreaLookupEngine *avahi_wide_area_engine_new(AvahiServer *s) { AvahiWideAreaLookupEngine *e; - + assert(s); e = avahi_new(AvahiWideAreaLookupEngine, 1); @@ -590,7 +590,7 @@ AvahiWideAreaLookupEngine *avahi_wide_area_engine_new(AvahiServer *s) { if (e->fd_ipv4 >= 0) close(e->fd_ipv4); - + avahi_free(e); return NULL; } @@ -598,7 +598,7 @@ AvahiWideAreaLookupEngine *avahi_wide_area_engine_new(AvahiServer *s) { /* Create watches */ e->watch_ipv4 = e->watch_ipv6 = NULL; - + if (e->fd_ipv4 >= 0) e->watch_ipv4 = s->poll_api->watch_new(e->server->poll_api, e->fd_ipv4, AVAHI_WATCH_IN, socket_event, e); if (e->fd_ipv6 >= 0) @@ -622,12 +622,12 @@ AvahiWideAreaLookupEngine *avahi_wide_area_engine_new(AvahiServer *s) { void avahi_wide_area_engine_free(AvahiWideAreaLookupEngine *e) { assert(e); - + avahi_wide_area_clear_cache(e); while (e->lookups) lookup_destroy(e->lookups); - + avahi_hashmap_free(e->cache_by_key); avahi_hashmap_free(e->lookups_by_id); avahi_hashmap_free(e->lookups_by_key); @@ -640,7 +640,7 @@ void avahi_wide_area_engine_free(AvahiWideAreaLookupEngine *e) { if (e->fd_ipv6 >= 0) close(e->fd_ipv6); - + if (e->fd_ipv4 >= 0) close(e->fd_ipv4); @@ -660,14 +660,14 @@ void avahi_wide_area_set_servers(AvahiWideAreaLookupEngine *e, const AvahiAddres assert(e); if (a) { - for (e->n_dns_servers = 0; n > 0 && e->n_dns_servers < AVAHI_WIDE_AREA_SERVERS_MAX; a++, n--) + for (e->n_dns_servers = 0; n > 0 && e->n_dns_servers < AVAHI_WIDE_AREA_SERVERS_MAX; a++, n--) if ((a->proto == AVAHI_PROTO_INET && e->fd_ipv4 >= 0) || (a->proto == AVAHI_PROTO_INET6 && e->fd_ipv6 >= 0)) e->dns_servers[e->n_dns_servers++] = *a; } else { assert(n == 0); e->n_dns_servers = 0; } - + e->current_dns_server = 0; avahi_wide_area_clear_cache(e); @@ -675,12 +675,12 @@ void avahi_wide_area_set_servers(AvahiWideAreaLookupEngine *e, const AvahiAddres void avahi_wide_area_cache_dump(AvahiWideAreaLookupEngine *e, AvahiDumpCallback callback, void* userdata) { AvahiWideAreaCacheEntry *c; - + assert(e); assert(callback); callback(";; WIDE AREA CACHE ;;; ", userdata); - + for (c = e->cache; c; c = c->cache_next) { char *t = avahi_record_to_string(c->record); callback(t, userdata); @@ -692,7 +692,7 @@ unsigned avahi_wide_area_scan_cache(AvahiWideAreaLookupEngine *e, AvahiKey *key, AvahiWideAreaCacheEntry *c; AvahiKey *cname_key; unsigned n = 0; - + assert(e); assert(key); assert(callback); @@ -708,7 +708,7 @@ unsigned avahi_wide_area_scan_cache(AvahiWideAreaLookupEngine *e, AvahiKey *key, callback(e, AVAHI_BROWSER_NEW, AVAHI_LOOKUP_RESULT_WIDE_AREA|AVAHI_LOOKUP_RESULT_CACHED, c->record, userdata); n++; } - + avahi_key_unref(cname_key); } @@ -722,4 +722,4 @@ int avahi_wide_area_has_servers(AvahiWideAreaLookupEngine *e) { } - + diff --git a/avahi-core/wide-area.h b/avahi-core/wide-area.h index 1af613b..84fa851 100644 --- a/avahi-core/wide-area.h +++ b/avahi-core/wide-area.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-daemon/caps.c b/avahi-daemon/caps.c index fbb9d7a..c629bc7 100644 --- a/avahi-daemon/caps.c +++ b/avahi-daemon/caps.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,18 +38,18 @@ int avahi_caps_reduce(void) { int ret = 0; cap_t caps; static cap_value_t cap_values[] = { CAP_SYS_CHROOT, CAP_SETUID, CAP_SETGID }; - + /* Let's reduce our caps to the minimum set and tell Linux to keep * them across setuid(). This is called before we drop * privileges. */ - + caps = cap_init(); assert(caps); cap_clear(caps); cap_set_flag(caps, CAP_EFFECTIVE, 3, cap_values, CAP_SET); cap_set_flag(caps, CAP_PERMITTED, 3, cap_values, CAP_SET); - + if (cap_set_proc(caps) < 0) { avahi_log_error("cap_set_proc() failed: %s", strerror(errno)); ret = -1; @@ -73,7 +73,7 @@ int avahi_caps_reduce2(void) { /* Reduce our caps to the bare minimum and tell Linux not to keep * them across setuid(). This is called after we drop * privileges. */ - + /* No longer retain caps across setuid() */ if (prctl(PR_SET_KEEPCAPS, 0, 0, 0, 0) < 0) { avahi_log_error("prctl(PR_SET_KEEPCAPS) failed: %s", strerror(errno)); @@ -106,12 +106,12 @@ int avahi_caps_drop_all(void) { caps = cap_init(); assert(caps); cap_clear(caps); - + if (cap_set_proc(caps) < 0) { avahi_log_error("cap_set_proc() failed: %s", strerror(errno)); ret = -1; } cap_free(caps); - + return ret; } diff --git a/avahi-daemon/caps.h b/avahi-daemon/caps.h index 788aceb..660b91c 100644 --- a/avahi-daemon/caps.h +++ b/avahi-daemon/caps.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-daemon/chroot.c b/avahi-daemon/chroot.c index 20e2f03..b796648 100644 --- a/avahi-daemon/chroot.c +++ b/avahi-daemon/chroot.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 @@ -111,14 +111,14 @@ static int send_fd(int fd, int payload_fd) { } cmsg; /* Send a file descriptor over the socket */ - + memset(&iov, 0, sizeof(iov)); memset(&msg, 0, sizeof(msg)); memset(&cmsg, 0, sizeof(cmsg)); - - iov.iov_base = &dummy; + + iov.iov_base = &dummy; iov.iov_len = sizeof(dummy); - + msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_name = NULL; @@ -127,7 +127,7 @@ static int send_fd(int fd, int payload_fd) { msg.msg_control = &cmsg; msg.msg_controllen = sizeof(cmsg); msg.msg_flags = 0; - + cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(int)); cmsg.hdr.cmsg_level = SOL_SOCKET; cmsg.hdr.cmsg_type = SCM_RIGHTS; @@ -155,10 +155,10 @@ static int recv_fd(int fd) { memset(&iov, 0, sizeof(iov)); memset(&msg, 0, sizeof(msg)); memset(&cmsg, 0, sizeof(cmsg)); - + iov.iov_base = &dummy; iov.iov_len = sizeof(dummy); - + msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_name = NULL; @@ -167,12 +167,12 @@ static int recv_fd(int fd) { msg.msg_control = cmsg.buf; msg.msg_controllen = sizeof(cmsg); msg.msg_flags = 0; - + cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(int)); cmsg.hdr.cmsg_level = SOL_SOCKET; cmsg.hdr.cmsg_type = SCM_RIGHTS; *((int*) CMSG_DATA(&cmsg.hdr)) = -1; - + if (recvmsg(fd, &msg, 0) <= 0) { avahi_log_error("recvmsg() failed: %s", strerror(errno)); return -1; @@ -183,7 +183,7 @@ static int recv_fd(int fd) { errno = EINVAL; return -1; } - + if (!(h = CMSG_FIRSTHDR(&msg))) { avahi_log_error("recvmsg() sent no fd."); errno = EINVAL; @@ -197,7 +197,7 @@ static int recv_fd(int fd) { return *((int*)CMSG_DATA(h)); } } - + static int helper_main(int fd) { int ret = 1; assert(fd >= 0); @@ -207,7 +207,7 @@ static int helper_main(int fd) { * mind that this code is security sensitive! */ avahi_log_debug(__FILE__": chroot() helper started"); - + for (;;) { uint8_t command; ssize_t r; @@ -217,7 +217,7 @@ static int helper_main(int fd) { /* EOF? */ if (r == 0) break; - + avahi_log_error(__FILE__": read() failed: %s", strerror(errno)); goto fail; } @@ -250,7 +250,7 @@ static int helper_main(int fd) { avahi_log_error(__FILE__": write() failed: %s\n", strerror(errno)); goto fail; } - + break; } @@ -258,24 +258,24 @@ static int helper_main(int fd) { goto fail; close(payload); - + break; } case AVAHI_CHROOT_UNLINK_SOCKET: case AVAHI_CHROOT_UNLINK_PID: { uint8_t c = AVAHI_CHROOT_SUCCESS; - + unlink(unlink_file_name_table[(int) command]); if (write(fd, &c, sizeof(c)) != sizeof(c)) { avahi_log_error(__FILE__": write() failed: %s\n", strerror(errno)); goto fail; } - + break; } - + default: avahi_log_error(__FILE__": Unknown command %02x.", command); break; @@ -283,11 +283,11 @@ static int helper_main(int fd) { } ret = 0; - + fail: avahi_log_debug(__FILE__": chroot() helper exiting with return value %i", ret); - + return ret; } @@ -296,12 +296,12 @@ int avahi_chroot_helper_start(const char *argv0) { pid_t pid; assert(helper_fd < 0); - + if (socketpair(AF_UNIX, SOCK_STREAM, 0, sock) < 0) { avahi_log_error("socketpair() failed: %s", strerror(errno)); return -1; } - + if ((pid = fork()) < 0) { close(sock[0]); close(sock[1]); @@ -310,14 +310,14 @@ int avahi_chroot_helper_start(const char *argv0) { } else if (pid == 0) { setsid(); - + /* Drop all remaining capabilities */ avahi_caps_drop_all(); avahi_set_proc_title(argv0, "%s: chroot helper", argv0); daemon_retval_done(); - + close(sock[0]); helper_main(sock[1]); _exit(0); @@ -342,7 +342,7 @@ int avahi_chroot_helper_get_fd(const char *fname) { if (helper_fd >= 0) { uint8_t command; - + for (command = 2; command < AVAHI_CHROOT_MAX; command++) if (get_file_name_table[(int) command] && strcmp(fname, get_file_name_table[(int) command]) == 0) @@ -355,7 +355,7 @@ int avahi_chroot_helper_get_fd(const char *fname) { } assert(get_file_name_table[(int) command]); - + if (write(helper_fd, &command, sizeof(command)) < 0) { avahi_log_error("write() failed: %s\n", strerror(errno)); return -1; @@ -386,7 +386,7 @@ int avahi_chroot_helper_unlink(const char *fname) { if (helper_fd >= 0) { uint8_t c, command; ssize_t r; - + for (command = 2; command < AVAHI_CHROOT_MAX; command++) if (unlink_file_name_table[(int) command] && strcmp(fname, unlink_file_name_table[(int) command]) == 0) @@ -407,11 +407,11 @@ int avahi_chroot_helper_unlink(const char *fname) { avahi_log_error("read() failed: %s\n", r < 0 ? strerror(errno) : "EOF"); return -1; } - + return 0; - + } else - + return unlink(fname); - + } diff --git a/avahi-daemon/chroot.h b/avahi-daemon/chroot.h index ea61c5a..0a8c2b6 100644 --- a/avahi-daemon/chroot.h +++ b/avahi-daemon/chroot.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-daemon/dbus-async-address-resolver.c b/avahi-daemon/dbus-async-address-resolver.c index f05af8f..1e71443 100644 --- a/avahi-daemon/dbus-async-address-resolver.c +++ b/avahi-daemon/dbus-async-address-resolver.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,7 +43,7 @@ void avahi_dbus_async_address_resolver_free(AsyncAddressResolverInfo *i) { dbus_connection_unregister_object_path(server->bus, i->path); avahi_free(i->path); } - + AVAHI_LLIST_REMOVE(AsyncAddressResolverInfo, async_address_resolvers, i->client->async_address_resolvers, i); i->client->n_objects--; @@ -55,12 +55,12 @@ void avahi_dbus_async_address_resolver_free(AsyncAddressResolverInfo *i) { void avahi_dbus_async_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const AvahiAddress *address, const char *host_name, AvahiLookupResultFlags flags, void* userdata) { AsyncAddressResolverInfo *i = userdata; DBusMessage *reply; - + assert(r); assert(i); reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, avahi_dbus_map_resolve_signal_name(event)); - + if (event == AVAHI_RESOLVER_FOUND) { char t[AVAHI_ADDRESS_STR_MAX], *pt = t; int32_t i_interface, i_protocol, i_aprotocol; @@ -74,7 +74,7 @@ void avahi_dbus_async_address_resolver_callback(AvahiSAddressResolver *r, AvahiI i_protocol = (int32_t) protocol; i_aprotocol = (int32_t) address->proto; u_flags = (uint32_t) flags; - + dbus_message_append_args( reply, DBUS_TYPE_INT32, &i_interface, @@ -90,7 +90,7 @@ void avahi_dbus_async_address_resolver_callback(AvahiSAddressResolver *r, AvahiI avahi_dbus_append_server_error(reply); } - dbus_message_set_destination(reply, i->client->name); + dbus_message_set_destination(reply, i->client->name); dbus_connection_send(server->bus, reply, NULL); dbus_message_unref(reply); } @@ -102,7 +102,7 @@ DBusHandlerResult avahi_dbus_msg_async_address_resolver_impl(DBusConnection *c, assert(c); assert(m); assert(i); - + dbus_error_init(&error); avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", @@ -113,11 +113,11 @@ DBusHandlerResult avahi_dbus_msg_async_address_resolver_impl(DBusConnection *c, /* Introspection */ if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) return avahi_dbus_handle_introspect(c, m, "AddressResolver.introspect"); - + /* Access control */ - if (strcmp(dbus_message_get_sender(m), i->client->name)) + if (strcmp(dbus_message_get_sender(m), i->client->name)) return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL); - + if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Free")) { if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { @@ -128,12 +128,12 @@ DBusHandlerResult avahi_dbus_msg_async_address_resolver_impl(DBusConnection *c, avahi_dbus_async_address_resolver_free(i); return avahi_dbus_respond_ok(c, m); } - + avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m)); fail: if (dbus_error_is_set(&error)) dbus_error_free(&error); - + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } diff --git a/avahi-daemon/dbus-async-host-name-resolver.c b/avahi-daemon/dbus-async-host-name-resolver.c index a2c99a7..4bc9d59 100644 --- a/avahi-daemon/dbus-async-host-name-resolver.c +++ b/avahi-daemon/dbus-async-host-name-resolver.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 @@ -54,12 +54,12 @@ void avahi_dbus_async_host_name_resolver_free(AsyncHostNameResolverInfo *i) { void avahi_dbus_async_host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *host_name, const AvahiAddress *a, AvahiLookupResultFlags flags, void* userdata) { AsyncHostNameResolverInfo *i = userdata; DBusMessage *reply; - + assert(r); assert(i); reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, avahi_dbus_map_resolve_signal_name(event)); - + if (event == AVAHI_RESOLVER_FOUND) { char t[AVAHI_ADDRESS_STR_MAX], *pt = t; int32_t i_interface, i_protocol, i_aprotocol; @@ -73,7 +73,7 @@ void avahi_dbus_async_host_name_resolver_callback(AvahiSHostNameResolver *r, Ava i_protocol = (int32_t) protocol; i_aprotocol = (int32_t) a->proto; u_flags = (uint32_t) flags; - + dbus_message_append_args( reply, DBUS_TYPE_INT32, &i_interface, @@ -88,7 +88,7 @@ void avahi_dbus_async_host_name_resolver_callback(AvahiSHostNameResolver *r, Ava avahi_dbus_append_server_error(reply); } - dbus_message_set_destination(reply, i->client->name); + dbus_message_set_destination(reply, i->client->name); dbus_connection_send(server->bus, reply, NULL); dbus_message_unref(reply); } @@ -100,7 +100,7 @@ DBusHandlerResult avahi_dbus_msg_async_host_name_resolver_impl(DBusConnection *c assert(c); assert(m); assert(i); - + dbus_error_init(&error); avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", @@ -111,11 +111,11 @@ DBusHandlerResult avahi_dbus_msg_async_host_name_resolver_impl(DBusConnection *c /* Introspection */ if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) return avahi_dbus_handle_introspect(c, m, "HostNameResolver.introspect"); - + /* Access control */ - if (strcmp(dbus_message_get_sender(m), i->client->name)) + if (strcmp(dbus_message_get_sender(m), i->client->name)) return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL); - + if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Free")) { if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { @@ -126,13 +126,13 @@ DBusHandlerResult avahi_dbus_msg_async_host_name_resolver_impl(DBusConnection *c avahi_dbus_async_host_name_resolver_free(i); return avahi_dbus_respond_ok(c, m); } - + avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m)); fail: if (dbus_error_is_set(&error)) dbus_error_free(&error); - + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } diff --git a/avahi-daemon/dbus-async-service-resolver.c b/avahi-daemon/dbus-async-service-resolver.c index a9a1364..efb5202 100644 --- a/avahi-daemon/dbus-async-service-resolver.c +++ b/avahi-daemon/dbus-async-service-resolver.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,7 +43,7 @@ void avahi_dbus_async_service_resolver_free(AsyncServiceResolverInfo *i) { dbus_connection_unregister_object_path(server->bus, i->path); avahi_free(i->path); } - + AVAHI_LLIST_REMOVE(AsyncServiceResolverInfo, async_service_resolvers, i->client->async_service_resolvers, i); i->client->n_objects--; @@ -64,26 +64,26 @@ void avahi_dbus_async_service_resolver_callback( const AvahiAddress *a, uint16_t port, AvahiStringList *txt, - AvahiLookupResultFlags flags, + AvahiLookupResultFlags flags, void* userdata) { AsyncServiceResolverInfo *i = userdata; DBusMessage *reply; - + assert(r); assert(i); reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, avahi_dbus_map_resolve_signal_name(event)); - + if (event == AVAHI_RESOLVER_FOUND) { char t[AVAHI_ADDRESS_STR_MAX], *pt = t; int32_t i_interface, i_protocol, i_aprotocol; uint32_t u_flags; - + assert(host_name); /* avahi_log_debug(__FILE__": [%s] Successfully resolved service <%s.%s.%s>", i->path, name, type, domain); */ - + if (a) avahi_address_snprint(t, sizeof(t), a); else @@ -97,9 +97,9 @@ void avahi_dbus_async_service_resolver_callback( i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; - if (a) + if (a) i_aprotocol = (int32_t) a->proto; - else + else i_aprotocol = AVAHI_PROTO_UNSPEC; u_flags = (uint32_t) flags; @@ -127,7 +127,7 @@ void avahi_dbus_async_service_resolver_callback( avahi_dbus_append_server_error(reply); } - dbus_message_set_destination(reply, i->client->name); + dbus_message_set_destination(reply, i->client->name); dbus_connection_send(server->bus, reply, NULL); dbus_message_unref(reply); } @@ -139,7 +139,7 @@ DBusHandlerResult avahi_dbus_msg_async_service_resolver_impl(DBusConnection *c, assert(c); assert(m); assert(i); - + dbus_error_init(&error); avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", @@ -150,11 +150,11 @@ DBusHandlerResult avahi_dbus_msg_async_service_resolver_impl(DBusConnection *c, /* Introspection */ if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) return avahi_dbus_handle_introspect(c, m, "ServiceResolver.introspect"); - + /* Access control */ - if (strcmp(dbus_message_get_sender(m), i->client->name)) + if (strcmp(dbus_message_get_sender(m), i->client->name)) return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL); - + if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Free")) { if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { @@ -165,13 +165,13 @@ DBusHandlerResult avahi_dbus_msg_async_service_resolver_impl(DBusConnection *c, avahi_dbus_async_service_resolver_free(i); return avahi_dbus_respond_ok(c, m); } - + avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m)); fail: if (dbus_error_is_set(&error)) dbus_error_free(&error); - + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } diff --git a/avahi-daemon/dbus-domain-browser.c b/avahi-daemon/dbus-domain-browser.c index b529ede..a42c63e 100644 --- a/avahi-daemon/dbus-domain-browser.c +++ b/avahi-daemon/dbus-domain-browser.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,7 +43,7 @@ void avahi_dbus_domain_browser_free(DomainBrowserInfo *i) { dbus_connection_unregister_object_path(server->bus, i->path); avahi_free(i->path); } - + AVAHI_LLIST_REMOVE(DomainBrowserInfo, domain_browsers, i->client->domain_browsers, i); i->client->n_objects--; @@ -59,7 +59,7 @@ DBusHandlerResult avahi_dbus_msg_domain_browser_impl(DBusConnection *c, DBusMess assert(c); assert(m); assert(i); - + dbus_error_init(&error); avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", @@ -70,11 +70,11 @@ DBusHandlerResult avahi_dbus_msg_domain_browser_impl(DBusConnection *c, DBusMess /* Introspection */ if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) return avahi_dbus_handle_introspect(c, m, "DomainBrowser.introspect"); - + /* Access control */ - if (strcmp(dbus_message_get_sender(m), i->client->name)) + if (strcmp(dbus_message_get_sender(m), i->client->name)) return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL); - + if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "Free")) { if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { @@ -84,15 +84,15 @@ DBusHandlerResult avahi_dbus_msg_domain_browser_impl(DBusConnection *c, DBusMess avahi_dbus_domain_browser_free(i); return avahi_dbus_respond_ok(c, m); - + } - + avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m)); fail: if (dbus_error_is_set(&error)) dbus_error_free(&error); - + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } @@ -101,7 +101,7 @@ void avahi_dbus_domain_browser_callback(AvahiSDomainBrowser *b, AvahiIfIndex int DBusMessage *m; int32_t i_interface, i_protocol; uint32_t u_flags; - + assert(b); assert(i); @@ -122,8 +122,8 @@ void avahi_dbus_domain_browser_callback(AvahiSDomainBrowser *b, AvahiIfIndex int DBUS_TYPE_INVALID); } else if (event == AVAHI_BROWSER_FAILURE) avahi_dbus_append_server_error(m); - - dbus_message_set_destination(m, i->client->name); + + dbus_message_set_destination(m, i->client->name); dbus_connection_send(server->bus, m, NULL); dbus_message_unref(m); } diff --git a/avahi-daemon/dbus-entry-group.c b/avahi-daemon/dbus-entry-group.c index 0e1a21c..6311a95 100644 --- a/avahi-daemon/dbus-entry-group.c +++ b/avahi-daemon/dbus-entry-group.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 @@ -49,7 +49,7 @@ void avahi_dbus_entry_group_free(EntryGroupInfo *i) { i->client->n_objects--; assert(i->client->n_objects >= 0); - + avahi_free(i); } @@ -58,13 +58,13 @@ void avahi_dbus_entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiE DBusMessage *m; int32_t t; const char *e; - + assert(s); assert(g); assert(i); m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "StateChanged"); - + t = (int32_t) state; if (state == AVAHI_ENTRY_GROUP_FAILURE) e = avahi_error_number_to_dbus(avahi_server_errno(s)); @@ -72,13 +72,13 @@ void avahi_dbus_entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiE e = AVAHI_DBUS_ERR_COLLISION; else e = AVAHI_DBUS_ERR_OK; - + dbus_message_append_args( m, DBUS_TYPE_INT32, &t, DBUS_TYPE_STRING, &e, DBUS_TYPE_INVALID); - dbus_message_set_destination(m, i->client->name); + dbus_message_set_destination(m, i->client->name); dbus_connection_send(server->bus, m, NULL); dbus_message_unref(m); } @@ -90,7 +90,7 @@ DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage assert(c); assert(m); assert(i); - + dbus_error_init(&error); avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", @@ -101,11 +101,11 @@ DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage /* Introspection */ if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) return avahi_dbus_handle_introspect(c, m, "EntryGroup.introspect"); - + /* Access control */ - if (strcmp(dbus_message_get_sender(m), i->client->name)) + if (strcmp(dbus_message_get_sender(m), i->client->name)) return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL); - + if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "Free")) { if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { @@ -115,7 +115,7 @@ DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage avahi_dbus_entry_group_free(i); return avahi_dbus_respond_ok(c, m); - + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "Commit")) { if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { @@ -125,12 +125,12 @@ DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage if (avahi_s_entry_group_commit(i->entry_group) < 0) return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); - + return avahi_dbus_respond_ok(c, m); - - + + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "Reset")) { - + if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { avahi_log_warn("Error parsing EntryGroup::Reset message"); goto fail; @@ -139,7 +139,7 @@ DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage avahi_s_entry_group_reset(i->entry_group); i->n_entries = 0; return avahi_dbus_respond_ok(c, m); - + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "IsEmpty")) { if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { @@ -148,10 +148,10 @@ DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage } return avahi_dbus_respond_boolean(c, m, !!avahi_s_entry_group_is_empty(i->entry_group)); - + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "GetState")) { AvahiEntryGroupState state; - + if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { avahi_log_warn("Error parsing EntryGroup::GetState message"); goto fail; @@ -159,14 +159,14 @@ DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage state = avahi_s_entry_group_get_state(i->entry_group); return avahi_dbus_respond_int32(c, m, (int32_t) state); - + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddService")) { int32_t interface, protocol; uint32_t flags; char *type, *name, *domain, *host; uint16_t port; AvahiStringList *strlst = NULL; - + if (!dbus_message_get_args( m, &error, DBUS_TYPE_INT32, &interface, @@ -176,7 +176,7 @@ DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage DBUS_TYPE_STRING, &type, DBUS_TYPE_STRING, &domain, DBUS_TYPE_STRING, &host, - DBUS_TYPE_UINT16, &port, + DBUS_TYPE_UINT16, &port, DBUS_TYPE_INVALID) || !type || !name || avahi_dbus_read_strlst(m, 8, &strlst) < 0) { @@ -202,17 +202,17 @@ DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage if (!(flags & AVAHI_PUBLISH_UPDATE)) i->n_entries ++; - + avahi_string_list_free(strlst); - + return avahi_dbus_respond_ok(c, m); - + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddServiceSubtype")) { int32_t interface, protocol; uint32_t flags; char *type, *name, *domain, *subtype; - + if (!dbus_message_get_args( m, &error, DBUS_TYPE_INT32, &interface, @@ -233,12 +233,12 @@ DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage if (domain && !*domain) domain = NULL; - if (avahi_server_add_service_subtype(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, (AvahiPublishFlags) flags, name, type, domain, subtype) < 0) + if (avahi_server_add_service_subtype(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, (AvahiPublishFlags) flags, name, type, domain, subtype) < 0) return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); if (!(flags & AVAHI_PUBLISH_UPDATE)) i->n_entries ++; - + return avahi_dbus_respond_ok(c, m); } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "UpdateServiceTxt")) { @@ -246,7 +246,7 @@ DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage uint32_t flags; char *type, *name, *domain; AvahiStringList *strlst; - + if (!dbus_message_get_args( m, &error, DBUS_TYPE_INT32, &interface, @@ -271,15 +271,15 @@ DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage } avahi_string_list_free(strlst); - + return avahi_dbus_respond_ok(c, m); - + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddAddress")) { int32_t interface, protocol; uint32_t flags; char *name, *address; AvahiAddress a; - + if (!dbus_message_get_args( m, &error, DBUS_TYPE_INT32, &interface, @@ -294,7 +294,7 @@ DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage if (!(flags & AVAHI_PUBLISH_UPDATE) && i->n_entries >= ENTRIES_PER_ENTRY_GROUP_MAX) return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_ENTRIES, NULL); - + if (!(avahi_address_parse(address, AVAHI_PROTO_UNSPEC, &a))) return avahi_dbus_respond_error(c, m, AVAHI_ERR_INVALID_ADDRESS, NULL); @@ -303,7 +303,7 @@ DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage if (!(flags & AVAHI_PUBLISH_UPDATE)) i->n_entries ++; - + return avahi_dbus_respond_ok(c, m); } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddRecord")) { int32_t interface, protocol; @@ -312,7 +312,7 @@ DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage char *name; void *rdata; AvahiRecord *r; - + if (!dbus_message_get_args( m, &error, DBUS_TYPE_INT32, &interface, @@ -341,7 +341,7 @@ DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage avahi_record_unref (r); return avahi_dbus_respond_error(c, m, AVAHI_ERR_INVALID_RDATA, NULL); } - + if (avahi_server_add(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, (AvahiPublishFlags) flags, r) < 0) { avahi_record_unref (r); return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); @@ -349,18 +349,18 @@ DBusHandlerResult avahi_dbus_msg_entry_group_impl(DBusConnection *c, DBusMessage if (!(flags & AVAHI_PUBLISH_UPDATE)) i->n_entries ++; - - avahi_record_unref (r); + + avahi_record_unref (r); return avahi_dbus_respond_ok(c, m); - } - - + } + + avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m)); fail: if (dbus_error_is_set(&error)) dbus_error_free(&error); - + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } diff --git a/avahi-daemon/dbus-internal.h b/avahi-daemon/dbus-internal.h index 11c1094..0727b2f 100644 --- a/avahi-daemon/dbus-internal.h +++ b/avahi-daemon/dbus-internal.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 @@ -56,7 +56,7 @@ struct EntryGroupInfo { char *path; int n_entries; - + AVAHI_LLIST_FIELDS(EntryGroupInfo, entry_groups); }; @@ -152,7 +152,7 @@ struct Client { char *name; unsigned current_id; int n_objects; - + AVAHI_LLIST_FIELDS(Client, clients); AVAHI_LLIST_HEAD(EntryGroupInfo, entry_groups); AVAHI_LLIST_HEAD(SyncHostNameResolverInfo, sync_host_name_resolvers); @@ -224,7 +224,7 @@ void avahi_dbus_sync_service_resolver_callback( const AvahiAddress *a, uint16_t port, AvahiStringList *txt, - AvahiLookupResultFlags flags, + AvahiLookupResultFlags flags, void* userdata); void avahi_dbus_async_service_resolver_free(AsyncServiceResolverInfo *i); @@ -240,7 +240,7 @@ void avahi_dbus_async_service_resolver_callback( const AvahiAddress *a, uint16_t port, AvahiStringList *txt, - AvahiLookupResultFlags flags, + AvahiLookupResultFlags flags, void* userdata); DBusHandlerResult avahi_dbus_msg_async_service_resolver_impl(DBusConnection *c, DBusMessage *m, void *userdata); diff --git a/avahi-daemon/dbus-protocol.c b/avahi-daemon/dbus-protocol.c index d61935a..d0cb4ad 100644 --- a/avahi-daemon/dbus-protocol.c +++ b/avahi-daemon/dbus-protocol.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 @@ -71,7 +71,7 @@ static int dbus_connect(void); static void dbus_disconnect(void); static void client_free(Client *c) { - + assert(server); assert(c); @@ -83,7 +83,7 @@ static void client_free(Client *c) { while (c->async_host_name_resolvers) avahi_dbus_async_host_name_resolver_free(c->async_host_name_resolvers); - + while (c->sync_address_resolvers) avahi_dbus_sync_address_resolver_free(c->sync_address_resolvers); @@ -109,7 +109,7 @@ static void client_free(Client *c) { avahi_dbus_record_browser_free(c->record_browsers); assert(c->n_objects == 0); - + avahi_free(c->name); AVAHI_LLIST_REMOVE(Client, clients, server->clients, c); avahi_free(c); @@ -133,14 +133,14 @@ static Client *client_get(const char *name, int create) { if (server->n_clients >= CLIENTS_MAX) return NULL; - + /* If not existent yet, create a new entry */ client = avahi_new(Client, 1); client->id = server->current_id++; client->name = avahi_strdup(name); client->current_id = 0; client->n_objects = 0; - + AVAHI_LLIST_HEAD_INIT(EntryGroupInfo, client->entry_groups); AVAHI_LLIST_HEAD_INIT(SyncHostNameResolverInfo, client->sync_host_name_resolvers); AVAHI_LLIST_HEAD_INIT(AsyncHostNameResolverInfo, client->async_host_name_resolvers); @@ -157,7 +157,7 @@ static Client *client_get(const char *name, int create) { server->n_clients++; assert(server->n_clients > 0); - + return client; } @@ -190,11 +190,11 @@ static DBusHandlerResult msg_signal_filter_impl(AVAHI_GCC_UNUSED DBusConnection if (server->reconnect) { avahi_log_warn("Disconnected from D-Bus, trying to reconnect in %ims...", RECONNECT_MSEC); - + dbus_disconnect(); - + avahi_elapse_time(&tv, RECONNECT_MSEC, 0); - + if (server->reconnect_timeout) server->poll_api->timeout_update(server->reconnect_timeout, &tv); else @@ -203,9 +203,9 @@ static DBusHandlerResult msg_signal_filter_impl(AVAHI_GCC_UNUSED DBusConnection avahi_log_warn("Disconnected from D-Bus, exiting."); raise(SIGQUIT); } - + return DBUS_HANDLER_RESULT_HANDLED; - + } else if (dbus_message_is_signal(m, DBUS_INTERFACE_DBUS, "NameAcquired")) { char *name; @@ -216,7 +216,7 @@ static DBusHandlerResult msg_signal_filter_impl(AVAHI_GCC_UNUSED DBusConnection /* avahi_log_info(__FILE__": name acquired (%s)", name); */ return DBUS_HANDLER_RESULT_HANDLED; - + } else if (dbus_message_is_signal(m, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) { char *name, *old, *new; @@ -229,7 +229,7 @@ static DBusHandlerResult msg_signal_filter_impl(AVAHI_GCC_UNUSED DBusConnection Client *client; if ((client = client_get(name, FALSE))) { - avahi_log_debug(__FILE__": client %s vanished.", name); + avahi_log_debug(__FILE__": client %s vanished.", name); client_free(client); } } @@ -238,7 +238,7 @@ static DBusHandlerResult msg_signal_filter_impl(AVAHI_GCC_UNUSED DBusConnection fail: if (dbus_error_is_set(&error)) dbus_error_free(&error); - + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } @@ -254,7 +254,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) return avahi_dbus_handle_introspect(c, m, "Server.introspect"); - + else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetHostName")) { if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { @@ -263,23 +263,23 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH } return avahi_dbus_respond_string(c, m, avahi_server_get_host_name(avahi_server)); - + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "SetHostName")) { char *name; - + if (!dbus_message_get_args(m, &error, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID)) { avahi_log_warn("Error parsing Server::SetHostName message"); goto fail; } - - if (avahi_server_set_host_name(avahi_server, name) < 0) + + if (avahi_server_set_host_name(avahi_server, name) < 0) return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); avahi_log_info("Changing host name to '%s'.", name); - + return avahi_dbus_respond_ok(c, m); - + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetDomainName")) { if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { @@ -295,9 +295,9 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH avahi_log_warn("Error parsing Server::GetHostNameFqdn message"); goto fail; } - + return avahi_dbus_respond_string(c, m, avahi_server_get_host_name_fqdn(avahi_server)); - + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "IsNSSSupportAvailable")) { if (!(dbus_message_get_args(m, &error, DBUS_TYPE_INVALID))) { avahi_log_warn("Error parsing Server::IsNSSSupportAvailable message"); @@ -305,14 +305,14 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH } return avahi_dbus_respond_boolean(c, m, nss_support); - + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetVersionString")) { if (!(dbus_message_get_args(m, &error, DBUS_TYPE_INVALID))) { avahi_log_warn("Error parsing Server::GetVersionString message"); goto fail; } - + return avahi_dbus_respond_string(c, m, PACKAGE_STRING); } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetAPIVersion")) { @@ -321,17 +321,17 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH avahi_log_warn("Error parsing Server::GetAPIVersion message"); goto fail; } - + return avahi_dbus_respond_uint32(c, m, AVAHI_DBUS_API_VERSION); } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetState")) { AvahiServerState state; - + if (!(dbus_message_get_args(m, &error, DBUS_TYPE_INVALID))) { avahi_log_warn("Error parsing Server::GetState message"); goto fail; } - + state = avahi_server_get_state(avahi_server); return avahi_dbus_respond_int32(c, m, (int32_t) state); @@ -341,13 +341,13 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH avahi_log_warn("Error parsing Server::GetLocalServiceCookie message"); goto fail; } - + return avahi_dbus_respond_uint32(c, m, avahi_server_get_local_service_cookie(avahi_server)); } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetNetworkInterfaceNameByIndex")) { int32_t idx; char name[IF_NAMESIZE]; - + if (!(dbus_message_get_args(m, &error, DBUS_TYPE_INT32, &idx, DBUS_TYPE_INVALID))) { avahi_log_warn("Error parsing Server::GetNetworkInterfaceNameByIndex message"); goto fail; @@ -361,14 +361,14 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH snprintf(txt, sizeof(txt), "OS Error: %s", strerror(errno)); return avahi_dbus_respond_error(c, m, AVAHI_ERR_OS, txt); } - + return avahi_dbus_respond_string(c, m, name); #endif - + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetNetworkInterfaceIndexByName")) { char *n; int32_t idx; - + if (!(dbus_message_get_args(m, &error, DBUS_TYPE_STRING, &n, DBUS_TYPE_INVALID)) || !n) { avahi_log_warn("Error parsing Server::GetNetworkInterfaceIndexByName message"); goto fail; @@ -382,13 +382,13 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH snprintf(txt, sizeof(txt), "OS Error: %s", strerror(errno)); return avahi_dbus_respond_error(c, m, AVAHI_ERR_OS, txt); } - + return avahi_dbus_respond_int32(c, m, idx); #endif } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetAlternativeHostName")) { char *n, * t; - + if (!(dbus_message_get_args(m, &error, DBUS_TYPE_STRING, &n, DBUS_TYPE_INVALID)) || !n) { avahi_log_warn("Error parsing Server::GetAlternativeHostName message"); goto fail; @@ -402,7 +402,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetAlternativeServiceName")) { char *n, *t; - + if (!(dbus_message_get_args(m, &error, DBUS_TYPE_STRING, &n, DBUS_TYPE_INVALID)) || !n) { avahi_log_warn("Error parsing Server::GetAlternativeServiceName message"); goto fail; @@ -413,7 +413,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH avahi_free(t); return DBUS_HANDLER_RESULT_HANDLED; - + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "EntryGroupNew")) { Client *client; EntryGroupInfo *i; @@ -433,7 +433,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH if (disable_user_service_publishing) return avahi_dbus_respond_error(c, m, AVAHI_ERR_NOT_PERMITTED, NULL); - + if (!(client = client_get(dbus_message_get_sender(m), TRUE))) { avahi_log_warn("Too many clients, client request failed."); return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL); @@ -451,7 +451,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH i->n_entries = 0; AVAHI_LLIST_PREPEND(EntryGroupInfo, entry_groups, client->entry_groups, i); client->n_objects++; - + if (!(i->entry_group = avahi_s_entry_group_new(avahi_server, avahi_dbus_entry_group_callback, i))) { avahi_dbus_entry_group_free(i); return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); @@ -460,14 +460,14 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH i->path = avahi_strdup_printf("/Client%u/EntryGroup%u", client->id, i->id); dbus_connection_register_object_path(c, i->path, &vtable, i); return avahi_dbus_respond_path(c, m, i->path); - + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "ResolveHostName")) { Client *client; int32_t interface, protocol, aprotocol; uint32_t flags; char *name; SyncHostNameResolverInfo *i; - + if (!dbus_message_get_args( m, &error, DBUS_TYPE_INT32, &interface, @@ -500,9 +500,9 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH avahi_dbus_sync_host_name_resolver_free(i); return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); } - + return DBUS_HANDLER_RESULT_HANDLED; - + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "ResolveAddress")) { Client *client; int32_t interface, protocol; @@ -510,13 +510,13 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH char *address; SyncAddressResolverInfo *i; AvahiAddress a; - + if (!dbus_message_get_args( m, &error, DBUS_TYPE_INT32, &interface, DBUS_TYPE_INT32, &protocol, DBUS_TYPE_STRING, &address, - DBUS_TYPE_UINT32, &flags, + DBUS_TYPE_UINT32, &flags, DBUS_TYPE_INVALID) || !address) { avahi_log_warn("Error parsing Server::ResolveAddress message"); goto fail; @@ -545,9 +545,9 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH avahi_dbus_sync_address_resolver_free(i); return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); } - + return DBUS_HANDLER_RESULT_HANDLED; - + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "DomainBrowserNew")) { Client *client; DomainBrowserInfo *i; @@ -562,7 +562,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH int32_t interface, protocol, type; uint32_t flags; char *domain; - + if (!dbus_message_get_args( m, &error, DBUS_TYPE_INT32, &interface, @@ -618,7 +618,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH int32_t interface, protocol; uint32_t flags; char *domain; - + if (!dbus_message_get_args( m, &error, DBUS_TYPE_INT32, &interface, @@ -654,11 +654,11 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH avahi_dbus_service_type_browser_free(i); return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); } - + i->path = avahi_strdup_printf("/Client%u/ServiceTypeBrowser%u", client->id, i->id); dbus_connection_register_object_path(c, i->path, &vtable, i); return avahi_dbus_respond_path(c, m, i->path); - + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "ServiceBrowserNew")) { Client *client; ServiceBrowserInfo *i; @@ -673,7 +673,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH int32_t interface, protocol; uint32_t flags; char *domain, *type; - + if (!dbus_message_get_args( m, &error, DBUS_TYPE_INT32, &interface, @@ -714,14 +714,14 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH i->path = avahi_strdup_printf("/Client%u/ServiceBrowser%u", client->id, i->id); dbus_connection_register_object_path(c, i->path, &vtable, i); return avahi_dbus_respond_path(c, m, i->path); - + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "ResolveService")) { Client *client; int32_t interface, protocol, aprotocol; uint32_t flags; char *name, *type, *domain; SyncServiceResolverInfo *i; - + if (!dbus_message_get_args( m, &error, DBUS_TYPE_INT32, &interface, @@ -740,7 +740,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH avahi_log_warn("Too many clients, client request failed."); return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL); } - + if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) { avahi_log_warn("Too many objects for client '%s', client request failed.", client->name); return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL); @@ -751,7 +751,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH if (!*name) name = NULL; - + i = avahi_new(SyncServiceResolverInfo, 1); i->client = client; i->message = dbus_message_ref(m); @@ -762,9 +762,9 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH avahi_dbus_sync_service_resolver_free(i); return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL); } - + return DBUS_HANDLER_RESULT_HANDLED; - + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "ServiceResolverNew")) { Client *client; int32_t interface, protocol, aprotocol; @@ -793,7 +793,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH avahi_log_warn("Error parsing Server::ServiceResolverNew message"); goto fail; } - + if (!(client = client_get(dbus_message_get_sender(m), TRUE))) { avahi_log_warn(__FILE__": Too many clients, client request failed."); return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL); @@ -809,7 +809,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH if (!*name) name = NULL; - + i = avahi_new(AsyncServiceResolverInfo, 1); i->id = ++client->current_id; i->client = client; @@ -823,7 +823,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH } /* avahi_log_debug(__FILE__": [%s], new service resolver for <%s.%s.%s>", i->path, name, type, domain); */ - + i->path = avahi_strdup_printf("/Client%u/ServiceResolver%u", client->id, i->id); dbus_connection_register_object_path(c, i->path, &vtable, i); return avahi_dbus_respond_path(c, m, i->path); @@ -842,7 +842,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH NULL, NULL }; - + if (!dbus_message_get_args( m, &error, DBUS_TYPE_INT32, &interface, @@ -854,7 +854,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH avahi_log_warn("Error parsing Server::HostNameResolverNew message"); goto fail; } - + if (!(client = client_get(dbus_message_get_sender(m), TRUE))) { avahi_log_warn(__FILE__": Too many clients, client request failed."); return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL); @@ -896,7 +896,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH NULL, NULL }; - + if (!dbus_message_get_args( m, &error, DBUS_TYPE_INT32, &interface, @@ -936,7 +936,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH i->path = avahi_strdup_printf("/Client%u/AddressResolver%u", client->id, i->id); dbus_connection_register_object_path(c, i->path, &vtable, i); return avahi_dbus_respond_path(c, m, i->path); - + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "RecordBrowserNew")) { Client *client; RecordBrowserInfo *i; @@ -953,7 +953,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH char *name; uint16_t type, clazz; AvahiKey *key; - + if (!dbus_message_get_args( m, &error, DBUS_TYPE_INT32, &interface, @@ -967,7 +967,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH goto fail; } - if (!avahi_is_valid_domain_name(name)) + if (!avahi_is_valid_domain_name(name)) return avahi_dbus_respond_error(c, m, AVAHI_ERR_INVALID_DOMAIN_NAME, NULL); if (!(client = client_get(dbus_message_get_sender(m), TRUE))) { @@ -997,7 +997,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH } avahi_key_unref(key); - + i->path = avahi_strdup_printf("/Client%u/RecordBrowser%u", client->id, i->id); dbus_connection_register_object_path(c, i->path, &vtable, i); return avahi_dbus_respond_path(c, m, i->path); @@ -1008,7 +1008,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH fail: if (dbus_error_is_set(&error)) dbus_error_free(&error); - + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } @@ -1016,7 +1016,7 @@ void dbus_protocol_server_state_changed(AvahiServerState state) { DBusMessage *m; int32_t t; const char *e; - + if (!server || !server->bus) return; @@ -1029,7 +1029,7 @@ void dbus_protocol_server_state_changed(AvahiServerState state) { e = avahi_error_number_to_dbus(avahi_server_errno(avahi_server)); else e = AVAHI_DBUS_ERR_OK; - + dbus_message_append_args(m, DBUS_TYPE_INT32, &t, DBUS_TYPE_STRING, &e, DBUS_TYPE_INVALID); dbus_connection_send(server->bus, m, NULL); dbus_message_unref(m); @@ -1052,7 +1052,7 @@ static int dbus_connect(void) { dbus_error_init(&error); -#ifdef HAVE_DBUS_BUS_GET_PRIVATE +#ifdef HAVE_DBUS_BUS_GET_PRIVATE if (!(server->bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error))) { assert(dbus_error_is_set(&error)); avahi_log_error("dbus_bus_get_private(): %s", error.message); @@ -1064,7 +1064,7 @@ static int dbus_connect(void) { if (!(a = getenv("DBUS_SYSTEM_BUS_ADDRESS")) || !*a) a = DBUS_SYSTEM_BUS_DEFAULT_ADDRESS; - + if (!(server->bus = dbus_connection_open_private(a, &error))) { assert(dbus_error_is_set(&error)); avahi_log_error("dbus_bus_open_private(): %s", error.message); @@ -1078,14 +1078,14 @@ static int dbus_connect(void) { } } #endif - + if (avahi_dbus_connection_glue(server->bus, server->poll_api) < 0) { avahi_log_error("avahi_dbus_connection_glue() failed"); goto fail; } dbus_connection_set_exit_on_disconnect(server->bus, FALSE); - + if (dbus_bus_request_name( server->bus, AVAHI_DBUS_NAME, @@ -1108,14 +1108,14 @@ static int dbus_connect(void) { avahi_log_error("dbus_connection_add_filter() failed"); goto fail; } - + dbus_bus_add_match(server->bus, "type='signal',""interface='" DBUS_INTERFACE_DBUS "'", &error); if (dbus_error_is_set(&error)) { avahi_log_error("dbus_bus_add_match(): %s", error.message); goto fail; } - + if (!(dbus_connection_register_object_path(server->bus, AVAHI_DBUS_PATH_SERVER, &server_vtable, NULL))) { avahi_log_error("dbus_connection_register_object_path() failed"); goto fail; @@ -1145,7 +1145,7 @@ static void dbus_disconnect(void) { while (server->clients) client_free(server->clients); - + assert(server->n_clients == 0); if (server->bus) { @@ -1179,11 +1179,11 @@ int dbus_protocol_setup(const AvahiPoll *poll_api, int _disable_user_service_pub goto fail; avahi_log_warn("WARNING: Failed to contact D-Bus daemon, retrying in %ims.", RECONNECT_MSEC); - + avahi_elapse_time(&tv, RECONNECT_MSEC, 0); server->reconnect_timeout = server->poll_api->timeout_new(server->poll_api, &tv, reconnect_callback, NULL); } - + return 0; fail: @@ -1209,7 +1209,7 @@ void dbus_protocol_shutdown(void) { if (server->reconnect_timeout) server->poll_api->timeout_free(server->reconnect_timeout); - + avahi_free(server); server = NULL; } diff --git a/avahi-daemon/dbus-protocol.h b/avahi-daemon/dbus-protocol.h index d4404f2..9934d4a 100644 --- a/avahi-daemon/dbus-protocol.h +++ b/avahi-daemon/dbus-protocol.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-daemon/dbus-record-browser.c b/avahi-daemon/dbus-record-browser.c index ea23fe4..6c2652a 100644 --- a/avahi-daemon/dbus-record-browser.c +++ b/avahi-daemon/dbus-record-browser.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 @@ -58,7 +58,7 @@ DBusHandlerResult avahi_dbus_msg_record_browser_impl(DBusConnection *c, DBusMess assert(c); assert(m); assert(i); - + dbus_error_init(&error); avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", @@ -69,11 +69,11 @@ DBusHandlerResult avahi_dbus_msg_record_browser_impl(DBusConnection *c, DBusMess /* Introspection */ if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) return avahi_dbus_handle_introspect(c, m, "RecordBrowser.introspect"); - + /* Access control */ - if (strcmp(dbus_message_get_sender(m), i->client->name)) + if (strcmp(dbus_message_get_sender(m), i->client->name)) return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL); - + if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "Free")) { if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { @@ -83,15 +83,15 @@ DBusHandlerResult avahi_dbus_msg_record_browser_impl(DBusConnection *c, DBusMess avahi_dbus_record_browser_free(i); return avahi_dbus_respond_ok(c, m); - + } - + avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m)); fail: if (dbus_error_is_set(&error)) dbus_error_free(&error); - + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } @@ -103,12 +103,12 @@ void avahi_dbus_record_browser_callback( AvahiRecord *record, AvahiLookupResultFlags flags, void* userdata) { - + RecordBrowserInfo *i = userdata; DBusMessage *m = NULL; int32_t i_interface, i_protocol; uint32_t u_flags; - + assert(b); assert(i); @@ -122,7 +122,7 @@ void avahi_dbus_record_browser_callback( uint8_t rdata[0xFFFF]; size_t size; assert(record); - + if (!(dbus_message_append_args( m, DBUS_TYPE_INT32, &i_interface, @@ -132,28 +132,28 @@ void avahi_dbus_record_browser_callback( DBUS_TYPE_UINT16, &record->key->type, DBUS_TYPE_INVALID))) goto fail; - + if ((size = avahi_rdata_serialize(record, rdata, sizeof(rdata))) == (size_t) -1 || avahi_dbus_append_rdata(m, rdata, size) < 0) { avahi_log_debug(__FILE__": Failed to append rdata"); dbus_message_unref(m); return; } - + dbus_message_append_args( m, DBUS_TYPE_UINT32, &u_flags, DBUS_TYPE_INVALID); - + } else if (event == AVAHI_BROWSER_FAILURE) avahi_dbus_append_server_error(m); - - dbus_message_set_destination(m, i->client->name); + + dbus_message_set_destination(m, i->client->name); dbus_connection_send(server->bus, m, NULL); dbus_message_unref(m); return; - + fail: if (m) diff --git a/avahi-daemon/dbus-service-browser.c b/avahi-daemon/dbus-service-browser.c index 1515ddf..d59d8f9 100644 --- a/avahi-daemon/dbus-service-browser.c +++ b/avahi-daemon/dbus-service-browser.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,7 +43,7 @@ void avahi_dbus_service_browser_free(ServiceBrowserInfo *i) { dbus_connection_unregister_object_path(server->bus, i->path); avahi_free(i->path); } - + AVAHI_LLIST_REMOVE(ServiceBrowserInfo, service_browsers, i->client->service_browsers, i); i->client->n_objects--; @@ -59,7 +59,7 @@ DBusHandlerResult avahi_dbus_msg_service_browser_impl(DBusConnection *c, DBusMes assert(c); assert(m); assert(i); - + dbus_error_init(&error); avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", @@ -70,11 +70,11 @@ DBusHandlerResult avahi_dbus_msg_service_browser_impl(DBusConnection *c, DBusMes /* Introspection */ if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) return avahi_dbus_handle_introspect(c, m, "ServiceBrowser.introspect"); - + /* Access control */ - if (strcmp(dbus_message_get_sender(m), i->client->name)) + if (strcmp(dbus_message_get_sender(m), i->client->name)) return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL); - + if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "Free")) { if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { @@ -84,15 +84,15 @@ DBusHandlerResult avahi_dbus_msg_service_browser_impl(DBusConnection *c, DBusMes avahi_dbus_service_browser_free(i); return avahi_dbus_respond_ok(c, m); - + } - + avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m)); fail: if (dbus_error_is_set(&error)) dbus_error_free(&error); - + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } @@ -101,7 +101,7 @@ void avahi_dbus_service_browser_callback(AvahiSServiceBrowser *b, AvahiIfIndex i DBusMessage *m; int32_t i_interface, i_protocol; uint32_t u_flags; - + assert(b); assert(i); @@ -113,16 +113,16 @@ void avahi_dbus_service_browser_callback(AvahiSServiceBrowser *b, AvahiIfIndex i if (avahi_dbus_is_our_own_service(i->client, interface, protocol, name, type, domain) > 0) flags |= AVAHI_LOOKUP_RESULT_OUR_OWN; } - + i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; u_flags = (uint32_t) flags; - + if (event == AVAHI_BROWSER_NEW || event == AVAHI_BROWSER_REMOVE) { assert(name); assert(type); assert(domain); - + dbus_message_append_args( m, DBUS_TYPE_INT32, &i_interface, @@ -134,8 +134,8 @@ void avahi_dbus_service_browser_callback(AvahiSServiceBrowser *b, AvahiIfIndex i DBUS_TYPE_INVALID); } else if (event == AVAHI_BROWSER_FAILURE) avahi_dbus_append_server_error(m); - - dbus_message_set_destination(m, i->client->name); + + dbus_message_set_destination(m, i->client->name); dbus_connection_send(server->bus, m, NULL); dbus_message_unref(m); } diff --git a/avahi-daemon/dbus-service-type-browser.c b/avahi-daemon/dbus-service-type-browser.c index 9207a74..d2572eb 100644 --- a/avahi-daemon/dbus-service-type-browser.c +++ b/avahi-daemon/dbus-service-type-browser.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,7 +43,7 @@ void avahi_dbus_service_type_browser_free(ServiceTypeBrowserInfo *i) { dbus_connection_unregister_object_path(server->bus, i->path); avahi_free(i->path); } - + AVAHI_LLIST_REMOVE(ServiceTypeBrowserInfo, service_type_browsers, i->client->service_type_browsers, i); i->client->n_objects--; @@ -59,7 +59,7 @@ DBusHandlerResult avahi_dbus_msg_service_type_browser_impl(DBusConnection *c, DB assert(c); assert(m); assert(i); - + dbus_error_init(&error); avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s", @@ -70,11 +70,11 @@ DBusHandlerResult avahi_dbus_msg_service_type_browser_impl(DBusConnection *c, DB /* Introspection */ if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) return avahi_dbus_handle_introspect(c, m, "ServiceTypeBrowser.introspect"); - + /* Access control */ - if (strcmp(dbus_message_get_sender(m), i->client->name)) + if (strcmp(dbus_message_get_sender(m), i->client->name)) return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL); - + if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "Free")) { if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { @@ -84,15 +84,15 @@ DBusHandlerResult avahi_dbus_msg_service_type_browser_impl(DBusConnection *c, DB avahi_dbus_service_type_browser_free(i); return avahi_dbus_respond_ok(c, m); - + } - + avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m)); fail: if (dbus_error_is_set(&error)) dbus_error_free(&error); - + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } @@ -101,7 +101,7 @@ void avahi_dbus_service_type_browser_callback(AvahiSServiceTypeBrowser *b, Avahi DBusMessage *m; int32_t i_interface, i_protocol; uint32_t u_flags; - + assert(b); assert(i); @@ -124,8 +124,8 @@ void avahi_dbus_service_type_browser_callback(AvahiSServiceTypeBrowser *b, Avahi DBUS_TYPE_INVALID); } else if (event == AVAHI_BROWSER_FAILURE) avahi_dbus_append_server_error(m); - - dbus_message_set_destination(m, i->client->name); + + dbus_message_set_destination(m, i->client->name); dbus_connection_send(server->bus, m, NULL); dbus_message_unref(m); } diff --git a/avahi-daemon/dbus-sync-address-resolver.c b/avahi-daemon/dbus-sync-address-resolver.c index 0a5fa59..fe4a131 100644 --- a/avahi-daemon/dbus-sync-address-resolver.c +++ b/avahi-daemon/dbus-sync-address-resolver.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 @@ -50,7 +50,7 @@ void avahi_dbus_sync_address_resolver_free(SyncAddressResolverInfo *i) { void avahi_dbus_sync_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const AvahiAddress *address, const char *host_name, AvahiLookupResultFlags flags, void* userdata) { SyncAddressResolverInfo *i = userdata; - + assert(r); assert(address); assert(i); @@ -68,7 +68,7 @@ void avahi_dbus_sync_address_resolver_callback(AvahiSAddressResolver *r, AvahiIf i_protocol = (int32_t) protocol; i_aprotocol = (int32_t) address->proto; u_flags = (uint32_t) flags; - + reply = dbus_message_new_method_return(i->message); dbus_message_append_args( reply, diff --git a/avahi-daemon/dbus-sync-host-name-resolver.c b/avahi-daemon/dbus-sync-host-name-resolver.c index 9750dd4..307eebf 100644 --- a/avahi-daemon/dbus-sync-host-name-resolver.c +++ b/avahi-daemon/dbus-sync-host-name-resolver.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 @@ -50,7 +50,7 @@ void avahi_dbus_sync_host_name_resolver_free(SyncHostNameResolverInfo *i) { void avahi_dbus_sync_host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *host_name, const AvahiAddress *a, AvahiLookupResultFlags flags, void* userdata) { SyncHostNameResolverInfo *i = userdata; - + assert(r); assert(host_name); assert(i); @@ -68,7 +68,7 @@ void avahi_dbus_sync_host_name_resolver_callback(AvahiSHostNameResolver *r, Avah i_protocol = (int32_t) protocol; i_aprotocol = (int32_t) a->proto; u_flags = (uint32_t) flags; - + reply = dbus_message_new_method_return(i->message); dbus_message_append_args( reply, diff --git a/avahi-daemon/dbus-sync-service-resolver.c b/avahi-daemon/dbus-sync-service-resolver.c index 21ae481..df17203 100644 --- a/avahi-daemon/dbus-sync-service-resolver.c +++ b/avahi-daemon/dbus-sync-service-resolver.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,11 +60,11 @@ void avahi_dbus_sync_service_resolver_callback( const AvahiAddress *a, uint16_t port, AvahiStringList *txt, - AvahiLookupResultFlags flags, + AvahiLookupResultFlags flags, void* userdata) { - + SyncServiceResolverInfo *i = userdata; - + assert(r); assert(i); @@ -73,13 +73,13 @@ void avahi_dbus_sync_service_resolver_callback( int32_t i_interface, i_protocol, i_aprotocol; uint32_t u_flags; DBusMessage *reply; - + assert(host_name); if (!name) name = ""; - if (a) + if (a) avahi_address_snprint(t, sizeof(t), a); else t[0] = 0; @@ -88,12 +88,12 @@ void avahi_dbus_sync_service_resolver_callback( if (avahi_dbus_is_our_own_service(i->client, interface, protocol, name, type, domain) > 0) flags |= AVAHI_LOOKUP_RESULT_OUR_OWN; - + i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; - if (a) + if (a) i_aprotocol = (int32_t) a->proto; - else + else i_aprotocol = AVAHI_PROTO_UNSPEC; u_flags = (uint32_t) flags; @@ -112,7 +112,7 @@ void avahi_dbus_sync_service_resolver_callback( DBUS_TYPE_INVALID); avahi_dbus_append_string_list(reply, txt); - + dbus_message_append_args( reply, DBUS_TYPE_UINT32, &u_flags, @@ -122,7 +122,7 @@ void avahi_dbus_sync_service_resolver_callback( dbus_message_unref(reply); } else { assert(event == AVAHI_RESOLVER_FAILURE); - + avahi_dbus_respond_error(server->bus, i->message, avahi_server_errno(avahi_server), NULL); } diff --git a/avahi-daemon/dbus-util.c b/avahi-daemon/dbus-util.c index ca08d7b..9375fed 100644 --- a/avahi-daemon/dbus-util.c +++ b/avahi-daemon/dbus-util.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 @@ -52,13 +52,13 @@ DBusHandlerResult avahi_dbus_respond_error(DBusConnection *c, DBusMessage *m, in if (!text) text = avahi_strerror(error); - + reply = dbus_message_new_error(m, avahi_error_number_to_dbus(error), text); dbus_connection_send(c, reply, NULL); dbus_message_unref(reply); avahi_log_debug(__FILE__": Responding error '%s' (%i)", text, error); - + return DBUS_HANDLER_RESULT_HANDLED; } @@ -69,7 +69,7 @@ DBusHandlerResult avahi_dbus_respond_string(DBusConnection *c, DBusMessage *m, c dbus_message_append_args(reply, DBUS_TYPE_STRING, &text, DBUS_TYPE_INVALID); dbus_connection_send(c, reply, NULL); dbus_message_unref(reply); - + return DBUS_HANDLER_RESULT_HANDLED; } @@ -80,7 +80,7 @@ DBusHandlerResult avahi_dbus_respond_int32(DBusConnection *c, DBusMessage *m, in dbus_message_append_args(reply, DBUS_TYPE_INT32, &i, DBUS_TYPE_INVALID); dbus_connection_send(c, reply, NULL); dbus_message_unref(reply); - + return DBUS_HANDLER_RESULT_HANDLED; } @@ -91,7 +91,7 @@ DBusHandlerResult avahi_dbus_respond_uint32(DBusConnection *c, DBusMessage *m, u dbus_message_append_args(reply, DBUS_TYPE_UINT32, &u, DBUS_TYPE_INVALID); dbus_connection_send(c, reply, NULL); dbus_message_unref(reply); - + return DBUS_HANDLER_RESULT_HANDLED; } @@ -102,7 +102,7 @@ DBusHandlerResult avahi_dbus_respond_boolean(DBusConnection *c, DBusMessage *m, dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN, &b, DBUS_TYPE_INVALID); dbus_connection_send(c, reply, NULL); dbus_message_unref(reply); - + return DBUS_HANDLER_RESULT_HANDLED; } @@ -112,7 +112,7 @@ DBusHandlerResult avahi_dbus_respond_ok(DBusConnection *c, DBusMessage *m) { reply = dbus_message_new_method_return(m); dbus_connection_send(c, reply, NULL); dbus_message_unref(reply); - + return DBUS_HANDLER_RESULT_HANDLED; } @@ -123,7 +123,7 @@ DBusHandlerResult avahi_dbus_respond_path(DBusConnection *c, DBusMessage *m, con dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); dbus_connection_send(c, reply, NULL); dbus_message_unref(reply); - + return DBUS_HANDLER_RESULT_HANDLED; } @@ -131,7 +131,7 @@ void avahi_dbus_append_server_error(DBusMessage *reply) { const char *t; t = avahi_error_number_to_dbus(avahi_server_errno(avahi_server)); - + dbus_message_append_args( reply, DBUS_TYPE_STRING, &t, @@ -166,7 +166,7 @@ static char *file_get_contents(const char *fname) { char *buf = NULL; assert(fname); - + #ifdef ENABLE_CHROOT fd = avahi_chroot_helper_get_fd(fname); #else @@ -205,22 +205,22 @@ static char *file_get_contents(const char *fname) { close(fd); return buf; - + fail: if (fd >= 0) close(fd); - + if (buf) avahi_free(buf); return NULL; - + } DBusHandlerResult avahi_dbus_handle_introspect(DBusConnection *c, DBusMessage *m, const char *fname) { char *contents, *path; DBusError error; - + assert(c); assert(m); assert(fname); @@ -235,21 +235,21 @@ DBusHandlerResult avahi_dbus_handle_introspect(DBusConnection *c, DBusMessage *m path = avahi_strdup_printf("%s/%s", AVAHI_DBUS_INTROSPECTION_DIR, fname); contents = file_get_contents(path); avahi_free(path); - + if (!contents) { avahi_log_error("Failed to load introspection data."); goto fail; } - + avahi_dbus_respond_string(c, m, contents); avahi_free(contents); - + return DBUS_HANDLER_RESULT_HANDLED; fail: if (dbus_error_is_set(&error)) dbus_error_free(&error); - + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } @@ -257,20 +257,20 @@ fail: void avahi_dbus_append_string_list(DBusMessage *reply, AvahiStringList *txt) { AvahiStringList *p; DBusMessageIter iter, sub; - + assert(reply); dbus_message_iter_init_append(reply, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "ay", &sub); - + for (p = txt; p; p = p->next) { DBusMessageIter sub2; const uint8_t *data = p->text; - + dbus_message_iter_open_container(&sub, DBUS_TYPE_ARRAY, "y", &sub2); - dbus_message_iter_append_fixed_array(&sub2, DBUS_TYPE_BYTE, &data, p->size); + dbus_message_iter_append_fixed_array(&sub2, DBUS_TYPE_BYTE, &data, p->size); dbus_message_iter_close_container(&sub, &sub2); - + } dbus_message_iter_close_container(&iter, &sub); } @@ -281,12 +281,12 @@ int avahi_dbus_read_rdata(DBusMessage *m, int idx, void **rdata, uint32_t *size) uint8_t *k; assert(m); - + dbus_message_iter_init(m, &iter); for (j = 0; j < idx; j++) dbus_message_iter_next(&iter); - + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY || dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_BYTE) goto fail; @@ -296,9 +296,9 @@ int avahi_dbus_read_rdata(DBusMessage *m, int idx, void **rdata, uint32_t *size) *rdata = k; *size = n; - + return 0; - + fail: avahi_log_warn("Error parsing data"); @@ -314,49 +314,49 @@ int avahi_dbus_read_strlst(DBusMessage *m, int idx, AvahiStringList **l) { assert(m); assert(l); - + dbus_message_iter_init(m, &iter); for (j = 0; j < idx; j++) dbus_message_iter_next(&iter); - + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY || dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_ARRAY) goto fail; dbus_message_iter_recurse(&iter, &sub); - + for (;;) { int at, n; const uint8_t *k; DBusMessageIter sub2; - + if ((at = dbus_message_iter_get_arg_type(&sub)) == DBUS_TYPE_INVALID) break; - + assert(at == DBUS_TYPE_ARRAY); - + if (dbus_message_iter_get_element_type(&sub) != DBUS_TYPE_BYTE) goto fail; dbus_message_iter_recurse(&sub, &sub2); - + k = (const uint8_t*) ""; n = 0; dbus_message_iter_get_fixed_array(&sub2, &k, &n); if (!k) k = (const uint8_t*) ""; - + strlst = avahi_string_list_add_arbitrary(strlst, k, n); - + dbus_message_iter_next(&sub); } *l = strlst; - + return 0; - + fail: avahi_log_warn("Error parsing TXT data"); @@ -381,15 +381,15 @@ int avahi_dbus_is_our_own_service(Client *c, AvahiIfIndex interface, AvahiProtoc int avahi_dbus_append_rdata(DBusMessage *message, const void *rdata, size_t size) { DBusMessageIter iter, sub; - + assert(message); - + dbus_message_iter_init_append(message, &iter); - + if (!(dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &sub)) || !(dbus_message_iter_append_fixed_array(&sub, DBUS_TYPE_BYTE, &rdata, size)) || !(dbus_message_iter_close_container(&iter, &sub))) return -1; - + return 0; } diff --git a/avahi-daemon/dbus-util.h b/avahi-daemon/dbus-util.h index e994915..cc0fb9b 100644 --- a/avahi-daemon/dbus-util.h +++ b/avahi-daemon/dbus-util.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-daemon/ini-file-parser-test.c b/avahi-daemon/ini-file-parser-test.c index 6560ab9..b37f496 100644 --- a/avahi-daemon/ini-file-parser-test.c +++ b/avahi-daemon/ini-file-parser-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 @@ -52,7 +52,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { for (i = split; *i; i++) printf("<%s> ", *i); - + avahi_strfreev(split); printf("\n"); diff --git a/avahi-daemon/ini-file-parser.c b/avahi-daemon/ini-file-parser.c index 1b50335..6746a9b 100644 --- a/avahi-daemon/ini-file-parser.c +++ b/avahi-daemon/ini-file-parser.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,14 +38,14 @@ AvahiIniFile* avahi_ini_file_load(const char *fname) { FILE *fo; AvahiIniFileGroup *group = NULL; unsigned line; - + assert(fname); if (!(fo = fopen(fname, "r"))) { avahi_log_error("Failed to open file '%s': %s", fname, strerror(errno)); return NULL; } - + f = avahi_new(AvahiIniFile, 1); AVAHI_LLIST_HEAD_INIT(AvahiIniFileGroup, f->groups); f->n_groups = 0; @@ -54,12 +54,12 @@ AvahiIniFile* avahi_ini_file_load(const char *fname) { while (!feof(fo)) { char ln[256], *s, *e; AvahiIniFilePair *pair; - + if (!(fgets(ln, sizeof(ln), fo))) break; line++; - + s = ln + strspn(ln, " \t"); s[strcspn(s, "\r\n")] = 0; @@ -69,19 +69,19 @@ AvahiIniFile* avahi_ini_file_load(const char *fname) { if (*s == '[') { /* new group */ - + if (!(e = strchr(s, ']'))) { avahi_log_error("Unclosed group header in %s:%u: <%s>", fname, line, s); goto fail; } *e = 0; - + group = avahi_new(AvahiIniFileGroup, 1); group->name = avahi_strdup(s+1); group->n_pairs = 0; AVAHI_LLIST_HEAD_INIT(AvahiIniFilePair, group->pairs); - + AVAHI_LLIST_PREPEND(AvahiIniFileGroup, groups, f->groups, group); f->n_groups++; } else { @@ -91,26 +91,26 @@ AvahiIniFile* avahi_ini_file_load(const char *fname) { avahi_log_error("Missing assignment in %s:%u: <%s>", fname, line, s); goto fail; } - + if (!group) { avahi_log_error("Assignment outside group in %s:%u <%s>", fname, line, s); goto fail; } - + /* Split the key and the value */ *(e++) = 0; - + pair = avahi_new(AvahiIniFilePair, 1); pair->key = avahi_strdup(s); pair->value = avahi_strdup(e); - + AVAHI_LLIST_PREPEND(AvahiIniFilePair, pairs, group->pairs, pair); group->n_pairs++; } } - + fclose(fo); - + return f; fail: @@ -130,7 +130,7 @@ void avahi_ini_file_free(AvahiIniFile *f) { while ((g = f->groups)) { AvahiIniFilePair *p; - + while ((p = g->pairs)) { avahi_free(p->key); avahi_free(p->value); @@ -190,7 +190,7 @@ void avahi_strfreev(char **p) { if (!p) return; - + for (i = p; *i; i++) avahi_free(*i); diff --git a/avahi-daemon/ini-file-parser.h b/avahi-daemon/ini-file-parser.h index 82c5acf..10108db 100644 --- a/avahi-daemon/ini-file-parser.h +++ b/avahi-daemon/ini-file-parser.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-daemon/main.h b/avahi-daemon/main.h index 77af0d0..dff37c1 100644 --- a/avahi-daemon/main.h +++ b/avahi-daemon/main.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-daemon/setproctitle.c b/avahi-daemon/setproctitle.c index 09b7f65..b9afc0f 100644 --- a/avahi-daemon/setproctitle.c +++ b/avahi-daemon/setproctitle.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 @@ -66,7 +66,7 @@ void avahi_init_proc_title(int argc, char **argv) { argv_size = endptr - argv_buffer[0]; /* Make a copy of environ */ - + new_environ = avahi_malloc(sizeof(char*) * (i + 1)); for (i = 0; environ[i]; i++) new_environ[i] = avahi_strdup(environ[i]); @@ -75,7 +75,7 @@ void avahi_init_proc_title(int argc, char **argv) { environ = new_environ; #endif -} +} void avahi_set_proc_title(const char *name, const char *fmt,...) { #ifdef HAVE_SETPROCTITLE @@ -90,16 +90,16 @@ void avahi_set_proc_title(const char *name, const char *fmt,...) { #elif __linux__ size_t l; va_list ap; - + if (!argv_buffer) return; - + va_start(ap, fmt); vsnprintf(argv_buffer[0], argv_size, fmt, ap); va_end(ap); l = strlen(argv_buffer[0]); - + memset(argv_buffer[0] + l, 0, argv_size - l); argv_buffer[1] = NULL; #endif @@ -108,6 +108,6 @@ void avahi_set_proc_title(const char *name, const char *fmt,...) { if (name) prctl(PR_SET_NAME, (unsigned long) name, 0, 0, 0); - + #endif } diff --git a/avahi-daemon/setproctitle.h b/avahi-daemon/setproctitle.h index a8f2a1a..80c1ef5 100644 --- a/avahi-daemon/setproctitle.h +++ b/avahi-daemon/setproctitle.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-daemon/simple-protocol.h b/avahi-daemon/simple-protocol.h index 1e64036..95a8fcd 100644 --- a/avahi-daemon/simple-protocol.h +++ b/avahi-daemon/simple-protocol.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-daemon/static-hosts.c b/avahi-daemon/static-hosts.c index c0a5952..6509840 100644 --- a/avahi-daemon/static-hosts.c +++ b/avahi-daemon/static-hosts.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 @@ -75,7 +75,7 @@ static void entry_group_callback(AvahiServer *s, AVAHI_GCC_UNUSED AvahiSEntryGro case AVAHI_ENTRY_GROUP_FAILURE: avahi_log_notice ("Failed to establish static host name \"%s\": %s.", h->host, avahi_strerror (avahi_server_errno (s))); break; - + case AVAHI_ENTRY_GROUP_UNCOMMITED: case AVAHI_ENTRY_GROUP_REGISTERING: ; @@ -84,7 +84,7 @@ static void entry_group_callback(AvahiServer *s, AVAHI_GCC_UNUSED AvahiSEntryGro static StaticHost *static_host_new(void) { StaticHost *s; - + s = avahi_new(StaticHost, 1); s->group = NULL; @@ -105,7 +105,7 @@ static void static_host_free(StaticHost *s) { avahi_s_entry_group_free (s->group); avahi_free(s->host); - + avahi_free(s); } @@ -114,7 +114,7 @@ static StaticHost *static_host_find(const char *host, const AvahiAddress *a) { assert(host); assert(a); - + for (h = hosts; h; h = h->hosts_next) if (!strcmp(h->host, host) && !avahi_address_cmp(a, &h->address)) return h; @@ -136,10 +136,10 @@ static void add_static_host_to_server(StaticHost *h) int err; const AvahiServerConfig *config; config = avahi_server_get_config(avahi_server); - + p = (h->address.proto == AVAHI_PROTO_INET && config->publish_a_on_ipv6) || (h->address.proto == AVAHI_PROTO_INET6 && config->publish_aaaa_on_ipv4) ? AVAHI_PROTO_UNSPEC : h->address.proto; - + if ((err = avahi_server_add_address(avahi_server, h->group, AVAHI_IF_UNSPEC, p, 0, h->host, &h->address)) < 0) { avahi_log_error ("Static host name %s: avahi_server_add_address failure: %s", h->host, avahi_strerror(err)); return; @@ -154,7 +154,7 @@ static void remove_static_host_from_server(StaticHost *h) if (h->group) avahi_s_entry_group_reset (h->group); } - + void static_hosts_add_to_server(void) { StaticHost *h; @@ -182,7 +182,7 @@ void static_hosts_load(int in_chroot) { } current_iteration++; - + while (!feof(f)) { unsigned int len; char ln[256], *s; @@ -228,7 +228,7 @@ void static_hosts_load(int in_chroot) { /* Skip past any more spaces */ s += strspn(s, " \t"); - + /* Anything left? */ if (*s != 0) { avahi_log_error ("%s:%d: Junk on the end of the line!", filename, line); @@ -261,7 +261,7 @@ void static_hosts_load(int in_chroot) { for (h = hosts; h; h = next) { next = h->hosts_next; - + if (h->iteration != current_iteration) { avahi_log_info("Static hostname %s vanished, removing.", h->host); static_host_free(h); @@ -269,7 +269,7 @@ void static_hosts_load(int in_chroot) { } fail: - + fclose(f); } diff --git a/avahi-daemon/static-hosts.h b/avahi-daemon/static-hosts.h index 2fdb0bd..6ac9378 100644 --- a/avahi-daemon/static-hosts.h +++ b/avahi-daemon/static-hosts.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-daemon/static-services.h b/avahi-daemon/static-services.h index a2bc355..2c066d2 100644 --- a/avahi-daemon/static-services.h +++ b/avahi-daemon/static-services.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-dnsconfd/main.c b/avahi-dnsconfd/main.c index d10374b..4002193 100644 --- a/avahi-dnsconfd/main.c +++ b/avahi-dnsconfd/main.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 @@ -92,7 +92,7 @@ static void server_info_free(DNSServerInfo *i) { assert(i); avahi_free(i->address); - + AVAHI_LLIST_REMOVE(DNSServerInfo, servers, servers, i); avahi_free(i); } @@ -112,7 +112,7 @@ static DNSServerInfo* get_server_info(AvahiIfIndex interface, AvahiProtocol prot static DNSServerInfo* new_server_info(AvahiIfIndex interface, AvahiProtocol protocol, const char *address) { DNSServerInfo *i; - + assert(address); i = avahi_new(DNSServerInfo, 1); @@ -121,7 +121,7 @@ static DNSServerInfo* new_server_info(AvahiIfIndex interface, AvahiProtocol prot i->address = avahi_strdup(address); AVAHI_LLIST_PREPEND(DNSServerInfo, servers, servers, i); - + return i; } @@ -129,7 +129,7 @@ static int set_cloexec(int fd) { int n; assert(fd >= 0); - + if ((n = fcntl(fd, F_GETFD)) < 0) return -1; @@ -152,7 +152,7 @@ static int open_socket(void) { daemon_log(LOG_ERR, "fcntl(): %s", strerror(errno)); goto fail; } - + memset(&sa, 0, sizeof(sa)); sa.sun_family = AF_UNIX; strncpy(sa.sun_path, AVAHI_SOCKET, sizeof(sa.sun_path)-1); @@ -166,7 +166,7 @@ static int open_socket(void) { } return fd; - + fail: if (fd >= 0) close(fd); @@ -199,7 +199,7 @@ static ssize_t loop_write(int fd, const void*data, size_t size) { static char *concat_dns_servers(AvahiIfIndex interface) { DNSServerInfo *i; char *r = NULL; - + for (i = servers; i; i = i->servers_next) if (i->interface == interface || interface <= 0) { DNSServerInfo *j; @@ -213,7 +213,7 @@ static char *concat_dns_servers(AvahiIfIndex interface) { if (j != i) continue; - + if (!r) t = avahi_strdup(i->address); else @@ -229,7 +229,7 @@ static char *concat_dns_servers(AvahiIfIndex interface) { static void set_env(const char *name, const char *value) { char **e; size_t l; - + assert(name); assert(value); @@ -239,7 +239,7 @@ static void set_env(const char *name, const char *value) { /* Search for the variable */ if (strlen(*e) < l+1) continue; - + if (strncmp(*e, name, l) != 0 || (*e)[l] != '=') continue; @@ -260,19 +260,19 @@ static void run_script(int new, AvahiIfIndex interface, AvahiProtocol protocol, assert(interface > 0); - if (!if_indextoname(interface, name)) + if (!if_indextoname(interface, name)) return; - + p = concat_dns_servers(interface); set_env(ENV_INTERFACE_DNS_SERVERS, p ? p : ""); - avahi_free(p); + avahi_free(p); p = concat_dns_servers(-1); set_env(ENV_DNS_SERVERS, p ? p : ""); - avahi_free(p); + avahi_free(p); set_env(ENV_INTERFACE, name); - + snprintf(ia, sizeof(ia), "%i", (int) interface); snprintf(pa, sizeof(pa), "%i", (int) protocol); @@ -298,8 +298,8 @@ static int new_line(const char *l) { AvahiProtocol protocol; int i_interface, i_protocol, port; char a[AVAHI_ADDRESS_STR_MAX]; - - assert(state == BROWSING); + + assert(state == BROWSING); if (*l != '<' && *l != '>') { daemon_log(LOG_ERR, "Avahi sent us an invalid browsing line: %s", l); @@ -325,7 +325,7 @@ static int new_line(const char *l) { } else { DNSServerInfo *i; - if (port == 53) + if (port == 53) if ((i = get_server_info(interface, protocol, a))) { daemon_log(LOG_INFO, "DNS Server %s removed (interface: %i.%s)", a, interface, avahi_proto_to_string(protocol)); server_info_free(i); @@ -334,13 +334,13 @@ static int new_line(const char *l) { } } - + return 0; } static int do_connect(void) { int fd = -1; - + if ((fd = open_socket()) < 0) goto fail; @@ -355,7 +355,7 @@ static int do_connect(void) { fail: if (fd >= 0) close(fd); - + return -1; } @@ -365,7 +365,7 @@ static void free_dns_server_info_list(void) { AvahiProtocol protocol = servers->protocol; char *address = avahi_strdup(servers->address); server_info_free(servers); - + run_script(0, interface, protocol, address); avahi_free(address); } @@ -385,7 +385,7 @@ static void help(FILE *f, const char *argv0) { static int parse_command_line(int argc, char *argv[]) { int c; - + static const struct option long_options[] = { { "help", no_argument, NULL, 'h' }, { "daemonize", no_argument, NULL, 'D' }, @@ -426,7 +426,7 @@ static int parse_command_line(int argc, char *argv[]) { fprintf(stderr, "Too many arguments\n"); return -1; } - + return 0; } @@ -436,14 +436,14 @@ static int run_daemon(void) { size_t buflen = 0; AVAHI_LLIST_HEAD_INIT(DNSServerInfo, servers); - + daemon_signal_init(SIGINT, SIGTERM, SIGCHLD, SIGHUP, 0); /* Allocate some memory for our environment variables */ putenv(avahi_strdup(ENV_INTERFACE"=")); putenv(avahi_strdup(ENV_DNS_SERVERS"=")); putenv(avahi_strdup(ENV_INTERFACE_DNS_SERVERS"=")); - + if ((fd = do_connect()) < 0) goto finish; @@ -492,19 +492,19 @@ static int run_daemon(void) { case SIGCHLD: waitpid(-1, NULL, WNOHANG); break; - + case SIGHUP: daemon_log(LOG_INFO, "Refreshing DNS Server list"); - + close(fd); free_dns_server_info_list(); - + if ((fd = do_connect()) < 0) goto finish; - + break; } - + } else if (FD_ISSET(fd, &rfds)) { ssize_t r; char *n; @@ -530,27 +530,27 @@ static int run_daemon(void) { if (buflen >= sizeof(buf)-1) { /* The incoming line is horribly long */ buf[sizeof(buf)-1] = 0; - + if (new_line(buf) < 0) goto finish; - + buflen = 0; } } } - + finish: free_dns_server_info_list(); if (fd >= 0) close(fd); - + daemon_signal_done(); if (ret != 0 && daemonize) daemon_retval_send(1); - + return ret; } @@ -570,7 +570,7 @@ int main(int argc, char *argv[]) { daemon_pid_file_ident = daemon_log_ident = argv0; daemon_pid_file_proc = pid_file_proc; - + if (parse_command_line(argc, argv) < 0) goto finish; @@ -589,7 +589,7 @@ int main(int argc, char *argv[]) { if (daemonize) { daemon_retval_init(); - + if ((pid = daemon_fork()) < 0) goto finish; else if (pid != 0) { @@ -625,18 +625,18 @@ int main(int argc, char *argv[]) { r = 0; } else if (command == DAEMON_HELP) { help(stdout, argv0); - + r = 0; } else if (command == DAEMON_VERSION) { printf("%s "PACKAGE_VERSION"\n", argv0); - + r = 0; } else if (command == DAEMON_KILL) { if (daemon_pid_file_kill_wait(SIGTERM, 5) < 0) { daemon_log(LOG_WARNING, "Failed to kill daemon: %s", strerror(errno)); goto finish; } - + r = 0; } else if (command == DAEMON_REFRESH) { if (daemon_pid_file_kill(SIGHUP) < 0) { @@ -653,7 +653,7 @@ finish: if (daemonize) daemon_retval_done(); - + if (wrote_pid_file) daemon_pid_file_remove(); diff --git a/avahi-glib/glib-malloc.c b/avahi-glib/glib-malloc.c index 2968abc..5c6a02e 100644 --- a/avahi-glib/glib-malloc.c +++ b/avahi-glib/glib-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 diff --git a/avahi-glib/glib-malloc.h b/avahi-glib/glib-malloc.h index 675ccb5..391d274 100644 --- a/avahi-glib/glib-malloc.h +++ b/avahi-glib/glib-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-glib/glib-watch-test.c b/avahi-glib/glib-watch-test.c index 733c81f..bd7d9ac 100644 --- a/avahi-glib/glib-watch-test.c +++ b/avahi-glib/glib-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 @@ -43,7 +43,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); @@ -70,7 +70,7 @@ static void wakeup(AvahiTimeout *t, AVAHI_GCC_UNUSED void *userdata) { int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { AvahiGLibPoll *g; struct timeval tv; - + g = avahi_glib_poll_new(NULL, G_PRIORITY_DEFAULT); assert(g); @@ -86,6 +86,6 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { g_main_loop_unref(loop); avahi_glib_poll_free(g); - + return 0; } diff --git a/avahi-glib/glib-watch.c b/avahi-glib/glib-watch.c index f0fd934..72a778b 100644 --- a/avahi-glib/glib-watch.c +++ b/avahi-glib/glib-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 @@ -32,10 +32,10 @@ struct AvahiWatch { AvahiGLibPoll *glib_poll; int dead; - + GPollFD pollfd; int pollfd_added; - + AvahiWatchCallback callback; void *userdata; @@ -51,7 +51,7 @@ struct AvahiTimeout { AvahiTimeoutCallback callback; void *userdata; - + AVAHI_LLIST_FIELDS(AvahiTimeout, timeouts); }; @@ -62,7 +62,7 @@ struct AvahiGLibPoll { gboolean timeout_req_cleanup; gboolean watch_req_cleanup; - + AVAHI_LLIST_HEAD(AvahiWatch, watches); AVAHI_LLIST_HEAD(AvahiTimeout, timeouts); }; @@ -111,7 +111,7 @@ static AvahiWatchEvent map_events_from_glib(gushort events) { static AvahiWatch* watch_new(const AvahiPoll *api, int fd, AvahiWatchEvent events, AvahiWatchCallback callback, void *userdata) { AvahiWatch *w; AvahiGLibPoll *g; - + assert(api); assert(fd >= 0); assert(callback); @@ -121,7 +121,7 @@ static AvahiWatch* watch_new(const AvahiPoll *api, int fd, AvahiWatchEvent event if (!(w = avahi_new(AvahiWatch, 1))) return NULL; - + w->glib_poll = g; w->pollfd.fd = fd; w->pollfd.events = map_events_to_glib(events); @@ -160,7 +160,7 @@ static void watch_free(AvahiWatch *w) { g_source_remove_poll(&w->glib_poll->source, &w->pollfd); w->pollfd_added = FALSE; } - + w->dead = TRUE; w->glib_poll->timeout_req_cleanup = TRUE; } @@ -168,7 +168,7 @@ static void watch_free(AvahiWatch *w) { static AvahiTimeout* timeout_new(const AvahiPoll *api, const struct timeval *tv, AvahiTimeoutCallback callback, void *userdata) { AvahiTimeout *t; AvahiGLibPoll *g; - + assert(api); assert(callback); @@ -177,13 +177,13 @@ static AvahiTimeout* timeout_new(const AvahiPoll *api, const struct timeval *tv, if (!(t = avahi_new(AvahiTimeout, 1))) return NULL; - + t->glib_poll = g; t->dead = FALSE; if ((t->enabled = !!tv)) t->expiry = *tv; - + t->callback = callback; t->userdata = userdata; @@ -195,7 +195,7 @@ static AvahiTimeout* timeout_new(const AvahiPoll *api, const struct timeval *tv, static void timeout_update(AvahiTimeout *t, const struct timeval *tv) { assert(t); assert(!t->dead); - + if ((t->enabled = !!tv)) t->expiry = *tv; } @@ -234,10 +234,10 @@ static AvahiTimeout* find_next_timeout(AvahiGLibPoll *g) { assert(g); for (t = g->timeouts; t; t = t->timeouts_next) { - + if (t->dead || !t->enabled) continue; - + if (!n || avahi_timeval_compare(&t->expiry, &n->expiry) < 0) n = t; } @@ -266,7 +266,7 @@ static gboolean prepare_func(GSource *source, gint *timeout) { if (g->timeout_req_cleanup) cleanup_timeouts(g, 0); - + if ((next_timeout = find_next_timeout(g))) { GTimeVal now; struct timeval tvnow; @@ -275,7 +275,7 @@ static gboolean prepare_func(GSource *source, gint *timeout) { g_source_get_current_time(source, &now); tvnow.tv_sec = now.tv_sec; tvnow.tv_usec = now.tv_usec; - + usec = avahi_timeval_diff(&next_timeout->expiry, &tvnow); if (usec <= 0) { @@ -286,7 +286,7 @@ static gboolean prepare_func(GSource *source, gint *timeout) { *timeout = (gint) (usec / 1000); } else *timeout = -1; - + return FALSE; } @@ -303,7 +303,7 @@ static gboolean check_func(GSource *source) { g_source_get_current_time(source, &now); tvnow.tv_sec = now.tv_sec; tvnow.tv_usec = now.tv_usec; - + if (avahi_timeval_compare(&next_timeout->expiry, &tvnow) <= 0) return TRUE; } @@ -311,7 +311,7 @@ static gboolean check_func(GSource *source) { for (w = g->watches; w; w = w->watches_next) if (w->pollfd.revents > 0) return TRUE; - + return FALSE; } @@ -319,7 +319,7 @@ static gboolean dispatch_func(GSource *source, AVAHI_GCC_UNUSED GSourceFunc call AvahiGLibPoll* g = (AvahiGLibPoll*) source; AvahiWatch *w; AvahiTimeout *next_timeout; - + g_assert(g); if ((next_timeout = find_next_timeout(g))) { @@ -328,13 +328,13 @@ static gboolean dispatch_func(GSource *source, AVAHI_GCC_UNUSED GSourceFunc call g_source_get_current_time(source, &now); tvnow.tv_sec = now.tv_sec; tvnow.tv_usec = now.tv_usec; - + if (avahi_timeval_compare(&next_timeout->expiry, &tvnow) < 0) { start_timeout_callback(next_timeout); return TRUE; } } - + for (w = g->watches; w; w = w->watches_next) if (w->pollfd.revents > 0) { assert(w->callback); @@ -348,7 +348,7 @@ static gboolean dispatch_func(GSource *source, AVAHI_GCC_UNUSED GSourceFunc call AvahiGLibPoll *avahi_glib_poll_new(GMainContext *context, gint priority) { AvahiGLibPoll *g; - + static GSourceFuncs source_funcs = { prepare_func, check_func, @@ -362,22 +362,22 @@ AvahiGLibPoll *avahi_glib_poll_new(GMainContext *context, gint priority) { g_main_context_ref(g->context = context ? context : g_main_context_default()); g->api.userdata = g; - + g->api.watch_new = watch_new; g->api.watch_free = watch_free; g->api.watch_update = watch_update; g->api.watch_get_events = watch_get_events; - + g->api.timeout_new = timeout_new; g->api.timeout_free = timeout_free; g->api.timeout_update = timeout_update; g->watch_req_cleanup = FALSE; g->timeout_req_cleanup = FALSE; - + AVAHI_LLIST_HEAD_INIT(AvahiWatch, g->watches); AVAHI_LLIST_HEAD_INIT(AvahiTimeout, g->timeouts); - + g_source_attach(&g->source, g->context); g_source_set_priority(&g->source, priority); g_source_set_can_recurse(&g->source, FALSE); diff --git a/avahi-glib/glib-watch.h b/avahi-glib/glib-watch.h index 78f7742..cd8cbaa 100644 --- a/avahi-glib/glib-watch.h +++ b/avahi-glib/glib-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-qt/qt-watch.h b/avahi-qt/qt-watch.h index a702a76..6de2c0d 100644 --- a/avahi-qt/qt-watch.h +++ b/avahi-qt/qt-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-utils/sigint.c b/avahi-utils/sigint.c index eb97f38..448a069 100644 --- a/avahi-utils/sigint.c +++ b/avahi-utils/sigint.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 AvahiWatch *watch = NULL; static int set_nonblock(int fd) { int n; - + assert(fd >= 0); if ((n = fcntl(fd, F_GETFL)) < 0) @@ -69,7 +69,7 @@ static void close_pipe_fds(void) { static void watch_callback(AvahiWatch *w, int fd, AvahiWatchEvent event, AVAHI_GCC_UNUSED void *userdata) { int s; ssize_t l; - + assert(w); assert(fd == pipe_fds[0]); assert(event == AVAHI_WATCH_IN); @@ -84,7 +84,7 @@ static void watch_callback(AvahiWatch *w, int fd, AvahiWatchEvent event, AVAHI_G int sigint_install(AvahiSimplePoll *spoll) { struct sigaction sa; const AvahiPoll *p; - + assert(spoll); assert(!simple_poll); assert(pipe_fds[0] == -1 && pipe_fds[1] == -1); @@ -106,7 +106,7 @@ int sigint_install(AvahiSimplePoll *spoll) { close_pipe_fds(); return -1; } - + if (sigaction(SIGTERM, &sa, &old_sigterm_sa) < 0) { sigaction(SIGINT, &old_sigint_sa, NULL); fprintf(stderr, "sigaction() failed: %s\n", strerror(errno)); @@ -117,13 +117,13 @@ int sigint_install(AvahiSimplePoll *spoll) { p = avahi_simple_poll_get(spoll); watch = p->watch_new(p, pipe_fds[0], AVAHI_WATCH_IN, watch_callback, NULL); assert(watch); - + simple_poll = spoll; return 0; } void sigint_uninstall(void) { - + if (!simple_poll) return; diff --git a/avahi-utils/sigint.h b/avahi-utils/sigint.h index 0bc5c34..4aef74f 100644 --- a/avahi-utils/sigint.h +++ b/avahi-utils/sigint.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-utils/stdb.c b/avahi-utils/stdb.c index b7a5ed3..759ecbd 100644 --- a/avahi-utils/stdb.c +++ b/avahi-utils/stdb.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 @@ -74,10 +74,10 @@ const char* stdb_lookup(const char *name) { data.dptr = NULL; data.dsize = 0; - + if ((loc = setlocale(LC_MESSAGES, NULL))) { char k[256]; - + snprintf(k, sizeof(k), "%s[%s]", name, loc); key.dptr = k; key.dsize = strlen(k); @@ -91,7 +91,7 @@ const char* stdb_lookup(const char *name) { if (!data.dptr) { char l[32], *e; snprintf(l, sizeof(l), "%s", loc); - + if ((e = strchr(l, '@'))) { *e = 0; snprintf(k, sizeof(k), "%s[%s]", name, l); @@ -139,9 +139,9 @@ const char* stdb_lookup(const char *name) { avahi_free(buffer); buffer = avahi_strndup(data.dptr, data.dsize); free(data.dptr); - + return buffer; - + fail: return name; @@ -169,12 +169,12 @@ void stdb_shutdown(void) { char *stdb_getent(void) { datum key; - + if (init() < 0) return NULL; for (;;) { - + if (!enum_key) { #ifdef HAVE_GDBM key = gdbm_firstkey(gdbm_file); @@ -185,7 +185,7 @@ char *stdb_getent(void) { } else { key.dptr = enum_key; key.dsize = strlen(enum_key); - + #ifdef HAVE_GDBM key = gdbm_nextkey(gdbm_file, key); #endif @@ -196,10 +196,10 @@ char *stdb_getent(void) { avahi_free(enum_key); enum_key = NULL; - + if (!key.dptr) return NULL; - + enum_key = avahi_strndup(key.dptr, key.dsize); free(key.dptr); diff --git a/avahi-utils/stdb.h b/avahi-utils/stdb.h index 3f8ccc0..7fab765 100644 --- a/avahi-utils/stdb.h +++ b/avahi-utils/stdb.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/docs/socket-auto-port.c b/docs/socket-auto-port.c index 75dffaf..3c68c70 100644 --- a/docs/socket-auto-port.c +++ b/docs/socket-auto-port.c @@ -12,11 +12,11 @@ int main(int argc, char *argv[]) { struct sockaddr_storage sa; socklen_t salen; uint16_t port; - + if ((s = socket(PF_INET6, SOCK_STREAM, 0)) < 0) { if (errno == EAFNOSUPPORT) s = socket(PF_INET, SOCK_STREAM, 0); - + if (s < 0) { perror("socket()"); return 1; @@ -44,6 +44,6 @@ int main(int argc, char *argv[]) { /* ... hic sunt leones ... */ sleep(60); - + return 0; } diff --git a/examples/client-browse-services.c b/examples/client-browse-services.c index de6a970..b932e0a 100644 --- a/examples/client-browse-services.c +++ b/examples/client-browse-services.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 @@ -63,9 +63,9 @@ static void resolve_callback( case AVAHI_RESOLVER_FOUND: { char a[AVAHI_ADDRESS_STR_MAX], *t; - + fprintf(stderr, "Service '%s' of type '%s' in domain '%s':\n", name, type, domain); - + avahi_address_snprint(a, sizeof(a), address); t = avahi_string_list_to_string(txt); fprintf(stderr, @@ -85,7 +85,7 @@ static void resolve_callback( !!(flags & AVAHI_LOOKUP_RESULT_WIDE_AREA), !!(flags & AVAHI_LOOKUP_RESULT_MULTICAST), !!(flags & AVAHI_LOOKUP_RESULT_CACHED)); - + avahi_free(t); } } @@ -103,7 +103,7 @@ static void browse_callback( const char *domain, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void* userdata) { - + AvahiClient *c = userdata; assert(b); @@ -111,7 +111,7 @@ static void browse_callback( switch (event) { case AVAHI_BROWSER_FAILURE: - + fprintf(stderr, "(Browser) %s\n", avahi_strerror(avahi_client_errno(avahi_service_browser_get_client(b)))); avahi_simple_poll_quit(simple_poll); return; @@ -126,7 +126,7 @@ static void browse_callback( if (!(avahi_service_resolver_new(c, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, resolve_callback, c))) fprintf(stderr, "Failed to resolve service '%s': %s\n", name, avahi_strerror(avahi_client_errno(c))); - + break; case AVAHI_BROWSER_REMOVE: @@ -171,7 +171,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char*argv[]) { fprintf(stderr, "Failed to create client: %s\n", avahi_strerror(error)); goto fail; } - + /* Create the service browser */ if (!(sb = avahi_service_browser_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_http._tcp", NULL, 0, browse_callback, client))) { fprintf(stderr, "Failed to create service browser: %s\n", avahi_strerror(avahi_client_errno(client))); @@ -180,15 +180,15 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char*argv[]) { /* Run the main loop */ avahi_simple_poll_loop(simple_poll); - + ret = 0; - + fail: - + /* Cleanup things */ if (sb) avahi_service_browser_free(sb); - + if (client) avahi_client_free(client); diff --git a/examples/core-browse-services.c b/examples/core-browse-services.c index 53b18ee..65c59fa 100644 --- a/examples/core-browse-services.c +++ b/examples/core-browse-services.c @@ -7,23 +7,23 @@ * End user applications should *not* use this API and should use * the D-Bus or C APIs, please see * client-browse-services.c and glib-integration.c - * + * * I repeat, you probably do *not* want to use this example. */ /*** 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 @@ static void resolve_callback( AvahiStringList *txt, AvahiLookupResultFlags flags, AVAHI_GCC_UNUSED void* userdata) { - + assert(r); /* Called whenever a service has been resolved successfully or timed out */ @@ -74,9 +74,9 @@ static void resolve_callback( case AVAHI_RESOLVER_FOUND: { char a[AVAHI_ADDRESS_STR_MAX], *t; - + fprintf(stderr, "(Resolver) Service '%s' of type '%s' in domain '%s':\n", name, type, domain); - + avahi_address_snprint(a, sizeof(a), address); t = avahi_string_list_to_string(txt); fprintf(stderr, @@ -97,7 +97,7 @@ static void resolve_callback( avahi_free(t); } } - + avahi_s_service_resolver_free(r); } @@ -111,7 +111,7 @@ static void browse_callback( const char *domain, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void* userdata) { - + AvahiServer *s = userdata; assert(b); @@ -120,7 +120,7 @@ static void browse_callback( switch (event) { case AVAHI_BROWSER_FAILURE: - + fprintf(stderr, "(Browser) %s\n", avahi_strerror(avahi_server_errno(server))); avahi_simple_poll_quit(simple_poll); return; @@ -132,10 +132,10 @@ static void browse_callback( function we free it. If the server is terminated before the callback function is called the server will free the resolver for us. */ - + if (!(avahi_s_service_resolver_new(s, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, resolve_callback, s))) fprintf(stderr, "Failed to resolve service '%s': %s\n", name, avahi_strerror(avahi_server_errno(s))); - + break; case AVAHI_BROWSER_REMOVE: @@ -175,7 +175,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char*argv[]) { avahi_address_parse("192.168.50.1", AVAHI_PROTO_UNSPEC, &config.wide_area_servers[0]); config.n_wide_area_servers = 1; config.enable_wide_area = 1; - + /* Allocate a new server */ server = avahi_server_new(avahi_simple_poll_get(simple_poll), &config, NULL, NULL, &error); @@ -187,24 +187,24 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char*argv[]) { fprintf(stderr, "Failed to create server: %s\n", avahi_strerror(error)); goto fail; } - + /* Create the service browser */ if (!(sb = avahi_s_service_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_http._tcp", NULL, 0, browse_callback, server))) { fprintf(stderr, "Failed to create service browser: %s\n", avahi_strerror(avahi_server_errno(server))); goto fail; } - + /* Run the main loop */ avahi_simple_poll_loop(simple_poll); - + ret = 0; - + fail: - + /* Cleanup things */ if (sb) avahi_s_service_browser_free(sb); - + if (server) avahi_server_free(server); diff --git a/examples/core-publish-service.c b/examples/core-publish-service.c index 6370383..d7d7395 100644 --- a/examples/core-publish-service.c +++ b/examples/core-publish-service.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 entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntry /* Called whenever the entry group state changes */ switch (state) { - + case AVAHI_ENTRY_GROUP_ESTABLISHED: /* The entry group has been established successfully */ @@ -57,23 +57,23 @@ static void entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntry case AVAHI_ENTRY_GROUP_COLLISION: { char *n; - + /* A service name collision happened. Let's pick a new name */ n = avahi_alternative_service_name(name); avahi_free(name); name = n; - + fprintf(stderr, "Service name collision, renaming service to '%s'\n", name); - + /* And recreate the services */ create_services(s); break; } - + case AVAHI_ENTRY_GROUP_FAILURE : fprintf(stderr, "Entry group failure: %s\n", avahi_strerror(avahi_server_errno(s))); - + /* Some kind of failure happened while we were registering our services */ avahi_simple_poll_quit(simple_poll); break; @@ -95,7 +95,7 @@ static void create_services(AvahiServer *s) { fprintf(stderr, "avahi_entry_group_new() failed: %s\n", avahi_strerror(avahi_server_errno(s))); goto fail; } - + fprintf(stderr, "Adding service '%s'\n", name); /* Create some random TXT data */ @@ -141,7 +141,7 @@ static void server_callback(AvahiServer *s, AvahiServerState state, AVAHI_GCC_UN case AVAHI_SERVER_RUNNING: /* The serve has startup successfully and registered its host * name on the network, so it's time to create our services */ - + if (!group) create_services(s); @@ -150,16 +150,16 @@ static void server_callback(AvahiServer *s, AvahiServerState state, AVAHI_GCC_UN case AVAHI_SERVER_COLLISION: { char *n; int r; - + /* A host name collision happened. Let's pick a new name for the server */ n = avahi_alternative_host_name(avahi_server_get_host_name(s)); fprintf(stderr, "Host name collision, retrying with '%s'\n", n); r = avahi_server_set_host_name(s, n); avahi_free(n); - + if (r < 0) { fprintf(stderr, "Failed to set new host name: %s\n", avahi_strerror(r)); - + avahi_simple_poll_quit(simple_poll); return; } @@ -169,7 +169,7 @@ static void server_callback(AvahiServer *s, AvahiServerState state, AVAHI_GCC_UN /* Fall through */ case AVAHI_SERVER_REGISTERING: - + /* Let's drop our registered services. When the server is back * in AVAHI_SERVER_RUNNING state we will register them * again with the new host name. */ @@ -179,9 +179,9 @@ static void server_callback(AvahiServer *s, AvahiServerState state, AVAHI_GCC_UN break; case AVAHI_SERVER_FAILURE: - + /* Terminate on failure */ - + fprintf(stderr, "Server failure: %s\n", avahi_strerror(avahi_server_errno(s))); avahi_simple_poll_quit(simple_poll); break; @@ -196,7 +196,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char*argv[]) { AvahiServer *server = NULL; int error; int ret = 1; - + /* Initialize the pseudo-RNG */ srand(time(NULL)); @@ -205,14 +205,14 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char*argv[]) { fprintf(stderr, "Failed to create simple poll object.\n"); goto fail; } - + name = avahi_strdup("MegaPrinter"); /* Let's set the host name for this server. */ avahi_server_config_init(&config); config.host_name = avahi_strdup("gurkiman"); config.publish_workstation = 0; - + /* Allocate a new server */ server = avahi_server_new(avahi_simple_poll_get(simple_poll), &config, server_callback, NULL, &error); @@ -227,11 +227,11 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char*argv[]) { /* Run the main loop */ avahi_simple_poll_loop(simple_poll); - + ret = 0; - + fail: - + /* Cleanup things */ if (server) @@ -241,6 +241,6 @@ fail: avahi_simple_poll_free(simple_poll); avahi_free(name); - + return ret; } diff --git a/examples/glib-integration.c b/examples/glib-integration.c index ab53687..4213d74 100644 --- a/examples/glib-integration.c +++ b/examples/glib-integration.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 @@ -45,7 +45,7 @@ avahi_timeout_event_glib (void *userdata) GMainLoop *loop = userdata; g_message ("GLIB API Timeout reached, quitting main loop!"); - + /* Quit the application */ g_main_loop_quit (loop); @@ -121,7 +121,7 @@ main (AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) goto fail; } - + /* Make a call to get the version string from the daemon */ version = avahi_client_get_version_string (client); @@ -132,7 +132,7 @@ main (AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) goto fail; } - + g_message ("Avahi Server Version: %s", version); /* Start the GLIB Main Loop */ -- 2.39.5