diff options
author | Lennart Poettering <lennart@poettering.net> | 2005-08-05 18:59:21 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2005-08-05 18:59:21 +0000 |
commit | 0632e854728e8e64552ae08f90852d4a2658539e (patch) | |
tree | 0fab7d52e01da7ab9b81b8409dcf70cceb7d2852 /avahi-core/browse-service.c | |
parent | d76069e946b4e89c828c96340677e40f583080c9 (diff) |
* add proper error codes and patch everything to make use of it
* parameter validity checkin in all user visible functions of libavahi-core
* two new python tools/examples avahi-resolve-host-name and avahi-resolve-address
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@238 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-core/browse-service.c')
-rw-r--r-- | avahi-core/browse-service.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/avahi-core/browse-service.c b/avahi-core/browse-service.c index f72ce6c..34a2536 100644 --- a/avahi-core/browse-service.c +++ b/avahi-core/browse-service.c @@ -93,21 +93,36 @@ AvahiServiceBrowser *avahi_service_browser_new(AvahiServer *server, AvahiIfIndex g_assert(callback); g_assert(service_type); + if (!avahi_valid_service_type(service_type)) { + avahi_server_set_errno(server, AVAHI_ERR_INVALID_SERVICE_TYPE); + return NULL; + } + + if (domain && !avahi_valid_domain_name(domain)) { + avahi_server_set_errno(server, AVAHI_ERR_INVALID_DOMAIN_NAME); + return NULL; + } + b = g_new(AvahiServiceBrowser, 1); b->server = server; b->domain_name = avahi_normalize_name(domain ? domain : "local"); b->service_type = avahi_normalize_name(service_type); b->callback = callback; b->userdata = userdata; + AVAHI_LLIST_PREPEND(AvahiServiceBrowser, browser, server->service_browsers, b); n = g_strdup_printf("%s.%s", b->service_type, b->domain_name); k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR); g_free(n); b->record_browser = avahi_record_browser_new(server, interface, protocol, k, record_browser_callback, b); + avahi_key_unref(k); - AVAHI_LLIST_PREPEND(AvahiServiceBrowser, browser, server->service_browsers, b); + if (!b->record_browser) { + avahi_service_browser_free(b); + return NULL; + } return b; } @@ -117,7 +132,9 @@ void avahi_service_browser_free(AvahiServiceBrowser *b) { AVAHI_LLIST_REMOVE(AvahiServiceBrowser, browser, b->server->service_browsers, b); - avahi_record_browser_free(b->record_browser); + if (b->record_browser) + avahi_record_browser_free(b->record_browser); + g_free(b->domain_name); g_free(b->service_type); g_free(b); |