gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r30858 - in gnunet-dbus: . src


From: gnunet
Subject: [GNUnet-SVN] r30858 - in gnunet-dbus: . src
Date: Mon, 25 Nov 2013 10:28:13 +0100

Author: canndrew
Date: 2013-11-25 10:28:13 +0100 (Mon, 25 Nov 2013)
New Revision: 30858

Added:
   gnunet-dbus/src/gnunet-service-dht-dbus.h
   gnunet-dbus/src/gnunet-service-dht-dbus_dht.h
   gnunet-dbus/src/gnunet_dbus_lib_block.c
   gnunet-dbus/src/gnunet_dbus_lib_dht.c
   gnunet-dbus/src/gnunet_xstring_lib.c
   gnunet-dbus/src/gnunet_xstring_lib.h
Removed:
   gnunet-dbus/src/gnunet_dbus_lib_pop_block.c
   gnunet-dbus/src/gnunet_dbus_lib_pop_dht.c
   gnunet-dbus/src/xstring.c
   gnunet-dbus/src/xstring.h
Modified:
   gnunet-dbus/
   gnunet-dbus/Makefile.am
   gnunet-dbus/configure.ac
   gnunet-dbus/src/
   gnunet-dbus/src/Makefile.am
   gnunet-dbus/src/gnunet-service-dht-dbus.c
   gnunet-dbus/src/gnunet-service-dht-dbus_dht.c
   gnunet-dbus/src/gnunet_dbus_lib.c
   gnunet-dbus/src/gnunet_dbus_lib.h
   gnunet-dbus/src/gnunet_dbus_lib_pop.c
Log:
Added more to gnunet-dbus, still not usable.

Index: gnunet-dbus
===================================================================
--- gnunet-dbus 2013-11-25 02:39:37 UTC (rev 30857)
+++ gnunet-dbus 2013-11-25 09:28:13 UTC (rev 30858)

Property changes on: gnunet-dbus
___________________________________________________________________
Modified: svn:ignore
## -1,16 +1,20 ##
-*.in
-
 Makefile
+Makefile.in
 aclocal.m4
+ar-lib
 autom4te.cache
-autoscan-2.69.log
+config.guess
 config.h
+config.h.in
 config.log
 config.status
+config.sub
 configure
-configure.scan
 depcomp
 install-sh
+libtool
+ltmain.sh
+m4
 missing
 stamp-h1
 
Modified: gnunet-dbus/Makefile.am
===================================================================
--- gnunet-dbus/Makefile.am     2013-11-25 02:39:37 UTC (rev 30857)
+++ gnunet-dbus/Makefile.am     2013-11-25 09:28:13 UTC (rev 30858)
@@ -1,2 +1,4 @@
 SUBDIRS = src
 
+ACLOCAL_AMFLAGS = -I m4
+

Modified: gnunet-dbus/configure.ac
===================================================================
--- gnunet-dbus/configure.ac    2013-11-25 02:39:37 UTC (rev 30857)
+++ gnunet-dbus/configure.ac    2013-11-25 09:28:13 UTC (rev 30858)
@@ -1,7 +1,17 @@
 AC_INIT([gnunet-dbus],[0.9.5a],address@hidden)
 AM_INIT_AUTOMAKE([-Wall -Werror])
+AC_CONFIG_MACRO_DIR([m4])
 AC_PROG_CC
+AM_PROG_AR
+LT_INIT([disable-static dlopen win32-dll])
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_FILES([Makefile src/Makefile])
+
+PKG_CHECK_MODULES([DBUS], [dbus-1 >= 1.6.12])
+
+CFLAGS="$CFLAGS -Wall -Werror"
+CFLAGS="$CFLAGS $DBUS_CFLAGS"
+LDFLAGS="$LDFLAGS $DBUS_LDFLAGS"
+
 AC_OUTPUT
 

Index: gnunet-dbus/src
===================================================================
--- gnunet-dbus/src     2013-11-25 02:39:37 UTC (rev 30857)
+++ gnunet-dbus/src     2013-11-25 09:28:13 UTC (rev 30858)

Property changes on: gnunet-dbus/src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,3 ##
+.deps
+Makefile
+Makefile.in
Modified: gnunet-dbus/src/Makefile.am
===================================================================
--- gnunet-dbus/src/Makefile.am 2013-11-25 02:39:37 UTC (rev 30857)
+++ gnunet-dbus/src/Makefile.am 2013-11-25 09:28:13 UTC (rev 30858)
@@ -1,3 +1,23 @@
+lib_LTLIBRARIES = \
+       libgnunetdbus.la \
+       libgnunetdbus_dht.la \
+       libgnunetdbus_block.la \
+       libgnunetxstring.la
+
+libgnunetdbus_la_SOURCES = \
+       gnunet_dbus_lib.h \
+       gnunet_dbus_lib.c \
+       gnunet_dbus_lib_pop.c
+
+libgnunetdbus_dht_la_SOURCES = \
+       gnunet_dbus_lib_dht.c
+
+libgnunetdbus_block_la_SOURCES = \
+       gnunet_dbus_lib_block.c
+
+libgnunetxstring_la_SOURCES = \
+       gnunet_xstring_lib.c
+
 bin_PROGRAMS = \
   gnunet-service-dht-dbus
 
@@ -2,7 +22,9 @@
 gnunet_service_dht_dbus_SOURCES = \
-  gnunet-service-dht-dbus.c \
-  gnunet_dbus_lib.c \
-  xstring.c
+  gnunet-service-dht-dbus.c
 
 gnunet_service_dht_dbus_LDADD = \
+  libgnunetdbus.la \
+       libgnunetdbus_dht.la \
+       libgnunetdbus_block.la \
+       libgnunetxstring.la \
   -lgnunetutil

Modified: gnunet-dbus/src/gnunet-service-dht-dbus.c
===================================================================
--- gnunet-dbus/src/gnunet-service-dht-dbus.c   2013-11-25 02:39:37 UTC (rev 
30857)
+++ gnunet-dbus/src/gnunet-service-dht-dbus.c   2013-11-25 09:28:13 UTC (rev 
30858)
@@ -16,9 +16,10 @@
 #include <gnunet/gnunet_program_lib.h>
 #include <gnunet/gnunet_getopt_lib.h>
 #include <gnunet/gnunet_scheduler_lib.h>
