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/dbus-util.c | 90 ++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 45 deletions(-) (limited to 'avahi-daemon/dbus-util.c') 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; } -- cgit