]> git.meshlink.io Git - catta/commitdiff
rename resolve.[ch] to browse.[ch]
authorLennart Poettering <lennart@poettering.net>
Sun, 22 May 2005 02:03:53 +0000 (02:03 +0000)
committerLennart Poettering <lennart@poettering.net>
Sun, 22 May 2005 02:03:53 +0000 (02:03 +0000)
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@84 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

avahi-core/Makefile.am
avahi-core/browse.c [new file with mode: 0644]
avahi-core/browse.h [new file with mode: 0644]
avahi-core/resolve-address.c
avahi-core/resolve-host-name.c
avahi-core/resolve.c [deleted file]
avahi-core/resolve.h [deleted file]
avahi-core/server.c
avahi-core/server.h

index 24b81b081a3a5ca239b04ac28dbe88f53cb278f8..95eeea77c890d7a2c93a2ef23e2bb52a8a7564ce 100644 (file)
@@ -54,7 +54,7 @@ libavahi_core_la_SOURCES = \
        query-sched.c query-sched.h \
        probe-sched.c probe-sched.h \
        announce.c announce.h \
-       resolve.c resolve.h \
+       browse.c browse.h \
        strlst.c strlst.h \
        rrlist.c rrlist.h \
        alternative.c alternative.h \
diff --git a/avahi-core/browse.c b/avahi-core/browse.c
new file mode 100644 (file)
index 0000000..c959831
--- /dev/null
@@ -0,0 +1,215 @@
+/* $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
+  USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "browse.h"
+#include "util.h"
+
+struct AvahiRecordBrowser {
+    gboolean dead;
+    
+    AvahiServer *server;
+    AvahiKey *key;
+    gint interface;
+    guchar protocol;
+    gint n_query;
+    guint sec_delay;
+
+    AvahiTimeEvent *time_event;
+
+    AvahiRecordBrowserCallback callback;
+    gpointer userdata;
+
+    AVAHI_LLIST_FIELDS(AvahiRecordBrowser, resolver);
+    AVAHI_LLIST_FIELDS(AvahiRecordBrowser, by_key);
+};
+
+static void elapse(AvahiTimeEvent *e, void *userdata) {
+    AvahiRecordBrowser *s = userdata;
+    GTimeVal tv;
+/*     gchar *t; */
+    
+    g_assert(s);
+
+    avahi_server_post_query(s->server, s->interface, s->protocol, s->key);
+
+    if (s->n_query++ <= 8)
+        s->sec_delay *= 2;
+
+/*     g_message("%i. Continuous querying for %s", s->n_query, t = avahi_key_to_string(s->key)); */
+/*     g_free(t); */
+    
+    avahi_elapse_time(&tv, s->sec_delay*1000, 0);
+    avahi_time_event_queue_update(s->server->time_event_queue, s->time_event, &tv);
+}
+
+struct cbdata {
+    AvahiRecordBrowser *record_browser;
+    AvahiInterface *interface;
+};
+
+static gpointer scan_cache_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEntry *e, gpointer userdata) {
+    struct cbdata *cbdata = userdata;
+
+    g_assert(c);
+    g_assert(pattern);
+    g_assert(e);
+    g_assert(cbdata);
+
+    if (cbdata->record_browser->dead)
+        return NULL;
+
+    cbdata->record_browser->callback(
+        cbdata->record_browser,
+        cbdata->interface->hardware->index,
+        cbdata->interface->protocol,
+        AVAHI_BROWSER_NEW,
+        e->record,
+        cbdata->record_browser->userdata);
+
+    return NULL;
+}
+
+static void scan_interface_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, gpointer userdata) {
+    AvahiRecordBrowser *s = userdata;
+    struct cbdata cbdata = { s, i };
+
+    g_assert(m);
+    g_assert(i);
+    g_assert(s);
+
+    avahi_cache_walk(i->cache, s->key, scan_cache_callback, &cbdata);
+}
+
+AvahiRecordBrowser *avahi_record_browser_new(AvahiServer *server, gint interface, guchar protocol, AvahiKey *key, AvahiRecordBrowserCallback callback, gpointer userdata) {
+    AvahiRecordBrowser *b, *t;
+    GTimeVal tv;
+
+    g_assert(server);
+    g_assert(key);
+    g_assert(callback);
+
+    g_assert(!avahi_key_is_pattern(key));
+    
+    b = g_new(AvahiRecordBrowser, 1);
+    b->dead = FALSE;
+    b->server = server;
+    b->key = avahi_key_ref(key);
+    b->interface = interface;
+    b->protocol = protocol;
+    b->callback = callback;
+    b->userdata = userdata;
+    b->n_query = 1;
+    b->sec_delay = 1;
+
+    avahi_server_post_query(b->server, b->interface, b->protocol, b->key);
+    
+    avahi_elapse_time(&tv, b->sec_delay*1000, 0);
+    b->time_event = avahi_time_event_queue_add(server->time_event_queue, &tv, elapse, b);
+
+    AVAHI_LLIST_PREPEND(AvahiRecordBrowser, resolver, server->record_browsers, b);
+
+    /* Add the new entry to the record_browser hash table */
+    t = g_hash_table_lookup(server->record_browser_hashtable, key);
+    AVAHI_LLIST_PREPEND(AvahiRecordBrowser, by_key, t, b);
+    g_hash_table_replace(server->record_browser_hashtable, key, t);
+
+    /* Scan the caches */
+    avahi_interface_monitor_walk(b->server->monitor, b->interface, b->protocol, scan_interface_callback, b);
+    
+    return b;
+}
+
+void avahi_record_browser_free(AvahiRecordBrowser *b) {
+    g_assert(b);
+    g_assert(!b->dead);
+
+    b->dead = TRUE;
+    b->server->need_browser_cleanup = TRUE;
+
+    if (b->time_event) {
+        avahi_time_event_queue_remove(b->server->time_event_queue, b->time_event);
+        b->time_event = NULL;
+    }
+}
+
+void avahi_record_browser_destroy(AvahiRecordBrowser *b) {
+    AvahiRecordBrowser *t;
+    
+    g_assert(b);
+    
+    AVAHI_LLIST_REMOVE(AvahiRecordBrowser, resolver, b->server->record_browsers, b);
+
+    t = g_hash_table_lookup(b->server->record_browser_hashtable, b->key);
+    AVAHI_LLIST_REMOVE(AvahiRecordBrowser, by_key, t, b);
+    if (t)
+        g_hash_table_replace(b->server->record_browser_hashtable, t->key, t);
+    else
+        g_hash_table_remove(b->server->record_browser_hashtable, b->key);
+
+    if (b->time_event)
+        avahi_time_event_queue_remove(b->server->time_event_queue, b->time_event);
+    avahi_key_unref(b->key);
+    
+    g_free(b);
+}
+
+void avahi_browser_cleanup(AvahiServer *server) {
+    AvahiRecordBrowser *b;
+    AvahiRecordBrowser *n;
+    
+    g_assert(server);
+
+    for (b = server->record_browsers; b; b = n) {
+        n = b->resolver_next;
+        
+        if (b->dead)
+            avahi_record_browser_destroy(b);
+    }
+
+    server->need_browser_cleanup = FALSE;
+}
+
+void avahi_browser_notify(AvahiServer *server, AvahiInterface *i, AvahiRecord *record, AvahiBrowserEvent event) {
+    AvahiRecordBrowser *b;
+    
+    g_assert(server);
+    g_assert(record);
+
+    for (b = g_hash_table_lookup(server->record_browser_hashtable, record->key); b; b = b->by_key_next)
+        if (!b->dead && avahi_interface_match(i, b->interface, b->protocol))
+                b->callback(b, i->hardware->index, i->protocol, event, record, b->userdata);
+}
+
+gboolean avahi_is_subscribed(AvahiServer *server, AvahiInterface *i, AvahiKey *k) {
+    AvahiRecordBrowser *b;
+    g_assert(server);
+    g_assert(k);
+
+    for (b = g_hash_table_lookup(server->record_browser_hashtable, k); b; b = b->by_key_next)
+        if (!b->dead && avahi_interface_match(i, b->interface, b->protocol))
+            return TRUE;
+
+    return FALSE;
+}
diff --git a/avahi-core/browse.h b/avahi-core/browse.h
new file mode 100644 (file)
index 0000000..f993d3e
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef foobrowsehfoo
+#define foobrowsehfoo
+
+/* $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
+  USA.
+***/
+
+#include "llist.h"
+#include "core.h"
+#include "timeeventq.h"
+#include "server.h"
+
+void avahi_browser_cleanup(AvahiServer *server);
+void avahi_browser_notify(AvahiServer *s, AvahiInterface *i, AvahiRecord *record, AvahiBrowserEvent event);
+
+gboolean avahi_is_subscribed(AvahiServer *s, AvahiInterface *i, AvahiKey *k);
+
+void avahi_record_browser_destroy(AvahiRecordBrowser *b);
+
+#endif
index a4870aa0d3b8856400b1591c44e59373c553de7e..f6fa6358563f261624d5a8b43f65a119c3fe2079 100644 (file)
@@ -23,7 +23,7 @@
 #include <config.h>
 #endif
 