+#include <gnunet/gnunet_dht_service.h>
 
 #include "gnunet_dbus_lib.h"
-
+#include "gnunet-service-dht-dbus_dht.h"
 #include "xstring.h"
 
 /*
@@ -29,14 +30,9 @@
   /*
    * The program configuration
    */
-  GNUNET_CONFIGURATION_Handle *cfg;
+  struct GNUNET_CONFIGURATION_Handle *cfg;
 
   /*
-   * linked list of connected clients
-   */
-  struct DHTClient *clients;
-
-  /*
    * GNUNET_OK or GNUNET_SYSERR. Checked during exit to see if there was an 
error.
    */
   int run_error;
@@ -47,16 +43,7 @@
  */
 struct DHTClient
 {
-  /* doubly-linked list */
-  struct DHTClient *next;
-  struct DHTClient *prev;
-
   /*
-   * DBus client data
-   */
-  struct GNUNET_DBUS_Client *client;
-
-  /*
    * Our connection to the dht service.
    * Each connected client uses it's own connection.
    */
@@ -73,21 +60,23 @@
 
 /*
  * Run whenever a new never-before-seen client starts talking to our service.
+ *
+ * @param service the service the client is talking to.
  * @param client the new client, created and passed to us by gnunet_lib_dbus
- * @param cls our DHT
  */
 static int
 client_connects (
-    GNUNET_DBUS_Client *client,
-    void *cls)
+    struct GNUNET_DBUS_Service *service,
+    struct GNUNET_DBUS_Client *client)
 {
-  struct DHT *dht = (struct DHT *)cls;
+  struct DHT *dht = (struct DHT *)GNUNET_DBUS_service_get_data (service);
   struct DHTClient *dht_client = GNUNET_new (struct DHTClient);
   if (! dht_client)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to allocate memory for 
connecting client.\n");
     return GNUNET_SYSERR;
   };
+  GNUNET_DBUS_client_set_data (client, dht_client);
 
   struct GNUNET_DHT_Handle *dht_handle = GNUNET_DHT_connect (
       dht->cfg,
@@ -98,11 +87,9 @@
     GNUNET_free (dht_client);
     return GNUNET_SYSERR;
   };
+  dht_client->dht_handle = dht_handle;
 
-  dht_client->dht_handle = dht_handle;
-  dht_client->next = dht->clients;
-  dht_client->prev = NULL;
-  dht->clients = dht_client;
+  return GNUNET_OK;
 };
 
 /*
@@ -125,21 +112,21 @@
   struct DHT *dht = (struct DHT *)cls;
   dht->run_error = GNUNET_SYSERR;
 
-  struct GNUNET_DBUS_Service *service = GNUNET_DBUS_create_service("dht", cfg, 
client_connects, dht);
+  struct GNUNET_DBUS_Service *service = GNUNET_DBUS_service_create("dht", cfg, 
dht);
   if (NULL == service)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create service.\n");
     return;
   };
 
-  struct GNUNET_DBUS_Object *dht = GNUNET_DBUS_object_create (service, "/dht", 
NULL);
-  if (! dht)
+  struct GNUNET_DBUS_Object *dht_obj = GNUNET_DBUS_object_create (service, 
"/dht", NULL);
+  if (! dht_obj)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create /dht object.\n");
     return;
   };
 
-  int err = GNUNET_DBUS_object_add_method (dht, "org.gnunet.dht", "put", 
method_dht_put);
+  int err = GNUNET_DBUS_object_add_method (dht_obj, "org.gnunet.dht", "put", 
method_dht_put);
   if (GNUNET_OK != err)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to add org.gnunet.dht.put 
method\n");

Added: gnunet-dbus/src/gnunet-service-dht-dbus.h
===================================================================
--- gnunet-dbus/src/gnunet-service-dht-dbus.h                           (rev 0)
+++ gnunet-dbus/src/gnunet-service-dht-dbus.h   2013-11-25 09:28:13 UTC (rev 
30858)
@@ -0,0 +1,14 @@
+#ifndef GNUNET_SERVICE_DHT_DBUS_H
+#define GNUNET_SERVICE_DHT_DBUS_H
+
+struct DHTPut
+{
+  struct DHTPut *next;
+  struct DHTPut *prev;
+
+  struct GNUNET_DHT_PutHandle *put_handle;
+  char *path;
+};
+
+#endif
+

Modified: gnunet-dbus/src/gnunet-service-dht-dbus_dht.c
===================================================================
--- gnunet-dbus/src/gnunet-service-dht-dbus_dht.c       2013-11-25 02:39:37 UTC 
(rev 30857)
+++ gnunet-dbus/src/gnunet-service-dht-dbus_dht.c       2013-11-25 09:28:13 UTC 
(rev 30858)
@@ -22,12 +22,12 @@
 
 DBusMessage *
 method_dht_introspect (
-    GNUNET_DBUS_Client *client,
-    DBusMessage *message,
-    void *wrapped)
+    struct GNUNET_DBUS_Client *client,
+    struct GNUNET_DBUS_Object *object,
+    DBusMessage *message)
 {
   (void)client;
-  (void)wrapped;
+  (void)object;
 
   DBusMessage *ret = dbus_message_new_method_return (message);
   if (! ret)
@@ -50,11 +50,19 @@
   return ret;
 };
 
+void
+put_continuation (
+    void *cls,
+    int success)
+{
+  
+};
+
 DBusMessage *
 method_dht_put (
-    GNUNET_DBUS_Client *client,
-    DBusMessage *message,
-    void *wrapped)
+    struct GNUNET_DBUS_Client *client,
+    struct GNUNET_DBUS_Object *object,
+    DBusMessage *message)
 {
   DBusMessage *ret = NULL;
 
@@ -77,15 +85,42 @@
   if (ret)
     return ret;
 
-  struct DHT *dht = (struct DHT *)wrapped;
-  struct DHTClient dht_client = dht_find_client (client);
+  struct DHT *dht                 = (struct DHT *)GNUNET_DBUS_object_get_data 
(object);
+  struct DHTClient *dht_client    = (struct DHTClient 
*)GNUNET_DBUS_client_get_data (client);
+  struct DHTPut *dht_put          = GNUNET_new (struct DHTPut);
+
+  size_t path_size = GNUNET_XSTRING_NEW_DEFAULT_SIZE;
+  char *path = GNUNET_XSTRING_new ();
+  GNUNET_XSTRING_appendf (&path, &path_size, "/outgoing/%08x", 
dbus_message_get_serial (message));
+  dht_put->path = path;
   
+
   struct GNUNET_DHT_PutHandle *ph = GNUNET_DHT_put (
       dht_client->dht_handle,
       key,
       desired_replication_level,
-      
+      options,
+      type,
+      size,
+      data,
+      expiration,
+      timeout,
+      put_continuation,
+      dht_put);
+  if (! ph)
+  {
+    GNUNET_free (dht_put);
+    return dbus_message_new_error_printf (
+        message,
+        DBUS_ERROR_FAILED,
+        "Failed to create put request. GNUNET_DHT_put returned NULL");
+  };
 
-    
+
+  dht_put->put_handle = ph;
+
+  dht_put->next = dht->puts;
+  dht_put->prev = NULL;
+  dht->puts = dht_put;
 };
 

Added: gnunet-dbus/src/gnunet-service-dht-dbus_dht.h
===================================================================
--- gnunet-dbus/src/gnunet-service-dht-dbus_dht.h                               
(rev 0)
+++ gnunet-dbus/src/gnunet-service-dht-dbus_dht.h       2013-11-25 09:28:13 UTC 
(rev 30858)
@@ -0,0 +1,17 @@
+#ifndef GNUNET_SERVICE_DHT_DBUS_DHT_H
+#define GNUNET_SERVICE_DHT_DBUS_DHT_H
+
+DBusMessage *
+method_dht_introspect (
+    GNUNET_DBUS_Client *client,
+    DBusMessage *message,
+    void *wrapped);
+
+DBusMessage *
+method_dht_put (
+    GNUNET_DBUS_Client *client,
+    DBusMessage *message,
+    void *wrapped);
+
+#endif
+

Modified: gnunet-dbus/src/gnunet_dbus_lib.c
===================================================================
--- gnunet-dbus/src/gnunet_dbus_lib.c   2013-11-25 02:39:37 UTC (rev 30857)
+++ gnunet-dbus/src/gnunet_dbus_lib.c   2013-11-25 09:28:13 UTC (rev 30858)
@@ -57,12 +57,35 @@
   struct Watch *watches;
 
   /*
-   * Callback to execute whenever a new client connects to
-   * the service.
+   * Callback that is executed when we receive a message from a new
+   * never-before-seen client
    */
   GNUNET_DBUS_ClientConnects client_connects;
