]> git.meshlink.io Git - catta/commitdiff
* Move avahi-core/llist.h to avahi-common/llist.h, not installed.
authorTrent Lloyd <lathiat@bur.st>
Mon, 8 Aug 2005 18:03:51 +0000 (18:03 +0000)
committerTrent Lloyd <lathiat@bur.st>
Mon, 8 Aug 2005 18:03:51 +0000 (18:03 +0000)
 * avahi-client/
   - Add copyright notice
   - Remove glib, various cleanups
   - Remove alternative host/service functions (available in avahi-common)

git-svn-id: file:///home/lennart/svn/public/avahi/trunk@275 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

17 files changed:
avahi-client/Makefile.am
avahi-client/client-test.c
avahi-client/client.c
avahi-client/client.h
avahi-common/Makefile.am
avahi-common/llist.h [new file with mode: 0644]
avahi-core/announce.h
avahi-core/browse.h
avahi-core/cache.h
avahi-core/iface.h
avahi-core/llist.h [deleted file]
avahi-core/rrlist.c
avahi-core/server.h
avahi-daemon/dbus-protocol.c
avahi-daemon/simple-protocol.c
avahi-daemon/static-services.c
avahi-dnsconfd/main.c

index 2d5a6544a01b73f18742ba9a4c02379397d9ce0a..a01ede249f77cfc86583e5e1d0f9776baf456702 100644 (file)
 
 AM_CFLAGS=-I$(top_srcdir)
 
-# GLIB 2.0
-AM_CFLAGS+=$(GLIB20_CFLAGS)
-AM_LDADD=$(GLIB20_LIBS)
-
 # DBUS
 AM_CFLAGS+=$(DBUS_CFLAGS)
-AM_LDADD+=$(DBUS_LIBS)
+AM_LDADD=$(DBUS_LIBS)
 
 # This cool debug trap works on i386/gcc only
 AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")'