-#include "resolve.h"
+#include "browse.h"
 #include "util.h"
 
 struct AvahiAddressResolver {
index 9fbf80345d37cbec3097f6fc3df48a13ef8d6ce9..751ba72cc472c77daf2f9c3de0428eb4a73e246f 100644 (file)
@@ -23,7 +23,7 @@
 #include <config.h>
 #endif
 
-#include "resolve.h"
+#include "browse.h"
 #include "util.h"
 
 struct AvahiHostNameResolver {
diff --git a/avahi-core/resolve.c b/avahi-core/resolve.c
deleted file mode 100644 (file)
index 42eba35..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-/* $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
-  USA.
-***/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "resolve.h"
-#include "util.h"
-
-struct AvahiRecordBrowser {
-    gboolean dead;
-    
-    AvahiServer *server;
-    AvahiKey *key;
-    gint interface;
-    guchar protocol;
-    gint n_query;
-    guint sec_delay;
-
-    AvahiTimeEvent *time_event;
-
-    AvahiRecordBrowserCallback callback;
-    gpointer userdata;
-
-    AVAHI_LLIST_FIELDS(AvahiRecordBrowser, resolver);
-    AVAHI_LLIST_FIELDS(AvahiRecordBrowser, by_key);
-};
-
-static void elapse(AvahiTimeEvent *e, void *userdata) {
-    AvahiRecordBrowser *s = userdata;
-    GTimeVal tv;
-/*     gchar *t; */
-    
-    g_assert(s);
-
-    avahi_server_post_query(s->server, s->interface, s->protocol, s->key);
-
-    if (s->n_query++ <= 8)
-        s->sec_delay *= 2;
-
-/*     g_message("%i. Continuous querying for %s", s->n_query, t = avahi_key_to_string(s->key)); */
-/*     g_free(t); */
-    
-    avahi_elapse_time(&tv, s->sec_delay*1000, 0);
-    avahi_time_event_queue_update(s->server->time_event_queue, s->time_event, &tv);
-}
-
-struct cbdata {
-    AvahiRecordBrowser *record_browser;
-    AvahiInterface *interface;
-};
-
-static gpointer scan_cache_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEntry *e, gpointer userdata) {
-    struct cbdata *cbdata = userdata;
-
-    g_assert(c);
-    g_assert(pattern);
-    g_assert(e);
-    g_assert(cbdata);
-
-    if (cbdata->record_browser->dead)
-        return NULL;
-
-    cbdata->record_browser->callback(
-        cbdata->record_browser,
-        cbdata->interface->hardware->index,
-        cbdata->interface->protocol,
-        AVAHI_BROWSER_NEW,
-        e->record,
-        cbdata->record_browser->userdata);
-
-    return NULL;
-}
-
-static void scan_interface_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, gpointer userdata) {
-    AvahiRecordBrowser *s = userdata;
-    struct cbdata cbdata = { s, i };
-
-    g_assert(m);
-    g_assert(i);
-    g_assert(s);
-
-    avahi_cache_walk(i->cache, s->key, scan_cache_callback, &cbdata);
-}
-
-AvahiRecordBrowser *avahi_record_browser_new(AvahiServer *server, gint interface, guchar protocol, AvahiKey *key, AvahiRecordBrowserCallback callback, gpointer userdata) {
-    AvahiRecordBrowser *b, *t;
-    GTimeVal tv;
-
-    g_assert(server);
-    g_assert(key);
-    g_assert(callback);
-
-    g_assert(!avahi_key_is_pattern(key));
-    
-    b = g_new(AvahiRecordBrowser, 1);
-    b->dead = FALSE;
-    b->server = server;
-    b->key = avahi_key_ref(key);
-    b->interface = interface;
-    b->protocol = protocol;
-    b->callback = callback;
-    b->userdata = userdata;
-    b->n_query = 1;
-    b->sec_delay = 1;
-
-    avahi_server_post_query(b->server, b->interface, b->protocol, b->key);
-    
-    avahi_elapse_time(&tv, b->sec_delay*1000, 0);
-    b->time_event = avahi_time_event_queue_add(server->time_event_queue, &tv, elapse, b);
-
-    AVAHI_LLIST_PREPEND(AvahiRecordBrowser, resolver, server->record_browsers, b);
-
-    /* Add the new entry to the record_browser hash table */
-    t = g_hash_table_lookup(server->record_browser_hashtable, key);
-    AVAHI_LLIST_PREPEND(AvahiRecordBrowser, by_key, t, b);
-    g_hash_table_replace(server->record_browser_hashtable, key, t);
-
-    /* Scan the caches */
-    avahi_interface_monitor_walk(b->server->monitor, b->interface, b->protocol, scan_interface_callback, b);
-    
-    return b;
-}
-
-void avahi_record_browser_free(AvahiRecordBrowser *b) {
-    g_assert(b);
-    g_assert(!b->dead);
-
-    b->dead = TRUE;
-    b->server->need_browser_cleanup = TRUE;
-
-    if (b->time_event) {
-        avahi_time_event_queue_remove(b->server->time_event_queue, b->time_event);
-        b->time_event = NULL;
-    }
-}
-
-void avahi_record_browser_destroy(AvahiRecordBrowser *b) {
-    AvahiRecordBrowser *t;
-    
-    g_assert(b);
-    
-    AVAHI_LLIST_REMOVE(AvahiRecordBrowser, resolver, b->server->record_browsers, b);
-
-    t = g_hash_table_lookup(b->server->record_browser_hashtable, b->key);
-    AVAHI_LLIST_REMOVE(AvahiRecordBrowser, by_key, t, b);
-    if (t)
-        g_hash_table_replace(b->server->record_browser_hashtable, t->key, t);
-    else
-        g_hash_table_remove(b->server->record_browser_hashtable, b->key);
-
-    if (b->time_event)
-        avahi_time_event_queue_remove(b->server->time_event_queue, b->time_event);
-    avahi_key_unref(b->key);
-    
-    g_free(b);
-}
-
-void avahi_browser_cleanup(AvahiServer *server) {
-    AvahiRecordBrowser *b;
-    AvahiRecordBrowser *n;
-    
-    g_assert(server);
-
-    for (b = server->record_browsers; b; b = n) {
-        n = b->resolver_next;
-        
-        if (b->dead)
-            avahi_record_browser_destroy(b);
-    }
-
-    server->need_browser_cleanup = FALSE;
-}
-
-void avahi_browser_notify(AvahiServer *server, AvahiInterface *i, AvahiRecord *record, AvahiBrowserEvent event) {
-    AvahiRecordBrowser *b;
-    
-    g_assert(server);
-    g_assert(record);
-
-    for (b = g_hash_table_lookup(server->record_browser_hashtable, record->key); b; b = b->by_key_next)
-        if (!b->dead && avahi_interface_match(i, b->interface, b->protocol))
-                b->callback(b, i->hardware->index, i->protocol, event, record, b->userdata);
-}
-
-gboolean avahi_is_subscribed(AvahiServer *server, AvahiInterface *i, AvahiKey *k) {
-    AvahiRecordBrowser *b;
-    g_assert(server);
-    g_assert(k);
-
-    for (b = g_hash_table_lookup(server->record_browser_hashtable, k); b; b = b->by_key_next)
-        if (!b->dead && avahi_interface_match(i, b->interface, b->protocol))
-            return TRUE;
-
-    return FALSE;
-}
diff --git a/avahi-core/resolve.h b/avahi-core/resolve.h
deleted file mode 100644 (file)
index 6659430..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef fooresolvehfoo
-#define fooresolvehfoo
-
-/* $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
-  USA.
-***/
-
-#include "llist.h"
-#include "core.h"
-#include "resolve.h"
-#include "timeeventq.h"
-#include "server.h"
-
-void avahi_browser_cleanup(AvahiServer *server);
-void avahi_browser_notify(AvahiServer *s, AvahiInterface *i, AvahiRecord *record, AvahiBrowserEvent event);
-
-gboolean avahi_is_subscribed(AvahiServer *s, AvahiInterface *i, AvahiKey *k);
-
-void avahi_record_browser_destroy(AvahiRecordBrowser *b);
-
-#endif
index dd0f707b6be3a957fc320cd4362358bf54d2a273..b00e4ee054832a560f8d645d0dec4bf15b431d6d 100644 (file)
@@ -33,7 +33,7 @@
 #include "util.h"
 #include "iface.h"
 #include "socket.h"
-#include "resolve.h"
+#include "browse.h"
 
 #define AVAHI_HOST_RR_HOLDOFF_MSEC 1000
 
index 93ae1f07acf4e2f8a4d459ae39e7d002e1b24e17..472617445d524c6e8adabd711c89aa449b5bbb4c 100644 (file)
@@ -28,7 +28,7 @@
 #include "llist.h"
 #include "timeeventq.h"
 #include "announce.h"
-#include "resolve.h"
+#include "browse.h"
 #include "dns.h"
 #include "rrlist.h"