+
+  /*
+   * Linked list of DBus clients we have seen.
+   */
+  struct GNUNET_DBUS_Client *clients;
+
+  /*
+   * Application-specific data associated with this service.
+   */
+  void *data;
 };
 
+struct GNUNET_DBUS_Client
+{
+  struct GNUNET_DBUS_Client *next;
+  struct GNUNET_DBUS_Client *prev;
+
+  const char *unique_name;
+
+  /*
+   * Application-specific data associated with this client
+   */
+  void *data;
+};
+
 /*
  * A container for methods that can be exposed on DBus.
  */
@@ -72,8 +95,18 @@
   struct Method *next;
   struct Method *prev;
 
+  /*
+   * DBus interface of the method
+   */
+  const char *interface;
+  
+  /*
+   * Name of the method as accessible through DBus
+   */
+  const char *method_name;
+
   /* The actual method */
-  GNUNET_DBUS_Method *method;
+  GNUNET_DBUS_Method method;
 };
 
 /*
@@ -87,7 +120,7 @@
    * Closure passed in to GNUNET_DBUS_object_create.
    * Points to the actual data structure wrapped by this DBus object.
    */
-  void *wrapped;
+  void *data;
 
   /*
    * The service we are an object of
@@ -293,7 +326,7 @@
   w->prev = NULL;
   service->watches = w;
 
-  if(dbus_watch_enabled(watch))
+  if(dbus_watch_get_enabled (watch))
   {
     int err = watch_schedule (w);
     if (GNUNET_OK != err)
@@ -370,7 +403,7 @@
     return;
   };
 
-  bool enabled = dbus_watch_enabled (watch);
+  bool enabled = dbus_watch_get_enabled (watch);
   bool scheduled = w->scheduled;
 
   if (enabled && ! scheduled)
@@ -383,7 +416,7 @@
 free_service(
     void *service)
 {
-  GNUNET_DBUS_destroy_service((struct GNUNET_DBUS_Service *)service);
+  GNUNET_DBUS_service_destroy ((struct GNUNET_DBUS_Service *)service);
 };
 
 /*
@@ -393,15 +426,20 @@
  *                      "org.gnunet.`peername`" to form the name of the DBus
  *                      service.
  * @param cfg The service configuration
+ * @param data the appliation-specific data associated with this service
  */
 struct GNUNET_DBUS_Service *
-GNUNET_DBUS_create_service (
+GNUNET_DBUS_service_create (
     const char *service_name,
-    const struct GNUNET_CONFIGURATION_Handle *cfg)
+    const struct GNUNET_CONFIGURATION_Handle *cfg,
+    GNUNET_DBUS_ClientConnects client_connects,
+    void *data)
 {
   struct GNUNET_DBUS_Service *ret;
   ret = GNUNET_new(struct GNUNET_DBUS_Service);
   ret->watches = NULL;
+  ret->client_connects = client_connects;
+  ret->data = data;
 
   DBusError err;
   DBusConnection *conn;
@@ -413,14 +451,14 @@
   {
     GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to dbus system bus 
(%s)\n", err.message);
     dbus_error_free(&err);
-    GNUNET_DBUS_destroy_service (ret);
+    GNUNET_free (ret);
     return NULL;
   };
   if(! conn)
   {
     GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to dbus system bus; 
dbus_bus_get returned NULL\n");
     dbus_error_free(&err);
-    GNUNET_DBUS_destroy_service (ret);
+    GNUNET_free (ret);
     return NULL;
   };
   ret->conn = conn;
@@ -429,7 +467,7 @@
   if(! succ)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "dbus_connection_set_watch_functions 
returned false. Out of memory.\n");
-    GNUNET_DBUS_destroy_service (ret);
+    GNUNET_free (ret);
     return NULL;
   };
 
