summaryrefslogtreecommitdiffstats
path: root/avahi-compat-libdns_sd
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-06-25 01:08:29 +0200
committerLennart Poettering <lennart@poettering.net>2010-06-25 01:08:29 +0200
commita97605e07ad7f44f2f65e15be64880e61a39ab43 (patch)
tree740527503048f5a2b2078741cfd13fc2ae6d4d1e /avahi-compat-libdns_sd
parent238909aaff10489fe538c8c54e3f82fe8a54b849 (diff)
from now on we enforce a strict whitespace regime
Diffstat (limited to 'avahi-compat-libdns_sd')
-rw-r--r--avahi-compat-libdns_sd/compat.c184
-rw-r--r--avahi-compat-libdns_sd/dns_sd.h66
-rw-r--r--avahi-compat-libdns_sd/null-test.c6
-rw-r--r--avahi-compat-libdns_sd/txt.c56
-rw-r--r--avahi-compat-libdns_sd/unsupported.c18
-rw-r--r--avahi-compat-libdns_sd/warn.c24
-rw-r--r--avahi-compat-libdns_sd/warn.h6
7 files changed, 180 insertions, 180 deletions
diff --git a/avahi-compat-libdns_sd/compat.c b/avahi-compat-libdns_sd/compat.c
index 7c2686a..819b770 100644
--- a/avahi-compat-libdns_sd/compat.c
+++ b/avahi-compat-libdns_sd/compat.c
@@ -2,17 +2,17 @@
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@@ -64,7 +64,7 @@ struct type_info {
struct _DNSServiceRef_t {
int n_ref;
-
+
AvahiSimplePoll *simple_poll;
int thread_fd, main_fd;
@@ -73,7 +73,7 @@ struct _DNSServiceRef_t {
int thread_running;
pthread_mutex_t mutex;
-
+
void *context;
DNSServiceBrowseReply service_browser_callback;
DNSServiceResolveReply service_resolver_callback;
@@ -100,10 +100,10 @@ static DNSServiceErrorType map_error(int error) {
switch (error) {
case AVAHI_OK :
return kDNSServiceErr_NoError;
-
+
case AVAHI_ERR_BAD_STATE :
return kDNSServiceErr_BadState;
-
+
case AVAHI_ERR_INVALID_HOST_NAME:
case AVAHI_ERR_INVALID_DOMAIN_NAME:
case AVAHI_ERR_INVALID_TTL:
@@ -137,13 +137,13 @@ static DNSServiceErrorType map_error(int error) {
case AVAHI_ERR_INVALID_INTERFACE:
case AVAHI_ERR_INVALID_PROTOCOL:
return kDNSServiceErr_BadInterfaceIndex;
-
+
case AVAHI_ERR_INVALID_FLAGS:
return kDNSServiceErr_BadFlags;
-
+
case AVAHI_ERR_NOT_FOUND:
return kDNSServiceErr_NoSuchName;
-
+
case AVAHI_ERR_VERSION_MISMATCH:
return kDNSServiceErr_Incompatible;
@@ -179,7 +179,7 @@ static void type_info_free(struct type_info *i) {
static int type_info_parse(struct type_info *i, const char *t) {
char *token = NULL;
-
+
assert(i);
assert(t);
@@ -190,12 +190,12 @@ static int type_info_parse(struct type_info *i, const char *t) {
if (*t == 0)
break;
-
+
l = strcspn(t, ",");
if (l <= 0)
goto fail;
-
+
token = avahi_strndup(t, l);
if (!token)
@@ -211,7 +211,7 @@ static int type_info_parse(struct type_info *i, const char *t) {
token = NULL;
} else {
char *fst;
-
+
/* This is not the first token, hence a subtype */
if (!(fst = avahi_strdup_printf("%s._sub.%s", token, i->type)))
@@ -239,7 +239,7 @@ static int type_info_parse(struct type_info *i, const char *t) {
if (i->type)
return 0;
-
+
fail:
type_info_free(i);
avahi_free(token);
@@ -265,7 +265,7 @@ static int read_command(int fd) {
char command;
assert(fd >= 0);
-
+
if ((r = read(fd, &command, 1)) != 1) {
fprintf(stderr, __FILE__": read() failed: %s\n", r < 0 ? strerror(errno) : "EOF");
return -1;
@@ -288,15 +288,15 @@ static int write_command(int fd, char reply) {
static int poll_func(struct pollfd *ufds, unsigned int nfds, int timeout, void *userdata) {
DNSServiceRef sdref = userdata;
int ret;
-
+
assert(sdref);
-
+
ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex));
/* fprintf(stderr, "pre-syscall\n"); */
ret = poll(ufds, nfds, timeout);
/* fprintf(stderr, "post-syscall\n"); */
-
+
ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex));
return ret;
@@ -308,7 +308,7 @@ static void * thread_func(void *data) {
sigfillset(&mask);
pthread_sigmask(SIG_BLOCK, &mask, NULL);
-
+
sdref->thread = pthread_self();
sdref->thread_running = 1;
@@ -319,7 +319,7 @@ static void * thread_func(void *data) {
break;
/* fprintf(stderr, "Command: %c\n", command); */
-
+
switch (command) {
case COMMAND_POLL: {
@@ -329,12 +329,12 @@ static void * thread_func(void *data) {
for (;;) {
errno = 0;
-
+
if ((ret = avahi_simple_poll_run(sdref->simple_poll)) < 0) {
if (errno == EINTR)
continue;
-
+
fprintf(stderr, __FILE__": avahi_simple_poll_run() failed: %s\n", strerror(errno));
}
@@ -345,14 +345,14 @@ static void * thread_func(void *data) {
if (write_command(sdref->thread_fd, ret < 0 ? COMMAND_POLL_FAILED : COMMAND_POLL_DONE) < 0)
break;
-
+
break;
}
case COMMAND_QUIT:
return NULL;
}
-
+
}
return NULL;
@@ -402,12 +402,12 @@ static DNSServiceRef sdref_new(void) {
/* Queue an initial POLL command for the thread */
if (write_command(sdref->main_fd, COMMAND_POLL) < 0)
goto fail;
-
+
if (pthread_create(&sdref->thread, NULL, thread_func, sdref) != 0)
goto fail;
sdref->thread_running = 1;
-
+
return sdref;
fail:
@@ -420,7 +420,7 @@ fail:
static void sdref_free(DNSServiceRef sdref) {
assert(sdref);
-
+
if (sdref->thread_running) {
ASSERT_SUCCESS(write_command(sdref->main_fd, COMMAND_QUIT));
avahi_simple_poll_wakeup(sdref->simple_poll);
@@ -447,9 +447,9 @@ static void sdref_free(DNSServiceRef sdref) {
avahi_free(sdref->service_host);
type_info_free(&sdref->type_info);
-
+
avahi_string_list_free(sdref->service_txt);
-
+
avahi_free(sdref);
}
@@ -471,7 +471,7 @@ static void sdref_unref(DNSServiceRef sdref) {
int DNSSD_API DNSServiceRefSockFD(DNSServiceRef sdref) {
AVAHI_WARN_LINKAGE;
-
+
if (!sdref || sdref->n_ref <= 0)
return -1;
@@ -485,15 +485,15 @@ DNSServiceErrorType DNSSD_API DNSServiceProcessResult(DNSServiceRef sdref) {
if (!sdref || sdref->n_ref <= 0)
return kDNSServiceErr_BadParam;
-
+
sdref_ref(sdref);
ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex));
-
+
/* Cleanup notification socket */
if (read_command(sdref->main_fd) != COMMAND_POLL_DONE)
goto finish;
-
+
if (avahi_simple_poll_dispatch(sdref->simple_poll) < 0)
goto finish;
@@ -508,13 +508,13 @@ DNSServiceErrorType DNSSD_API DNSServiceProcessResult(DNSServiceRef sdref) {
/* Request the poll */
if (write_command(sdref->main_fd, COMMAND_POLL) < 0)
goto finish;
-
+
ret = kDNSServiceErr_NoError;
-
+
finish:
ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex));
-
+
sdref_unref(sdref);
return ret;
@@ -546,7 +546,7 @@ static void service_browser_callback(
type = add_trailing_dot(type, type_fixed, sizeof(type_fixed));
domain = add_trailing_dot(domain, domain_fixed, sizeof(domain_fixed));
-
+
switch (event) {
case AVAHI_BROWSER_NEW:
sdref->service_browser_callback(sdref, kDNSServiceFlagsAdd, interface, kDNSServiceErr_NoError, name, type, domain, sdref->context);
@@ -559,7 +559,7 @@ static void service_browser_callback(
case AVAHI_BROWSER_FAILURE:
sdref->service_browser_callback(sdref, 0, interface, map_error(avahi_client_errno(sdref->client)), NULL, NULL, NULL, sdref->context);
break;
-
+
case AVAHI_BROWSER_CACHE_EXHAUSTED:
case AVAHI_BROWSER_ALL_FOR_NOW:
break;
@@ -569,7 +569,7 @@ static void service_browser_callback(
static void generic_client_callback(AvahiClient *s, AvahiClientState state, void* userdata) {
DNSServiceRef sdref = userdata;
int error = kDNSServiceErr_Unknown;
-
+
assert(s);
assert(sdref);
assert(sdref->n_ref >= 1);
@@ -609,7 +609,7 @@ DNSServiceErrorType DNSSD_API DNSServiceBrowse(
DNSServiceRef sdref = NULL;
AvahiIfIndex ifindex;
struct type_info type_info;
-
+
AVAHI_WARN_LINKAGE;
if (!ret_sdref || !regtype)
@@ -622,7 +622,7 @@ DNSServiceErrorType DNSSD_API DNSServiceBrowse(
}
type_info_init(&type_info);
-
+
if (type_info_parse(&type_info, regtype) < 0 || type_info.n_subtypes > 1) {
type_info_free(&type_info);
@@ -630,7 +630,7 @@ DNSServiceErrorType DNSSD_API DNSServiceBrowse(
return kDNSServiceErr_Unsupported;
} else
regtype = type_info.subtypes ? (char*) type_info.subtypes->text : type_info.type;
-
+
if (!(sdref = sdref_new())) {
type_info_free(&type_info);
return kDNSServiceErr_Unknown;
@@ -640,26 +640,26 @@ DNSServiceErrorType DNSSD_API DNSServiceBrowse(
sdref->service_browser_callback = callback;
ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex));
-
+
if (!(sdref->client = avahi_client_new(avahi_simple_poll_get(sdref->simple_poll), 0, generic_client_callback, sdref, &error))) {
ret = map_error(error);
goto finish;
}
ifindex = interface == kDNSServiceInterfaceIndexAny ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface;
-
+
if (!(sdref->service_browser = avahi_service_browser_new(sdref->client, ifindex, AVAHI_PROTO_UNSPEC, regtype, domain, 0, service_browser_callback, sdref))) {
ret = map_error(avahi_client_errno(sdref->client));
goto finish;
}
-
+
ret = kDNSServiceErr_NoError;
*ret_sdref = sdref;
-
+
finish:
ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex));
-
+
if (ret != kDNSServiceErr_NoError)
DNSServiceRefDeallocate(sdref);
@@ -707,7 +707,7 @@ static void service_resolver_callback(
assert(ret == AVAHI_OK);
strcat(full_name, ".");
-
+
sdref->service_resolver_callback(sdref, 0, interface, kDNSServiceErr_NoError, full_name, host_name, htons(port), l, (unsigned char*) p, sdref->context);
avahi_free(p);
@@ -753,27 +753,27 @@ DNSServiceErrorType DNSSD_API DNSServiceResolve(
sdref->service_resolver_callback = callback;
ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex));
-
+
if (!(sdref->client = avahi_client_new(avahi_simple_poll_get(sdref->simple_poll), 0, generic_client_callback, sdref, &error))) {
ret = map_error(error);
goto finish;
}
ifindex = interface == kDNSServiceInterfaceIndexAny ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface;
-
+
if (!(sdref->service_resolver = avahi_service_resolver_new(sdref->client, ifindex, AVAHI_PROTO_UNSPEC, name, regtype, domain, AVAHI_PROTO_UNSPEC, 0, service_resolver_callback, sdref))) {
ret = map_error(avahi_client_errno(sdref->client));
goto finish;
}
-
+
ret = kDNSServiceErr_NoError;
*ret_sdref = sdref;
-
+
finish:
ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex));
-
+
if (ret != kDNSServiceErr_NoError)
DNSServiceRefDeallocate(sdref);
@@ -782,7 +782,7 @@ finish:
int DNSSD_API DNSServiceConstructFullName (
char *fullName,
- const char *service,
+ const char *service,
const char *regtype,
const char *domain) {
@@ -793,7 +793,7 @@ int DNSSD_API DNSServiceConstructFullName (
if (avahi_service_name_join(fullName, kDNSServiceMaxDomainName, service, regtype, domain) < 0)
return -1;
-
+
return 0;
}
@@ -827,7 +827,7 @@ static void domain_browser_callback(
case AVAHI_BROWSER_FAILURE:
sdref->domain_browser_callback(sdref, 0, interface, map_error(avahi_client_errno(sdref->client)), domain, sdref->context);
break;
-
+
case AVAHI_BROWSER_CACHE_EXHAUSTED:
case AVAHI_BROWSER_ALL_FOR_NOW:
break;
@@ -865,28 +865,28 @@ DNSServiceErrorType DNSSD_API DNSServiceEnumerateDomains(
sdref->domain_browser_callback = callback;
ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex));
-
+
if (!(sdref->client = avahi_client_new(avahi_simple_poll_get(sdref->simple_poll), 0, generic_client_callback, sdref, &error))) {
ret = map_error(error);
goto finish;
}
ifindex = interface == kDNSServiceInterfaceIndexAny ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface;
-
+
if (!(sdref->domain_browser = avahi_domain_browser_new(sdref->client, ifindex, AVAHI_PROTO_UNSPEC, "local",
flags == kDNSServiceFlagsRegistrationDomains ? AVAHI_DOMAIN_BROWSER_REGISTER : AVAHI_DOMAIN_BROWSER_BROWSE,
0, domain_browser_callback, sdref))) {
ret = map_error(avahi_client_errno(sdref->client));
goto finish;
}
-
+
ret = kDNSServiceErr_NoError;
*ret_sdref = sdref;
-
+
finish:
ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex));
-
+
if (ret != kDNSServiceErr_NoError)
DNSServiceRefDeallocate(sdref);
@@ -904,7 +904,7 @@ static void reg_report_error(DNSServiceRef sdref, DNSServiceErrorType error) {
regtype = add_trailing_dot(sdref->type_info.type, regtype_fixed, sizeof(regtype_fixed));
domain = add_trailing_dot(sdref->service_domain, domain_fixed, sizeof(domain_fixed));
-
+
sdref->service_register_callback(
sdref, 0, error,
sdref->service_name_chosen ? sdref->service_name_chosen : sdref->service_name,
@@ -916,7 +916,7 @@ static void reg_report_error(DNSServiceRef sdref, DNSServiceErrorType error) {
static int reg_create_service(DNSServiceRef sdref) {
int ret;
AvahiStringList *l;
-
+
assert(sdref);
assert(sdref->n_ref >= 1);
@@ -964,7 +964,7 @@ static void reg_client_callback(AvahiClient *s, AvahiClientState state, void* us
/* We've not been setup completely */
if (!sdref->entry_group)
return;
-
+
switch (state) {
case AVAHI_CLIENT_FAILURE:
reg_report_error(sdref, kDNSServiceErr_Unknown);
@@ -994,29 +994,29 @@ static void reg_client_callback(AvahiClient *s, AvahiClientState state, void* us
if (!sdref->service_name_chosen) {
assert(sdref->service_name);
-
+
if (!(sdref->service_name_chosen = avahi_strdup(sdref->service_name))) {
reg_report_error(sdref, kDNSServiceErr_NoMemory);
return;
}
}
-
+
/* Register the service */
if ((ret = reg_create_service(sdref)) < 0) {
reg_report_error(sdref, map_error(ret));
return;
}
-
+
break;
}
-
+
case AVAHI_CLIENT_S_COLLISION:
case AVAHI_CLIENT_S_REGISTERING:
/* Remove our entry */
avahi_entry_group_reset(sdref->entry_group);
-
+
break;
case AVAHI_CLIENT_CONNECTING:
@@ -1042,7 +1042,7 @@ static void reg_entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState st
case AVAHI_ENTRY_GROUP_COLLISION: {
char *n;
int ret;
-
+
/* Remove our entry */
avahi_entry_group_reset(sdref->entry_group);
@@ -1061,7 +1061,7 @@ static void reg_entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState st
reg_report_error(sdref, map_error(ret));
return;
}
-
+
break;
}
@@ -1074,7 +1074,7 @@ static void reg_entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState st
/* Inform the user */
reg_report_error(sdref, map_error(avahi_client_errno(sdref->client)));
break;
-
+
}
}
@@ -1082,14 +1082,14 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister (
DNSServiceRef *ret_sdref,
DNSServiceFlags flags,
uint32_t interface,
- const char *name,
+ const char *name,
const char *regtype,
- const char *domain,
- const char *host,
+ const char *domain,
+ const char *host,
uint16_t port,
uint16_t txtLen,
- const void *txtRecord,
- DNSServiceRegisterReply callback,
+ const void *txtRecord,
+ DNSServiceRegisterReply callback,
void *context) {
DNSServiceErrorType ret = kDNSServiceErr_Unknown;
@@ -1103,7 +1103,7 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister (
if (!ret_sdref || !regtype)
return kDNSServiceErr_BadParam;
*ret_sdref = NULL;
-
+
if (!txtRecord) {
txtLen = 1;
txtRecord = "";
@@ -1114,7 +1114,7 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister (
return kDNSServiceErr_Unsupported;
}
- if (txtLen > 0)
+ if (txtLen > 0)
if (avahi_string_list_parse(txtRecord, txtLen, &txt) < 0)
return kDNSServiceErr_Invalid;
@@ -1122,7 +1122,7 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister (
avahi_string_list_free(txt);
return kDNSServiceErr_Invalid;
}
-
+
if (!(sdref = sdref_new())) {
avahi_string_list_free(txt);
type_info_free(&type_info);
@@ -1141,9 +1141,9 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister (
sdref->service_txt = txt;
/* Some OOM checking would be cool here */
-
+
ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex));
-
+
if (!(sdref->client = avahi_client_new(avahi_simple_poll_get(sdref->simple_poll), 0, reg_client_callback, sdref, &error))) {
ret = map_error(error);
goto finish;
@@ -1185,20 +1185,20 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister (
goto finish;
}
-
+
if ((error = reg_create_service(sdref)) < 0) {
ret = map_error(error);
goto finish;
}
}
-
+
ret = kDNSServiceErr_NoError;
*ret_sdref = sdref;
-
+
finish:
ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex));
-
+
if (ret != kDNSServiceErr_NoError)
DNSServiceRefDeallocate(sdref);
@@ -1207,7 +1207,7 @@ finish:
DNSServiceErrorType DNSSD_API DNSServiceUpdateRecord(
DNSServiceRef sdref,
- DNSRecordRef rref,
+ DNSRecordRef rref,
DNSServiceFlags flags,
uint16_t rdlen,
const void *rdata,
@@ -1226,7 +1226,7 @@ DNSServiceErrorType DNSSD_API DNSServiceUpdateRecord(
return kDNSServiceErr_Unsupported;
}
- if (rdlen > 0)
+ if (rdlen > 0)
if (avahi_string_list_parse(rdata, rdlen, &txt) < 0)
return kDNSServiceErr_Invalid;
@@ -1251,7 +1251,7 @@ DNSServiceErrorType DNSSD_API DNSServiceUpdateRecord(
sdref->type_info.type,
sdref->service_domain,
sdref->service_txt) < 0) {
-
+
ret = map_error(avahi_client_errno(sdref->client));
goto finish;
}
@@ -1260,10 +1260,10 @@ DNSServiceErrorType DNSSD_API DNSServiceUpdateRecord(
avahi_string_list_free(txt);
ret = kDNSServiceErr_NoError;
-
+
finish:
ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex));
-
+
return ret;
}
diff --git a/avahi-compat-libdns_sd/dns_sd.h b/avahi-compat-libdns_sd/dns_sd.h
index b7eb8a2..66e494e 100644
--- a/avahi-compat-libdns_sd/dns_sd.h
+++ b/avahi-compat-libdns_sd/dns_sd.h
@@ -2,27 +2,27 @@
*
* Copyright (c) 2003-2004, Apple Computer, Inc. All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without
+ * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
@@ -150,7 +150,7 @@ enum
/* Flag for signifying that a query or registration should be performed exclusively via multicast DNS,
* even for a name in a domain (e.g. foo.apple.com.) that would normally imply unicast DNS.
*/
-
+
kDNSServiceFlagsReturnCNAME = 0x800
/* Flag for returning CNAME records in the DNSServiceQueryRecord call. CNAME records are
* normally followed without indicating to the client that there was a CNAME record.
@@ -316,23 +316,23 @@ enum
*/
-/*
+/*
* Constants for specifying an interface index
*
* Specific interface indexes are identified via a 32-bit unsigned integer returned
* by the if_nametoindex() family of calls.
- *
+ *
* If the client passes 0 for interface index, that means "do the right thing",
* which (at present) means, "if the name is in an mDNS local multicast domain
* (e.g. 'local.', '254.169.in-addr.arpa.', '{8,9,A,B}.E.F.ip6.arpa.') then multicast
* on all applicable interfaces, otherwise send via unicast to the appropriate
* DNS server." Normally, most clients will use 0 for interface index to
* automatically get the default sensible behaviour.
- *
+ *
* If the client passes a positive interface index, then for multicast names that
* indicates to do the operation only on that one interface. For unicast names the
* interface index is ignored unless kDNSServiceFlagsForceMulticast is also set.
- *
+ *
* If the client passes kDNSServiceInterfaceIndexLocalOnly when registering
* a service, then that service will be found *only* by other local clients
* on the same machine that are browsing using kDNSServiceInterfaceIndexLocalOnly
@@ -341,7 +341,7 @@ enum
* running on the same machine, this allows the client to advertise that service
* in a way such that it does not inadvertently appear in service lists on
* all the other machines on the network.
- *
+ *
* If the client passes kDNSServiceInterfaceIndexLocalOnly when browsing
* then it will find *all* records registered on that same local machine.
* Clients explicitly wishing to discover *only* LocalOnly services can
@@ -494,7 +494,7 @@ typedef void (DNSSD_API *DNSServiceDomainEnumReply)
/* DNSServiceEnumerateDomains() Parameters:
*
*
- * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
+ * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
* then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError,
* and the enumeration operation will run indefinitely until the client
* terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate().
@@ -578,7 +578,7 @@ typedef void (DNSSD_API *DNSServiceRegisterReply)
/* DNSServiceRegister() Parameters:
*
- * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
+ * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
* then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError,
* and the registration will remain active indefinitely until the client
* terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate().
@@ -843,7 +843,7 @@ typedef void (DNSSD_API *DNSServiceBrowseReply)
/* DNSServiceBrowse() Parameters:
*
- * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
+ * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
* then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError,
* and the browse operation will run indefinitely until the client
* terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate().
@@ -964,7 +964,7 @@ typedef void (DNSSD_API *DNSServiceResolveReply)
/* DNSServiceResolve() Parameters
*
- * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
+ * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
* then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError,
* and the resolve operation will run indefinitely until the client
* terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate().
@@ -1190,7 +1190,7 @@ typedef void (DNSSD_API *DNSServiceQueryRecordReply)
/* DNSServiceQueryRecord() Parameters:
*
- * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
+ * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
* then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError,
* and the query operation will run indefinitely until the client
* terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate().
@@ -1683,7 +1683,7 @@ DNSServiceErrorType DNSSD_API TXTRecordGetItemAtIndex
* calls by this user that do not specify an explicit domain will browse and
* register in this wide-area domain in addition to .local. In addition, this
* domain will be returned as a Browse domain via domain enumeration calls.
- *
+ *
*
* Parameters:
*
@@ -1700,8 +1700,8 @@ DNSServiceErrorType DNSSD_API DNSServiceSetDefaultDomainForUser
(
DNSServiceFlags flags,
const char *domain
- );
-
+ );
+
#endif //__APPLE_API_PRIVATE
// Some C compiler cleverness. We can make the compiler check certain things for us,
diff --git a/avahi-compat-libdns_sd/null-test.c b/avahi-compat-libdns_sd/null-test.c
index a6c03df..8accc13 100644
--- a/avahi-compat-libdns_sd/null-test.c
+++ b/avahi-compat-libdns_sd/null-test.c
@@ -2,17 +2,17 @@
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
diff --git a/avahi-compat-libdns_sd/txt.c b/avahi-compat-libdns_sd/txt.c
index 2b539e6..74f8a5f 100644
--- a/avahi-compat-libdns_sd/txt.c
+++ b/avahi-compat-libdns_sd/txt.c
@@ -2,17 +2,17 @@
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@@ -51,7 +51,7 @@ void DNSSD_API TXTRecordCreate(
AVAHI_WARN_LINKAGE;
assert(txtref);
-
+
/* Apple's API design is flawed in so many ways, including the
* fact that it isn't compatible with 64 bit processors. To work
* around this we need some magic here which involves allocating
@@ -75,7 +75,7 @@ void DNSSD_API TXTRecordDeallocate(TXTRecordRef *txtref) {
TXTRecordInternal *t;
AVAHI_WARN_LINKAGE;
-
+
assert(txtref);
t = INTERNAL_PTR(txtref);
if (!t)
@@ -91,7 +91,7 @@ void DNSSD_API TXTRecordDeallocate(TXTRecordRef *txtref) {
static int make_sure_fits_in(TXTRecordInternal *t, size_t size) {
uint8_t *n;
size_t nsize;
-
+
assert(t);
if (t->size + size <= t->max_size)
@@ -101,13 +101,13 @@ static int make_sure_fits_in(TXTRecordInternal *t, size_t size) {
if (nsize > 0xFFFF)
return -1;
-
+
if (!(n = avahi_realloc(t->malloc_buffer, nsize)))
return -1;
if (!t->malloc_buffer && t->size)
memcpy(n, t->buffer, t->size);
-
+
t->buffer = t->malloc_buffer = n;
t->max_size = nsize;
@@ -134,7 +134,7 @@ static int remove_key(TXTRecordInternal *t, const char *key) {
/* Key longer than buffer */
if (key_len > t->size - i - 1)
break;
-
+
if (key_len <= *p &&
strncmp(key, (char*) p+1, key_len) == 0 &&
(key_len == *p || p[1+key_len] == '=')) {
@@ -150,7 +150,7 @@ static int remove_key(TXTRecordInternal *t, const char *key) {
found = 1;
} else {
/* Skip to next */
-
+
i += *p +1;
p += *p +1;
}
@@ -162,7 +162,7 @@ static int remove_key(TXTRecordInternal *t, const char *key) {
DNSServiceErrorType DNSSD_API TXTRecordSetValue(
TXTRecordRef *txtref,
const char *key,
- uint8_t length,
+ uint8_t length,
const void *value) {
TXTRecordInternal *t;
@@ -186,7 +186,7 @@ DNSServiceErrorType DNSSD_API TXTRecordSetValue(
if (n > 0xFF)
return kDNSServiceErr_Invalid;
-
+
if (make_sure_fits_in(t, 1 + n) < 0)
return kDNSServiceErr_NoMemory;
@@ -196,7 +196,7 @@ DNSServiceErrorType DNSSD_API TXTRecordSetValue(
*(p++) = (uint8_t) n;
t->size ++;
-
+
memcpy(p, key, l);
p += l;
t->size += l;
@@ -267,7 +267,7 @@ static const uint8_t *find_key(const uint8_t *buffer, size_t size, const char *k
key_len = strlen(key);
assert(key_len <= 0xFF);
-
+
p = buffer;
i = 0;
@@ -280,7 +280,7 @@ static const uint8_t *find_key(const uint8_t *buffer, size_t size, const char *k
/* Key longer than buffer */
if (key_len > size - i - 1)
return NULL;
-
+
if (key_len <= *p &&
strncmp(key, (const char*) p+1, key_len) == 0 &&
(key_len == *p || p[1+key_len] == '=')) {
@@ -288,7 +288,7 @@ static const uint8_t *find_key(const uint8_t *buffer, size_t size, const char *k
/* Key matches, so let's return it */
return p;
- }
+ }
/* Skip to next */
i += *p +1;
@@ -326,7 +326,7 @@ const void * DNSSD_API TXTRecordGetValuePtr(
const uint8_t *p;
size_t n, l;
-
+
AVAHI_WARN_LINKAGE;
assert(key);
@@ -336,7 +336,7 @@ const void * DNSSD_API TXTRecordGetValuePtr(
if (*key == 0 || strchr(key, '=') || strlen(key) > 0xFF) /* Empty or invalid key */
return NULL;
-
+
assert(buffer);
if (!(p = find_key(buffer, size, key)))
@@ -351,20 +351,20 @@ const void * DNSSD_API TXTRecordGetValuePtr(
if (n <= 0)
goto fail;
-
+
assert(*p == '=');
p++;
n--;
if (value_len)
*value_len = n;
-
+
return p;
fail:
if (value_len)
*value_len = 0;
-
+
return NULL;
}
@@ -381,12 +381,12 @@ uint16_t DNSSD_API TXTRecordGetCount(
if (!size)
return 0;
-
+
assert(buffer);
-
+
p = buffer;
i = 0;
-
+
while (i < size) {
/* Does the item fit in? */
@@ -418,7 +418,7 @@ DNSServiceErrorType DNSSD_API TXTRecordGetItemAtIndex(
size_t i;
unsigned n = 0;
DNSServiceErrorType ret = kDNSServiceErr_Invalid;
-
+
AVAHI_WARN_LINKAGE;
if (!size)
@@ -428,7 +428,7 @@ DNSServiceErrorType DNSSD_API TXTRecordGetItemAtIndex(
p = buffer;
i = 0;
-
+
while (i < size) {
/* Does the item fit in? */
@@ -451,7 +451,7 @@ DNSServiceErrorType DNSSD_API TXTRecordGetItemAtIndex(
strncpy(key, (const char*) p + 1, l);
key[l] = 0;
-
+
if (d) {
if (value_len)
*value_len = *p - l - 1;
@@ -486,6 +486,6 @@ fail:
if (value_len)
*value_len = 0;
- return ret;
+ return ret;
}
diff --git a/avahi-compat-libdns_sd/unsupported.c b/avahi-compat-libdns_sd/unsupported.c
index a460b41..2a23aed 100644
--- a/avahi-compat-libdns_sd/unsupported.c
+++ b/avahi-compat-libdns_sd/unsupported.c
@@ -2,17 +2,17 @@
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@@ -43,7 +43,7 @@ DNSServiceErrorType DNSSD_API DNSServiceRegisterRecord (
AVAHI_GCC_UNUSED void *context) {
AVAHI_WARN_UNSUPPORTED;
-
+
return kDNSServiceErr_Unsupported;
}
@@ -58,7 +58,7 @@ DNSServiceErrorType DNSSD_API DNSServiceQueryRecord (
AVAHI_GCC_UNUSED void *context) {
AVAHI_WARN_UNSUPPORTED;
-
+
return kDNSServiceErr_Unsupported;
}
@@ -72,13 +72,13 @@ DNSServiceErrorType DNSSD_API DNSServiceReconfirmRecord (
AVAHI_GCC_UNUSED const void *rdata) {
AVAHI_WARN_UNSUPPORTED;
-
+
return kDNSServiceErr_Unsupported;
}
DNSServiceErrorType DNSSD_API DNSServiceCreateConnection(AVAHI_GCC_UNUSED DNSServiceRef *sdRef) {
AVAHI_WARN_UNSUPPORTED;
-
+
return kDNSServiceErr_Unsupported;
}
@@ -92,7 +92,7 @@ DNSServiceErrorType DNSSD_API DNSServiceAddRecord(
AVAHI_GCC_UNUSED uint32_t ttl) {
AVAHI_WARN_UNSUPPORTED;
-
+
return kDNSServiceErr_Unsupported;
}
@@ -102,7 +102,7 @@ DNSServiceErrorType DNSSD_API DNSServiceRemoveRecord(
AVAHI_GCC_UNUSED DNSServiceFlags flags) {
AVAHI_WARN_UNSUPPORTED;
-
+
return kDNSServiceErr_Unsupported;
}
diff --git a/avahi-compat-libdns_sd/warn.c b/avahi-compat-libdns_sd/warn.c
index d3389c1..94aa535 100644
--- a/avahi-compat-libdns_sd/warn.c
+++ b/avahi-compat-libdns_sd/warn.c
@@ -2,17 +2,17 @@
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@@ -55,25 +55,25 @@ const char *avahi_exe_name(void) {
/* Yes, I know, this is not portable. But who cares? It's for
* cosmetics only, anyway. */
-
+
pthread_mutex_lock(&mutex);
if (exe_name[0] == 0) {
int k;
-
+
if ((k = readlink("/proc/self/exe", exe_name, sizeof(exe_name)-1)) < 0)
snprintf(exe_name, sizeof(exe_name), "(unknown)");
else {
char *slash;
-
+
assert((size_t) k <= sizeof(exe_name)-1);
exe_name[k] = 0;
-
+
if ((slash = strrchr(exe_name, '/')))
memmove(exe_name, slash+1, strlen(slash)+1);
}
}
-
+
pthread_mutex_unlock(&mutex);
return exe_name;
@@ -89,14 +89,14 @@ void avahi_warn(const char *fmt, ...) {
char msg[512] = "*** WARNING *** ";
va_list ap;
size_t n;
-
+
assert(fmt);
-
+
va_start(ap, fmt);
n = strlen(msg);
vsnprintf(msg + n, sizeof(msg) - n, fmt, ap);
va_end(ap);
-
+
fprintf(stderr, "%s\n", msg);
openlog(avahi_exe_name(), LOG_PID, LOG_USER);
@@ -106,7 +106,7 @@ void avahi_warn(const char *fmt, ...) {
void avahi_warn_linkage(void) {
int w;
-
+
pthread_mutex_lock(&linkage_mutex);
w = linkage_warning;
linkage_warning = 1;
diff --git a/avahi-compat-libdns_sd/warn.h b/avahi-compat-libdns_sd/warn.h
index da64fab..6bd8478 100644
--- a/avahi-compat-libdns_sd/warn.h
+++ b/avahi-compat-libdns_sd/warn.h
@@ -5,17 +5,17 @@
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307