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-client/browser.c | 106 +++++++++++++++---------------- avahi-client/check-nss-test.c | 6 +- avahi-client/check-nss.c | 14 ++--- avahi-client/client-test.c | 30 ++++----- avahi-client/client.h | 10 +-- avahi-client/entrygroup.c | 138 ++++++++++++++++++++--------------------- avahi-client/internal.h | 12 ++-- avahi-client/publish.h | 20 +++--- avahi-client/resolver.c | 112 ++++++++++++++++----------------- avahi-client/rr-test.c | 20 +++--- avahi-client/srv-test.c | 12 ++-- avahi-client/xdg-config-test.c | 8 +-- avahi-client/xdg-config.h | 6 +- 13 files changed, 247 insertions(+), 247 deletions(-) (limited to 'avahi-client') diff --git a/avahi-client/browser.c b/avahi-client/browser.c index 24393b8..1889694 100644 --- a/avahi-client/browser.c +++ b/avahi-client/browser.c @@ -2,17 +2,17 @@ /*** This file is part of avahi. - + avahi is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + avahi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with avahi; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -44,7 +44,7 @@ static void parse_environment(AvahiDomainBrowser *b) { char buf[AVAHI_DOMAIN_NAME_MAX*3], *e, *t, *p; assert(b); - + if (!(e = getenv("AVAHI_BROWSE_DOMAINS"))) return; @@ -60,17 +60,17 @@ static void parse_environment(AvahiDomainBrowser *b) { static void parse_domain_file(AvahiDomainBrowser *b) { FILE *f; char buf[AVAHI_DOMAIN_NAME_MAX]; - + assert(b); if (!(f = avahi_xdg_config_open("avahi/browse-domains"))) return; - - + + while (fgets(buf, sizeof(buf)-1, f)) { char domain[AVAHI_DOMAIN_NAME_MAX]; buf[strcspn(buf, "\n\r")] = 0; - + if (avahi_normalize_name(buf, domain, sizeof(domain))) b->static_browse_domains = avahi_string_list_add(b->static_browse_domains, domain); } @@ -112,7 +112,7 @@ AvahiDomainBrowser* avahi_domain_browser_new( AvahiLookupFlags flags, AvahiDomainBrowserCallback callback, void *userdata) { - + AvahiDomainBrowser *db = NULL; DBusMessage *message = NULL, *reply = NULL; DBusError error; @@ -156,7 +156,7 @@ AvahiDomainBrowser* avahi_domain_browser_new( } db->static_browse_domains = avahi_string_list_reverse(db->static_browse_domains); - + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "DomainBrowserNew"))) { avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; @@ -208,10 +208,10 @@ AvahiDomainBrowser* avahi_domain_browser_new( goto fail; } } - + dbus_message_unref(message); dbus_message_unref(reply); - + return db; fail: @@ -223,7 +223,7 @@ fail: if (db) avahi_domain_browser_free(db); - + if (message) dbus_message_unref(message); @@ -241,13 +241,13 @@ AvahiClient* avahi_domain_browser_get_client (AvahiDomainBrowser *b) { int avahi_domain_browser_free (AvahiDomainBrowser *b) { AvahiClient *client; int r = AVAHI_OK; - + assert(b); assert(b->ref >= 1); if (--(b->ref) >= 1) return AVAHI_OK; - + client = b->client; if (b->path && avahi_client_is_connected(b->client)) @@ -257,7 +257,7 @@ int avahi_domain_browser_free (AvahiDomainBrowser *b) { if (b->defer_timeout) b->client->poll_api->timeout_free(b->defer_timeout); - + avahi_string_list_free(b->static_browse_domains); avahi_free(b->path); avahi_free(b); @@ -276,7 +276,7 @@ DBusHandlerResult avahi_domain_browser_event (AvahiClient *client, AvahiBrowserE assert(client); assert(message); - + dbus_error_init (&error); if (!(path = dbus_message_get_path(message))) @@ -295,7 +295,7 @@ DBusHandlerResult avahi_domain_browser_event (AvahiClient *client, AvahiBrowserE switch (event) { case AVAHI_BROWSER_NEW: case AVAHI_BROWSER_REMOVE: - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_INT32, &interface, @@ -309,14 +309,14 @@ DBusHandlerResult avahi_domain_browser_event (AvahiClient *client, AvahiBrowserE } break; - + case AVAHI_BROWSER_CACHE_EXHAUSTED: case AVAHI_BROWSER_ALL_FOR_NOW: break; case AVAHI_BROWSER_FAILURE: { char *etxt; - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_STRING, &etxt, @@ -325,7 +325,7 @@ DBusHandlerResult avahi_domain_browser_event (AvahiClient *client, AvahiBrowserE fprintf(stderr, "Failed to parse browser event.\n"); goto fail; } - + avahi_client_set_errno(db->client, avahi_error_dbus_to_number(etxt)); break; } @@ -337,7 +337,7 @@ DBusHandlerResult avahi_domain_browser_event (AvahiClient *client, AvahiBrowserE /* We had this entry already in the static entries */ return DBUS_HANDLER_RESULT_HANDLED; } - + db->callback(db, (AvahiIfIndex) interface, (AvahiProtocol) protocol, event, domain, (AvahiLookupResultFlags) flags, db->userdata); return DBUS_HANDLER_RESULT_HANDLED; @@ -354,10 +354,10 @@ AvahiServiceTypeBrowser* avahi_service_type_browser_new( AvahiIfIndex interface, AvahiProtocol protocol, const char *domain, - AvahiLookupFlags flags, + AvahiLookupFlags flags, AvahiServiceTypeBrowserCallback callback, void *userdata) { - + AvahiServiceTypeBrowser *b = NULL; DBusMessage *message = NULL, *reply = NULL; DBusError error; @@ -398,12 +398,12 @@ AvahiServiceTypeBrowser* avahi_service_type_browser_new( avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "ServiceTypeBrowserNew"))) { avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; u_flags = (uint32_t) flags; @@ -446,7 +446,7 @@ AvahiServiceTypeBrowser* avahi_service_type_browser_new( return b; fail: - + if (dbus_error_is_set(&error)) { avahi_client_set_dbus_error(client, &error); dbus_error_free(&error); @@ -454,7 +454,7 @@ fail: if (b) avahi_service_type_browser_free(b); - + if (message) dbus_message_unref(message); @@ -497,7 +497,7 @@ DBusHandlerResult avahi_service_type_browser_event (AvahiClient *client, AvahiBr assert(client); assert(message); - + dbus_error_init (&error); if (!(path = dbus_message_get_path(message))) @@ -513,7 +513,7 @@ DBusHandlerResult avahi_service_type_browser_event (AvahiClient *client, AvahiBr domain = b->domain; interface = b->interface; protocol = b->protocol; - + switch (event) { case AVAHI_BROWSER_NEW: case AVAHI_BROWSER_REMOVE: @@ -530,14 +530,14 @@ DBusHandlerResult avahi_service_type_browser_event (AvahiClient *client, AvahiBr goto fail; } break; - + case AVAHI_BROWSER_CACHE_EXHAUSTED: case AVAHI_BROWSER_ALL_FOR_NOW: break; case AVAHI_BROWSER_FAILURE: { char *etxt; - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_STRING, &etxt, @@ -546,7 +546,7 @@ DBusHandlerResult avahi_service_type_browser_event (AvahiClient *client, AvahiBr fprintf(stderr, "Failed to parse browser event.\n"); goto fail; } - + avahi_client_set_errno(b->client, avahi_error_dbus_to_number(etxt)); break; } @@ -569,10 +569,10 @@ AvahiServiceBrowser* avahi_service_browser_new( AvahiProtocol protocol, const char *type, const char *domain, - AvahiLookupFlags flags, + AvahiLookupFlags flags, AvahiServiceBrowserCallback callback, void *userdata) { - + AvahiServiceBrowser *b = NULL; DBusMessage *message = NULL, *reply = NULL; DBusError error; @@ -598,7 +598,7 @@ AvahiServiceBrowser* avahi_service_browser_new( avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + b->client = client; b->callback = callback; b->userdata = userdata; @@ -613,13 +613,13 @@ AvahiServiceBrowser* avahi_service_browser_new( avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (domain && domain[0]) if (!(b->domain = avahi_strdup(domain))) { avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "ServiceBrowserNew"))) { avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; @@ -664,7 +664,7 @@ AvahiServiceBrowser* avahi_service_browser_new( dbus_message_unref(message); dbus_message_unref(reply); - + return b; fail: @@ -675,7 +675,7 @@ fail: if (b) avahi_service_browser_free(b); - + if (message) dbus_message_unref(message); @@ -737,7 +737,7 @@ DBusHandlerResult avahi_service_browser_event(AvahiClient *client, AvahiBrowserE switch (event) { case AVAHI_BROWSER_NEW: case AVAHI_BROWSER_REMOVE: - + if (!dbus_message_get_args ( message, &error, DBUS_TYPE_INT32, &interface, @@ -759,7 +759,7 @@ DBusHandlerResult avahi_service_browser_event(AvahiClient *client, AvahiBrowserE case AVAHI_BROWSER_FAILURE: { char *etxt; - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_STRING, &etxt, @@ -768,7 +768,7 @@ DBusHandlerResult avahi_service_browser_event(AvahiClient *client, AvahiBrowserE fprintf(stderr, "Failed to parse browser event.\n"); goto fail; } - + avahi_client_set_errno(b->client, avahi_error_dbus_to_number(etxt)); break; } @@ -795,7 +795,7 @@ AvahiRecordBrowser* avahi_record_browser_new( AvahiLookupFlags flags, AvahiRecordBrowserCallback callback, void *userdata) { - + AvahiRecordBrowser *b = NULL; DBusMessage *message = NULL, *reply = NULL; DBusError error; @@ -818,7 +818,7 @@ AvahiRecordBrowser* avahi_record_browser_new( avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + b->client = client; b->callback = callback; b->userdata = userdata; @@ -835,7 +835,7 @@ AvahiRecordBrowser* avahi_record_browser_new( avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "RecordBrowserNew"))) { avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; @@ -881,7 +881,7 @@ AvahiRecordBrowser* avahi_record_browser_new( dbus_message_unref(message); dbus_message_unref(reply); - + return b; fail: @@ -892,7 +892,7 @@ fail: if (b) avahi_record_browser_free(b); - + if (message) dbus_message_unref(message); @@ -978,7 +978,7 @@ DBusHandlerResult avahi_record_browser_event(AvahiClient *client, AvahiBrowserEv for (j = 0; j < 5; j++) dbus_message_iter_next(&iter); - + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY || dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_BYTE) goto fail; @@ -987,12 +987,12 @@ DBusHandlerResult avahi_record_browser_event(AvahiClient *client, AvahiBrowserEv dbus_message_iter_get_fixed_array(&sub, &rdata, &rdata_size); dbus_message_iter_next(&iter); - + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT32) goto fail; dbus_message_iter_get_basic(&iter, &flags); - + break; } @@ -1002,7 +1002,7 @@ DBusHandlerResult avahi_record_browser_event(AvahiClient *client, AvahiBrowserEv case AVAHI_BROWSER_FAILURE: { char *etxt; - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_STRING, &etxt, @@ -1011,7 +1011,7 @@ DBusHandlerResult avahi_record_browser_event(AvahiClient *client, AvahiBrowserEv fprintf(stderr, "Failed to parse browser event.\n"); goto fail; } - + avahi_client_set_errno(b->client, avahi_error_dbus_to_number(etxt)); break; } diff --git a/avahi-client/check-nss-test.c b/avahi-client/check-nss-test.c index 52aa81e..43d6a22 100644 --- a/avahi-client/check-nss-test.c +++ b/avahi-client/check-nss-test.c @@ -2,17 +2,17 @@ /*** This file is part of avahi. - + avahi is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + avahi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with avahi; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 diff --git a/avahi-client/check-nss.c b/avahi-client/check-nss.c index 0a933fa..69eefa5 100644 --- a/avahi-client/check-nss.c +++ b/avahi-client/check-nss.c @@ -2,17 +2,17 @@ /*** This file is part of avahi. - + avahi is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + avahi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with avahi; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -32,19 +32,19 @@ int avahi_nss_support(void) { int b = 0; - + #ifdef HAVE_DLOPEN static const char * const libs[] = { "libnss_mdns.so.2", "libnss_mdns4.so.2", "libnss_mdns6.so.2", NULL }; - + const char * const *l; - + for (l = libs; *l; l++) { void *dl; - + if ((dl = dlopen(*l, RTLD_LAZY))) { b = 1; dlclose(dl); diff --git a/avahi-client/client-test.c b/avahi-client/client-test.c index 7d30651..32e1487 100644 --- a/avahi-client/client-test.c +++ b/avahi-client/client-test.c @@ -2,17 +2,17 @@ /*** This file is part of avahi. - + avahi is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + avahi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with avahi; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -58,7 +58,7 @@ static void avahi_domain_browser_callback( const char *domain, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void *userdata) { - + printf ("DOMAIN-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, domain ? domain : "NULL", (char*)userdata); } @@ -76,7 +76,7 @@ static void avahi_service_resolver_callback( AvahiStringList *txt, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void *userdata) { - + char addr[64]; char *txtr; if (event == AVAHI_RESOLVER_FAILURE) { @@ -99,7 +99,7 @@ static void avahi_service_browser_callback ( const char *domain, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void *userdata) { - + AvahiServiceResolver *sr; printf ("SERVICE-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), name (%s), type (%s), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, name ? name : "NULL", type, domain ? domain : "NULL", (char*)userdata); @@ -120,7 +120,7 @@ static void avahi_service_type_browser_callback ( const char *domain, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void *userdata) { - + printf ("SERVICE-TYPE-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), type (%s), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, type ? type : "NULL", domain ? domain : "NULL", (char*)userdata); } @@ -133,7 +133,7 @@ static void avahi_address_resolver_callback ( const char *name, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void *userdata) { - + char addr[64]; if (event == AVAHI_RESOLVER_FAILURE) { printf ("ADDRESS-RESOLVER: Callback on AddressResolver, timed out.\n"); @@ -152,11 +152,11 @@ static void avahi_host_name_resolver_callback ( const AvahiAddress *a, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void *userdata) { - + AvahiClient *client; AvahiAddressResolver *ar; char addr[64]; - + if (event == AVAHI_RESOLVER_FAILURE) { printf ("HOST-NAME-RESOLVER: Callback on HostNameResolver, timed out.\n"); return; @@ -227,7 +227,7 @@ int main (AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { simple_poll = avahi_simple_poll_new(); poll_api = avahi_simple_poll_get(simple_poll); - + if (!(avahi = avahi_client_new(poll_api, 0, avahi_client_callback, "omghai2u", &error))) { fprintf(stderr, "Client failed: %s\n", avahi_strerror(error)); goto fail; @@ -246,7 +246,7 @@ int main (AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { ret = avahi_client_get_host_name_fqdn (avahi); printf("FQDN: %s (Error Return: %s)\n", ret, ret ? "OK" : avahi_strerror(avahi_client_errno(avahi))); - + cookie = avahi_client_get_local_service_cookie(avahi); printf("Local service cookie: %u (Error Return: %s)\n", cookie, cookie != AVAHI_SERVICE_COOKIE_INVALID ? "OK" : avahi_strerror(avahi_client_errno(avahi))); @@ -254,7 +254,7 @@ int main (AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { printf("Creating entry group: %s\n", group ? "OK" : avahi_strerror(avahi_client_errno (avahi))); assert(group); - + printf("Sucessfully created entry group %p\n", (void*) group); printf("%s\n", avahi_strerror(avahi_entry_group_add_service (group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "Lathiat's Site", "_http._tcp", NULL, NULL, 80, "foo=bar", NULL))); @@ -263,7 +263,7 @@ int main (AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { avahi_entry_group_commit (group); domain = avahi_domain_browser_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DOMAIN_BROWSER_BROWSE, 0, avahi_domain_browser_callback, "omghai3u"); - + if (domain == NULL) printf ("Failed to create domain browser object\n"); else @@ -317,7 +317,7 @@ int main (AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { avahi_simple_poll_loop(simple_poll); printf("terminating...\n"); - + fail: if (avahi) diff --git a/avahi-client/client.h b/avahi-client/client.h index 2f86d02..986afb3 100644 --- a/avahi-client/client.h +++ b/avahi-client/client.h @@ -5,17 +5,17 @@ /*** This file is part of avahi. - + avahi is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + avahi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with avahi; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -44,7 +44,7 @@ typedef enum { AVAHI_CLIENT_S_RUNNING = AVAHI_SERVER_RUNNING, /**< Server state: RUNNING */ AVAHI_CLIENT_S_COLLISION = AVAHI_SERVER_COLLISION, /**< Server state: COLLISION */ AVAHI_CLIENT_FAILURE = 100, /**< Some kind of error happened on the client side */ - AVAHI_CLIENT_CONNECTING = 101 /**< We're still connecting. This state is only entered when AVAHI_CLIENT_NO_FAIL has been passed to avahi_client_new() and the daemon is not yet available. */ + AVAHI_CLIENT_CONNECTING = 101 /**< We're still connecting. This state is only entered when AVAHI_CLIENT_NO_FAIL has been passed to avahi_client_new() and the daemon is not yet available. */ } AvahiClientState; typedef enum { @@ -93,7 +93,7 @@ const char* avahi_client_get_domain_name (AvahiClient*); const char* avahi_client_get_host_name_fqdn (AvahiClient*); /** Get state */ -AvahiClientState avahi_client_get_state(AvahiClient *client); +AvahiClientState avahi_client_get_state(AvahiClient *client); /** @{ \name Error Handling */ diff --git a/avahi-client/entrygroup.c b/avahi-client/entrygroup.c index e2fc3b9..cbe1882 100644 --- a/avahi-client/entrygroup.c +++ b/avahi-client/entrygroup.c @@ -2,17 +2,17 @@ /*** This file is part of avahi. - + avahi is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + avahi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with avahi; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -57,23 +57,23 @@ static int retrieve_state(AvahiEntryGroup *group) { int r = AVAHI_OK; int32_t state; AvahiClient *client; - + dbus_error_init(&error); assert(group); client = group->client; - + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "GetState"))) { r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); goto fail; } - + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); @@ -84,7 +84,7 @@ static int retrieve_state(AvahiEntryGroup *group) { dbus_message_unref(reply); return state; - + fail: if (dbus_error_is_set(&error)) { r = avahi_client_set_dbus_error(client, &error); @@ -120,14 +120,14 @@ AvahiEntryGroup* avahi_entry_group_new (AvahiClient *client, AvahiEntryGroupCall avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + group->client = client; group->callback = callback; group->userdata = userdata; group->state_valid = 0; group->path = NULL; AVAHI_LLIST_PREPEND(AvahiEntryGroup, groups, client->groups, group); - + if (!(message = dbus_message_new_method_call( AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, @@ -148,7 +148,7 @@ AvahiEntryGroup* avahi_entry_group_new (AvahiClient *client, AvahiEntryGroupCall avahi_client_set_errno (client, AVAHI_ERR_DBUS_ERROR); goto fail; } - + if (!(group->path = avahi_strdup (path))) { /* FIXME: We don't remove the object on the server side */ @@ -161,7 +161,7 @@ AvahiEntryGroup* avahi_entry_group_new (AvahiClient *client, AvahiEntryGroupCall avahi_client_set_errno(client, state); goto fail; } - + avahi_entry_group_set_state(group, (AvahiEntryGroupState) state); dbus_message_unref(message); @@ -177,13 +177,13 @@ fail: if (group) avahi_entry_group_free(group); - + if (message) dbus_message_unref(message); if (reply) dbus_message_unref(reply); - + return NULL; } @@ -192,23 +192,23 @@ static int entry_group_simple_method_call(AvahiEntryGroup *group, const char *me DBusError error; int r = AVAHI_OK; AvahiClient *client; - + dbus_error_init(&error); assert(group); client = group->client; - + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, method))) { r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); goto fail; } - + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); @@ -219,7 +219,7 @@ static int entry_group_simple_method_call(AvahiEntryGroup *group, const char *me dbus_message_unref(reply); return AVAHI_OK; - + fail: if (dbus_error_is_set(&error)) { r = avahi_client_set_dbus_error(client, &error); @@ -238,12 +238,12 @@ fail: int avahi_entry_group_free(AvahiEntryGroup *group) { AvahiClient *client = group->client; int r = AVAHI_OK; - + assert(group); - + if (group->path && avahi_client_is_connected(client)) r = entry_group_simple_method_call(group, "Free"); - + AVAHI_LLIST_REMOVE(AvahiEntryGroup, groups, client->groups, group); avahi_free(group->path); @@ -255,7 +255,7 @@ int avahi_entry_group_free(AvahiEntryGroup *group) { int avahi_entry_group_commit(AvahiEntryGroup *group) { int ret; assert(group); - + if (!group->path || !avahi_client_is_connected(group->client)) return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); @@ -269,13 +269,13 @@ int avahi_entry_group_commit(AvahiEntryGroup *group) { int avahi_entry_group_reset(AvahiEntryGroup *group) { int ret; assert(group); - + if (!group->path || !avahi_client_is_connected(group->client)) return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); if ((ret = entry_group_simple_method_call(group, "Reset")) < 0) return ret; - + group->state_valid = 0; return ret; } @@ -285,13 +285,13 @@ int avahi_entry_group_get_state (AvahiEntryGroup *group) { if (group->state_valid) return group->state; - + return retrieve_state(group); } AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup *group) { assert(group); - + return group->client; } @@ -301,7 +301,7 @@ int avahi_entry_group_is_empty (AvahiEntryGroup *group) { int r = AVAHI_OK; int b; AvahiClient *client; - + assert(group); client = group->client; @@ -309,18 +309,18 @@ int avahi_entry_group_is_empty (AvahiEntryGroup *group) { return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); dbus_error_init(&error); - + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "IsEmpty"))) { r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); goto fail; } - + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_BOOLEAN, &b, DBUS_TYPE_INVALID) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); @@ -331,7 +331,7 @@ int avahi_entry_group_is_empty (AvahiEntryGroup *group) { dbus_message_unref(reply); return !!b; - + fail: if (dbus_error_is_set(&error)) { r = avahi_client_set_dbus_error(client, &error); @@ -349,16 +349,16 @@ fail: static int append_rdata(DBusMessage *message, const void *rdata, size_t size) { DBusMessageIter iter, sub; - + assert(message); - + dbus_message_iter_init_append(message, &iter); - + if (!(dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &sub)) || !(dbus_message_iter_append_fixed_array(&sub, DBUS_TYPE_BYTE, &rdata, size)) || !(dbus_message_iter_close_container(&iter, &sub))) return -1; - + return 0; } @@ -373,7 +373,7 @@ static int append_string_list(DBusMessage *message, AvahiStringList *txt) { /* Reverse the string list, so that we can pass it in-order to the server */ txt = avahi_string_list_reverse(txt); - + if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "ay", &sub)) goto fail; @@ -381,7 +381,7 @@ static int append_string_list(DBusMessage *message, AvahiStringList *txt) { for (p = txt; p != NULL; p = p->next) { DBusMessageIter sub2; const uint8_t *data = p->text; - + if (!(dbus_message_iter_open_container(&sub, DBUS_TYPE_ARRAY, "y", &sub2)) || !(dbus_message_iter_append_fixed_array(&sub2, DBUS_TYPE_BYTE, &data, p->size)) || !(dbus_message_iter_close_container(&sub, &sub2))) @@ -412,7 +412,7 @@ int avahi_entry_group_add_service_strlst( const char *host, uint16_t port, AvahiStringList *txt) { - + DBusMessage *message = NULL, *reply = NULL; int r = AVAHI_OK; DBusError error; @@ -434,9 +434,9 @@ int avahi_entry_group_add_service_strlst( if (!host) host = ""; - + dbus_error_init(&error); - + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddService"))) { r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; @@ -461,13 +461,13 @@ int avahi_entry_group_add_service_strlst( r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); goto fail; } - + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); @@ -480,7 +480,7 @@ int avahi_entry_group_add_service_strlst( return AVAHI_OK; fail: - + if (dbus_error_is_set(&error)) { r = avahi_client_set_dbus_error(client, &error); dbus_error_free(&error); @@ -506,7 +506,7 @@ int avahi_entry_group_add_service( const char *host, uint16_t port, ...) { - + va_list va; int r; AvahiStringList *txt; @@ -552,7 +552,7 @@ int avahi_entry_group_add_service_subtype( domain = ""; dbus_error_init(&error); - + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddServiceSubtype"))) { r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; @@ -575,13 +575,13 @@ int avahi_entry_group_add_service_subtype( r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); goto fail; } - + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); @@ -594,7 +594,7 @@ int avahi_entry_group_add_service_subtype( return AVAHI_OK; fail: - + if (dbus_error_is_set(&error)) { r = avahi_client_set_dbus_error(client, &error); dbus_error_free(&error); @@ -615,9 +615,9 @@ int avahi_entry_group_update_service_txt( AvahiIfIndex interface, AvahiProtocol protocol, AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, + const char *name, + const char *type, + const char *domain, ...) { va_list va; @@ -637,9 +637,9 @@ int avahi_entry_group_update_service_txt_strlst( AvahiIfIndex interface, AvahiProtocol protocol, AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, + const char *name, + const char *type, + const char *domain, AvahiStringList *txt) { DBusMessage *message = NULL, *reply = NULL; @@ -660,9 +660,9 @@ int avahi_entry_group_update_service_txt_strlst( if (!domain) domain = ""; - + dbus_error_init(&error); - + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "UpdateServiceTxt"))) { r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; @@ -691,7 +691,7 @@ int avahi_entry_group_update_service_txt_strlst( r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); goto fail; } - + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); @@ -704,7 +704,7 @@ int avahi_entry_group_update_service_txt_strlst( return AVAHI_OK; fail: - + if (dbus_error_is_set(&error)) { r = avahi_client_set_dbus_error(client, &error); dbus_error_free(&error); @@ -745,7 +745,7 @@ int avahi_entry_group_add_address( return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); dbus_error_init(&error); - + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddAddress"))) { r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; @@ -754,7 +754,7 @@ int avahi_entry_group_add_address( i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; u_flags = (uint32_t) flags; - + if (!avahi_address_snprint (s_address, sizeof (s_address), a)) { r = avahi_client_set_errno(client, AVAHI_ERR_INVALID_ADDRESS); @@ -772,13 +772,13 @@ int avahi_entry_group_add_address( r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); goto fail; } - + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); @@ -791,7 +791,7 @@ int avahi_entry_group_add_address( return AVAHI_OK; fail: - + if (dbus_error_is_set(&error)) { r = avahi_client_set_dbus_error(client, &error); dbus_error_free(&error); @@ -834,7 +834,7 @@ int avahi_entry_group_add_record( return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); dbus_error_init(&error); - + if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddRecord"))) { r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; @@ -843,7 +843,7 @@ int avahi_entry_group_add_record( i_interface = (int32_t) interface; i_protocol = (int32_t) protocol; u_flags = (uint32_t) flags; - + if (!dbus_message_append_args( message, DBUS_TYPE_INT32, &i_interface, @@ -857,13 +857,13 @@ int avahi_entry_group_add_record( r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY); goto fail; } - + if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); goto fail; } - + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) || dbus_error_is_set (&error)) { r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); @@ -876,7 +876,7 @@ int avahi_entry_group_add_record( return AVAHI_OK; fail: - + if (dbus_error_is_set(&error)) { r = avahi_client_set_dbus_error(client, &error); dbus_error_free(&error); diff --git a/avahi-client/internal.h b/avahi-client/internal.h index e49dd15..f4ff938 100644 --- a/avahi-client/internal.h +++ b/avahi-client/internal.h @@ -5,17 +5,17 @@ /*** This file is part of avahi. - + avahi is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + avahi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with avahi; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -39,10 +39,10 @@ struct AvahiClient { char *version_string, *host_name, *host_name_fqdn, *domain_name; uint32_t local_service_cookie; int local_service_cookie_valid; - + AvahiClientCallback callback; void *userdata; - + AVAHI_LLIST_HEAD(AvahiEntryGroup, groups); AVAHI_LLIST_HEAD(AvahiDomainBrowser, domain_browsers); AVAHI_LLIST_HEAD(AvahiServiceBrowser, service_browsers); @@ -65,7 +65,7 @@ struct AvahiEntryGroup { struct AvahiDomainBrowser { int ref; - + char *path; AvahiClient *client; AvahiDomainBrowserCallback callback; diff --git a/avahi-client/publish.h b/avahi-client/publish.h index 1efc85f..0884d3e 100644 --- a/avahi-client/publish.h +++ b/avahi-client/publish.h @@ -5,17 +5,17 @@ /*** This file is part of avahi. - + avahi is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + avahi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with avahi; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -92,7 +92,7 @@ int avahi_entry_group_add_service( AvahiPublishFlags flags /**< Usually 0, unless you know what you do */, const char *name /**< The name for the new service. Must be valid service name. i.e. a string shorter than 63 characters and valid UTF-8. May not be NULL. */, const char *type /**< The service type for the new service, such as _http._tcp. May not be NULL. */, - const char *domain /**< The domain to register this domain in. We recommend to pass NULL here, to let the daemon decide */, + const char *domain /**< The domain to register this domain in. We recommend to pass NULL here, to let the daemon decide */, const char *host /**< The host this services is residing on. We recommend to pass NULL here, the daemon will than automatically insert the local host name in that case */, uint16_t port /**< The IP port number of this service */, ...) AVAHI_GCC_SENTINEL; @@ -127,9 +127,9 @@ int avahi_entry_group_update_service_txt( AvahiIfIndex interface /**< The interface this service is announced on. This should match the value passed to the original avahi_entry_group_add_service() call. */, AvahiProtocol protocol /**< The protocol this service is announced with. This should match the value passed to the original avahi_entry_group_add_service() call. */, AvahiPublishFlags flags /**< Only != 0 if you really know what you do */, - const char *name /**< The name of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, - const char *type /**< The type of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, - const char *domain /**< The domain this service resides is, as passed to avahi_entry_group_add_service(). May be NULL. */, + const char *name /**< The name of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, + const char *type /**< The type of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, + const char *domain /**< The domain this service resides is, as passed to avahi_entry_group_add_service(). May be NULL. */, ...) AVAHI_GCC_SENTINEL; /** Update a TXT record for an existing service. Similar to avahi_entry_group_update_service_txt() but takes an AvahiStringList for the TXT strings, instead of a NULL terminated list of arguments. */ @@ -138,9 +138,9 @@ int avahi_entry_group_update_service_txt_strlst( AvahiIfIndex interface, AvahiProtocol protocol, AvahiPublishFlags flags, - const char *name, - const char *type, - const char *domain, + const char *name, + const char *type, + const char *domain, AvahiStringList *strlst); /** \cond fulldocs */ diff --git a/avahi-client/resolver.c b/avahi-client/resolver.c index 4403a12..c1ace37 100644 --- a/avahi-client/resolver.c +++ b/avahi-client/resolver.c @@ -2,17 +2,17 @@ /*** This file is part of avahi. - + avahi is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + avahi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with avahi; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -48,7 +48,7 @@ DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolv assert(client); assert(message); - + dbus_error_init (&error); if (!(path = dbus_message_get_path(message))) @@ -70,7 +70,7 @@ DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolv uint16_t port; DBusMessageIter iter, sub; AvahiAddress a; - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_INT32, &interface, @@ -84,48 +84,48 @@ DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolv DBUS_TYPE_UINT16, &port, DBUS_TYPE_INVALID) || dbus_error_is_set (&error)) { - + fprintf(stderr, "Failed to parse resolver event.\n"); goto fail; } - + dbus_message_iter_init(message, &iter); - + for (j = 0; j < 9; j++) dbus_message_iter_next(&iter); - + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY || dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_ARRAY) { fprintf(stderr, "Error parsing service resolving message\n"); goto fail; } - + strlst = NULL; dbus_message_iter_recurse(&iter, &sub); - + for (;;) { DBusMessageIter sub2; int at; const uint8_t *k; int n; - + if ((at = dbus_message_iter_get_arg_type(&sub)) == DBUS_TYPE_INVALID) break; - + assert(at == DBUS_TYPE_ARRAY); - + if (dbus_message_iter_get_element_type(&sub) != DBUS_TYPE_BYTE) { fprintf(stderr, "Error parsing service resolving message\n"); goto fail; } - + dbus_message_iter_recurse(&sub, &sub2); k = NULL; n = 0; dbus_message_iter_get_fixed_array(&sub2, &k, &n); if (k && n > 0) strlst = avahi_string_list_add_arbitrary(strlst, k, n); - + dbus_message_iter_next(&sub); } @@ -137,23 +137,23 @@ DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolv } dbus_message_iter_get_basic(&iter, &flags); - + assert(address); if (address[0] == 0) address = NULL; else avahi_address_parse(address, (AvahiProtocol) aprotocol, &a); - + r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, type, domain, host, address ? &a : NULL, port, strlst, (AvahiLookupResultFlags) flags, r->userdata); - + avahi_string_list_free(strlst); break; } - + case AVAHI_RESOLVER_FAILURE: { char *etxt; - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_STRING, &etxt, @@ -162,7 +162,7 @@ DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolv fprintf(stderr, "Failed to parse resolver event.\n"); goto fail; } - + avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt)); r->callback(r, r->interface, r->protocol, event, r->name, r->type, r->domain, NULL, NULL, 0, NULL, 0, r->userdata); break; @@ -171,7 +171,7 @@ DBusHandlerResult avahi_service_resolver_event (AvahiClient *client, AvahiResolv return DBUS_HANDLER_RESULT_HANDLED; - + fail: dbus_error_free (&error); avahi_string_list_free(strlst); @@ -196,7 +196,7 @@ AvahiServiceResolver * avahi_service_resolver_new( int32_t i_interface, i_protocol, i_aprotocol; uint32_t u_flags; char *path; - + assert(client); assert(type); @@ -205,7 +205,7 @@ AvahiServiceResolver * avahi_service_resolver_new( if (!name) name = ""; - + dbus_error_init (&error); if (!avahi_client_is_connected(client)) { @@ -225,7 +225,7 @@ AvahiServiceResolver * avahi_service_resolver_new( r->name = r->type = r->domain = NULL; r->interface = interface; r->protocol = protocol; - + AVAHI_LLIST_PREPEND(AvahiServiceResolver, service_resolvers, client->service_resolvers, r); if (name && name[0]) @@ -244,8 +244,8 @@ AvahiServiceResolver * avahi_service_resolver_new( avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - - + + if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "ServiceResolverNew"))) { avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; @@ -290,13 +290,13 @@ AvahiServiceResolver * avahi_service_resolver_new( avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY); goto fail; } - + dbus_message_unref(message); dbus_message_unref(reply); return r; - + fail: if (dbus_error_is_set(&error)) { @@ -306,13 +306,13 @@ fail: if (r) avahi_service_resolver_free(r); - + if (message) dbus_message_unref(message); if (reply) dbus_message_unref(reply); - + return NULL; } @@ -353,7 +353,7 @@ DBusHandlerResult avahi_host_name_resolver_event (AvahiClient *client, AvahiReso assert(client); assert(message); - + dbus_error_init (&error); if (!(path = dbus_message_get_path(message))) @@ -372,7 +372,7 @@ DBusHandlerResult avahi_host_name_resolver_event (AvahiClient *client, AvahiReso uint32_t flags; char *name, *address; AvahiAddress a; - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_INT32, &interface, @@ -386,20 +386,20 @@ DBusHandlerResult avahi_host_name_resolver_event (AvahiClient *client, AvahiReso fprintf(stderr, "Failed to parse resolver event.\n"); goto fail; } - + assert(address); if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) { fprintf(stderr, "Failed to parse address\n"); goto fail; } - + r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, &a, (AvahiLookupResultFlags) flags, r->userdata); break; } - + case AVAHI_RESOLVER_FAILURE: { char *etxt; - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_STRING, &etxt, @@ -408,7 +408,7 @@ DBusHandlerResult avahi_host_name_resolver_event (AvahiClient *client, AvahiReso fprintf(stderr, "Failed to parse resolver event.\n"); goto fail; } - + avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt)); r->callback(r, r->interface, r->protocol, event, r->host_name, NULL, 0, r->userdata); break; @@ -416,7 +416,7 @@ DBusHandlerResult avahi_host_name_resolver_event (AvahiClient *client, AvahiReso } return DBUS_HANDLER_RESULT_HANDLED; - + fail: dbus_error_free (&error); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; @@ -439,7 +439,7 @@ AvahiHostNameResolver * avahi_host_name_resolver_new( int32_t i_interface, i_protocol, i_aprotocol; uint32_t u_flags; char *path; - + assert(client); assert(name); @@ -462,7 +462,7 @@ AvahiHostNameResolver * avahi_host_name_resolver_new( r->interface = interface; r->protocol = protocol; r->host_name = NULL; - + AVAHI_LLIST_PREPEND(AvahiHostNameResolver, host_name_resolvers, client->host_name_resolvers, r); if (!(r->host_name = avahi_strdup(name))) { @@ -517,7 +517,7 @@ AvahiHostNameResolver * avahi_host_name_resolver_new( dbus_message_unref(reply); return r; - + fail: if (dbus_error_is_set(&error)) { @@ -527,7 +527,7 @@ fail: if (r) avahi_host_name_resolver_free(r); - + if (message) dbus_message_unref(message); @@ -572,7 +572,7 @@ DBusHandlerResult avahi_address_resolver_event (AvahiClient *client, AvahiResolv assert(client); assert(message); - + dbus_error_init (&error); if (!(path = dbus_message_get_path(message))) @@ -591,7 +591,7 @@ DBusHandlerResult avahi_address_resolver_event (AvahiClient *client, AvahiResolv uint32_t flags; char *name, *address; AvahiAddress a; - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_INT32, &interface, @@ -605,20 +605,20 @@ DBusHandlerResult avahi_address_resolver_event (AvahiClient *client, AvahiResolv fprintf(stderr, "Failed to parse resolver event.\n"); goto fail; } - + assert(address); if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) { fprintf(stderr, "Failed to parse address\n"); goto fail; } - + r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, &a, name, (AvahiLookupResultFlags) flags, r->userdata); break; } case AVAHI_RESOLVER_FAILURE: { char *etxt; - + if (!dbus_message_get_args( message, &error, DBUS_TYPE_STRING, &etxt, @@ -627,7 +627,7 @@ DBusHandlerResult avahi_address_resolver_event (AvahiClient *client, AvahiResolv fprintf(stderr, "Failed to parse resolver event.\n"); goto fail; } - + avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt)); r->callback(r, r->interface, r->protocol, event, &r->address, NULL, 0, r->userdata); break; @@ -635,7 +635,7 @@ DBusHandlerResult avahi_address_resolver_event (AvahiClient *client, AvahiResolv } return DBUS_HANDLER_RESULT_HANDLED; - + fail: dbus_error_free (&error); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; @@ -646,7 +646,7 @@ AvahiAddressResolver * avahi_address_resolver_new( AvahiIfIndex interface, AvahiProtocol protocol, const AvahiAddress *a, - AvahiLookupFlags flags, + AvahiLookupFlags flags, AvahiAddressResolverCallback callback, void *userdata) { @@ -685,7 +685,7 @@ AvahiAddressResolver * avahi_address_resolver_new( r->interface = interface; r->protocol = protocol; r->address = *a; - + AVAHI_LLIST_PREPEND(AvahiAddressResolver, address_resolvers, client->address_resolvers, r); if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "AddressResolverNew"))) { @@ -720,7 +720,7 @@ AvahiAddressResolver * avahi_address_resolver_new( avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); goto fail; } - + if (!(r->path = avahi_strdup(path))) { /* FIXME: We don't remove the object on the server side */ @@ -733,7 +733,7 @@ AvahiAddressResolver * avahi_address_resolver_new( dbus_message_unref(reply); return r; - + fail: if (dbus_error_is_set(&error)) { @@ -743,7 +743,7 @@ fail: if (r) avahi_address_resolver_free(r); - + if (message) dbus_message_unref(message); diff --git a/avahi-client/rr-test.c b/avahi-client/rr-test.c index 9fffa5d..2a5d64a 100644 --- a/avahi-client/rr-test.c +++ b/avahi-client/rr-test.c @@ -2,17 +2,17 @@ /*** This file is part of avahi. - + avahi is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + avahi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with avahi; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -37,11 +37,11 @@ static void hexdump(const void* p, size_t size) { assert(p); printf("Dumping %lu bytes from %p:\n", (unsigned long) size, p); - + while (size > 0) { unsigned i; - for (i = 0; i < 16; i++) { + for (i = 0; i < 16; i++) { if (i < size) printf("%02x ", c[i]); else @@ -54,14 +54,14 @@ static void hexdump(const void* p, size_t size) { else printf(" "); } - + printf("\n"); c += 16; if (size <= 16) break; - + size -= 16; } } @@ -91,13 +91,13 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { const AvahiPoll *poll_api; AvahiClient *client; AvahiRecordBrowser *r; - + simple_poll = avahi_simple_poll_new(); assert(simple_poll); - + poll_api = avahi_simple_poll_get(simple_poll); assert(poll_api); - + client = avahi_client_new(poll_api, 0, NULL, NULL, NULL); assert(client); diff --git a/avahi-client/srv-test.c b/avahi-client/srv-test.c index 5242947..5f5e1de 100644 --- a/avahi-client/srv-test.c +++ b/avahi-client/srv-test.c @@ -2,17 +2,17 @@ /*** This file is part of avahi. - + avahi is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + avahi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with avahi; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -56,13 +56,13 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { const AvahiPoll *poll_api; AvahiClient *client; AvahiServiceResolver *r; - + simple_poll = avahi_simple_poll_new(); assert(simple_poll); - + poll_api = avahi_simple_poll_get(simple_poll); assert(poll_api); - + client = avahi_client_new(poll_api, 0, NULL, NULL, NULL); assert(client); diff --git a/avahi-client/xdg-config-test.c b/avahi-client/xdg-config-test.c index 2e1c88f..35ed25c 100644 --- a/avahi-client/xdg-config-test.c +++ b/avahi-client/xdg-config-test.c @@ -2,17 +2,17 @@ /*** This file is part of avahi. - + avahi is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + avahi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with avahi; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -32,7 +32,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { FILE *f; f = avahi_xdg_config_open("foo"); - + if (f) fclose(f); diff --git a/avahi-client/xdg-config.h b/avahi-client/xdg-config.h index 88f66a8..9948580 100644 --- a/avahi-client/xdg-config.h +++ b/avahi-client/xdg-config.h @@ -5,17 +5,17 @@ /*** This file is part of avahi. - + avahi is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + avahi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with avahi; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -- cgit