@@ -439,7 +477,7 @@
   if(dbus_error_is_set(&err)) {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to request the bus name 
(%s)\n", err.message);
     dbus_error_free(&err);
-    GNUNET_DBUS_destroy_service (ret);
+    GNUNET_DBUS_service_destroy (ret);
     return NULL;
   };
   switch(request_result) {
@@ -447,11 +485,11 @@
     break;
   case DBUS_REQUEST_NAME_REPLY_EXISTS:
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to request the bus name 
\"%s\"; name is already taken.\n", name);
-    GNUNET_DBUS_destroy_service (ret);
+    GNUNET_DBUS_service_destroy (ret);
     return NULL;
   default:
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unable to interpret result of 
dbus_request_name (%d)\n", request_result);
-    GNUNET_DBUS_destroy_service (ret);
+    GNUNET_DBUS_service_destroy (ret);
     return NULL;
   };
 
@@ -480,6 +518,13 @@
   GNUNET_free (service);
 };
 
+void *
+GNUNET_DBUS_service_get_data (
+    struct GNUNET_DBUS_Service *service)
+{
+  return service->data;
+};
+
 DBusHandlerResult
 handle_object_message (
     DBusConnection *conn,
@@ -488,20 +533,48 @@
 {
   struct GNUNET_DBUS_Object *obj = (struct GNUNET_DBUS_Object *)cls;
 
-  const char *type = dbus_message_type_to_string (dbus_message_get_type 
(message));
+#if 1
+  const char *type_string = dbus_message_type_to_string (dbus_message_get_type 
(message));
   const char *interface = dbus_message_get_interface (message);
   const char *member = dbus_message_get_member (message);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Recieved DBus message for %s\n", 
obj->path);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "    type      == %s\n", type      ? 
type      : "(none)");
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "    interface == %s\n", interface ? 
interface : "(none)");
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "    member    == %s\n", member    ? 
member    : "(none)");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "    type      == %s\n", type_string ? 
type_string : "(none)");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "    interface == %s\n", interface   ? 
interface   : "(none)");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "    member    == %s\n", member      ? 
member      : "(none)");
+#endif
 
-
   int type = dbus_message_get_type (message);
   if (type != DBUS_MESSAGE_TYPE_METHOD_CALL)