index cc41f49e9c1d02b527d6324e9011aea31db29223..530394f2ef72e849f550356e80b0eeb28936ece6 100644 (file)
@@ -1,3 +1,24 @@
+/* $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 <avahi-client/client.h>
 #include <stdio.h>
 #include <glib.h>
@@ -17,13 +38,20 @@ main (int argc, char *argv[])
 
     ret = avahi_client_get_version_string (avahi);
     printf ("Avahi Server Version: %s\n", ret);
+    g_free (ret);
 
     ret = avahi_client_get_host_name (avahi);
     printf ("Host Name: %s\n", ret);
+    g_free (ret);
+
+    ret = avahi_client_get_domain_name (avahi);
+    printf ("Domain Name: %s\n", ret);
+    g_free (ret);
+
+    ret = avahi_client_get_host_name_fqdn (avahi);
+    printf ("FQDN: %s\n", ret);
+    g_free (ret);
 
-    ret = avahi_client_get_alternative_host_name (avahi, "ubuntu");
-    printf ("Alternative Host Name: %s\n", ret);
-    
     g_free (avahi);
 
     g_main_loop_run (loop);
index 290d76748aabc93e551ac3f8d58671f663aebe6e..f5de8588d870a8fd3d260115f2c6118ea2129599 100644 (file)
@@ -1,8 +1,33 @@
+/* $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 <avahi-client/client.h>
 #include <avahi-common/dbus.h>
+#include <avahi-common/llist.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include <glib.h>
 #include <string.h>
 
 #define DBUS_API_SUBJECT_TO_CHANGE
 
 #include <stdlib.h>
 
-struct _AvahiClientPriv
+struct _AvahiClient
 {
     DBusConnection *bus;
+    AVAHI_LLIST_HEAD(AvahiEntryGroup, groups);
+};
+
+struct _AvahiEntryGroup {
+    char *path;
+    AvahiClient *parent;
+    AVAHI_LLIST_FIELDS(AvahiEntryGroup, groups);
 };
 
 static DBusHandlerResult
@@ -56,28 +88,6 @@ out:
     return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 }
 
-static gint _dbus_add_match (DBusConnection *bus, char *type, char *interface, char *sender, char *path)
-{
-    DBusError error;
-    char *filter;
-
-    g_assert (bus != NULL);
-
-    dbus_error_init (&error);
-    filter = g_strdup_printf ("type='%s', interface='%s', sender='%s', path='%s'", type, interface, sender, path);
-    dbus_bus_add_match (bus, filter, &error);
-    g_free (filter);
-
-    if (dbus_error_is_set (&error))
-    {
-        fprintf (stderr, "Error adding filter match: %s\n", error.message);
-        dbus_error_free (&error);
-        return FALSE;
-    }
-
-    return TRUE;
-}
-
 AvahiClient *
 avahi_client_new ()
 {
@@ -85,16 +95,17 @@ avahi_client_new ()
     DBusError error;
 
     tmp = g_new (AvahiClient, 1);
-    tmp->priv = g_new (AvahiClientPriv, 1);
 
-    g_assert (tmp != NULL);
-    g_assert (tmp->priv != NULL);
-    
+    if (tmp == NULL)
+        goto fail;
+
+    AVAHI_LLIST_HEAD_INIT(AvahiEntryGroup, tmp->groups);
+
     dbus_error_init (&error);
 
-    tmp->priv->bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
+    tmp->bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
 
-    dbus_connection_setup_with_g_main (tmp->priv->bus, NULL);
+    dbus_connection_setup_with_g_main (tmp->bus, NULL);
 
     if (dbus_error_is_set (&error)) {
         fprintf(stderr, "Error getting system d-bus: %s\n", error.message);
@@ -102,21 +113,47 @@ avahi_client_new ()
         goto fail;
     }
 
-    dbus_connection_set_exit_on_disconnect (tmp->priv->bus, FALSE);
+    dbus_connection_set_exit_on_disconnect (tmp->bus, FALSE);
 
-    if (!dbus_connection_add_filter (tmp->priv->bus, filter_func, tmp, NULL))
+    if (!dbus_connection_add_filter (tmp->bus, filter_func, tmp, NULL))
     {
         fprintf (stderr, "Failed to add d-bus filter\n");
         goto fail;
     }
 
-    if (!_dbus_add_match (tmp->priv->bus, "signal", AVAHI_DBUS_INTERFACE_SERVER, AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER)) goto fail;
-    if (!_dbus_add_match (tmp->priv->bus, "signal", DBUS_INTERFACE_DBUS, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS)) goto fail;
+    dbus_bus_add_match (tmp->bus,
+            "type='signal', "
+            "interface='" AVAHI_DBUS_INTERFACE_SERVER "', "
+            "sender='" AVAHI_DBUS_NAME "', "
+            "path='" AVAHI_DBUS_PATH_SERVER "'",
+            &error);
+
+    if (dbus_error_is_set (&error))
+    {
+        fprintf (stderr, "Error adding filter match: %s\n", error.message);
+        dbus_error_free (&error);
+        goto fail;
+
+    }   
+
+    dbus_bus_add_match (tmp->bus,
+            "type='signal', "
+            "interface='" DBUS_INTERFACE_DBUS "', "
+            "sender='" DBUS_SERVICE_DBUS "', "
+            "path='" DBUS_PATH_DBUS "'",
+            &error);
+
+    if (dbus_error_is_set (&error))
+    {
+        fprintf (stderr, "Error adding filter match: %s\n", error.message);
+        dbus_error_free (&error);
+        goto fail;
+
+    }   
 
     return tmp;
 
 fail:
-    if (tmp->priv) free (tmp->priv);
     if (tmp) free (tmp);
     return NULL;
 }
@@ -127,7 +164,7 @@ avahi_client_get_string_reply_and_block (AvahiClient *client, char *method, char
     DBusMessage *message;
     DBusMessage *reply;
     DBusError error;
-    char *ret;
+    char *ret, *new;
 
     g_assert (client != NULL);
     g_assert (method != NULL);
@@ -135,7 +172,6 @@ avahi_client_get_string_reply_and_block (AvahiClient *client, char *method, char
     dbus_error_init (&error);
 
     message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, method);
-    fprintf (stderr, "message = dbus_message_new_method_call (%s, %s, %s, %s)\n", AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, method);
 
     if (param != NULL)
     {
@@ -146,7 +182,7 @@ avahi_client_get_string_reply_and_block (AvahiClient *client, char *method, char
         }
     }
     
-    reply = dbus_connection_send_with_reply_and_block (client->priv->bus, message, -1, &error);
+    reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error);
 
     if (dbus_error_is_set (&error))
     {
@@ -172,7 +208,9 @@ avahi_client_get_string_reply_and_block (AvahiClient *client, char *method, char
         return NULL;
     }
 
-    return ret;
+    new = strdup (ret);
+
+    return new;
 }
 
 char*
@@ -199,14 +237,19 @@ avahi_client_get_host_name_fqdn (AvahiClient *client)
     return avahi_client_get_string_reply_and_block (client, "GetHostNameFqdn", NULL);
 }
 
-char*
-avahi_client_get_alternative_host_name (AvahiClient *client, char *host)
+AvahiEntryGroup*
+avahi_entry_group_new (AvahiClient *client)
 {
-    return avahi_client_get_string_reply_and_block (client, "GetAlternativeHostName", host);
-}
+    AvahiEntryGroup *tmp;
 
-char*
-avahi_client_get_alternative_service_name (AvahiClient *client, char *service)
-{
-    return avahi_client_get_string_reply_and_block (client, "GetAlternativeServiceName", service);
+    tmp = malloc (sizeof (AvahiEntryGroup));
+
+    tmp->parent = client;
+
+    AVAHI_LLIST_PREPEND(AvahiEntryGroup, groups, client->groups, tmp);
+
+    return tmp;
+fail:
+    if (tmp) free (tmp);
+    return NULL;
 }
index 5b0e9109aecdb415573fda6f2238806128f6d29d..0fb6419b52f45e6c02c731f319baf9f22f14fdb1 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef fooclienthfoo
 #define fooclienthfoo
 
-/* $Id: core.h 98 2005-06-04 18:56:52Z lathiat $ */
+/* $Id$ */
 
 /***
   This file is part of avahi.
 
 AVAHI_C_DECL_BEGIN
 
-typedef struct _AvahiClientPriv AvahiClientPriv;
+typedef struct _AvahiClient AvahiClient;
 
-typedef struct _AvahiClient {
-       int serverid;
-    AvahiClientPriv *priv;
-} AvahiClient;
+typedef struct _AvahiEntryGroup AvahiEntryGroup;
 
 /** Creates a new client instance */
 AvahiClient* avahi_client_new ();
