]> git.meshlink.io Git - catta/blobdiff - avahi-core/browse-domain.c
forgot to pull the publish_no_reverse change to the example.
[catta] / avahi-core / browse-domain.c
index 5948c9b9c159d4bdbec0bbcd6d5feb876defa6d7..9705b2a52a620ecf9088f08b42511ad9fe7ef25b 100644 (file)
@@ -1,18 +1,16 @@
-/* $Id$ */
-
 /***
   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
@@ -23,6 +21,8 @@
 #include <config.h>
 #endif
 
+#include <stdlib.h>
+
 #include <avahi-common/domain.h>
 #include <avahi-common/malloc.h>
 #include <avahi-common/error.h>
@@ -32,9 +32,9 @@
 
 struct AvahiSDomainBrowser {
     int ref;
-    
+
     AvahiServer *server;
-    
+
     AvahiSRecordBrowser *record_browser;
 
     AvahiDomainBrowserType type;
@@ -44,7 +44,7 @@ struct AvahiSDomainBrowser {
     AvahiTimeEvent *defer_event;
 
     int all_for_now_scheduled;
-    
+
     AVAHI_LLIST_FIELDS(AvahiSDomainBrowser, browser);
 };
 
@@ -63,7 +63,7 @@ static void record_browser_callback(
     AvahiRecord *record,
     AvahiLookupResultFlags flags,
     void* userdata) {
-    
+
     AvahiSDomainBrowser *b = userdata;
     char *n = NULL;
 
@@ -76,7 +76,7 @@ static void record_browser_callback(
         b->all_for_now_scheduled = 1;
         return;
     }
-    
+
     /* Filter flags */
     flags &= AVAHI_LOOKUP_RESULT_CACHED | AVAHI_LOOKUP_RESULT_MULTICAST | AVAHI_LOOKUP_RESULT_WIDE_AREA;
 
@@ -88,21 +88,21 @@ static void record_browser_callback(
             AvahiStringList *l;
 
             /* Filter out entries defined statically */
-            
+
             for (l = b->server->config.browse_domains; l; l = l->next)
                 if (avahi_domain_equal((char*) l->text, n))
                     return;
         }
-        
+
     }
-        
+
     b->callback(b, interface, protocol, event, n, flags, b->userdata);
 }
 
 static void defer_callback(AvahiTimeEvent *e, void *userdata) {
     AvahiSDomainBrowser *b = userdata;
     AvahiStringList *l;
-    
+
     assert(e);
     assert(b);
 
@@ -115,22 +115,22 @@ static void defer_callback(AvahiTimeEvent *e, void *userdata) {
     inc_ref(b);
 
     for (l = b->server->config.browse_domains; l; l = l->next) {
-        
+
         /* Check whether this object still exists outside our own
          * stack frame */
         if (b->ref <= 1)
             break;
-        
+
         b->callback(b, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_BROWSER_NEW, (char*) l->text, AVAHI_LOOKUP_RESULT_STATIC, b->userdata);
     }
 
     if (b->ref > 1) {
         /* If the ALL_FOR_NOW event has already been scheduled, execute it now */
-        
-        if (b->all_for_now_scheduled) 
+
+        if (b->all_for_now_scheduled)
             b->callback(b, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_BROWSER_ALL_FOR_NOW, NULL, 0, b->userdata);
     }
-    
+
     /* Decrease ref counter */
     avahi_s_domain_browser_free(b);
 }
@@ -152,12 +152,12 @@ AvahiSDomainBrowser *avahi_s_domain_browser_new(
         "dr",
         "lb"
     };
-    
+
     AvahiSDomainBrowser *b;
     AvahiKey *k = NULL;
     char n[AVAHI_DOMAIN_NAME_MAX];
     int r;
-    
+
     assert(server);
     assert(callback);
 
@@ -174,7 +174,7 @@ AvahiSDomainBrowser *avahi_s_domain_browser_new(
         avahi_server_set_errno(server, r);
         return NULL;
     }
-    
+
     if (!(b = avahi_new(AvahiSDomainBrowser, 1))) {
         avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
         return NULL;
@@ -195,24 +195,24 @@ AvahiSDomainBrowser *avahi_s_domain_browser_new(
         avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
         goto fail;
     }
-    
+
     if (!(b->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b)))
         goto fail;
-    
+
     avahi_key_unref(k);
 
     if (type == AVAHI_DOMAIN_BROWSER_BROWSE && b->server->config.browse_domains)
         b->defer_event = avahi_time_event_new(server->time_event_queue, NULL, defer_callback, b);
-    
+
     return b;
-    
+
 fail:
-    
+
     if (k)
         avahi_key_unref(k);
-    
+
     avahi_s_domain_browser_free(b);
-    
+
     return NULL;
 }
 
@@ -222,7 +222,7 @@ void avahi_s_domain_browser_free(AvahiSDomainBrowser *b) {
     assert(b->ref >= 1);
     if (--b->ref > 0)
         return;
-    
+
     AVAHI_LLIST_REMOVE(AvahiSDomainBrowser, browser, b->server->domain_browsers, b);
 
     if (b->record_browser)
@@ -230,6 +230,6 @@ void avahi_s_domain_browser_free(AvahiSDomainBrowser *b) {
 
     if (b->defer_event)
         avahi_time_event_free(b->defer_event);
-    
+
     avahi_free(b);
 }