-    return DBUS_RESULT_HANDLER_NOT_YET_HANDLED;
+    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 
-  Message *pos = obj->messages;
+  const char *sender = dbus_message_get_sender (message);
+  struct GNUNET_DBUS_Service *service = obj->service;
+  struct GNUNET_DBUS_Client *client = service->clients;
+  while (client)
+  {
+    if (! strcmp(client->unique_name, sender))
+      break;
+    client = client->next;
+  };
+  if (! client)
+  {
+    client = GNUNET_new (struct GNUNET_DBUS_Client);
+    client->unique_name = strdup (sender);
+    if (service->client_connects)
+    {
+      int err = service->client_connects (service, client);
+      if (GNUNET_OK != err)
+      {
+        GNUNET_free (client);
+        return DBUS_HANDLER_RESULT_HANDLED;
+      };
+    };
+    client->next = service->clients;
+    client->prev = NULL;
+    service->clients = client;
+  }
+
+  struct Method *pos = obj->methods;
   while (pos)
   {
     if (dbus_message_is_method_call (
@@ -509,7 +582,7 @@
         pos->interface,
         pos->method_name))
     {
-      DBusMessage *reply = pos->method (message, obj);
+      DBusMessage *reply = pos->method (client, obj, message);
       if (! reply)
       {
         GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "method returned NULL. Out of 
memory.\n");
@@ -527,7 +600,7 @@
 
 void
 handle_object_unregister (
-    DBusConnection *conn.
+    DBusConnection *conn,
     void *cls)
 {
   struct GNUNET_DBUS_Object *obj = (struct GNUNET_DBUS_Object *)cls;
@@ -538,13 +611,13 @@
 GNUNET_DBUS_object_create (
     struct GNUNET_DBUS_Service *service,
     const char *path,
-    void *wrapped)
+    void *data)
 {
-  GNUNET_DBUS_Object *ret;
+  struct GNUNET_DBUS_Object *ret;
   ret = GNUNET_new (struct GNUNET_DBUS_Object);
   ret->service = service;
   ret->path = path;
-  ret->wrapped = wrapped;
+  ret->data = data;
   ret->methods = NULL;
 
   DBusError err;
@@ -600,8 +673,8 @@
 
 int
 GNUNET_DBUS_object_add_method (
-    GNUNET_DBUS_Object *obj,
-    const char *interface.
+    struct GNUNET_DBUS_Object *obj,
+    const char *interface,
     const char *method_name,
     GNUNET_DBUS_Method method)
 {
@@ -609,14 +682,84 @@
   if (NULL == add)
     return GNUNET_SYSERR;
 
-  add->next = obj->methods;
-  add->prev = NULL;
   add->interface = interface;
   add->method_name = method_name;
   add->method = method;
+
+  add->next = obj->methods;
+  add->prev = NULL;
   obj->methods = add;
   return GNUNET_OK;
 };
 
+struct GNUNET_NETWORK_Handle *
+GNUNET_DBUS_create_socket_from_dbus_address(
+    const char *address)
+{
+  DBusAddressEntry *entry;
+  DBusAddressEntry **entries;
+  int entry_len;
+  int res;
+  struct GNUNET_NETWORK_Handle *ret;
+  int i;
 
+  DBusError err;
+  dbus_error_init(&err);
 
+  ret = NULL;
+  dbus_parse_address (address, &entries, &entry_len, &err);
+  if (dbus_error_is_set (&err))
+  {
+    dbus_error_free (&err);
+    return NULL;
+  };
+
+  for(i = 0, entry = entries[i]; entry; entry = entries[++i]) {
+    const char *method;
+        
+    method = dbus_address_entry_get_method(entry);
+    if(! strcmp(method, "unix")) {
+      struct sockaddr_un addr;
+      const char *path;
+      socklen_t addr_len;
+
+      addr.sun_family = AF_UNIX;
+      memset(addr.sun_path, 0, sizeof(addr.sun_path));
+      path = dbus_address_entry_get_value(entry, "path");
+      if(path) {
+        strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1);
+        addr_len = sizeof(addr);
+      }
+      else {
+        path = dbus_address_entry_get_value(entry, "abstract");
+        if(path) {
+          strncpy(addr.sun_path + 1, path, sizeof(addr.sun_path) - 2);
+          addr_len =   sizeof(addr) \
+                     + strnlen(addr.sun_path + 1, sizeof(addr.sun_path) - 1) \
+                     - sizeof(addr.sun_path);
+        }
+        else
+          continue;
+      };
+
+      ret = GNUNET_NETWORK_socket_create(AF_UNIX, SOCK_STREAM, 0);
+      if(! ret)
+        continue;
+
+      res = GNUNET_NETWORK_socket_connect(ret, (struct sockaddr *)&addr, 
addr_len);
+      if(res != GNUNET_OK) {
+        res = GNUNET_NETWORK_socket_close(ret);
+        if(res != GNUNET_OK)
+          GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to close socket.\n");
+        ret = NULL;
+        continue;
+      }
+
+      break;
+    }
+  };
+
+  dbus_address_entries_free(entries);
+  return ret;
+};
+

Modified: gnunet-dbus/src/gnunet_dbus_lib.h
===================================================================
--- gnunet-dbus/src/gnunet_dbus_lib.h   2013-11-25 02:39:37 UTC (rev 30857)
+++ gnunet-dbus/src/gnunet_dbus_lib.h   2013-11-25 09:28:13 UTC (rev 30858)
@@ -1,27 +1,143 @@
 #ifndef GNUNET_DBUS_LIB_H
 #define GNUNET_DBUS_LIB_H
 
+#include <dbus/dbus.h>
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
 #include <gnunet/gnunet_configuration_lib.h>
+#include <gnunet/gnunet_crypto_lib.h>
 
+struct GNUNET_DBUS_Service;
+struct GNUNET_DBUS_Client;
+struct GNUNET_DBUS_Object;
+
+struct GNUNET_DBUS_StringEnumPair
+{
+  const char *name;
+  int value;
+};
+
 typedef DBusMessage *(*GNUNET_DBUS_Method) (
-    DBusMessage *message,
-    void *wrapped);
+    struct GNUNET_DBUS_Client *client,
+    struct GNUNET_DBUS_Object *object,
+    DBusMessage *message);
 
 typedef int (*GNUNET_DBUS_ClientConnects) (
-    GNUNET_DBUS_Client *client,
-    void *cls);
+    struct GNUNET_DBUS_Service *service,
+    struct GNUNET_DBUS_Client *client);
 
-
-struct GNUNET_DBUS_Service;
-
 struct GNUNET_DBUS_Service *
-GNUNET_DBUS_create_service (
+GNUNET_DBUS_service_create (
     const char *service_name,
-    const struct GNUNET_CONFIGURATION_Handle *cfg);
+    const struct GNUNET_CONFIGURATION_Handle *cfg,
+    GNUNET_DBUS_ClientConnects client_connects,
+    void *data);
 
 void
-GNUNET_DBUS_destroy_service(
+GNUNET_DBUS_service_destroy (
     struct GNUNET_DBUS_Service *service);
 
+void *
+GNUNET_DBUS_service_get_data (
+    struct GNUNET_DBUS_Service *service);
+
+struct GNUNET_DBUS_Object *
+GNUNET_DBUS_object_create (
+    struct GNUNET_DBUS_Service *service,
+    const char *path,
+    void *data);
+
+int
+GNUNET_DBUS_object_destroy (
+    struct GNUNET_DBUS_Object *obj);
+
+int
+GNUNET_DBUS_object_add_method (
+    struct GNUNET_DBUS_Object *obj,
+    const char *interface,
+    const char *method_name,
+    GNUNET_DBUS_Method method);
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_basic (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    int expected_type,
+    void *value);
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_string (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    const char **val);
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_uint32 (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    dbus_uint32_t *value);
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_fixed_array (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    int expected_type,
+    void *value,
+    int *n_elements);
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_array_byte (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    const char **value,
+    int *n_elements);
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_bitfield (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    int *value,
+    const struct GNUNET_DBUS_StringEnumPair *fields);
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_enum (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    int *value,
+    const struct GNUNET_DBUS_StringEnumPair *names);
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_hashcode (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    struct GNUNET_HashCode *hc);
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_socket (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    struct GNUNET_NETWORK_Handle **socket_handle);
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_absolute_time (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    struct GNUNET_TIME_Absolute *value);
+
+struct GNUNET_NETWORK_Handle *
+GNUNET_DBUS_create_socket_from_dbus_address(
+    const char *address);
+
 #endif
 

Added: gnunet-dbus/src/gnunet_dbus_lib_block.c
===================================================================
--- gnunet-dbus/src/gnunet_dbus_lib_block.c                             (rev 0)
+++ gnunet-dbus/src/gnunet_dbus_lib_block.c     2013-11-25 09:28:13 UTC (rev 
30858)
@@ -0,0 +1,45 @@
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_block_lib.h>
+
+#include "gnunet_dbus_lib.h"
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_block_type (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    enum GNUNET_BLOCK_Type *value)
+{
+  static const struct GNUNET_DBUS_StringEnumPair names[] = {
+      {"any",            GNUNET_BLOCK_TYPE_ANY},
+      {"fs_dblock",      GNUNET_BLOCK_TYPE_FS_DBLOCK},
+      {"fs_iblock",      GNUNET_BLOCK_TYPE_FS_IBLOCK},
+      {"fs_kblock",      GNUNET_BLOCK_TYPE_FS_KBLOCK},
+      {"fs_sblock",      GNUNET_BLOCK_TYPE_FS_SBLOCK},
+      {"fs_nblock",      GNUNET_BLOCK_TYPE_FS_NBLOCK},
+      {"fs_ondemand",    GNUNET_BLOCK_TYPE_FS_ONDEMAND},
+      {"dht_hello",      GNUNET_BLOCK_TYPE_DHT_HELLO},
+      {"test",           GNUNET_BLOCK_TYPE_TEST},
+      {"fs_ublock",      GNUNET_BLOCK_TYPE_FS_UBLOCK},
+      {"dns",            GNUNET_BLOCK_TYPE_DNS},
+      {"gns_namerecord", GNUNET_BLOCK_TYPE_GNS_NAMERECORD},
+      {"mesh_peer",      GNUNET_BLOCK_TYPE_MESH_PEER},
+      {"regex",          GNUNET_BLOCK_TYPE_REGEX},
+      {"regex_accept",   GNUNET_BLOCK_TYPE_REGEX_ACCEPT}
+  };
+
+  int v;
+  DBusMessage *ret = GNUNET_DBUS_message_iter_pop_enum (
+      message,
+      iter,
+      arg_name,
+      &v,
+      names);
+  if (ret)
+    return ret;
+
+  *value = (enum GNUNET_BLOCK_Type)v;
+  return NULL;
+};
+

Added: gnunet-dbus/src/gnunet_dbus_lib_dht.c
===================================================================
--- gnunet-dbus/src/gnunet_dbus_lib_dht.c                               (rev 0)
+++ gnunet-dbus/src/gnunet_dbus_lib_dht.c       2013-11-25 09:28:13 UTC (rev 
30858)
@@ -0,0 +1,35 @@
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_dht_service.h>
+
+#include "gnunet_dbus_lib.h"
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_dht_routeoption (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    enum GNUNET_DHT_RouteOption *value)
+{
+  static const struct GNUNET_DBUS_StringEnumPair fields[] = {
+      {"demultiplex_everywhere", GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE},
+      {"record_route",           GNUNET_DHT_RO_RECORD_ROUTE},
+      {"find_peer",              GNUNET_DHT_RO_FIND_PEER},
+      {"bart",                   GNUNET_DHT_RO_BART}
+  };
+
+  int bf;
+  DBusMessage *ret = GNUNET_DBUS_message_iter_pop_bitfield (
+      message,
+      iter,
+      arg_name,
+      &bf,
+      fields);
+  if (ret)
+    return ret;
+
+  *value = (enum GNUNET_DHT_RouteOption)bf;
+  return NULL;
+};
+
+

Modified: gnunet-dbus/src/gnunet_dbus_lib_pop.c
===================================================================
--- gnunet-dbus/src/gnunet_dbus_lib_pop.c       2013-11-25 02:39:37 UTC (rev 
30857)
+++ gnunet-dbus/src/gnunet_dbus_lib_pop.c       2013-11-25 09:28:13 UTC (rev 
30858)
@@ -1,3 +1,12 @@
+#include <dbus/dbus.h>
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_strings_lib.h>
+
+#include "gnunet_dbus_lib.h"
+#include "gnunet_xstring_lib.h"
+
 DBusMessage *
 GNUNET_DBUS_message_iter_pop_basic (
     DBusMessage *message,
@@ -12,7 +21,7 @@
     return dbus_message_new_error_printf (
         message,
         DBUS_ERROR_INVALID_ARGS,
-        "Bad argument for '%s'. Expected %s. Got %s"
+        "Bad argument for '%s'. Expected %s. Got %s",
           arg_name,
           dbus_message_type_to_string (expected_type),
           dbus_message_type_to_string (arg_type));
@@ -28,9 +37,9 @@
     DBusMessage *message,
     DBusMessageIter *iter,
     const char *arg_name,
-    const char **val)
+    const char **value)
 {
-  return GNUNET_DBUS_message_get_basic (
+  return GNUNET_DBUS_message_iter_pop_basic (
       message,
       iter,
       arg_name,
@@ -110,6 +119,23 @@
       n_elements);
 };
 
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_array_string (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    const char ***value,
+    int *n_elements)
+{
+  return GNUNET_DBUS_message_iter_pop_fixed_array (
+      message,
+      iter,
+      arg_name,
+      DBUS_TYPE_STRING,
+      (void *)value,
+      n_elements);
+};
+
 /*
  * bitfield enums can be sent across the wire in either their integer form (as
  * an array of bit flags) or as an array of strings. Sending an int is more
@@ -123,7 +149,7 @@
     DBusMessageIter *iter,
     const char *arg_name,
     int *value,
-    const struct EnumName *fields)
+    const struct GNUNET_DBUS_StringEnumPair *fields)
 {
   uint32_t flags;
   DBusMessage *ret = GNUNET_DBUS_message_iter_pop_uint32 (message, iter, 
arg_name, &flags);
@@ -134,7 +160,7 @@
   };
   dbus_message_unref (ret);
 
-  char **options;
+  const char **options;
   int num_options;
   ret = GNUNET_DBUS_message_iter_pop_array_string (message, iter, arg_name, 
&options, &num_options);
   if (! ret)
@@ -158,7 +184,7 @@
         char *errmsg = GNUNET_XSTRING_new ();
         GNUNET_XSTRING_appendf (&errmsg, &size, "Unrecognized option '%s'. 
Valid options are: [", options[i]);
         for (j = 0; fields[j].name; j++)
-          GNUNET_XSTRING_append (&errmsg, "%s'%s'", j ? ", " : "", 
fields[j].name);
+          GNUNET_XSTRING_appendf (&errmsg, &size, "%s'%s'", j ? ", " : "", 
fields[j].name);
         GNUNET_XSTRING_append (&errmsg, &size, "].");
         ret = dbus_message_new_error_printf (
             message,
@@ -187,13 +213,13 @@
     DBusMessageIter *iter,
     const char *arg_name,
     int *value,
-    const struct EnumName *names)
+    const struct GNUNET_DBUS_StringEnumPair *names)
 {
   uint32_t v;
-  DBusMessage *ret = GNUNET_DBUS_message_iter_pop_uint32 (message, iter, 
arg_name, &flags);
+  DBusMessage *ret = GNUNET_DBUS_message_iter_pop_uint32 (message, iter, 
arg_name, &v);
   if (! ret)
   {
-    *value = (int)flags;
+    *value = (int)v;
     return NULL;
   };
   dbus_message_unref (ret);
@@ -215,9 +241,9 @@
     {
       size_t size = GNUNET_XSTRING_NEW_DEFAULT_SIZE;
       char *errmsg = GNUNET_XSTRING_new ();
-      GNUNET_XSTRING_appendf (&errmsg, &size, "Unrecognized option '%s'. Valid 
options are: [", names);
+      GNUNET_XSTRING_appendf (&errmsg, &size, "Unrecognized option '%s'. Valid 
options are: [", name);
       for (i = 0; names[i].name; i++)
-        GNUNET_XSTRING_append (&errmsg, "%s'%s'", i ? ", " : "", 
names[i].name);
+        GNUNET_XSTRING_appendf (&errmsg, &size, "%s'%s'", i ? ", " : "", 
names[i].name);
       GNUNET_XSTRING_append (&errmsg, &size, "].");
       ret = dbus_message_new_error_printf (
           message,

Deleted: gnunet-dbus/src/gnunet_dbus_lib_pop_block.c
===================================================================
--- gnunet-dbus/src/gnunet_dbus_lib_pop_block.c 2013-11-25 02:39:37 UTC (rev 
30857)
+++ gnunet-dbus/src/gnunet_dbus_lib_pop_block.c 2013-11-25 09:28:13 UTC (rev 
30858)
@@ -1,39 +0,0 @@
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_block_type (
-    DBusMessage *message,
-    DBusMessageIter *iter,
-    const char *arg_name,
-    enum GNUNET_BLOCK_Type *value)
-{
-  static const struct GNUNET_DBUS_EnumName names[] = {
-      {"any",            GNUNET_BLOCK_TYPE_ANY},
-      {"fs_dblock",      GNUNET_BLOCK_TYPE_FS_DBLOCK},
-      {"fs_iblock",      GNUNET_BLOCK_TYPE_FS_IBLOCK},
-      {"fs_kblock",      GNUNET_BLOCK_TYPE_FS_KBLOCK},
-      {"fs_sblock",      GNUNET_BLOCK_TYPE_FS_SBLOCK},
-      {"fs_nblock",      GNUNET_BLOCK_TYPE_FS_NBLOCK},
-      {"fs_ondemand",    GNUNET_BLOCK_TYPE_FS_ONDEMAND},
-      {"dht_hello",      GNUNET_BLOCK_TYPE_DHT_HELLO},
-      {"test",           GNUNET_BLOCK_TYPE_TEST},
-      {"fs_ublock",      GNUNET_BLOCK_TYPE_FS_UBLOCK},
-      {"dns",            GNUNET_BLOCK_TYPE_DNS},
-      {"gns_namerecord", GNUNET_BLOCK_TYPE_GNS_NAMERECORD},
-      {"mesh_peer",      GNUNET_BLOCK_TYPE_MESH_PEER},
-      {"regex",          GNUNET_BLOCK_TYPE_REGEX},
-      {"regex_accept",   GNUNET_BLOCK_TYPE_REGEX_ACCEPT}
-  };
-
-  int v;
-  DBusMessage *ret = GNUNET_DBUS_message_iter_pop_enum (
-      message,
-      iter,
-      arg_name,
-      &v,
-      names);
-  if (ret)
-    return ret;
-
-  *value = (enum GNUNET_BLOCK_Type)v;
-  return NULL;
-};
-

Deleted: gnunet-dbus/src/gnunet_dbus_lib_pop_dht.c
===================================================================
--- gnunet-dbus/src/gnunet_dbus_lib_pop_dht.c   2013-11-25 02:39:37 UTC (rev 
30857)
+++ gnunet-dbus/src/gnunet_dbus_lib_pop_dht.c   2013-11-25 09:28:13 UTC (rev 
30858)
@@ -1,29 +0,0 @@
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_dht_routeoption (
-    DBusMessage *message,
-    DBusMessageIter *iter,
-    const char *arg_name,
-    enum GNUNET_DHT_RouteOption *value)
-{
-  static const struct GNUNET_DBUS_EnumName fields[] = {
-      {"demultiplex_everywhere", GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE},
-      {"record_route",           GNUNET_DHT_RO_RECORD_ROUTE},
-      {"find_peer",              GNUNET_DHT_RO_FIND_PEER},
-      {"bart",                   GNUNET_DHT_RO_BART}
-  };
-
-  int bf;
-  DBusMessage *ret = GNUNET_DBUS_message_iter_pop_bitfield (
-      message,
-      iter,
-      arg_name,
-      &bf,
-      fields);
-  if (ret)
-    return ret;
-
-  *value = (enum GNUNET_DHT_RouteOption)bf;
-  return NULL;
-};
-
-

Added: gnunet-dbus/src/gnunet_xstring_lib.c
===================================================================
--- gnunet-dbus/src/gnunet_xstring_lib.c                                (rev 0)
+++ gnunet-dbus/src/gnunet_xstring_lib.c        2013-11-25 09:28:13 UTC (rev 
30858)
@@ -0,0 +1,99 @@
+#include <stdint.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <string.h>
+#include <stdio.h>
+#include <sys/socket.h>
+
+#include <gnunet/gnunet_common.h>
+
+#include "gnunet_xstring_lib.h"
+
+char *
+GNUNET_XSTRING_new()
+{
+  char *ret = (char *)GNUNET_malloc(GNUNET_XSTRING_NEW_DEFAULT_SIZE);
+  ret[0] = '\0';
+  return ret;
+};
+
+int
+GNUNET_XSTRING_append ( \
+    char **dest,
+    size_t *dest_size,
+    const char *arg)
+{
+  size_t old_len, new_len, total_len;
+  size_t newsize;
+
+  old_len = strnlen(*dest, *dest_size);
+  new_len = strlen(arg);
+  total_len = old_len + new_len;
+  newsize = *dest_size;
+
+  if(newsize == 0)
+    newsize = GNUNET_XSTRING_NEW_DEFAULT_SIZE;
+
+  while( \
+         (total_len + 1 > newsize || newsize < 
GNUNET_XSTRING_NEW_DEFAULT_SIZE) \
+      && newsize != 0)
+    newsize *= 2;
+
+  if(newsize == 0)
+    return GNUNET_SYSERR;
+
+  if(newsize > *dest_size)
+  {
+    *dest_size = newsize;
+    *dest = GNUNET_realloc(*dest, *dest_size);
+    if(*dest == NULL)
+      return GNUNET_SYSERR;
+  };
+
+  memcpy(*dest + old_len, arg, new_len + 1);
+  return GNUNET_OK;
+};
+
+int __attribute__ ((format (printf, 3, 4)))
+GNUNET_XSTRING_appendf ( \
+    char **dest,
+    size_t *dest_size,
+    const char *fmt,
+    ...)
+{
+  size_t old_len;
+  va_list args;
+  
+  old_len = strnlen(*dest, *dest_size);
+  va_start(args, fmt);
+
+  while(true)
+  {
+    size_t remaining;
+    char *end;
+    int written;
+
+    remaining = *dest_size - old_len;
+    end = *dest + old_len;
+    written = vsnprintf(end, remaining, fmt, args);
+
+    if(written < 0)
+      return GNUNET_SYSERR;
+
+    if((size_t)written >= remaining)
+    {
+      *dest_size *= 2;
+      *dest = GNUNET_realloc(*dest, *dest_size);
+      if(*dest == NULL)
+        return GNUNET_SYSERR;
+      continue;
+    };
+    
+    break;
+  };
+  va_end(args);
+
+  return GNUNET_OK;
+};
+
+

Added: gnunet-dbus/src/gnunet_xstring_lib.h
===================================================================
--- gnunet-dbus/src/gnunet_xstring_lib.h                                (rev 0)
+++ gnunet-dbus/src/gnunet_xstring_lib.h        2013-11-25 09:28:13 UTC (rev 
30858)
@@ -0,0 +1,26 @@
+#ifndef GNUNET_XSTRING_LIB_H
+#define GNUNET_XSTRING_LIB_H
+
+#include <stdlib.h>
+#include <stddef.h>
+
+#define GNUNET_XSTRING_NEW_DEFAULT_SIZE 64
+
+char *
+GNUNET_XSTRING_new ();
+
+int
+GNUNET_XSTRING_append ( \
+    char **dest,
+    size_t *dest_size,
+    const char *arg);
+
+int __attribute__ ((format (printf, 3, 4)))
+GNUNET_XSTRING_appendf ( \
+    char **dest,
+    size_t *dest_size,
+    const char *fmt,
+    ...);
+
+#endif // GNUNET_XSTRING_LIB_H
+

Deleted: gnunet-dbus/src/xstring.c
===================================================================
--- gnunet-dbus/src/xstring.c   2013-11-25 02:39:37 UTC (rev 30857)
+++ gnunet-dbus/src/xstring.c   2013-11-25 09:28:13 UTC (rev 30858)
@@ -1,96 +0,0 @@
-#include "xstring.h"
-
-#include <stdint.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <string.h>
-#include <sys/socket.h>
-
-#include <gnunet/gnunet_common.h>
-
-char *
-GNUNET_XSTRING_new()
-{
-  return (char *)GNUNET_malloc(GNUNET_XSTRING_NEW_DEFAULT_SIZE);
-};
-
-int
-GNUNET_XSTRING_append ( \
-    char **dest,
-    size_t *dest_size,
-    const char *arg)
-{
-  size_t old_len, new_len, total_len;
-  size_t newsize;
-
-  old_len = strnlen(*dest, *dest_size);
-  new_len = strlen(arg);
-  total_len = old_len + new_len;
-  newsize = *dest_size;
-
-  if(newsize == 0)
-    newsize = GNUNET_XSTRING_NEW_DEFAULT_SIZE;
-
-  while( \
-         (total_len + 1 > newsize || newsize < 
GNUNET_XSTRING_NEW_DEFAULT_SIZE) \
-      && newsize != 0)
-    newsize *= 2;
-
-  if(newsize == 0)
-    return GNUNET_SYSERR;
-
-  if(newsize > *dest_size)
-  {
-    *dest_size = newsize;
-    *dest = GNUNET_realloc(*dest, *dest_size);
-    if(*dest == NULL)
-      return GNUNET_SYSERR;
-  };
-
-  memcpy(*dest + old_len, arg, new_len + 1);
-  return GNUNET_OK;
-};
-
-int
-GNUNET_XSTRING_appendf ( \
-    char **dest,
-    size_t *dest_size,
-    const char *fmt,
-    ...)
-{
-  size_t old_len;
-  va_list args;
-  
-  old_len = strnlen(*dest, *dest_size);
-  va_start(args, fmt);
-
-  while(true)
-  {
-    size_t remaining;
-    char *end;
-    int written;
-
-    remaining = *dest_size - old_len;
-    end = *dest + old_len;
-    written = vsnprintf(end, remaining, fmt, args);
-
-    if(written < 0)
-      return GNUNET_SYSERR;
-
-    if((size_t)written >= remaining)
-    {
-      *dest_size *= 2;
-      *dest = GNUNET_realloc(*dest, *dest_size);
-      if(*dest == NULL)
-        return GNUNET_SYSERR;
-      continue;
-    };
-    
-    break;
-  };
-  va_end(args);
-
-  return GNUNET_OK;
-};
-
-

Deleted: gnunet-dbus/src/xstring.h
===================================================================
--- gnunet-dbus/src/xstring.h   2013-11-25 02:39:37 UTC (rev 30857)
+++ gnunet-dbus/src/xstring.h   2013-11-25 09:28:13 UTC (rev 30858)
@@ -1,26 +0,0 @@
-#ifndef GNUNET_XSTRING_LIB_H
-#define GNUNET_XSTRING_LIB_H
-
-#include <stdlib.h>
-#include <stddef.h>
-
-#define GNUNET_XSTRING_NEW_DEFAULT_SIZE 64
-
-char *
-GNUNET_XSTRING_new();
-
-int
-GNUNET_XSTRING_append ( \
-    char **dest,
-    size_t *dest_size,
-    const char *arg);
-
-int
-GNUNET_XSTRING_appendf ( \
-    char **dest,
-    size_t *dest_size,
-    const char *fmt,
-    ...);
-
-#endif // GNUNET_XSTRING_LIB_H
-




reply via email to

[Prev in Thread] Current Thread [Next in Thread]