From a97605e07ad7f44f2f65e15be64880e61a39ab43 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 25 Jun 2010 01:08:29 +0200 Subject: from now on we enforce a strict whitespace regime --- avahi-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 +- 30 files changed, 429 insertions(+), 429 deletions(-) (limited to 'avahi-daemon') 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 -- cgit