@@ -50,12 +47,6 @@ char* avahi_client_get_domain_name (AvahiClient*);
 /** Get FQDN domain name */
 char* avahi_client_get_host_name_fqdn (AvahiClient*);
 
-/** Get alternative host name for a host name that is taken */
-char* avahi_client_get_alternative_host_name (AvahiClient*, char*);
-
-/** Get alternative service name for a service name that is taken */
-char* avahi_client_get_alternative_service_name (AvahiClient*, char*);
-
 AVAHI_C_DECL_END
 
 #endif
index c327bd1b7c67d852f02dceabdf17358242ec918a..b96d19e44cf18a2ce367784b3e315f2248a47427 100644 (file)
@@ -40,6 +40,8 @@ if ENABLE_DBUS
 avahi_commoninclude_HEADERS += dbus.h
 endif
 
+noinst_HEADERS = llist.h
+
 noinst_PROGRAMS = \
        strlst-test \
        domain-test \
diff --git a/avahi-common/llist.h b/avahi-common/llist.h
new file mode 100644 (file)
index 0000000..7c28f31
--- /dev/null
@@ -0,0 +1,71 @@
+#ifndef foollistfoo
+#define foollistfoo
+
+/* $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 <glib.h>
+
+/* Some macros for maintaining doubly linked lists */
+
+/* The head of the linked list. Use this in the structure that shall
+ * contain the head of the linked list */
+#define AVAHI_LLIST_HEAD(t,name) t *name
+
+/* The pointers in the linked list's items. Use this in the item structure */
+#define AVAHI_LLIST_FIELDS(t,name) t *name##_next, *name##_prev
+
+/* Initialize the list's head */
+#define AVAHI_LLIST_HEAD_INIT(t,head) do { (head) = NULL; } while(0)
+
+/* Initialize a list item */
+#define AVAHI_LLIST_INIT(t,name,item) do { \
+                               t *_item = (item); \
+                               g_assert(_item); \
+                               _item->name##_prev = _item->name##_next = NULL; \
+                               } while(0)
+
+/* Prepend an item to the list */
+#define AVAHI_LLIST_PREPEND(t,name,head,item) do { \
+                                        t **_head = &(head), *_item = (item); \
+                                        g_assert(_item); \
+                                        if ((_item->name##_next = *_head)) \
+                                           _item->name##_next->name##_prev = _item; \
+                                        _item->name##_prev = NULL; \
+                                        *_head = _item; \
+                                        } while (0)
+
+/* Remove an item from the list */
+#define AVAHI_LLIST_REMOVE(t,name,head,item) do { \
+                                    t **_head = &(head), *_item = (item); \
+                                    g_assert(_item); \
+                                    if (_item->name##_next) \
+                                       _item->name##_next->name##_prev = _item->name##_prev; \
+                                    if (_item->name##_prev) \
+                                       _item->name##_prev->name##_next = _item->name##_next; \
+                                    else {\
+                                       g_assert(*_head == _item); \
+                                       *_head = _item->name##_next; \
+                                    } \
+                                    _item->name##_next = _item->name##_prev = NULL; \
+                                    } while(0)
+
+#endif
index 1cab21f8892a79ace0a43e6ed2553c767d0ea78a..9aee5741a05c7171361f063dfb7c90cda5603fc5 100644 (file)
@@ -26,7 +26,7 @@
 
 typedef struct AvahiAnnouncement AvahiAnnouncement;
 
-#include "llist.h"
+#include <avahi-common/llist.h>
 #include "iface.h"
 #include "server.h"
 #include "timeeventq.h"
index ac33c5115209cf52e496a1fd2de094bc104707c2..2c9a2ab297df0ba8366182e5f4992ed3d6c66d13 100644 (file)
@@ -22,7 +22,7 @@
   USA.
 ***/
 
-#include "llist.h"
+#include <avahi-common/llist.h>
 #include "core.h"
 #include "timeeventq.h"
 #include "server.h"
index b6e3e8addf70cb7829e61f09475f4f15bfa6711b..de685f4322e18aaf88c08a4ca6aeed70384b37fc 100644 (file)
@@ -26,9 +26,9 @@
 
 typedef struct AvahiCache AvahiCache;
 
+#include <avahi-common/llist.h>
 #include "prioq.h"
 #include "server.h"
-#include "llist.h"
 #include "timeeventq.h"
 
 typedef enum {
index c5c3c6117d21a92a13b8e0772b7a759027f7aa84..cb763591fe6630367bc9f0815748d2b3f041b262 100644 (file)
@@ -29,11 +29,11 @@ typedef struct AvahiInterfaceAddress AvahiInterfaceAddress;
 typedef struct AvahiInterface AvahiInterface;
 typedef struct AvahiHwInterface AvahiHwInterface;
 
+#include <avahi-common/llist.h>
 #include "address.h"
 #include "server.h"
 #include "netlink.h"
 #include "cache.h"
-#include "llist.h"
 #include "response-sched.h"
 #include "query-sched.h"
 #include "probe-sched.h"
diff --git a/avahi-core/llist.h b/avahi-core/llist.h
deleted file mode 100644 (file)
index 7c28f31..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef foollistfoo
-#define foollistfoo
-
-/* $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 <glib.h>
-
-/* Some macros for maintaining doubly linked lists */
-
-/* The head of the linked list. Use this in the structure that shall
- * contain the head of the linked list */
-#define AVAHI_LLIST_HEAD(t,name) t *name
-
-/* The pointers in the linked list's items. Use this in the item structure */
-#define AVAHI_LLIST_FIELDS(t,name) t *name##_next, *name##_prev
-
-/* Initialize the list's head */
-#define AVAHI_LLIST_HEAD_INIT(t,head) do { (head) = NULL; } while(0)
-
-/* Initialize a list item */
-#define AVAHI_LLIST_INIT(t,name,item) do { \
-                               t *_item = (item); \
-                               g_assert(_item); \
-                               _item->name##_prev = _item->name##_next = NULL; \
-                               } while(0)
-
-/* Prepend an item to the list */
-#define AVAHI_LLIST_PREPEND(t,name,head,item) do { \
-                                        t **_head = &(head), *_item = (item); \
-                                        g_assert(_item); \
-                                        if ((_item->name##_next = *_head)) \
-                                           _item->name##_next->name##_prev = _item; \
-                                        _item->name##_prev = NULL; \
-                                        *_head = _item; \
-                                        } while (0)
-
-/* Remove an item from the list */
-#define AVAHI_LLIST_REMOVE(t,name,head,item) do { \
-                                    t **_head = &(head), *_item = (item); \
-                                    g_assert(_item); \
-                                    if (_item->name##_next) \
-                                       _item->name##_next->name##_prev = _item->name##_prev; \
-                                    if (_item->name##_prev) \
-                                       _item->name##_prev->name##_next = _item->name##_next; \
-                                    else {\
-                                       g_assert(*_head == _item); \
-                                       *_head = _item->name##_next; \
-                                    } \
-                                    _item->name##_next = _item->name##_prev = NULL; \
-                                    } while(0)
-
-#endif
index 51e700c760fa610fe1ac6d2bdc285d6cb0be00c9..ce4640c9ccd5b5736cb55f6c3217d7d030df5abd 100644 (file)
@@ -19,8 +19,8 @@
   USA.
 ***/
 
+#include <avahi-common/llist.h>
 #include "rrlist.h"
-#include "llist.h"
 
 typedef struct AvahiRecordListItem AvahiRecordListItem;
 
index 6572fbb69e9983ade674cf7d3cf4113be455274c..5810dfaa5bd77a7032b4f8820acb60ef3dbe67eb 100644 (file)
   USA.
 ***/
 
+#include <avahi-common/llist.h>
 #include "core.h"
 #include "iface.h"
 #include "prioq.h"
-#include "llist.h"
 #include "timeeventq.h"
 #include "announce.h"
 #include "browse.h"
index eb7b913732ee016588c578bac7aaf2ea49e15460..7fe6bf9bba735e532b51eb1b1b3c7207dd7a40d6 100644 (file)
@@ -34,7 +34,7 @@
 #include <dbus/dbus.h>
 #include <dbus/dbus-glib-lowlevel.h>
 
-#include <avahi-core/llist.h>
+#include <avahi-common/llist.h>
 #include <avahi-core/log.h>
 #include <avahi-core/core.h>
 #include <avahi-common/dbus.h>
index d41cda523fd5cd44855d37278eb52d2a0485a3e2..39af043ca01a09686787fddedbb9bcac71a6dadd 100644 (file)
@@ -33,7 +33,7 @@
 
 #include <glib.h>
 
-#include <avahi-core/llist.h>
+#include <avahi-common/llist.h>
 #include <avahi-core/log.h>
 
 #include "simple-protocol.h"
index 0fdff1400209e8ed73baee47f45ffa4042eca0cc..659d00731f532e9ad99fdfc37d26b9e35e2a3ae3 100644 (file)
@@ -34,7 +34,7 @@
 #include <glib.h>
 #include <expat.h>
 
-#include <avahi-core/llist.h>
+#include <avahi-common/llist.h>
 #include <avahi-core/log.h>
 
 #include "main.h"
index 9f854cc3ca938b62a6dbf410f375b1358dfbcbda..957c91e6d7ae834e8fd6a3df1f7f1afd095efe86 100644 (file)
@@ -40,7 +40,7 @@
 #include <glib.h>
 
 #include <avahi-common/util.h>
-#include <avahi-core/llist.h>
+#include <avahi-common/llist.h>
 
 #include <libdaemon/dfork.h>
 #include <libdaemon/dsignal.h>