]> git.meshlink.io Git - catta/blobdiff - avahi-core/browse.c
* Rename various data structures to prevent a namespace conflict with avahi-core
[catta] / avahi-core / browse.c
index 2d14c90477899fc899be37c2fc5604b2b415932d..e2d996e2372d366103efa3391a45133d2bd1d1e7 100644 (file)
@@ -24,7 +24,7 @@
 #endif
 
 #include "browse.h"
-#include "util.h"
+#include "timeval.h"
 #include "log.h"
 
 struct AvahiRecordBrowser {
@@ -32,8 +32,8 @@ struct AvahiRecordBrowser {
     
     AvahiServer *server;
     AvahiKey *key;
-    gint interface;
-    guchar protocol;
+    AvahiIfIndex interface;
+    AvahiProtocol protocol;
     guint sec_delay;
 
     AvahiTimeEvent *time_event;
@@ -48,7 +48,7 @@ struct AvahiRecordBrowser {
 
 static void elapse(AvahiTimeEvent *e, void *userdata) {
     AvahiRecordBrowser *s = userdata;
-    GTimeVal tv;
+    struct timeval tv;
 /*     gchar *t;  */
     
     g_assert(s);
@@ -105,7 +105,7 @@ static void scan_interface_callback(AvahiInterfaceMonitor *m, AvahiInterface *i,
     avahi_cache_walk(i->cache, s->key, scan_cache_callback, &cbdata);
 }
 
-gboolean scan_idle_callback(gpointer data) {
+static gboolean scan_idle_callback(gpointer data) {
     AvahiRecordBrowser *b = data;
     g_assert(b);
 
@@ -116,15 +116,23 @@ gboolean scan_idle_callback(gpointer data) {
     return FALSE;
 }
 
-AvahiRecordBrowser *avahi_record_browser_new(AvahiServer *server, gint interface, guchar protocol, AvahiKey *key, AvahiRecordBrowserCallback callback, gpointer userdata) {
+AvahiRecordBrowser *avahi_record_browser_new(AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, AvahiKey *key, AvahiRecordBrowserCallback callback, gpointer userdata) {
     AvahiRecordBrowser *b, *t;
-    GTimeVal tv;
+    struct timeval tv;
 
     g_assert(server);
     g_assert(key);
     g_assert(callback);
 
-    g_assert(!avahi_key_is_pattern(key));
+    if (avahi_key_is_pattern(key)) {
+        avahi_server_set_errno(server, AVAHI_ERR_IS_PATTERN);
+        return NULL;
+    }
+
+    if (!avahi_key_valid(key)) {
+        avahi_server_set_errno(server, AVAHI_ERR_INVALID_KEY);
+        return NULL;
+    }
     
     b = g_new(AvahiRecordBrowser, 1);
     b->dead = FALSE;