gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r31728 - in gnunet-dbus: . src src/dht src/gns src/lib


From: gnunet
Subject: [GNUnet-SVN] r31728 - in gnunet-dbus: . src src/dht src/gns src/lib
Date: Tue, 24 Dec 2013 04:07:28 +0100

Author: canndrew
Date: 2013-12-24 04:07:27 +0100 (Tue, 24 Dec 2013)
New Revision: 31728

Added:
   gnunet-dbus/src/dht/
   gnunet-dbus/src/dht/Makefile.am
   gnunet-dbus/src/dht/gnunet-service-dht-dbus.c
   gnunet-dbus/src/dht/gnunet-service-dht-dbus.h
   gnunet-dbus/src/dht/gnunet-service-dht-dbus_client.c
   gnunet-dbus/src/dht/gnunet-service-dht-dbus_client.h
   gnunet-dbus/src/dht/gnunet-service-dht-dbus_dht.c
   gnunet-dbus/src/dht/gnunet-service-dht-dbus_dht.h
   gnunet-dbus/src/dht/gnunet-service-dht-dbus_put.c
   gnunet-dbus/src/gns/
   gnunet-dbus/src/gns/Makefile.am
   gnunet-dbus/src/gns/gnunet-service-gns-dbus.c
   gnunet-dbus/src/gns/gnunet-service-gns-dbus_gns.c
   gnunet-dbus/src/gns/gnunet-service-gns-dbus_gns.h
   gnunet-dbus/src/gns/gnunet-service-gns-dbus_lookup.h
   gnunet-dbus/src/lib/
   gnunet-dbus/src/lib/Makefile.am
   gnunet-dbus/src/lib/dbus_type_to_string.c
   gnunet-dbus/src/lib/dbus_type_to_string.h
   gnunet-dbus/src/lib/gnunet_dbus_lib.c
   gnunet-dbus/src/lib/gnunet_dbus_lib.h
   gnunet-dbus/src/lib/gnunet_dbus_lib_block.c
   gnunet-dbus/src/lib/gnunet_dbus_lib_crypto.c
   gnunet-dbus/src/lib/gnunet_dbus_lib_crypto.h
   gnunet-dbus/src/lib/gnunet_dbus_lib_dht.c
   gnunet-dbus/src/lib/gnunet_dbus_lib_pop.c
   gnunet-dbus/src/lib/gnunet_xstring_lib.c
   gnunet-dbus/src/lib/gnunet_xstring_lib.h
Removed:
   gnunet-dbus/src/gnunet-service-dht-dbus.c
   gnunet-dbus/src/gnunet-service-dht-dbus.h
   gnunet-dbus/src/gnunet-service-dht-dbus_dht.c
   gnunet-dbus/src/gnunet-service-dht-dbus_dht.h
   gnunet-dbus/src/gnunet_dbus_lib.c
   gnunet-dbus/src/gnunet_dbus_lib.h
   gnunet-dbus/src/gnunet_dbus_lib_block.c
   gnunet-dbus/src/gnunet_dbus_lib_dht.c
   gnunet-dbus/src/gnunet_dbus_lib_pop.c
   gnunet-dbus/src/gnunet_xstring_lib.c
   gnunet-dbus/src/gnunet_xstring_lib.h
Modified:
   gnunet-dbus/configure.ac
   gnunet-dbus/src/Makefile.am
Log:
Started writing gns-dbus service.

Modified: gnunet-dbus/configure.ac
===================================================================
--- gnunet-dbus/configure.ac    2013-12-24 00:57:09 UTC (rev 31727)
+++ gnunet-dbus/configure.ac    2013-12-24 03:07:27 UTC (rev 31728)
@@ -5,10 +5,18 @@
 AM_PROG_AR
 LT_INIT([disable-static dlopen win32-dll])
 AC_CONFIG_HEADERS([config.h])
-AC_CONFIG_FILES([Makefile src/Makefile])
+AC_CONFIG_FILES([
+Makefile
+src/Makefile
+src/lib/Makefile
+src/gns/Makefile
+])
 
 PKG_CHECK_MODULES([DBUS], [dbus-1 >= 1.6.12])
 
+AC_CHECK_LIB([dbus-1], [dbus_type_to_string])
+AC_REPLACE_FUNCS([dbus_type_to_string])
+
 CFLAGS="$CFLAGS -Wall -Werror"
 CFLAGS="$CFLAGS $DBUS_CFLAGS"
 LDFLAGS="$LDFLAGS $DBUS_LDFLAGS"

Modified: gnunet-dbus/src/Makefile.am
===================================================================
--- gnunet-dbus/src/Makefile.am 2013-12-24 00:57:09 UTC (rev 31727)
+++ gnunet-dbus/src/Makefile.am 2013-12-24 03:07:27 UTC (rev 31728)
@@ -1,33 +1,2 @@
-lib_LTLIBRARIES = \
-       libgnunetdbus.la \
-       libgnunetdbus_dht.la \
-       libgnunetdbus_block.la \
-       libgnunetxstring.la
+SUBDIRS = lib gns
 
-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
-
-gnunet_service_dht_dbus_SOURCES = \
-  gnunet-service-dht-dbus.c
-
-gnunet_service_dht_dbus_LDADD = \
-  libgnunetdbus.la \
-       libgnunetdbus_dht.la \
-       libgnunetdbus_block.la \
-       libgnunetxstring.la \
-  -lgnunetutil
-

Added: gnunet-dbus/src/dht/Makefile.am
===================================================================
--- gnunet-dbus/src/dht/Makefile.am                             (rev 0)
+++ gnunet-dbus/src/dht/Makefile.am     2013-12-24 03:07:27 UTC (rev 31728)
@@ -0,0 +1,13 @@
+bin_PROGRAMS = \
+  gnunet-service-dht-dbus
+
+gnunet_service_dht_dbus_SOURCES = \
+       gnunet-service-dht-dbus.c
+
+gnunet_service_dht_dbus_LDADD = \
+  libgnunetdbus.la \
+       libgnunetdbus_dht.la \
+       libgnunetdbus_block.la \
+       libgnunetxstring.la \
+  -lgnunetutil
+

Added: gnunet-dbus/src/dht/gnunet-service-dht-dbus.c
===================================================================
--- gnunet-dbus/src/dht/gnunet-service-dht-dbus.c                               
(rev 0)
+++ gnunet-dbus/src/dht/gnunet-service-dht-dbus.c       2013-12-24 03:07:27 UTC 
(rev 31728)
@@ -0,0 +1,124 @@
+#include "config.h"
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+#include <dbus/dbus.h>
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_strings_lib.h>
+#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"
+
+static void
+shutdown_task (
+    void *cls,
+    const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct DHT *dht = (struct DHT *)cls;
+
+  DHT_destroy (dht);
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down.\n");
+};
+
+/*
+ * Main function run by the scheduler.
+ *
+ * @param cls our one and only DHT object
+ * @param args remaining program command line args
+ * @param configfile name of the config file
+ * @param cfg the program configuration
+ */
+static void
+run (
+    void *cls,
+    char *const *args,
+    const char *configfile,
+    const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Running.\n");
+
+  struct DHT *dht = DHT_create (cfg);
+  if (NULL == dht)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create DHT.\n");
+    return;
+  };
+  
+  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, shutdown_task, 
dht);
+  return;
+};
+
+int
+main (int argc, char *const *argv)
+{
+  int ret;
+
+  static const struct GNUNET_GETOPT_CommandLineOption options[] = {
+    GNUNET_GETOPT_OPTION_END
+  };
+  static const char bin_name[] = "gnunet-service-dht-dbus [OPTIONS]";
+  static const char bin_help[] = gettext_noop ("DBus proxy for 
gnunet-service-dht");
+
+  ret = GNUNET_log_setup ("gnunet-service-dht-dbus", "DEBUG", NULL);
+  if (GNUNET_OK != ret)
+  {
+    fprintf(stderr, "ERROR: Failed to setup logging. GNUNET_log_setup returned 
%d\n", ret);
+    return 1;
+  }
+
+  ret = GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv);
+  if (GNUNET_OK != ret) {
+    size_t size;
+    char *error;
+    int i;
+
+    size = GNUNET_XSTRING_NEW_DEFAULT_SIZE;
+    error = GNUNET_XSTRING_new();
+    GNUNET_XSTRING_appendf(&error, &size, "Failed to utf8 encode arguments. 
GNUNET_STRINGS_get_utf_args(%d, {", argc);
+    for(i = 0; i < argc; i++) {
+      GNUNET_XSTRING_appendf(&error, &size, "\"%s\"", argv[i]);
+      if(i != argc - 1)
+        GNUNET_XSTRING_appendf(&error, &size, ", ");
+    };
+    GNUNET_XSTRING_appendf(&error, &size, "}, %p, %p) returned %d\n", &argc, 
&argv, ret);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s", error);
+    GNUNET_free(error);
+    return 1;
+  };
+
+  ret = GNUNET_PROGRAM_run (argc, argv, bin_name, bin_help, options, run, 
NULL);
+  if (GNUNET_OK != ret)
+  {
+    size_t size;
+    char *error;
+    int i;
+
+    size = GNUNET_XSTRING_NEW_DEFAULT_SIZE;
+    error = GNUNET_XSTRING_new();
+    GNUNET_XSTRING_appendf(&error, &size, "Failed to run program. 
GUNNET_PROGRAM_run(%d, {", argc);
+    for(i = 0; i < argc; i++)
+      GNUNET_XSTRING_appendf(&error, &size, "%s\"%s\"", i ? ", " : "", 
argv[i]);
+    GNUNET_XSTRING_appendf(&error, &size, "}, \"%s\", \"%s\", %p, %p, NULL) 
returned %d\n", bin_name, bin_help, &options, run, ret);
+    GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "%s", error);
+    GNUNET_free(error);
+    GNUNET_free ((void *)argv);
+    return 1;
+  };
+
+  GNUNET_free ((void *)argv);
+  return 0;
+};
+

Added: gnunet-dbus/src/dht/gnunet-service-dht-dbus.h
===================================================================
--- gnunet-dbus/src/dht/gnunet-service-dht-dbus.h                               
(rev 0)
+++ gnunet-dbus/src/dht/gnunet-service-dht-dbus.h       2013-12-24 03:07:27 UTC 
(rev 31728)
@@ -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
+

Added: gnunet-dbus/src/dht/gnunet-service-dht-dbus_client.c
===================================================================
--- gnunet-dbus/src/dht/gnunet-service-dht-dbus_client.c                        
        (rev 0)
+++ gnunet-dbus/src/dht/gnunet-service-dht-dbus_client.c        2013-12-24 
03:07:27 UTC (rev 31728)
@@ -0,0 +1,70 @@
+#include "gnunet-service-dht-dbus_client.h"
+
+/*
+ * Internal representation of connected dbus clients.
+ */
+struct DHTClient
+{
+  struct DHTClient *next;
+  struct DHTClient *prev;
+
+  struct DHTPut *puts;
+
+  char *unique_name;
+
+  /*
+   * Our connection to the dht service.
+   * Each connected client uses it's own connection.
+   */
+  struct GNUNET_DHT_Handle *dht_handle;
+};
+
+struct DHTClient *
+DHTClient_create (
+    const struct GNUNET_CONFIGURATION_Handle *cfg,
+    const char *unique_name)
+{
+  struct DHTClient *client = GNUNET_new (struct DHTClient);
+  client->next = NULL;
+  client->prev = NULL;
+  client->puts = NULL;
+  client->unique_name = GNUNET_strdup (unique_name);
+  client->dht_handle = GNUNET_DHT_connect (cfg, 1);
+
+  return client;
+};
+
+void
+DHTClient_destroy (
+    struct DHTClient *client)
+{
+  if (client->dht_handle)
+    GNUNET_DHT_disconenct (client->dht_handle);
+
+  if (client->puts)
+    DHTPut_destroy_all (client->puts);
+
+  GNUNET_free (client);
+};
+
+void DHTClient_destroy_all (
+    struct DHTClient *client)
+{
+  if (client->next)
+    DHTClient_destroy_all (client->next);
+
+  GNUNET_free (client);
+};
+
+void
+DHTClient_add_put (
+    struct DHTClient *client,
+    struct DHTPut *put)
+{
+  put->next = client->puts;
+  put->prev = NULL;
+  client->puts = put;
+};
+  
+
+

Added: gnunet-dbus/src/dht/gnunet-service-dht-dbus_client.h
===================================================================
--- gnunet-dbus/src/dht/gnunet-service-dht-dbus_client.h                        
        (rev 0)
+++ gnunet-dbus/src/dht/gnunet-service-dht-dbus_client.h        2013-12-24 
03:07:27 UTC (rev 31728)
@@ -0,0 +1,20 @@
+#ifndef GNUNET_SERVICE_DHT_DBUS_CLIENT_H
+#define GNUNET_SERVICE_DHT_DBUS_CLIENT_H
+
+struct DHTClient;
+
+struct DHTClient *
+DHTClient_create (
+    const struct GNUNET_CONFIGURATION_Handle *cfg,
+    const char *unique_name);
+
+void
+DHTClient_destroy (
+    struct DHTClient *);
+
+void
+DHTClient_destroy_all (
+    struct DHTClient *);
+
+#endif
+

Added: gnunet-dbus/src/dht/gnunet-service-dht-dbus_dht.c
===================================================================
--- gnunet-dbus/src/dht/gnunet-service-dht-dbus_dht.c                           
(rev 0)
+++ gnunet-dbus/src/dht/gnunet-service-dht-dbus_dht.c   2013-12-24 03:07:27 UTC 
(rev 31728)
@@ -0,0 +1,223 @@
+#include "gnunet-service-dht-dbus_dht.h"
+
+/*
+ * Internal representation of the DHT service.
+ */
+struct DHT
+{
+  /*
+   * The program configuration
+   */
+  struct GNUNET_CONFIGURATION_Handle *cfg;
+
+  struct GNUNET_DBUS_Service *service;
+  struct GNUNET_DBUS_Object *dht;
+  struct DHTClient *clients;
+};
+
+static const char *introspection_data_dht = \
+    DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE                                  
     \
+    "<node>\n"                                                                 
     \
+    "  <interface name=\"org.gnunet.dht\">\n"                                  
     \
+    "    <method name=\"put\">\n"                                              
     \
+    "      <arg name=\"key\" type=\"s\" direction=\"in\"/>\n"                  
     \
+    "      <arg name=\"desired_replication_level\" type=\"u\" 
direction=\"in\"/>\n" \
+    "      <arg name=\"options\" type=\"u\" direction=\"in\"/>\n"              
     \
+    "      <arg name=\"block_type\" type=\"u\" direction=\"in\"/>\n"           
     \
+    "      <arg name=\"socket\" type=\"s\" direction=\"in\"/>\n"               
     \
+    "      <arg name=\"expiration_time\" type=\"s\" direction=\"in\"/>\n"      
     \
+    "      <arg name=\"request\" type=\"o\" direction=\"out\"/>\n"             
     \
+    "    </method>\n"                                                          
     \
+    "  </interface>\n"                                                         
     \
+    "  <interface name=\"org.freedesktop.DBus.Introspectable\">\n"             
     \
+    "    <method name=\"Introspect\">\n"                                       
     \
+    "      <arg name=\"data\" type=\"s\" direction=\"out\"/>\n"                
     \
+    "    </method>\n"                                                          
     \
+    "  </interface>\n"                                                         
     \
+    "</node>\n"                                                                
     \
+    ;
+struct DHT *
+DHT_create (
+    GNUNET_CONFIGURATION_Handle *cfg)
+{
+  int err;
+  struct DHT *dht = GNUNET_new (struct DHT);
+  dht->cfg = cfg;
+  dht->service = GNUNET_DBUS_service_create ("dht", cfg);
+  if (! dht->service)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DBUS_service_create failed to 
create dht service.\n");
+    DHT_destroy (dht);
+    return NULL;
+  }
+  dht->dht = GNUNET_DBUS_object_create (dht);
+  if (! dht->dht)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DBUS_object_create failed to 
create /dht object.\n");
+    DHT_destroy (dht);
+    return NULL;
+  }
+  err = GNUNET_DBUS_object_add_method (dht->dht, "org.gnunet.dht", "put", 
method_dht_put);
+  if (GNUNET_OK != err)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DBUS_object_add_method failed 
to add put method to dht.\n");
+    DHT_destroy (dht);
+    return NULL;
+  }
+  err = GNUNET_DBUS_service_register_object (dht->service, dht->dht, "/dht");
+  if (GNUNET_OK != err)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DBUS_service_register_object 
failed to register /dht object.\n");
+    DHT_destroy (dht);
+    return NULL;
+  }
+  dht->clients = NULL;
+  return dht;
+};
+
+void
+DHT_destroy (
+    struct DHT *dht)
+{
+  if (dht->service)
+    GNUNET_DBUS_service_destroy (dht->service);
+  if (dht->dht)
+    GNUNET_DBUS_object_destroy (dht->dht);
+  if (dht->clients)
+    DHTClient_destroy_all (dht->clients);
+};
+
+static DBusMessage *
+method_dht_introspect (
+    struct GNUNET_DBUS_Client *client,
+    struct GNUNET_DBUS_Object *object,
+    DBusMessage *message)
+{
+  (void)client;
+  (void)object;
+
+  DBusMessage *ret = dbus_message_new_method_return (message);
+  if (! ret)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "dbus_message_new_method_return 
returned NULL. Out of memory.\n");
+    return NULL;
+  }
+
+  DBusMessageIter args;
+  dbus_message_iter_init_append (ret, &args);
+  if (! dbus_message_iter_append_basic (
+      &args,
+      DBUS_TYPE_STRING,
+      &introspection_data_dht))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "dbus_message_iter_append_basic 
returned NULL. Out of memory.\n");
+    return NULL;
+  };
+
+  return ret;
+};
+
+static void
+put_continuation (
+    void *cls,
+    int success)
+{
+  
+};
+
+static DBusMessage *
+method_dht_put (
+    struct GNUNET_DBUS_Object *object,
+    DBusMessage *message)
+{
+  DBusMessage *ret = NULL;
+
+  struct GNUNET_HashCode key;
+  uint32_t desired_replication_level;
+  enum GNUNET_DHT_RouteOption options;
+  enum GNUNET_BLOCK_Type type;
+  uint32_t size;
+  char *data;
+  struct GNUNET_TIME_Absolute expiration;
+
+  dbus_message_iter_init (message, &iter);
+  ret = ret ? ret : GNUNET_DBUS_message_iter_pop_hashcode (message, &iter, 
"key", &key);
+  ret = ret ? ret : GNUNET_DBUS_message_iter_pop_uint32 (message, &iter, 
"desired_replication_level", &desired_replication_level);
+  ret = ret ? ret : GNUNET_DBUS_message_iter_pop_dht_routeoption (message, 
&iter, "options", &options);
+  ret = ret ? ret : GNUNET_DBUS_message_iter_pop_block_type (message, &iter, 
"type", &type);
+  ret = ret ? ret : GNUNET_DBUS_message_iter_pop_uint32 (message, &iter, 
"size", &size);
+  ret = ret ? ret : GNUNET_DBUS_message_iter_pop_array_byte (message, &iter, 
"data", &data);
+  ret = ret ? ret : GNUNET_DBUS_message_iter_pop_absolute_time (message, 
&iter, "expiration", &expiration);
+  if (ret)
+    return ret;
+
+#if 0
+  struct DHT *dht                 = (struct DHT *)GNUNET_DBUS_object_get_data 
(object);
+  if (! dht)
+  {
+    return dbus_message_new_error_printf (
+      message,
+      DBUS_ERROR_FAILED,
+      "GNUNET_DBUS_object_get_data returned NULL in method_dht_put. Check 
GNUNet logs for more info.");
+  };
+
+  struct DHTClient *dht_client    = DHT_get_client (dht, 
dbus_message_get_sender (message));
+  if (! dht_client)
+  {
+    return dbus_message_new_error_printf (
+      message,
+      DBUS_ERROR_FAILED,
+      "DHT_get_client returned NULL in method_dht_put. Check GNUNet logs for 
more info.");
+  };
+
+  struct DHTPut *dht_put = GNUNET_new (struct DHTPut);
+  dht_put->ph = GNUNET_DHT_put (
+      dht_client->dht_handle,
+      key,
+      desired_replication_level,
+      options,
+      type,
+      size,
+      data,
+      expiration,
+      timeout,
+      put_continuation,
+      dht_put);
+  if (! dht_put->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->obj = GNUNET_DBUS_object_create (dht_put);
+  // add methods
+#endif
+
+  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));
+
+#if 0
+  GNUNET_DBUS_service_register_object (service, dht_put->obj, path);
+  GNUNET_free (path);
+
+  DHTClient_add_put (dht_client, dht_put);
+
+#endif
+
+  ret = dbus_message_new_method_return (message);
+  dbus_bool_t succ = dbus_message_append_args (ret, DBUS_TYPE_OBJECT_PATH, 
put_path, DBUS_TYPE_INVALID);
+  if (! succ)
+  {
+    DHTClient_cancel_put (dht_put);
+    dbus_message_unref (ret);
+    return NULL; // out of memory
+  };
+
+
+  
+};
+

Added: gnunet-dbus/src/dht/gnunet-service-dht-dbus_dht.h
===================================================================
--- gnunet-dbus/src/dht/gnunet-service-dht-dbus_dht.h                           
(rev 0)
+++ gnunet-dbus/src/dht/gnunet-service-dht-dbus_dht.h   2013-12-24 03:07:27 UTC 
(rev 31728)
@@ -0,0 +1,27 @@
+#ifndef GNUNET_SERVICE_DHT_DBUS_DHT_H
+#define GNUNET_SERVICE_DHT_DBUS_DHT_H
+
+struct DHT;
+
+struct DHT *
+DHT_create (
+    GNUNET_CONFIGURATION_Handle *cfg);
+
+void
+DHT_destroy (
+    struct DHT *dht);
+
+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
+

Added: gnunet-dbus/src/dht/gnunet-service-dht-dbus_put.c
===================================================================
--- gnunet-dbus/src/dht/gnunet-service-dht-dbus_put.c                           
(rev 0)
+++ gnunet-dbus/src/dht/gnunet-service-dht-dbus_put.c   2013-12-24 03:07:27 UTC 
(rev 31728)
@@ -0,0 +1,17 @@
+struct DHTPut
+{
+  struct GNUNET_DHT_PutHandle *ph;
+  GNUNET_DBUS_Object *obj;
+};
+
+
+struct DHTPut *
+DHTPut_create (
+    GNUNET_DBUS_Service *service,
+    GNUNET_DHT_Handle *dht_handle;
+{
+  struct DHTPut *ret = GNUNET_new (struct DHTPut);
+  dht->ph = GNUNET_DHT_put (
+      dht_handle,
+
+  

Added: gnunet-dbus/src/gns/Makefile.am
===================================================================
--- gnunet-dbus/src/gns/Makefile.am                             (rev 0)
+++ gnunet-dbus/src/gns/Makefile.am     2013-12-24 03:07:27 UTC (rev 31728)
@@ -0,0 +1,17 @@
+AM_CFLAGS = \
+       -I$(top_builddir)/src/lib
+
+bin_PROGRAMS = \
+       gnunet-service-gns-dbus
+
+gnunet_service_gns_dbus_SOURCES = \
+       gnunet-service-gns-dbus.c \
+       gnunet-service-gns-dbus_gns.c
+
+gnunet_service_gns_dbus_LDADD = \
+       $(top_builddir)/src/lib/libgnunetdbus.la \
+       $(top_builddir)/src/lib/libgnunetdbus_crypto.la \
+       $(top_builddir)/src/lib/libgnunetxstring.la \
+       -lgnunetgns \
+       -lgnunetutil
+

Added: gnunet-dbus/src/gns/gnunet-service-gns-dbus.c
===================================================================
--- gnunet-dbus/src/gns/gnunet-service-gns-dbus.c                               
(rev 0)
+++ gnunet-dbus/src/gns/gnunet-service-gns-dbus.c       2013-12-24 03:07:27 UTC 
(rev 31728)
@@ -0,0 +1,79 @@
+#include "config.h"
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_configuration_lib.h>
+#include <gnunet/gnunet_getopt_lib.h>
+#include <gnunet/gnunet_strings_lib.h>
+#include <gnunet/gnunet_program_lib.h>
+
+#include "gnunet-service-gns-dbus_gns.h"
+
+static void
+shutdown_task (
+    void *cls,
+    const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct GNSService *gns_service = (struct GNSService *)cls;
+
+  GNSService_destroy (gns_service);
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down.\n");
+};
+
+static void
+run (
+    void *cls,
+    char *const *args,
+    const char *configfile,
+    const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  struct GNSService *gns_service = GNSService_create (cfg);
+  if (! gns_service)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GNSService_create failed.\n");
+    return;
+  };
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Running.\n");
+
+  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, shutdown_task, 
gns_service);
+};
+
+int
+main (
+    int argc,
+    char *const *argv)
+{
+  int ret;
+
+  static const struct GNUNET_GETOPT_CommandLineOption options[] = {
+    GNUNET_GETOPT_OPTION_END
+  };
+  static const char bin_name[] = "gnunet-service-gns-dbus [OPTIONS]";
+  static const char bin_help[] = gettext_noop ("DBus proxyfor 
gnunet-service-gns");
+
+  ret = GNUNET_log_setup ("gnunet-service-gns-dbus", "DEBUG", NULL);
+  if (GNUNET_OK != ret)
+  {
+    fprintf (stderr, "ERROR: Failed to setup logging. GNUNET_log_setup 
returned %d\n", ret);
+    return 1;
+  }
+
+  ret = GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv);
+  if (GNUNET_OK != ret)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to parse command line 
options. GNUNET_STRINGS_get_utf8_args returned %d\n", ret);
+    return 1;
+  };
+
+  ret = GNUNET_PROGRAM_run (argc, argv, bin_name, bin_help, options, run, 
NULL);
+  if (GNUNET_OK != ret)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to run program. 
GNUNET_PROGRAM_run returned %d\n", ret);
+    return 1;
+  };
+
+  GNUNET_free ((void *)argv);
+  return 0;
+};
+

Added: gnunet-dbus/src/gns/gnunet-service-gns-dbus_gns.c
===================================================================
--- gnunet-dbus/src/gns/gnunet-service-gns-dbus_gns.c                           
(rev 0)
+++ gnunet-dbus/src/gns/gnunet-service-gns-dbus_gns.c   2013-12-24 03:07:27 UTC 
(rev 31728)
@@ -0,0 +1,301 @@
+#include "config.h"
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_gns_service.h>
+
+#include "gnunet_dbus_lib.h"
+#include "gnunet_dbus_lib_crypto.h"
+#include "gnunet_xstring_lib.h"
+#include "gnunet-service-gns-dbus_gns.h"
+#include "gnunet-service-gns-dbus_lookup.h"
+
+struct GNSService
+{
+  struct GNUNET_DBUS_Service *service;
+  struct GNUNET_DBUS_Object *object;
+  struct GNUNET_GNS_Handle *handle;
+  struct GNSLookup *lookups;
+  uint32_t lookup_id_gen;
+};
+
+static const char *gns_introspection_data = \
+    DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
+    "<node>\n"
+    "  <interface name='org.freedesktop.DBus.Introspectable'>\n"
+    "    <method name='Introspect'>\n"
+    "      <arg name='data' type='s' direction='out'/>\n"
+    "    </method>\n"
+    "  </interface>\n"
+    "  <interface name='org.gnunet.gns'>\n"
+    "    <method name='lookup'>\n"
+    "      <arg name='name' type='s' direction='in'/>\n"
+    "      <arg name='zone' type='s' direction='in'/>\n"
+    "      <arg name='type' type='u' direction='in'/>\n"
+    "      <arg name='only_cached' type='b' direction='in'/>\n"
+    "      <arg name='path' type='o' direction='out'/>\n"
+    "    </method>\n"
+    "  </interface>\n"
+    "</node>\n"
+    ;
+
+static const char *lookup_introspection_data = \
+    DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
+    "<node>\n"
+    "  <interface name='org.freedesktop.DBus.Introspectable'>\n"
+    "    <method name='Introspect'>\n"
+    "      <arg name='data' type='s' direction='out'/>\n"
+    "    </method>\n"
+    "  </interface>\n"
+    "</node>\n"
+    ;
+
+static DBusMessage *
+lookup_introspect (
+    struct GNUNET_DBUS_Object *object,
+    DBusMessage *message)
+{
+  DBusMessage *ret;
+
+  ret = dbus_message_new_method_return (message);
+  if (! ret)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "dbus_message_new_method_return 
returned NULL.\n");
+    return NULL;
+  };
+
+  DBusMessageIter args;
+  dbus_bool_t succ;
+
+  dbus_message_iter_init_append (ret, &args);
+  succ = dbus_message_iter_append_basic (
+      &args,
+      DBUS_TYPE_STRING,
+      &lookup_introspection_data);
+  if (! succ) {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "dbus_message_iter_append_basic 
failed.\n");
+    return NULL;
+  };
+
+  return ret;
+};
+
+static void
+gns_lookup_result (
+    void *cls,
+    uint32_t rd_count,
+    const struct GNUNET_GNSRECORD_Data *rd)
+{
+  
+};
+
+static DBusMessage *
+gns_introspect (
+    struct GNUNET_DBUS_Object *object,
+    DBusMessage *message)
+{
+  DBusMessage *ret;
+
+  ret = dbus_message_new_method_return (message);
+  if (! ret)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "dbus_message_new_method_return 
returned NULL. Out of memory.\n");
+    return NULL;
+  };
+
+  DBusMessageIter args;
+  dbus_bool_t succ;
+
+  dbus_message_iter_init_append (ret, &args);
+  succ = dbus_message_iter_append_basic (
+      &args,
+      DBUS_TYPE_STRING,
+      &gns_introspection_data);
+  if (! succ) {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "dbus_message_iter_append_basic 
failed. Out of memory.\n");
+    return NULL;
+  };
+
+  return ret;
+};
+
+static DBusMessage *
+gns_lookup (
+    struct GNUNET_DBUS_Object *object,
+    DBusMessage *message)
+{
+  DBusMessage *ret = NULL;
+
+  const char *name;
+  struct GNUNET_CRYPTO_EcdsaPublicKey zone;
+  dbus_uint32_t type;
+  dbus_bool_t only_cached;
+
+  DBusMessageIter iter;
+  dbus_message_iter_init (message, &iter);
+  ret = ret ? ret : GNUNET_DBUS_message_iter_pop_string (message, &iter, 
"name", &name);
+  ret = ret ? ret : GNUNET_DBUS_message_iter_pop_ecdsa_public_key (message, 
&iter, "zone", &zone);
+  ret = ret ? ret : GNUNET_DBUS_message_iter_pop_uint32 (message, &iter, 
"type", &type);
+  ret = ret ? ret : GNUNET_DBUS_message_iter_pop_bool (message, &iter, 
"only_cached", &only_cached);
+  //ret = ret ? ret : GNUNET_DBUS_message_iter_pop_string (message, &iter, 
"ego", &ego);
+  if (ret)
+    return ret;
+
+  struct GNSService *gns_service = (struct GNSService 
*)GNUNET_DBUS_object_get_data (object);
+
+  char *lpath = GNUNET_XSTRING_new ();
+  size_t lpath_size = GNUNET_XSTRING_NEW_DEFAULT_SIZE;
+  GNUNET_XSTRING_appendf(&lpath, &lpath_size, "/lookup/%08x", 
gns_service->lookup_id_gen++);
+
+  struct GNSLookup *lookup = GNUNET_new (struct GNSLookup);
+  lookup->path = lpath;
+  lookup->object = GNUNET_DBUS_object_create (lookup);
+  lookup->req = GNUNET_GNS_lookup (
+      gns_service->handle,
+      name,
+      &zone,
+      (int)type,
+      (int)only_cached,
+      NULL,
+      gns_lookup_result,
+      lookup);
+  lookup->next = gns_service->lookups;
+  lookup->prev = NULL;
+  if (gns_service->lookups)
+    gns_service->lookups->prev = lookup;
+  gns_service->lookups = lookup;
+
+  int err;
+  err = GNUNET_DBUS_object_add_method (lookup->object, 
"org.freedesktop.DBus.Introspectable", "Introspect", lookup_introspect);
+  if (GNUNET_OK != err)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create Introspect 
method.\n");
+    return NULL;
+  };
+
+  err = GNUNET_DBUS_service_register_object (gns_service->service, 
lookup->object, lookup->path);
+  if (GNUNET_OK != err)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "failed to register object path 
\"%s\"\n", lookup->path);
+    return NULL;
+  };
+
+  printf ("path is '%s'\n", lookup->path);
+
+  ret = dbus_message_new_method_return (message);
+  if (! ret)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "dbus_message_new_method_return 
failed.\n");
+    return NULL;
+  };
+
+  DBusMessageIter retiter;
+  dbus_message_iter_init_append (ret, &retiter);
+
+  dbus_bool_t succ = dbus_message_iter_append_basic (
+      &retiter,
+      DBUS_TYPE_OBJECT_PATH,
+      &lookup->path);
+  if (! succ)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "dbus_message_iter_append_basic 
failed. Out of memory.\n");
+    return NULL;
+  };
+
+  return ret;
+};
+
+struct GNSService *
+GNSService_create (
+    const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  struct GNSService *ret;
+  int err;
+
+  ret = GNUNET_new (struct GNSService);
+  if (! ret)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Out of memory!\n");
+    return NULL;
+  };
+
+  ret->handle = GNUNET_GNS_connect (cfg);
+  if (! ret->handle)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GNUNET_GNS_connect failed.\n");
+    GNSService_destroy (ret);
+    return NULL;
+  };
+
+  ret->service = GNUNET_DBUS_service_create ("gns", cfg);
+  if (! ret->service)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DBUS_service_create 
failed.\n");
+    GNSService_destroy (ret);
+    return NULL;
+  };
+
+  ret->object = GNUNET_DBUS_object_create (ret);
+  if (! ret->object)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DBUS_object_create 
failed.\n");
+    GNSService_destroy (ret);
+    return NULL;
+  };
+
+  err = GNUNET_DBUS_object_add_method (ret->object, 
"org.freedesktop.DBus.Introspectable", "Introspect", gns_introspect);
+  if (GNUNET_OK != err)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DBUS_object_add_method 
\"Introspect\" failed.\n");
+    GNSService_destroy (ret);
+    return NULL;
+  };
+
+  err = GNUNET_DBUS_object_add_method (ret->object, "org.gnunet.gns", 
"lookup", gns_lookup);
+  if (GNUNET_OK != err)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DBUS_object_add_method 
\"lookup\" failed.\n");
+    GNSService_destroy (ret);
+    return NULL;
+  };
+
+  err = GNUNET_DBUS_service_register_object (ret->service, ret->object, 
"/gns");
+  if (GNUNET_OK != err)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DBUS_service_register_object 
\"/gns\" failed.\n");
+    GNSService_destroy (ret);
+    return NULL;
+  };
+
+  ret->lookup_id_gen = 0;
+
+  return ret;
+};
+
+void
+GNSService_destroy (
+    struct GNSService *gns_service)
+{
+  if (gns_service->handle)
+    GNUNET_GNS_disconnect (gns_service->handle);
+
+  if (gns_service->service)
+    GNUNET_DBUS_service_destroy (gns_service->service);
+
+  if (gns_service->object)
+    GNUNET_DBUS_object_destroy (gns_service->object);
+
+  struct GNSLookup *lookup = gns_service->lookups;
+  while (lookup)
+  {
+    struct GNSLookup *next = lookup->next;
+    GNUNET_free (lookup->path);
+    GNUNET_DBUS_object_destroy (lookup->object);
+    GNUNET_free (lookup);
+
+    lookup = next;
+  };
+
+  GNUNET_free (gns_service);
+};
+

Added: gnunet-dbus/src/gns/gnunet-service-gns-dbus_gns.h
===================================================================
--- gnunet-dbus/src/gns/gnunet-service-gns-dbus_gns.h                           
(rev 0)
+++ gnunet-dbus/src/gns/gnunet-service-gns-dbus_gns.h   2013-12-24 03:07:27 UTC 
(rev 31728)
@@ -0,0 +1,19 @@
+#ifndef GNUNET_SERVICE_GNS_DBUS_GNS_H
+#define GNUNET_SERVICE_GNS_DBUS_GNS_H
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_configuration_lib.h>
+
+struct GNSService;
+
+struct GNSService *
+GNSService_create (
+    const struct GNUNET_CONFIGURATION_Handle *cfg);
+
+void
+GNSService_destroy (
+    struct GNSService *gns_service);
+
+#endif
+

Added: gnunet-dbus/src/gns/gnunet-service-gns-dbus_lookup.h
===================================================================
--- gnunet-dbus/src/gns/gnunet-service-gns-dbus_lookup.h                        
        (rev 0)
+++ gnunet-dbus/src/gns/gnunet-service-gns-dbus_lookup.h        2013-12-24 
03:07:27 UTC (rev 31728)
@@ -0,0 +1,21 @@
+#ifndef GNUNET_SERVICE_GNS_DBUS_LOOKUP_H
+#define GNUNET_SERVICE_GNS_DBUS_LOOKUP_H
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_gns_service.h>
+
+#include "gnunet_dbus_lib.h"
+
+struct GNSLookup
+{
+  struct GNSLookup *next;
+  struct GNSLookup *prev;
+
+  char *path;
+  struct GNUNET_GNS_LookupRequest *req;
+  struct GNUNET_DBUS_Object *object;
+};
+
+#endif
+

Deleted: gnunet-dbus/src/gnunet-service-dht-dbus.c
===================================================================
--- gnunet-dbus/src/gnunet-service-dht-dbus.c   2013-12-24 00:57:09 UTC (rev 
31727)
+++ gnunet-dbus/src/gnunet-service-dht-dbus.c   2013-12-24 03:07:27 UTC (rev 
31728)
@@ -1,215 +0,0 @@
-#include "config.h"
-
-#include <stdint.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-#include <dbus/dbus.h>
-
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_common.h>
-#include <gnunet/gnunet_strings_lib.h>
-#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"
-
-/*
- * Internal representation of the DHT service.
- */
-struct DHT
-{
-  /*
-   * The program configuration
-   */
-  struct GNUNET_CONFIGURATION_Handle *cfg;
-
-  /*
-   * GNUNET_OK or GNUNET_SYSERR. Checked during exit to see if there was an 
error.
-   */
-  int run_error;
-};
-
-/*
- * Internal representation of connected dbus clients.
- */
-struct DHTClient
-{
-  /*
-   * Our connection to the dht service.
-   * Each connected client uses it's own connection.
-   */
-  struct GNUNET_DHT_Handle *dht_handle;
-};
-
-static void
-shutdown_task (
-    void *cls,
-    const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Exiting.\n");
-};
-
-/*
- * 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
- */
-static int
-client_connects (
-    struct GNUNET_DBUS_Service *service,
-    struct GNUNET_DBUS_Client *client)
-{
-  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,
-      1);
-  if (! dht_handle)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DHT_connect returned NULL\n");
-    GNUNET_free (dht_client);
-    return GNUNET_SYSERR;
-  };
-  dht_client->dht_handle = dht_handle;
-
-  return GNUNET_OK;
-};
-
-/*
- * Main function run by the scheduler.
- *
- * @param cls our one and only DHT object
- * @param args remaining program command line args
- * @param configfile name of the config file
- * @param cfg the program configuration
- */
-static void
-run (
-    void *cls,
-    char *const *args,
-    const char *configfile,
-    const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Running.\n");
-
-  struct DHT *dht = (struct DHT *)cls;
-  dht->run_error = GNUNET_SYSERR;
-
-  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_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_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");
-    return;
-  };
-  
-  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, shutdown_task, 
service);
-  dht->run_error = GNUNET_OK;
-  return;
-};
-
-int
-main (int argc, char *const *argv)
-{
-  int ret;
-
-  static const struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_OPTION_END
-  };
-  static const char bin_name[] = "gnunet-service-dht-dbus [OPTIONS]";
-  static const char bin_help[] = gettext_noop ("DBus proxy for 
gnunet-service-dht");
-
-  ret = GNUNET_log_setup ("gnunet-service-dht-dbus", "DEBUG", NULL);
-  if (GNUNET_OK != ret)
-  {
-    fprintf(stderr, "ERROR: Failed to setup logging. GNUNET_log_setup returned 
%d\n", ret);
-    return 1;
-  }
-
-  struct DHT *dht = GNUNET_new (struct DHT);
-  if (! dht)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to allocate memory for 
DHT\n");
-    return 1;
-  };
-  dht->run_error = GNUNET_OK;
-
-  ret = GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv);
-  if (GNUNET_OK != ret) {
-    size_t size;
-    char *error;
-    int i;
-
-    size = GNUNET_XSTRING_NEW_DEFAULT_SIZE;
-    error = GNUNET_XSTRING_new();
-    GNUNET_XSTRING_appendf(&error, &size, "Failed to utf8 encode arguments. 
GNUNET_STRINGS_get_utf_args(%d, {", argc);
-    for(i = 0; i < argc; i++) {
-      GNUNET_XSTRING_appendf(&error, &size, "\"%s\"", argv[i]);
-      if(i != argc - 1)
-        GNUNET_XSTRING_appendf(&error, &size, ", ");
-    };
-    GNUNET_XSTRING_appendf(&error, &size, "}, %p, %p) returned %d\n", &argc, 
&argv, ret);
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s", error);
-    GNUNET_free(error);
-    return 1;
-  };
-
-  ret = GNUNET_PROGRAM_run (argc, argv, bin_name, bin_help, options, run, dht);
-  if (ret != GNUNET_OK)
-  {
-    size_t size;
-    char *error;
-    int i;
-
-    size = GNUNET_XSTRING_NEW_DEFAULT_SIZE;
-    error = GNUNET_XSTRING_new();
-    GNUNET_XSTRING_appendf(&error, &size, "Failed to run program. 
GUNNET_PROGRAM_run(%d, {", argc);
-    for(i = 0; i < argc; i++)
-      GNUNET_XSTRING_appendf(&error, &size, "%s\"%s\"", i ? ", " : "", 
argv[i]);
-    GNUNET_XSTRING_appendf(&error, &size, "}, \"%s\", \"%s\", %p, %p, NULL) 
returned %d\n", bin_name, bin_help, &options, run, ret);
-    GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "%s", error);
-    GNUNET_free(error);
-    GNUNET_free ((void *)argv);
-    return 1;
-  };
-  if (GNUNET_OK != dht->run_error)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "run failed.\n");
-    GNUNET_free ((void *)argv);
-    return 1;
-  };
-
-  GNUNET_free ((void *)argv);
-  return ret != GNUNET_OK;
-};
-

Deleted: gnunet-dbus/src/gnunet-service-dht-dbus.h
===================================================================
--- gnunet-dbus/src/gnunet-service-dht-dbus.h   2013-12-24 00:57:09 UTC (rev 
31727)
+++ gnunet-dbus/src/gnunet-service-dht-dbus.h   2013-12-24 03:07:27 UTC (rev 
31728)
@@ -1,14 +0,0 @@
-#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
-

Deleted: gnunet-dbus/src/gnunet-service-dht-dbus_dht.c
===================================================================
--- gnunet-dbus/src/gnunet-service-dht-dbus_dht.c       2013-12-24 00:57:09 UTC 
(rev 31727)
+++ gnunet-dbus/src/gnunet-service-dht-dbus_dht.c       2013-12-24 03:07:27 UTC 
(rev 31728)
@@ -1,126 +0,0 @@
-static const char *introspection_data_dht = \
-    DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE                                  
     \
-    "<node>\n"                                                                 
     \
-    "  <interface name=\"org.gnunet.dht\">\n"                                  
     \
-    "    <method name=\"put\">\n"                                              
     \
-    "      <arg name=\"key\" type=\"s\" direction=\"in\"/>\n"                  
     \
-    "      <arg name=\"desired_replication_level\" type=\"u\" 
direction=\"in\"/>\n" \
-    "      <arg name=\"options\" type=\"u\" direction=\"in\"/>\n"              
     \
-    "      <arg name=\"block_type\" type=\"u\" direction=\"in\"/>\n"           
     \
-    "      <arg name=\"socket\" type=\"s\" direction=\"in\"/>\n"               
     \
-    "      <arg name=\"expiration_time\" type=\"s\" direction=\"in\"/>\n"      
     \
-    "      <arg name=\"request\" type=\"o\" direction=\"out\"/>\n"             
     \
-    "    </method>\n"                                                          
     \
-    "  </interface>\n"                                                         
     \
-    "  <interface name=\"org.freedesktop.DBus.Introspectable\">\n"             
     \
-    "    <method name=\"Introspect\">\n"                                       
     \
-    "      <arg name=\"data\" type=\"s\" direction=\"out\"/>\n"                
     \
-    "    </method>\n"                                                          
     \
-    "  </interface>\n"                                                         
     \
-    "</node>\n"                                                                
     \
-    ;
-
-DBusMessage *
-method_dht_introspect (
-    struct GNUNET_DBUS_Client *client,
-    struct GNUNET_DBUS_Object *object,
-    DBusMessage *message)
-{
-  (void)client;
-  (void)object;
-
-  DBusMessage *ret = dbus_message_new_method_return (message);
-  if (! ret)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "dbus_message_new_method_return 
returned NULL. Out of memory.\n");
-    return NULL;
-  }
-
-  DBusMessageIter args;
-  dbus_message_iter_init_append (ret, &args);
-  if (! dbus_message_iter_append_basic (
-      &args,
-      DBUS_TYPE_STRING,
-      &introspection_data_dht))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "dbus_message_iter_append_basic 
returned NULL. Out of memory.\n");
-    return NULL;
-  };
-
-  return ret;
-};
-
-void
-put_continuation (
-    void *cls,
-    int success)
-{
-  
-};
-
-DBusMessage *
-method_dht_put (
-    struct GNUNET_DBUS_Client *client,
-    struct GNUNET_DBUS_Object *object,
-    DBusMessage *message)
-{
-  DBusMessage *ret = NULL;
-
-  struct GNUNET_HashCode key;
-  uint32_t desired_replication_level;
-  enum GNUNET_DHT_RouteOption options;
-  enum GNUNET_BLOCK_Type type;
-  uint32_t size;
-  char *data;
-  struct GNUNET_TIME_Absolute expiration;
-
-  dbus_message_iter_init (message, &iter);
-  ret = ret ? ret : GNUNET_DBUS_message_iter_pop_hashcode (message, &iter, 
"key", &key);
-  ret = ret ? ret : GNUNET_DBUS_message_iter_pop_uint32 (message, &iter, 
"desired_replication_level", &desired_replication_level);
-  ret = ret ? ret : GNUNET_DBUS_message_iter_pop_dht_routeoption (message, 
&iter, "options", &options);
-  ret = ret ? ret : GNUNET_DBUS_message_iter_pop_block_type (message, &iter, 
"type", &type);
-  ret = ret ? ret : GNUNET_DBUS_message_iter_pop_uint32 (message, &iter, 
"size", &size);
-  ret = ret ? ret : GNUNET_DBUS_message_iter_pop_array_byte (message, &iter, 
"data", &data);
-  ret = ret ? ret : GNUNET_DBUS_message_iter_pop_absolute_time (message, 
&iter, "expiration", &expiration);
-  if (ret)
-    return ret;
-
-  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;
-};
-

Deleted: gnunet-dbus/src/gnunet-service-dht-dbus_dht.h
===================================================================
--- gnunet-dbus/src/gnunet-service-dht-dbus_dht.h       2013-12-24 00:57:09 UTC 
(rev 31727)
+++ gnunet-dbus/src/gnunet-service-dht-dbus_dht.h       2013-12-24 03:07:27 UTC 
(rev 31728)
@@ -1,17 +0,0 @@
-#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
-

Deleted: gnunet-dbus/src/gnunet_dbus_lib.c
===================================================================
--- gnunet-dbus/src/gnunet_dbus_lib.c   2013-12-24 00:57:09 UTC (rev 31727)
+++ gnunet-dbus/src/gnunet_dbus_lib.c   2013-12-24 03:07:27 UTC (rev 31728)
@@ -1,765 +0,0 @@
-#include <stdint.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <sys/socket.h>
-
-#include <dbus/dbus.h>
-
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_common.h>
-#include <gnunet/gnunet_scheduler_lib.h>
-
-#include "gnunet_dbus_lib.h"
-
-/*
- * Wraps a file descriptor that needs to be watched 
- * for activity with select()
- */
-struct Watch
-{
-  /* doubly-linked list */
-  struct Watch *next;
-  struct Watch *prev;
-
-  /*
-   * DBus watch data. Contains the actual file descritor
-   */
-  DBusWatch *watch;
-
-  /*
-   * Have we asked the scheduler to watch this?
-   * May be false because the associated task may not have been
-   * re-scheduled yet after execution or because dbus has asked
-   * us to disable this watch.
-   */
-  bool scheduled;
-
-  /*
-   * The task that is watching our file descriptor.
-   * Only valid if scheduled is true.
-   */
-  GNUNET_SCHEDULER_TaskIdentifier task;
-};
-
-/*
- * Represents a DBus service such as "org.gnunet.dht"
- */
-struct GNUNET_DBUS_Service
-{
-  /*
-   * Our connection to the DBus message bus.
-   */
-  DBusConnection *conn;
-
-  /*
-   * Linked list of watches
-   */
-  struct Watch *watches;
-
-  /*
-   * 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.
- */
-struct Method
-{
-  /* doubly-linked list */
-  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;
-};
-
-/*
- * A DBus object exposed through a service.
- * In DBus, each service presents a set of objects and each object presents a
- * set of methods that can be called on it.
- */
-struct GNUNET_DBUS_Object
-{
-  /*
-   * Closure passed in to GNUNET_DBUS_object_create.
-   * Points to the actual data structure wrapped by this DBus object.
-   */
-  void *data;
-
-  /*
-   * The service we are an object of
-   */
-  struct GNUNET_DBUS_Service *service;
-
-  /*
-   * The object path
-   */
-  const char *path;
-
-  /*
-   * Linked list of methods this object exposes
-   */
-  struct Method *methods;
-};
-
-static void
-handle_watch (
-    void *cls,
-    const struct GNUNET_SCHEDULER_TaskContext *tc);
-
-static int
-watch_schedule (
-  struct Watch *w);
-
-static int
-watch_unschedule (
-    struct Watch *w);
-
-static dbus_bool_t
-watch_add (
-    DBusWatch *watch,
-    void *data);
-
-static void
-watch_remove (
-    DBusWatch *watch,
-    void *data);
-
-static void
-watch_toggle (
-    DBusWatch *watch,
-    void *data);
-
-/*
- * Called by the scheduler when a watch has activity on it
- *
- * @param cls The watch
- * @param tc the context given to us by the scheduler for this execution
- */
-static void
-handle_watch (
-    void *cls,
-    const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  struct Watch *w = (struct Watch *)cls;
-
-  unsigned flags = 0;
-  if (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)
-    flags |= DBUS_WATCH_READABLE;
-  if (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)
-    flags |= DBUS_WATCH_WRITABLE;
-  if (tc->reason & GNUNET_SCHEDULER_REASON_EXCEPTION)
-    flags |= DBUS_WATCH_ERROR;
-  if (flags)
-    dbus_watch_handle(w->watch, flags);
-
-  w->scheduled = false;
-
-  if(! (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
-  {
-    int err;
-    err = watch_schedule (w);
-    if (GNUNET_OK != err)
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "watch_schedule failed\n");
-  };
-};
-
-/*
- * Ask the scheduler to watch this watch for activity.
- *
- * @param w The watch
- * @return GNUNET_OK or GNUNET_SYSERR
- */
-static int
-watch_schedule (
-  struct Watch *w)
-{
-  DBusWatch *watch = w->watch;
-  unsigned flags = dbus_watch_get_flags (w->watch);
-
-  // sanity check
-  if (! dbus_watch_get_enabled (w->watch))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Tried the schedule watch that is 
disabled!\n");
-    return GNUNET_SYSERR;
-  };
-
-  if (w->scheduled)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Scheduling watch that is already 
scheduled!\n");
-    return GNUNET_SYSERR;
-  };
-
-  SOCKTYPE sock = dbus_watch_get_socket (watch);
-  if (-1 != sock)
-  {
-    struct GNUNET_NETWORK_Handle *h = GNUNET_NETWORK_socket_box_native(sock);
-    if (NULL == h)
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to box network socket 
passed in from dbus.\n");
-      return GNUNET_SYSERR;
-    };
-    w->task = GNUNET_SCHEDULER_add_net_with_priority(
-        GNUNET_TIME_UNIT_FOREVER_REL,
-        GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-        (flags & DBUS_WATCH_READABLE) ? h : NULL,
-        (flags & DBUS_WATCH_WRITABLE) ? h : NULL,
-        h,
-        handle_watch,
-        w);
-    w->scheduled = true;
-    return GNUNET_OK;
-  };
-
-  int fd = dbus_watch_get_unix_fd (watch);
-  if (-1 != fd)
-  {
-    struct GNUNET_DISK_FileHandle *h = GNUNET_DISK_get_handle_from_int_fd (fd);
-    if (NULL == h)
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to get handle for file 
descriptor passed in from dbus.\n");
-      return GNUNET_SYSERR;
-    };
-    w->task = GNUNET_SCHEDULER_add_file_with_priority(
-        GNUNET_TIME_UNIT_FOREVER_REL,
-        GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-        (flags & DBUS_WATCH_READABLE) ? h : NULL,
-        (flags & DBUS_WATCH_WRITABLE) ? h : NULL,
-        h,
-        handle_watch,
-        w);
-    w->scheduled = true;
-    return GNUNET_OK;
-  };
-
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to add watch.\n");
-  return GNUNET_SYSERR;
-};
-
-/*
- * Ask the scheduler to stop monitoring a watch either because we are shutting
- * down or dbus has asked us to disable this watch.
- *
- * @param w The watch
- * @return GNUNET_OK or GNUNET_SYSERR
- */
-static int
-watch_unschedule (
-    struct Watch *w)
-{
-  if(w->scheduled)
-  {
-    void *cls = GNUNET_SCHEDULER_cancel (w->task);
-    if ((struct Watch *)cls != w)
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to unschedule task. w == 
%p, GNUNET_SCHEDULER_cancel returned %p\n", w, cls);
-      return GNUNET_SYSERR;
-    }
-  }
-  else
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Attempting to unschedule task that 
is not scheduled!\n");
-    return GNUNET_SYSERR;
-  };
-
-  return GNUNET_OK;
-};
-
-/*
- * Called by DBus when it has a new watch that it wants us to watch.
- *
- * @param watch The DBus watch, created and passed to us by DBus.
- * @param data the GNUNET_DBUS_Service we passed to 
dbus_connection_set_watch_functions
- * @return true on success, false on an unrecoverable error such as running 
out of memory.
- */
-static dbus_bool_t
-watch_add (
-    DBusWatch *watch,
-    void *data)
-{
-  struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
-  struct Watch *w = GNUNET_new(struct Watch);
-
-  if(w == NULL)
-    return false;
-
-  w->watch = watch;
-  w->scheduled= false;
-
-  w->next = service->watches;
-  w->prev = NULL;
-  service->watches = w;
-
-  if(dbus_watch_get_enabled (watch))
-  {
-    int err = watch_schedule (w);
-    if (GNUNET_OK != err)
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to schedule watch.\n");
-      return false;
-    };
-  };
-
-  return true;
-};
-
-/*
- * Called by DBus when it want to permanently disable and remove a watch
- *
- * @param watch The DBus watch, passed to us by DBus.
- * @param data the GNUNET_DBUS_Service we passed to 
dbus_connection_set_watch_functions
- */
-static void
-watch_remove (
-    DBusWatch *watch,
-    void *data)
-{
-  struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
-  struct Watch *w = service->watches;
-
-  while(w && w->watch != watch)
-    w = w->next;
-
-  if (NULL == w)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Asked to remove watch that has not 
been added\n");
-    return;
-  };
-
-  if (w->scheduled)
-  {
-    int err = watch_unschedule (w);
-    if (GNUNET_OK != err)
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "watch_unschedule returned 
error.\n");
-  };
-
-  if (w->next)
-    w->next->prev = w->prev;
-  if (w->prev)
-    w->prev->next = w->next;
-  else
-    service->watches = w->next;
-
-  GNUNET_free (w);
-};
-
-/*
- * Called by DBus when it wants to enable or disable a watch.
- * Schedules or unschedules the scheduler to monitor this watch as appropriate.
- *
- * @param watch The DBus watch, passed to us by DBus.
- * @param data the GNUNET_DBUS_Service we passed to 
dbus_connection_set_watch_functions
- */
-static void
-watch_toggle (
-    DBusWatch *watch,
-    void *data)
-{
-  struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
-  struct Watch *w = service->watches;
-
-  while(w && w->watch != watch)
-    w = w->next;
-
-  if (NULL == w)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Asked to toggle watch that has not 
been added\n");
-    return;
-  };
-
-  bool enabled = dbus_watch_get_enabled (watch);
-  bool scheduled = w->scheduled;
-
-  if (enabled && ! scheduled)
-    watch_schedule (w);
-  if (! enabled && scheduled)
-    watch_unschedule (w);
-};
-
-static void
-free_service(
-    void *service)
-{
-  GNUNET_DBUS_service_destroy ((struct GNUNET_DBUS_Service *)service);
-};
-
-/*
- * Create a new DBus service and register it with the message bus.
- *
- * @param service_name  The name of the GNUnet service. Gets appended to
- *                      "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_service_create (
-    const char *service_name,
-    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;
-
-  dbus_error_init(&err);
-    
-  conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
-  if(dbus_error_is_set(&err))
-  {
-    GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to dbus system bus 
(%s)\n", err.message);
-    dbus_error_free(&err);
-    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_free (ret);
-    return NULL;
-  };
-  ret->conn = conn;
-
-  dbus_bool_t succ = dbus_connection_set_watch_functions (conn, watch_add, 
watch_remove, watch_toggle, ret, free_service);
-  if(! succ)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "dbus_connection_set_watch_functions 
returned false. Out of memory.\n");
-    GNUNET_free (ret);
-    return NULL;
-  };
-
-  char name[128];
-  snprintf(name, 128, "org.gnunet.%s", service_name);
-  int request_result = dbus_bus_request_name(conn, name, 
DBUS_NAME_FLAG_DO_NOT_QUEUE, &err);
-  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_service_destroy (ret);
-    return NULL;
-  };
-  switch(request_result) {
-  case DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER:
-    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_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_service_destroy (ret);
-    return NULL;
-  };
-
-  return ret;
-};
-
-void
-GNUNET_DBUS_service_destroy (
-    struct GNUNET_DBUS_Service *service)
-{
-  struct Watch *w = service->watches;
-  while (w)
-  {
-    struct Watch *next = w->next;
-    if (w->scheduled)
-    {
-      int err = watch_unschedule (w);
-      if (GNUNET_OK != err)
-        GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to unschedule watch 
that should have been scheduled while destroying service.\n");
-    };
-
-    GNUNET_free (w);
-    w = next;
-  };
-
-  GNUNET_free (service);
-};
-
-void *
-GNUNET_DBUS_service_get_data (
-    struct GNUNET_DBUS_Service *service)
-{
-  return service->data;
-};
-
-DBusHandlerResult
-handle_object_message (
-    DBusConnection *conn,
-    DBusMessage *message,
-    void *cls)
-{
-  struct GNUNET_DBUS_Object *obj = (struct GNUNET_DBUS_Object *)cls;
-
-#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_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_HANDLER_RESULT_NOT_YET_HANDLED;
-
-  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 (
-        message,
-        pos->interface,
-        pos->method_name))
-    {
-      DBusMessage *reply = pos->method (client, obj, message);
-      if (! reply)
-      {
-        GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "method returned NULL. Out of 
memory.\n");
-        return DBUS_HANDLER_RESULT_NEED_MEMORY;
-      };
-      dbus_bool_t succ = dbus_connection_send (conn, reply, NULL);
-      dbus_message_unref (reply);
-      return succ ? DBUS_HANDLER_RESULT_HANDLED : 
DBUS_HANDLER_RESULT_NEED_MEMORY;
-    };
-    pos = pos->next;
-  };
-
-  return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-};
-
-void
-handle_object_unregister (
-    DBusConnection *conn,
-    void *cls)
-{
-  struct GNUNET_DBUS_Object *obj = (struct GNUNET_DBUS_Object *)cls;
-  GNUNET_free (obj);
-}; 
-
-struct GNUNET_DBUS_Object *
-GNUNET_DBUS_object_create (
-    struct GNUNET_DBUS_Service *service,
-    const char *path,
-    void *data)
-{
-  struct GNUNET_DBUS_Object *ret;
-  ret = GNUNET_new (struct GNUNET_DBUS_Object);
-  ret->service = service;
-  ret->path = path;
-  ret->data = data;
-  ret->methods = NULL;
-
-  DBusError err;
-  dbus_error_init(&err);
-    
-  DBusObjectPathVTable vtable;
-  vtable.message_function = handle_object_message;
-  vtable.unregister_function = handle_object_unregister;
-  dbus_bool_t succ = dbus_connection_try_register_object_path (
-      service->conn,
-      path,
-      &vtable,
-      ret,
-      &err);
-  if (dbus_error_is_set (&err))
-  {
-    GNUNET_log (
-        GNUNET_ERROR_TYPE_ERROR,
-        "dbus_connection_try_register failed to register path \"%s\": %s\n",
-          path,
-          err.message);
-    GNUNET_free (ret);
-    return NULL;
-  };
-  if (! succ)
-  {
-    GNUNET_log (
-        GNUNET_ERROR_TYPE_ERROR,
-        "dbus_connection_try_register returned false when registering path 
\"%s\"\n",
-          path);
-    GNUNET_free (ret);
-    return NULL;
-  };
-
-  return ret;
-};
-
-int
-GNUNET_DBUS_object_destroy (
-    struct GNUNET_DBUS_Object *obj)
-{
-  /* object is freed in handle_object_unregister */
-  dbus_bool_t succ = dbus_connection_unregister_object_path (
-      obj->service->conn,
-      obj->path);
-  if (! succ)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to unregister object. Out of 
memory.\n");
-    return GNUNET_SYSERR;
-  };
-  return GNUNET_OK;
-};
-
-int
-GNUNET_DBUS_object_add_method (
-    struct GNUNET_DBUS_Object *obj,
-    const char *interface,
-    const char *method_name,
-    GNUNET_DBUS_Method method)
-{
-  struct Method *add = GNUNET_new (struct Method);
-  if (NULL == add)
-    return GNUNET_SYSERR;
-
-  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;
-};
-

Deleted: gnunet-dbus/src/gnunet_dbus_lib.h
===================================================================
--- gnunet-dbus/src/gnunet_dbus_lib.h   2013-12-24 00:57:09 UTC (rev 31727)
+++ gnunet-dbus/src/gnunet_dbus_lib.h   2013-12-24 03:07:27 UTC (rev 31728)
@@ -1,143 +0,0 @@
-#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) (
-    struct GNUNET_DBUS_Client *client,
-    struct GNUNET_DBUS_Object *object,
-    DBusMessage *message);
-
-typedef int (*GNUNET_DBUS_ClientConnects) (
-    struct GNUNET_DBUS_Service *service,
-    struct GNUNET_DBUS_Client *client);
-
-struct GNUNET_DBUS_Service *
-GNUNET_DBUS_service_create (
-    const char *service_name,
-    const struct GNUNET_CONFIGURATION_Handle *cfg,
-    GNUNET_DBUS_ClientConnects client_connects,
-    void *data);
-
-void
-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
-

Deleted: gnunet-dbus/src/gnunet_dbus_lib_block.c
===================================================================
--- gnunet-dbus/src/gnunet_dbus_lib_block.c     2013-12-24 00:57:09 UTC (rev 
31727)
+++ gnunet-dbus/src/gnunet_dbus_lib_block.c     2013-12-24 03:07:27 UTC (rev 
31728)
@@ -1,45 +0,0 @@
-#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;
-};
-

Deleted: gnunet-dbus/src/gnunet_dbus_lib_dht.c
===================================================================
--- gnunet-dbus/src/gnunet_dbus_lib_dht.c       2013-12-24 00:57:09 UTC (rev 
31727)
+++ gnunet-dbus/src/gnunet_dbus_lib_dht.c       2013-12-24 03:07:27 UTC (rev 
31728)
@@ -1,35 +0,0 @@
-#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;
-};
-
-

Deleted: gnunet-dbus/src/gnunet_dbus_lib_pop.c
===================================================================
--- gnunet-dbus/src/gnunet_dbus_lib_pop.c       2013-12-24 00:57:09 UTC (rev 
31727)
+++ gnunet-dbus/src/gnunet_dbus_lib_pop.c       2013-12-24 03:07:27 UTC (rev 
31728)
@@ -1,345 +0,0 @@
-#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,
-    DBusMessageIter *iter,
-    const char *arg_name,
-    int expected_type,
-    void *value)
-{
-  int arg_type = dbus_message_iter_get_arg_type (iter);
-  if (expected_type != arg_type)
-  {
-    return dbus_message_new_error_printf (
-        message,
-        DBUS_ERROR_INVALID_ARGS,
-        "Bad argument for '%s'. Expected %s. Got %s",
-          arg_name,
-          dbus_message_type_to_string (expected_type),
-          dbus_message_type_to_string (arg_type));
-  };
-  dbus_message_iter_get_basic (iter, value);
-  dbus_message_iter_next (iter);
-
-  return NULL;
-};
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_string (
-    DBusMessage *message,
-    DBusMessageIter *iter,
-    const char *arg_name,
-    const char **value)
-{
-  return GNUNET_DBUS_message_iter_pop_basic (
-      message,
-      iter,
-      arg_name,
-      DBUS_TYPE_STRING,
-      (void *)value);
-};
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_uint32 (
-    DBusMessage *message,
-    DBusMessageIter *iter,
-    const char *arg_name,
-    dbus_uint32_t *value)
-{
-  return GNUNET_DBUS_message_iter_pop_basic (
-      message,
-      iter,
-      arg_name,
-      DBUS_TYPE_UINT32,
-      (void *)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)
-{
-  int arg_type = dbus_message_iter_get_arg_type (iter);
-  if (DBUS_TYPE_ARRAY != arg_type)
-  {
-    return dbus_message_new_error_printf (
-        message,
-        DBUS_ERROR_INVALID_ARGS,
-        "Bad argument for '%s'. Expected %s. Got %s",
-          arg_name,
-          dbus_message_type_to_string (DBUS_TYPE_ARRAY),
-          dbus_message_type_to_string (arg_type));
-  };
-
-  int element_type = dbus_message_iter_get_element_type (iter);
-  if (expected_type != element_type)
-  {
-    return dbus_message_new_error_printf (
-        message,
-        DBUS_ERROR_INVALID_ARGS,
-        "Bad argument for '%s'. Expected array of %s. Got array of %s",
-          arg_name,
-          dbus_message_type_to_string (expected_type),
-          dbus_message_type_to_string (element_type));
-  };
-
-  DBusMessageIter itersub;
-  dbus_message_iter_recurse (iter, &itersub);
-  dbus_message_iter_get_fixed_array (&itersub, value, n_elements);
-
-  return NULL;
-};
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_array_byte (
-    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_BYTE,
-      (void *)value,
-      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
- * efficient and is what libraries built around the DBus API would use, people
- * using the DBus API directly may want to pass human-readable strings for
- * convenience.
- */
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_bitfield (
-    DBusMessage *message,
-    DBusMessageIter *iter,
-    const char *arg_name,
-    int *value,
-    const struct GNUNET_DBUS_StringEnumPair *fields)
-{
-  uint32_t flags;
-  DBusMessage *ret = GNUNET_DBUS_message_iter_pop_uint32 (message, iter, 
arg_name, &flags);
-  if (! ret)
-  {
-    *value = (int)flags;
-    return NULL;
-  };
-  dbus_message_unref (ret);
-
-  const char **options;
-  int num_options;
-  ret = GNUNET_DBUS_message_iter_pop_array_string (message, iter, arg_name, 
&options, &num_options);
-  if (! ret)
-  {
-    *value = 0;
-    int i;
-    for (i = 0; i < num_options; i++)
-    {
-      int j;
-      for (j = 0; fields[j].name; j++)
-      {
-        if (! strcmp (options[i], fields[j].name))
-        {
-          *value |= fields[j].value;
-          break;
-        };
-      };
-      if (! fields[j].name)
-      {
-        size_t size = GNUNET_XSTRING_NEW_DEFAULT_SIZE;
-        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_appendf (&errmsg, &size, "%s'%s'", j ? ", " : "", 
fields[j].name);
-        GNUNET_XSTRING_append (&errmsg, &size, "].");
-        ret = dbus_message_new_error_printf (
-            message,
-            DBUS_ERROR_INVALID_ARGS,
-            "%s",
-              errmsg);
-        GNUNET_free (errmsg);
-        return ret;
-      };
-    };
-
-    return NULL;
-  };
-  dbus_message_unref (ret);
-
-  return dbus_message_new_error_printf (
-      message,
-      DBUS_ERROR_INVALID_ARGS,
-      "Bad argument for '%s'. Expected either a bitfield uint32 or an array of 
string options.",
-        arg_name);
-};
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_enum (
-    DBusMessage *message,
-    DBusMessageIter *iter,
-    const char *arg_name,
-    int *value,
-    const struct GNUNET_DBUS_StringEnumPair *names)
-{
-  uint32_t v;
-  DBusMessage *ret = GNUNET_DBUS_message_iter_pop_uint32 (message, iter, 
arg_name, &v);
-  if (! ret)
-  {
-    *value = (int)v;
-    return NULL;
-  };
-  dbus_message_unref (ret);
-
-  const char *name;
-  ret = GNUNET_DBUS_message_iter_pop_string (message, iter, arg_name, &name);
-  if (! ret)
-  {
-    int i;
-    for (i = 0; names[i].name; i++)
-    {
-      if (! strcmp (name, names[i].name))
-      {
-        *value = names[i].value;
-        break;
-      };
-    };
-    if (! names[i].name)
-    {
-      size_t size = GNUNET_XSTRING_NEW_DEFAULT_SIZE;
-      char *errmsg = GNUNET_XSTRING_new ();
-      GNUNET_XSTRING_appendf (&errmsg, &size, "Unrecognized option '%s'. Valid 
options are: [", name);
-      for (i = 0; names[i].name; i++)
-        GNUNET_XSTRING_appendf (&errmsg, &size, "%s'%s'", i ? ", " : "", 
names[i].name);
-      GNUNET_XSTRING_append (&errmsg, &size, "].");
-      ret = dbus_message_new_error_printf (
-          message,
-          DBUS_ERROR_INVALID_ARGS,
-          "%s",
-            errmsg);
-      GNUNET_free (errmsg);
-      return ret;
-    };
-    return NULL;
-  };
-  dbus_message_unref (ret);
-  
-  return dbus_message_new_error_printf (
-      message,
-      DBUS_ERROR_INVALID_ARGS,
-      "Bad argument for '%s'. Expected either a uint32 or a string option",
-        arg_name);
-};
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_hashcode (
-    DBusMessage *message,
-    DBusMessageIter *iter,
-    const char *arg_name,
-    struct GNUNET_HashCode *hc)
-{
-  const char *hc_in;
-  DBusMessage *ret = GNUNET_DBUS_message_iter_pop_string (message, iter, 
arg_name, &hc_in);
-  if (ret)
-    return ret;
-
-  int err = GNUNET_CRYPTO_hash_from_string2 (hc_in, strlen(hc_in), hc);
-  if (GNUNET_OK != err)
-  {
-    return dbus_message_new_error_printf (
-        message,
-        DBUS_ERROR_INVALID_ARGS,
-        "Bad argument for '%s'. Malformed hash string. 
GNUNET_CRYPTO_hash_from_string2 returned %d",
-          arg_name,
-          err);
-  };
-
-  return NULL;
-};
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_socket (
-    DBusMessage *message,
-    DBusMessageIter *iter,
-    const char *arg_name,
-    struct GNUNET_NETWORK_Handle **socket_handle)
-{
-  const char *address;
-
-  DBusMessage *ret = GNUNET_DBUS_message_iter_pop_string (message, iter, 
arg_name, &address);
-  if (ret)
-    return ret;
-
-  *socket_handle = GNUNET_DBUS_create_socket_from_dbus_address (address);
-  if (! *socket_handle)
-  {
-    return dbus_message_new_error_printf (
-        message,
-        DBUS_ERROR_INVALID_ARGS,
-        "Bad argument for '%s'. Malformed address",
-          arg_name);
-  };
-
-  return NULL;
-};
-
-DBusMessage *
-GNUNET_DBUS_message_iter_pop_absolute_time (
-    DBusMessage *message,
-    DBusMessageIter *iter,
-    const char *arg_name,
-    struct GNUNET_TIME_Absolute *value)
-{
-  const char *time;
-  DBusMessage *ret = GNUNET_DBUS_message_iter_pop_string (message, iter, 
arg_name, &time);
-  if (ret)
-    return ret;
-
-  int err = GNUNET_STRINGS_fancy_time_to_absolute (time, value);
-  if (GNUNET_OK != err)
-  {
-    return dbus_message_new_error_printf (
-        message,
-        DBUS_ERROR_INVALID_ARGS,
-        "Bad argument for '%s'. Malformed time string. 
GNUNET_STRINGS_fancy_time_to_absolute returned %d",
-          arg_name,
-          err);
-  };
-
-  return NULL;
-};
-
-

Deleted: gnunet-dbus/src/gnunet_xstring_lib.c
===================================================================
--- gnunet-dbus/src/gnunet_xstring_lib.c        2013-12-24 00:57:09 UTC (rev 
31727)
+++ gnunet-dbus/src/gnunet_xstring_lib.c        2013-12-24 03:07:27 UTC (rev 
31728)
@@ -1,99 +0,0 @@
-#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;
-};
-
-

Deleted: gnunet-dbus/src/gnunet_xstring_lib.h
===================================================================
--- gnunet-dbus/src/gnunet_xstring_lib.h        2013-12-24 00:57:09 UTC (rev 
31727)
+++ gnunet-dbus/src/gnunet_xstring_lib.h        2013-12-24 03:07:27 UTC (rev 
31728)
@@ -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 __attribute__ ((format (printf, 3, 4)))
-GNUNET_XSTRING_appendf ( \
-    char **dest,
-    size_t *dest_size,
-    const char *fmt,
-    ...);
-
-#endif // GNUNET_XSTRING_LIB_H
-

Added: gnunet-dbus/src/lib/Makefile.am
===================================================================
--- gnunet-dbus/src/lib/Makefile.am                             (rev 0)
+++ gnunet-dbus/src/lib/Makefile.am     2013-12-24 03:07:27 UTC (rev 31728)
@@ -0,0 +1,37 @@
+lib_LTLIBRARIES = \
+       libgnunetdbus.la \
+       libgnunetdbus_dht.la \
+       libgnunetdbus_block.la \
+       libgnunetdbus_crypto.la \
+       libgnunetxstring.la
+
+libgnunetdbus_la_SOURCES = \
+       gnunet_dbus_lib.h \
+       gnunet_dbus_lib.c \
+       gnunet_dbus_lib_pop.c \
+       dbus_type_to_string.c
+
+libgnunetdbus_la_LIBADD = \
+       libgnunetxstring.la
+
+libgnunetdbus_la_DEPENDENCIES = \
+       libgnunetxstring.la
+
+libgnunetdbus_la_CFLAGS = \
+       $(DBUS_CFLAGS)
+
+libgnunetdbus_la_LDFLAGS = \
+       $(DBUS_LIBS)
+
+libgnunetdbus_dht_la_SOURCES = \
+       gnunet_dbus_lib_dht.c
+
+libgnunetdbus_block_la_SOURCES = \
+       gnunet_dbus_lib_block.c
+
+libgnunetdbus_crypto_la_SOURCES = \
+       gnunet_dbus_lib_crypto.c
+
+libgnunetxstring_la_SOURCES = \
+       gnunet_xstring_lib.c
+

Added: gnunet-dbus/src/lib/dbus_type_to_string.c
===================================================================
--- gnunet-dbus/src/lib/dbus_type_to_string.c                           (rev 0)
+++ gnunet-dbus/src/lib/dbus_type_to_string.c   2013-12-24 03:07:27 UTC (rev 
31728)
@@ -0,0 +1,61 @@
+#include "config.h"
+
+#include <dbus/dbus.h>
+
+/*
+ * Copy-pasted from libdbus dbus-marshall-basic.c
+ */
+const char *
+dbus_type_to_string (int typecode)
+{
+  switch (typecode)
+    {
+    case DBUS_TYPE_INVALID:
+      return "invalid";
+    case DBUS_TYPE_BOOLEAN:
+      return "boolean";
+    case DBUS_TYPE_BYTE:
+      return "byte";
+    case DBUS_TYPE_INT16:
+      return "int16";
+    case DBUS_TYPE_UINT16:
+      return "uint16";
+    case DBUS_TYPE_INT32:
+      return "int32";
+    case DBUS_TYPE_UINT32:
+      return "uint32";
+    case DBUS_TYPE_INT64:
+      return "int64";
+    case DBUS_TYPE_UINT64:
+      return "uint64";      
+    case DBUS_TYPE_DOUBLE:
+      return "double";
+    case DBUS_TYPE_STRING:
+      return "string";
+    case DBUS_TYPE_OBJECT_PATH:
+      return "object_path";
+    case DBUS_TYPE_SIGNATURE:
+      return "signature";
+    case DBUS_TYPE_STRUCT:
+      return "struct";
+    case DBUS_TYPE_DICT_ENTRY:
+      return "dict_entry";
+    case DBUS_TYPE_ARRAY:
+      return "array";
+    case DBUS_TYPE_VARIANT:
+      return "variant";
+    case DBUS_STRUCT_BEGIN_CHAR:
+      return "begin_struct";
+    case DBUS_STRUCT_END_CHAR:
+      return "end_struct";
+    case DBUS_DICT_ENTRY_BEGIN_CHAR:
+      return "begin_dict_entry";
+    case DBUS_DICT_ENTRY_END_CHAR:
+      return "end_dict_entry";
+    case DBUS_TYPE_UNIX_FD:
+      return "unix_fd";
+    default:
+      return "unknown";
+    }
+}
+

Added: gnunet-dbus/src/lib/dbus_type_to_string.h
===================================================================
--- gnunet-dbus/src/lib/dbus_type_to_string.h                           (rev 0)
+++ gnunet-dbus/src/lib/dbus_type_to_string.h   2013-12-24 03:07:27 UTC (rev 
31728)
@@ -0,0 +1,12 @@
+#ifndef DBUS_TYPE_TO_STRING_H
+#define DBUS_TYPE_TO_STRING_H
+
+#ifndef HAVE_dbus_type_to_string
+
+const char *
+dbus_type_to_string (int typecode);
+
+#endif
+
+#endif
+

Added: gnunet-dbus/src/lib/gnunet_dbus_lib.c
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib.c                               (rev 0)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib.c       2013-12-24 03:07:27 UTC (rev 
31728)
@@ -0,0 +1,1101 @@
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <sys/socket.h>
+
+#include <dbus/dbus.h>
+
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_scheduler_lib.h>
+
+#include "gnunet_dbus_lib.h"
+
+/*
+ * Wraps a file descriptor that needs to be watched 
+ * for activity with select()
+ */
+struct Watch
+{
+  /* doubly-linked list */
+  struct Watch *next;
+  struct Watch *prev;
+
+  /*
+   * DBus watch data. Contains the actual file descritor wrapped by libdbus
+   */
+  DBusWatch *watch;
+
+  /*
+   * Have we asked the scheduler to watch this?
+   * Will be false if the associated task has not been
+   * re-scheduled yet after execution or because dbus has asked
+   * us to disable this watch.
+   */
+  bool scheduled;
+
+  /*
+   * The task that is watching our file descriptor.
+   * Only valid if scheduled is true.
+   */
+  GNUNET_SCHEDULER_TaskIdentifier task;
+
+  struct GNUNET_NETWORK_Handle *net_handle;
+  struct GNUNET_DISK_FileHandle *file_handle;
+};
+
+struct Timeout
+{
+  /* doubly-linked list */
+  struct Timeout *next;
+  struct Timeout *prev;
+
+  DBusTimeout *timeout;
+
+  bool scheduled;
+
+  GNUNET_SCHEDULER_TaskIdentifier task;
+};
+
+/*
+ * Represents a DBus service such as "org.gnunet.dht"
+ */
+struct GNUNET_DBUS_Service
+{
+  /*
+   * Our connection to the DBus message bus.
+   */
+  DBusConnection *conn;
+
+  /*
+   * Linked list of watches
+   */
+  struct Watch *watches;
+
+  /*
+   * Linked list of timeouts
+   */
+  struct Timeout *timeouts;
+
+#if 0
+  /*
+   * 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;
+#endif
+};
+
+#if 0
+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;
+};
+#endif
+
+/*
+ * A container for methods that can be exposed on DBus.
+ */
+struct Method
+{
+  /* doubly-linked list */
+  struct Method *next;
+  struct Method *prev;
+
+  /*
+   * DBus interface of the method
+   */
+  const char *interface;
+  
+  /*
+   * Name of the method as through DBus
+   */
+  const char *method_name;
+
+  /* The actual method */
+  GNUNET_DBUS_Method method;
+};
+
+/*
+ * A DBus object exposed through a service.
+ * In DBus, each service presents a set of objects and each object presents a
+ * set of methods that can be called on it.
+ */
+struct GNUNET_DBUS_Object
+{
+  /*
+   * Closure passed in to GNUNET_DBUS_object_create.
+   * Points to the actual data structure wrapped by this DBus object.
+   */
+  void *data;
+
+#if 0
+  /*
+   * The service we are an object of
+   */
+  struct GNUNET_DBUS_Service *service;
+
+  /*
+   * The object path
+   */
+  const char *path;
+#endif
+
+  /*
+   * Linked list of methods this object exposes
+   */
+  struct Method *methods;
+};
+
+static void
+handle_watch (
+    void *cls,
+    const struct GNUNET_SCHEDULER_TaskContext *tc);
+
+static int
+watch_schedule (
+  struct Watch *w);
+
+static int
+watch_unschedule (
+    struct Watch *w);
+
+static dbus_bool_t
+watch_add (
+    DBusWatch *watch,
+    void *data);
+
+static void
+watch_remove (
+    DBusWatch *watch,
+    void *data);
+
+static void
+watch_toggle (
+    DBusWatch *watch,
+    void *data);
+
+/*
+ * Called by the scheduler when a watch has activity on it
+ *
+ * @param cls The watch
+ * @param tc the context given to us by the scheduler for this execution
+ */
+static void
+handle_watch (
+    void *cls,
+    const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct Watch *w = (struct Watch *)cls;
+
+  printf ("handle_watch\n");
+
+  unsigned flags = 0;
+  if (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)
+    flags |= DBUS_WATCH_READABLE;
+  if (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)
+    flags |= DBUS_WATCH_WRITABLE;
+#if 0
+  if (tc->reason & GNUNET_SCHEDULER_REASON_EXCEPTION)
+    flags |= DBUS_WATCH_ERROR;
+#endif
+  printf ("  %x\n", flags);
+  if (flags)
+    dbus_watch_handle(w->watch, flags);
+
+  w->scheduled = false;
+
+  if(! (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+  {
+    int err;
+    err = watch_schedule (w);
+    if (GNUNET_OK != err)
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "watch_schedule failed\n");
+  };
+};
+
+/*
+ * Ask the scheduler to watch this watch for activity.
+ *
+ * @param w The watch
+ * @return GNUNET_OK or GNUNET_SYSERR
+ */
+static int
+watch_schedule (
+  struct Watch *w)
+{
+  unsigned flags = dbus_watch_get_flags (w->watch);
+
+  printf ("watch_schedule\n");
+
+  // sanity check
+  if (! dbus_watch_get_enabled (w->watch))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Tried to schedule watch that is 
disabled!\n");
+    return GNUNET_SYSERR;
+  };
+
+  if (w->scheduled)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Scheduling watch that is already 
scheduled!\n");
+    return GNUNET_SYSERR;
+  };
+
+  if (w->net_handle)
+  {
+    w->task = GNUNET_SCHEDULER_add_net_with_priority(
+        GNUNET_TIME_UNIT_FOREVER_REL,
+        GNUNET_SCHEDULER_PRIORITY_DEFAULT,
+        w->net_handle,
+        flags & DBUS_WATCH_READABLE,
+        flags & DBUS_WATCH_WRITABLE,
+        handle_watch,
+        w);
+    w->scheduled = true;
+    return GNUNET_OK;
+  };
+
+  if (w->file_handle)
+  {
+    w->task = GNUNET_SCHEDULER_add_file_with_priority(
+        GNUNET_TIME_UNIT_FOREVER_REL,
+        GNUNET_SCHEDULER_PRIORITY_DEFAULT,
+        w->file_handle,
+        flags & DBUS_WATCH_READABLE,
+        flags & DBUS_WATCH_WRITABLE,
+        handle_watch,
+        w);
+    w->scheduled = true;
+    return GNUNET_OK;
+  };
+
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to schedule watch.\n");
+  return GNUNET_SYSERR;
+};
+
+/*
+ * Ask the scheduler to stop monitoring a watch either because we are shutting
+ * down or dbus has asked us to disable this watch.
+ *
+ * @param w The watch
+ * @return GNUNET_OK or GNUNET_SYSERR
+ */
+static int
+watch_unschedule (
+    struct Watch *w)
+{
+  printf ("watch_unschedule\n");
+
+  if(w->scheduled)
+  {
+    void *cls = GNUNET_SCHEDULER_cancel (w->task);
+    if ((struct Watch *)cls != w)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to unschedule task. w == 
%p, GNUNET_SCHEDULER_cancel returned %p\n", w, cls);
+      return GNUNET_SYSERR;
+    }
+  }
+  else
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Attempting to unschedule task that 
is not scheduled!\n");
+    return GNUNET_SYSERR;
+  };
+
+  return GNUNET_OK;
+};
+
+/*
+ * Called by DBus when it has a new watch that it wants us to watch.
+ *
+ * @param watch The DBus watch, created and passed to us by DBus.
+ * @param data the GNUNET_DBUS_Service we passed to 
dbus_connection_set_watch_functions
+ * @return true on success, false on an unrecoverable error such as running 
out of memory.
+ */
+static dbus_bool_t
+watch_add (
+    DBusWatch *watch,
+    void *data)
+{
+  struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
+  struct Watch *w = GNUNET_new (struct Watch);
+
+  printf ("watch_add\n");
+
+  if(w == NULL)
+    return false;
+
+  w->watch = watch;
+  w->scheduled = false;
+  w->net_handle = NULL;
+  w->file_handle = NULL;
+
+  SOCKTYPE sock = dbus_watch_get_socket (watch);
+  if (-1 != sock)
+  {
+    w->net_handle = GNUNET_NETWORK_socket_box_native (sock);
+    if (NULL == w->net_handle)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to box network socket 
passed in from dbus.\n");
+      GNUNET_free (w);
+      return false;
+    };
+  }
+  else {
+    int fd = dbus_watch_get_unix_fd (watch);
+    if (-1 != fd)
+    {
+      w->file_handle = GNUNET_DISK_get_handle_from_int_fd (fd);
+      if (NULL == w->file_handle)
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to box file handle passed 
in from dbus.\n");
+        GNUNET_free (w);
+        return false;
+      };
+    };
+  };
+
+  if (! w->net_handle && ! w->file_handle)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to add watch.\n");
+    GNUNET_free (w);
+  };
+
+  if (dbus_watch_get_enabled (watch))
+  {
+    int err = watch_schedule (w);
+    if (GNUNET_OK != err)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to schedule watch.\n");
+      if (w->net_handle)
+        GNUNET_free (w->net_handle);
+      if (w->file_handle)
+        GNUNET_free (w->file_handle);
+      GNUNET_free (w);
+      return false;
+    };
+  };
+
+  w->next = service->watches;
+  w->prev = NULL;
+  if (service->watches)
+    service->watches->prev = w;
+  service->watches = w;
+
+  return true;
+};
+
+/*
+ * Called by DBus when it want to permanently disable and remove a watch
+ *
+ * @param watch The DBus watch, passed to us by DBus.
+ * @param data the GNUNET_DBUS_Service we passed to 
dbus_connection_set_watch_functions
+ */
+static void
+watch_remove (
+    DBusWatch *watch,
+    void *data)
+{
+  struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
+  struct Watch *w = service->watches;
+
+  printf ("watch_remove\n");
+
+  while(w && w->watch != watch)
+    w = w->next;
+
+  if (NULL == w)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Asked to remove watch that has not 
been added\n");
+    return;
+  };
+
+  if (w->scheduled)
+  {
+    int err = watch_unschedule (w);
+    if (GNUNET_OK != err)
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "watch_unschedule returned 
error.\n");
+  };
+
+  if (w->net_handle)
+    GNUNET_free (w->net_handle);
+  if (w->file_handle)
+    GNUNET_free (w->file_handle);
+
+  if (w->next)
+    w->next->prev = w->prev;
+  if (w->prev)
+    w->prev->next = w->next;
+  else
+    service->watches = w->next;
+
+  GNUNET_free (w);
+};
+
+/*
+ * Called by DBus when it wants to enable or disable a watch.
+ * Schedules or unschedules the scheduler to monitor this watch as appropriate.
+ *
+ * @param watch The DBus watch, passed to us by DBus.
+ * @param data the GNUNET_DBUS_Service we passed to 
dbus_connection_set_watch_functions
+ */
+static void
+watch_toggle (
+    DBusWatch *watch,
+    void *data)
+{
+  struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
+  struct Watch *w = service->watches;
+
+  printf ("watch_toggle\n");
+
+  while(w && w->watch != watch)
+    w = w->next;
+
+  if (NULL == w)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Asked to toggle watch that has not 
been added\n");
+    return;
+  };
+
+  bool enabled = dbus_watch_get_enabled (watch);
+  bool scheduled = w->scheduled;
+
+  if (enabled && ! scheduled)
+    watch_schedule (w);
+  if (! enabled && scheduled)
+    watch_unschedule (w);
+};
+
+static int
+timeout_schedule (
+    struct Timeout *t);
+
+static void
+handle_timeout (
+    void *cls,
+    const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct Timeout *t = (struct Timeout *)cls;
+
+  printf ("handle_timeout\n");
+
+  if (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)
+    dbus_timeout_handle (t->timeout);
+
+  t->scheduled = false;
+
+  if (! (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+  {
+    int err;
+    err = timeout_schedule (t);
+    if (GNUNET_OK != err)
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "timeout_schedule failed\n");
+  };
+};
+
+static int
+timeout_schedule (
+    struct Timeout *t)
+{
+  printf ("timeout_schedule\n");
+
+  DBusTimeout *timeout = t->timeout;
+  if (! dbus_timeout_get_enabled (t->timeout))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Tried to schedule timeout that is 
disabled!\n");
+    return GNUNET_SYSERR;
+  };
+
+  if (t->scheduled)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Scheduling timeout that is already 
scheduled!\n");
+    return GNUNET_SYSERR;
+  };
+
+  int interval = dbus_timeout_get_interval (timeout);
+  struct GNUNET_TIME_Relative delay;
+  delay.rel_value_us = interval * 1000;
+  t->task = GNUNET_SCHEDULER_add_delayed (
+      delay,
+      handle_timeout,
+      t);
+  t->scheduled = true;
+  return GNUNET_OK;
+};
+
+static int
+timeout_unschedule (
+    struct Timeout *t)
+{
+  printf ("timeout_unschedule\n");
+
+  if (t->scheduled)
+  {
+    void *cls = GNUNET_SCHEDULER_cancel (t->task);
+    if ((struct Timeout *)cls != t)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to unschedule timeout. t == 
%p, GNUNET_SCHEDULER_cancel returned %p\n", t, cls);
+      return GNUNET_SYSERR;
+    };
+  }
+  else
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Attempting to unschedule task that 
is not scheduled!\n");
+    return GNUNET_SYSERR;
+  };
+
+  return GNUNET_OK;
+};
+
+static dbus_bool_t
+timeout_add (
+    DBusTimeout *timeout,
+    void *data)
+{
+  printf ("timeout_add\n");
+
+  struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
+  struct Timeout *t = GNUNET_new (struct Timeout);
+
+  if (t == NULL)
+    return false;
+
+  t->timeout = timeout;
+  t->scheduled = false;
+  
+  t->next = service->timeouts;
+  t->prev = NULL;
+  if (service->timeouts)
+    service->timeouts->prev = t;
+  service->timeouts = t;
+
+  if (dbus_timeout_get_enabled (timeout))
+  {
+    int err = timeout_schedule (t);
+    if (GNUNET_OK != err)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to schedule timeout.\n");
+      return false;
+    };
+  };
+  
+  return true;
+};
+
+static void
+timeout_remove (
+    DBusTimeout *timeout,
+    void *data)
+{
+  printf ("timeout_remove\n");
+
+  struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
+  struct Timeout *t = service->timeouts;
+
+  while (t && t->timeout != timeout)
+    t = t->next;
+
+  if (NULL == t)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "asked to remove timeout that has 
not been added\n");
+    return;
+  };
+
+  if (t->scheduled)
+  {
+    int err = timeout_unschedule (t);
+    if (GNUNET_OK != err)
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "timeout_unschedule failed.\n");
+  };
+
+  if (t->next)
+    t->next->prev = t->prev;
+  if (t->prev)
+    t->prev->next = t->next;
+  else
+    service->timeouts = t->next;
+
+  GNUNET_free (t);
+};
+
+static void
+timeout_toggle (
+    DBusTimeout *timeout,
+    void *data)
+{
+  printf ("timeout_toggle\n");
+
+  struct GNUNET_DBUS_Service *service = (struct GNUNET_DBUS_Service *)data;
+  struct Timeout *t = service->timeouts;
+
+  while (t && t->timeout != timeout)
+    t = t->next;
+
+  if (NULL == t)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "asked to remove timeout that has 
not been added\n");
+    return;
+  };
+
+  bool enabled = dbus_timeout_get_enabled (timeout);
+  bool scheduled = t->scheduled;
+
+  if (enabled && ! scheduled)
+    timeout_schedule (t);
+  if (! enabled && scheduled)
+    timeout_unschedule (t);
+};
+
+static void
+dispatch (
+    void *cls,
+    const struct GNUNET_SCHEDULER_TaskContext *tc);
+
+static void
+handle_dispatch (
+    DBusConnection *conn,
+    DBusDispatchStatus status)
+{
+  printf ("handle_dispatch\n");
+
+  switch (status)
+  {
+  case DBUS_DISPATCH_DATA_REMAINS:
+    GNUNET_SCHEDULER_add_continuation (
+        dispatch,
+        conn,
+        GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    break;
+  case DBUS_DISPATCH_COMPLETE:
+    break;
+  case DBUS_DISPATCH_NEED_MEMORY:
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Out of memory!\n");
+    break;
+  default:
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unrecognized dispatch status\n");
+    break;
+  };
+};
+
+static void
+dispatch (
+    void *cls,
+    const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  printf ("dispatch\n");
+
+  struct DBusConnection *conn = (struct DBusConnection *)cls;
+  dbus_connection_dispatch (conn);
+  handle_dispatch (conn, dbus_connection_get_dispatch_status (conn));
+};
+
+static void
+dispatch_status_changed (
+    DBusConnection *conn,
+    DBusDispatchStatus new_status,
+    void *data)
+{
+  (void)data;
+  printf ("dispatch_status_changed\n");
+
+  handle_dispatch (conn, new_status);
+};
+
+/*
+ * Create a new DBus service and register it with the message bus.
+ *
+ * @param service_name  The name of the GNUnet service. Gets appended to
+ *                      "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_service_create (
+    const char *service_name,
+    const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  struct GNUNET_DBUS_Service *ret;
+  ret = GNUNET_new(struct GNUNET_DBUS_Service);
+  ret->watches = NULL;
+
+  DBusError err;
+  DBusConnection *conn;
+
+  dbus_error_init(&err);
+    
+  conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
+  if(dbus_error_is_set(&err))
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to dbus system bus 
(%s)\n", err.message);
+    dbus_error_free(&err);
+    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_free (ret);
+    return NULL;
+  };
+  ret->conn = conn;
+
+  dbus_bool_t succ = dbus_connection_set_watch_functions (conn, watch_add, 
watch_remove, watch_toggle, ret, NULL);
+  if(! succ)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "dbus_connection_set_watch_functions 
returned false. Out of memory.\n");
+    GNUNET_DBUS_service_destroy (ret);
+    return NULL;
+  };
+
+  dbus_connection_set_dispatch_status_function (conn, dispatch_status_changed, 
ret, NULL);
+  handle_dispatch (conn, dbus_connection_get_dispatch_status (conn));
+
+  succ = dbus_connection_set_timeout_functions (conn, timeout_add, 
timeout_remove, timeout_toggle, ret, NULL);
+  if (! succ)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
"dbus_connection_set_timeout_functions returned false. Out of memory.\n");
+    GNUNET_DBUS_service_destroy (ret);
+    return NULL;
+  };
+
+  char name[128];
+  snprintf(name, 128, "org.gnunet.%s", service_name);
+  int request_result = dbus_bus_request_name(conn, name, 
DBUS_NAME_FLAG_DO_NOT_QUEUE, &err);
+  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_service_destroy (ret);
+    return NULL;
+  };
+  switch(request_result) {
+  case DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER:
+    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_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_service_destroy (ret);
+    return NULL;
+  };
+
+  return ret;
+};
+
+/*
+ * Destroy a dbus service, unregistering it from the messagebus and freeing
+ * it's associated memory.
+ *
+ * @param service The service.
+ */
+void
+GNUNET_DBUS_service_destroy (
+    struct GNUNET_DBUS_Service *service)
+{
+  dbus_connection_set_dispatch_status_function (service->conn, NULL, NULL, 
NULL);
+  dbus_connection_close (service->conn);
+  dbus_connection_unref (service->conn);
+
+  struct Watch *w = service->watches;
+  while (w)
+  {
+    struct Watch *next = w->next;
+    if (w->scheduled)
+    {
+      int err = watch_unschedule (w);
+      if (GNUNET_OK != err)
+        GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to unschedule watch 
that should have been scheduled while destroying service.\n");
+    };
+
+    GNUNET_free (w);
+    w = next;
+  };
+
+  struct Timeout *t = service->timeouts;
+  while (t)
+  {
+    struct Timeout *next = t->next;
+    if (t->scheduled)
+    {
+      int err = timeout_unschedule (t);
+      if (GNUNET_OK != err)
+        GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to unschedule timeout 
that should have been scheduled while destroying service.\n");
+    };
+    
+    GNUNET_free (t);
+    t = next;
+  };
+
+  GNUNET_free (service);
+};
+
+/*
+ * Called whenever a message arrives from DBus
+ *
+ * @param conn The connection it arrived on.
+ * @param message The message
+ * @param cls The closure passed to dbus_connection_try_register_object_path
+ *            in our case this is the GNUNET_DBUS_Object that the message was
+ *            sent to.
+ *
+ * @return DBUS_HANDLER_RESULT_NEED_MEMORY if anything failed due to lack of
+ *         memory.
+ *         DBUS_HANDLER_RESULT_HANDLED if any method returned a reply.
+ *         DBUS_HANDLER_RESULT_NOT_YET_HANDLED otherwise.
+ */
+DBusHandlerResult
+handle_object_message (
+    DBusConnection *conn,
+    DBusMessage *message,
+    void *cls)
+{
+  struct GNUNET_DBUS_Object *obj = (struct GNUNET_DBUS_Object *)cls;
+
+#if 1
+  const char *msg_path = dbus_message_get_path (message);
+  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_ERROR, "Recieved DBus message for %s\n", 
msg_path);
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "    type      == %s\n", type_string ? 
type_string : "(none)");
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "    interface == %s\n", interface   ? 
interface   : "(none)");
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "    member    == %s\n", member      ? 
member      : "(none)");
+#endif
+
+  int type = dbus_message_get_type (message);
+  if (type != DBUS_MESSAGE_TYPE_METHOD_CALL)
+    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+  struct Method *pos = obj->methods;
+  while (pos)
+  {
+    if (dbus_message_is_method_call (
+        message,
+        pos->interface,
+        pos->method_name))
+    {
+      DBusMessage *reply = pos->method (obj, message);
+      if (! reply)
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "method returned NULL. Out of 
memory.\n");
+        reply = dbus_message_new_error_printf (
+            message,
+            DBUS_ERROR_FAILED,
+            "Internal error. pos->method returned NULL.");
+      };
+      if (! dbus_message_get_no_reply (message))
+      {
+        dbus_bool_t succ = dbus_connection_send (conn, reply, NULL);
+        return succ ? DBUS_HANDLER_RESULT_HANDLED : 
DBUS_HANDLER_RESULT_NEED_MEMORY;
+      }
+      dbus_message_unref (reply);
+      return DBUS_HANDLER_RESULT_HANDLED;
+    };
+    pos = pos->next;
+  };
+
+  return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+};
+
+struct GNUNET_DBUS_Object *
+GNUNET_DBUS_object_create (
+    void *data)
+{
+  struct GNUNET_DBUS_Object *ret;
+  ret = GNUNET_new (struct GNUNET_DBUS_Object);
+  ret->data = data;
+  ret->methods = NULL;
+
+  return ret;
+};
+
+/*
+ * Destroys a GNUNET_DBUS_Object freeing it's memory.
+ * It is a bug to call this if the object is registered with any services.
+ *
+ * @param obj The object.
+ */
+void
+GNUNET_DBUS_object_destroy (
+    struct GNUNET_DBUS_Object *obj)
+{
+  struct Method *m = obj->methods;
+  while(m) {
+    struct Method *next = m->next;
+    GNUNET_free (m);
+    m = next;
+  };
+  GNUNET_free (obj);
+};
+
+void *
+GNUNET_DBUS_object_get_data (
+    struct GNUNET_DBUS_Object *obj)
+{
+  return obj->data;
+};
+
+int
+GNUNET_DBUS_service_register_object (
+    struct GNUNET_DBUS_Service *service,
+    struct GNUNET_DBUS_Object *obj,
+    const char *path)
+{
+  DBusError err;
+  dbus_error_init(&err);
+    
+  DBusObjectPathVTable vtable;
+  vtable.message_function = handle_object_message;
+  vtable.unregister_function = NULL;
+  dbus_bool_t succ = dbus_connection_try_register_object_path (
+      service->conn,
+      path,
+      &vtable,
+      obj,
+      &err);
+  if (dbus_error_is_set (&err))
+  {
+    GNUNET_log (
+        GNUNET_ERROR_TYPE_ERROR,
+        "dbus_connection_try_register failed to register path \"%s\": %s\n",
+          path,
+          err.message);
+    return GNUNET_SYSERR;
+  };
+  if (! succ)
+  {
+    GNUNET_log (
+        GNUNET_ERROR_TYPE_ERROR,
+        "dbus_connection_try_register returned false when registering path 
\"%s\"\n",
+          path);
+    return GNUNET_SYSERR;
+  };
+
+  return GNUNET_OK;
+};
+
+int
+GNUNET_DBUS_service_unregister_object (
+    struct GNUNET_DBUS_Service *service,
+    const char *path)
+{
+  dbus_bool_t succ = dbus_connection_unregister_object_path (service->conn, 
path);
+  if (! succ)
+  {
+    GNUNET_log (
+        GNUNET_ERROR_TYPE_ERROR,
+        "dbus_connection_unregister_object_path failed. Out of memory.\n");
+    return GNUNET_SYSERR;
+  };
+  return GNUNET_OK;
+};
+    
+
+int
+GNUNET_DBUS_object_add_method (
+    struct GNUNET_DBUS_Object *obj,
+    const char *interface,
+    const char *method_name,
+    GNUNET_DBUS_Method method)
+{
+  struct Method *add = GNUNET_new (struct Method);
+  if (NULL == add)
+    return GNUNET_SYSERR;
+
+  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;
+};
+

Added: gnunet-dbus/src/lib/gnunet_dbus_lib.h
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib.h                               (rev 0)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib.h       2013-12-24 03:07:27 UTC (rev 
31728)
@@ -0,0 +1,146 @@
+#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_Object;
+
+struct GNUNET_DBUS_StringEnumPair
+{
+  const char *name;
+  int value;
+};
+
+typedef DBusMessage *(*GNUNET_DBUS_Method) (
+    struct GNUNET_DBUS_Object *object,
+    DBusMessage *message);
+
+struct GNUNET_DBUS_Service *
+GNUNET_DBUS_service_create (
+    const char *service_name,
+    const struct GNUNET_CONFIGURATION_Handle *cfg);
+
+void
+GNUNET_DBUS_service_destroy (
+    struct GNUNET_DBUS_Service *service);
+
+struct GNUNET_DBUS_Object *
+GNUNET_DBUS_object_create (
+    void *data);
+
+void
+GNUNET_DBUS_object_destroy (
+    struct GNUNET_DBUS_Object *obj);
+
+void *
+GNUNET_DBUS_object_get_data (
+    struct GNUNET_DBUS_Object *obj);
+
+int
+GNUNET_DBUS_service_register_object (
+    struct GNUNET_DBUS_Service *service,
+    struct GNUNET_DBUS_Object *obj,
+    const char *path);
+
+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_bool (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    dbus_bool_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/lib/gnunet_dbus_lib_block.c
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_block.c                         (rev 0)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_block.c 2013-12-24 03:07:27 UTC (rev 
31728)
@@ -0,0 +1,59 @@
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_block_lib.h>
+
+#include "gnunet_dbus_lib.h"
+
+/*
+ * Pop a value of type GNUNET_BLOCK_Type from a DBusMessage
+ *
+ * @param message The message
+ * @param iter The iterator over the message. This will be advanced by one
+ *             argument
+ * @param arg_name The human-readable name of the argument. Used for producing
+ *                 error messages.
+ * @param value pointer to a location to store the GNUNET_BLOCK_Type
+ * 
+ * @return NULL on success, otherwise a pointer to a DBusMessage containing an
+ *         error reply that can be sent to a dbus client.
+ */
+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},
+      {NULL,             0}
+  };
+
+  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/lib/gnunet_dbus_lib_crypto.c
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_crypto.c                                
(rev 0)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_crypto.c        2013-12-24 03:07:27 UTC 
(rev 31728)
@@ -0,0 +1,32 @@
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_crypto_lib.h>
+
+#include "gnunet_dbus_lib.h"
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_ecdsa_public_key (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    struct GNUNET_CRYPTO_EcdsaPublicKey *key)
+{
+  const char *key_in;
+  DBusMessage *ret = GNUNET_DBUS_message_iter_pop_string (message, iter, 
arg_name, &key_in);
+  if (ret)
+    return ret;
+
+  int err = GNUNET_CRYPTO_ecdsa_public_key_from_string (key_in, strlen 
(key_in), key);
+  if (GNUNET_OK != err)
+  {
+    return dbus_message_new_error_printf (
+        message,
+        DBUS_ERROR_INVALID_ARGS,
+        "Bad argument for '%s'. Malformed ECDSA public key. 
GNUNET_CRYPTO_ecdsa_public_key_from_string returned %d",
+          arg_name,
+          err);
+  };
+
+  return NULL;
+};
+

Added: gnunet-dbus/src/lib/gnunet_dbus_lib_crypto.h
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_crypto.h                                
(rev 0)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_crypto.h        2013-12-24 03:07:27 UTC 
(rev 31728)
@@ -0,0 +1,12 @@
+#ifndef GNUNET_DBUS_LIB_CRYPTO_H
+#define GNUNET_DBUS_LIB_CRYPTO_H
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_ecdsa_public_key (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    struct GNUNET_CRYPTO_EcdsaPublicKey *key);
+
+#endif
+

Added: gnunet-dbus/src/lib/gnunet_dbus_lib_dht.c
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_dht.c                           (rev 0)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_dht.c   2013-12-24 03:07:27 UTC (rev 
31728)
@@ -0,0 +1,36 @@
+#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},
+      {NULL,                     0}
+  };
+
+  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/lib/gnunet_dbus_lib_pop.c
===================================================================
--- gnunet-dbus/src/lib/gnunet_dbus_lib_pop.c                           (rev 0)
+++ gnunet-dbus/src/lib/gnunet_dbus_lib_pop.c   2013-12-24 03:07:27 UTC (rev 
31728)
@@ -0,0 +1,362 @@
+#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"
+
+#include "dbus_type_to_string.h"
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_basic (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    int expected_type,
+    void *value)
+{
+  int arg_type = dbus_message_iter_get_arg_type (iter);
+  if (expected_type != arg_type)
+  {
+    return dbus_message_new_error_printf (
+        message,
+        DBUS_ERROR_INVALID_ARGS,
+        "Bad argument for '%s'. Expected %s. Got %s",
+          arg_name,
+          dbus_type_to_string (expected_type),
+          dbus_type_to_string (arg_type));
+  };
+  dbus_message_iter_get_basic (iter, value);
+  dbus_message_iter_next (iter);
+
+  return NULL;
+};
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_string (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    const char **value)
+{
+  return GNUNET_DBUS_message_iter_pop_basic (
+      message,
+      iter,
+      arg_name,
+      DBUS_TYPE_STRING,
+      (void *)value);
+};
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_uint32 (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    dbus_uint32_t *value)
+{
+  return GNUNET_DBUS_message_iter_pop_basic (
+      message,
+      iter,
+      arg_name,
+      DBUS_TYPE_UINT32,
+      (void *)value);
+};
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_bool (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    dbus_bool_t *value)
+{
+  return GNUNET_DBUS_message_iter_pop_basic (
+      message,
+      iter,
+      arg_name,
+      DBUS_TYPE_BOOLEAN,
+      (void *)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)
+{
+  int arg_type = dbus_message_iter_get_arg_type (iter);
+  if (DBUS_TYPE_ARRAY != arg_type)
+  {
+    return dbus_message_new_error_printf (
+        message,
+        DBUS_ERROR_INVALID_ARGS,
+        "Bad argument for '%s'. Expected %s. Got %s",
+          arg_name,
+          dbus_message_type_to_string (DBUS_TYPE_ARRAY),
+          dbus_message_type_to_string (arg_type));
+  };
+
+  int element_type = dbus_message_iter_get_element_type (iter);
+  if (expected_type != element_type)
+  {
+    return dbus_message_new_error_printf (
+        message,
+        DBUS_ERROR_INVALID_ARGS,
+        "Bad argument for '%s'. Expected array of %s. Got array of %s",
+          arg_name,
+          dbus_message_type_to_string (expected_type),
+          dbus_message_type_to_string (element_type));
+  };
+
+  DBusMessageIter itersub;
+  dbus_message_iter_recurse (iter, &itersub);
+  dbus_message_iter_get_fixed_array (&itersub, value, n_elements);
+
+  return NULL;
+};
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_array_byte (
+    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_BYTE,
+      (void *)value,
+      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
+ * efficient and is what libraries built around the DBus API would use, people
+ * using the DBus API directly may want to pass human-readable strings for
+ * convenience.
+ */
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_bitfield (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    int *value,
+    const struct GNUNET_DBUS_StringEnumPair *fields)
+{
+  uint32_t flags;
+  DBusMessage *ret = GNUNET_DBUS_message_iter_pop_uint32 (message, iter, 
arg_name, &flags);
+  if (! ret)
+  {
+    *value = (int)flags;
+    return NULL;
+  };
+  dbus_message_unref (ret);
+
+  const char **options;
+  int num_options;
+  ret = GNUNET_DBUS_message_iter_pop_array_string (message, iter, arg_name, 
&options, &num_options);
+  if (! ret)
+  {
+    *value = 0;
+    int i;
+    for (i = 0; i < num_options; i++)
+    {
+      int j;
+      for (j = 0; fields[j].name; j++)
+      {
+        if (! strcmp (options[i], fields[j].name))
+        {
+          *value |= fields[j].value;
+          break;
+        };
+      };
+      if (! fields[j].name)
+      {
+        size_t size = GNUNET_XSTRING_NEW_DEFAULT_SIZE;
+        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_appendf (&errmsg, &size, "%s'%s'", j ? ", " : "", 
fields[j].name);
+        GNUNET_XSTRING_append (&errmsg, &size, "].");
+        ret = dbus_message_new_error_printf (
+            message,
+            DBUS_ERROR_INVALID_ARGS,
+            "%s",
+              errmsg);
+        GNUNET_free (errmsg);
+        return ret;
+      };
+    };
+
+    return NULL;
+  };
+  dbus_message_unref (ret);
+
+  return dbus_message_new_error_printf (
+      message,
+      DBUS_ERROR_INVALID_ARGS,
+      "Bad argument for '%s'. Expected either a bitfield uint32 or an array of 
string options.",
+        arg_name);
+};
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_enum (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    int *value,
+    const struct GNUNET_DBUS_StringEnumPair *names)
+{
+  uint32_t v;
+  DBusMessage *ret = GNUNET_DBUS_message_iter_pop_uint32 (message, iter, 
arg_name, &v);
+  if (! ret)
+  {
+    *value = (int)v;
+    return NULL;
+  };
+  dbus_message_unref (ret);
+
+  const char *name;
+  ret = GNUNET_DBUS_message_iter_pop_string (message, iter, arg_name, &name);
+  if (! ret)
+  {
+    int i;
+    for (i = 0; names[i].name; i++)
+    {
+      if (! strcmp (name, names[i].name))
+      {
+        *value = names[i].value;
+        break;
+      };
+    };
+    if (! names[i].name)
+    {
+      size_t size = GNUNET_XSTRING_NEW_DEFAULT_SIZE;
+      char *errmsg = GNUNET_XSTRING_new ();
+      GNUNET_XSTRING_appendf (&errmsg, &size, "Unrecognized option '%s'. Valid 
options are: [", name);
+      for (i = 0; names[i].name; i++)
+        GNUNET_XSTRING_appendf (&errmsg, &size, "%s'%s'", i ? ", " : "", 
names[i].name);
+      GNUNET_XSTRING_append (&errmsg, &size, "].");
+      ret = dbus_message_new_error_printf (
+          message,
+          DBUS_ERROR_INVALID_ARGS,
+          "%s",
+            errmsg);
+      GNUNET_free (errmsg);
+      return ret;
+    };
+    return NULL;
+  };
+  dbus_message_unref (ret);
+  
+  return dbus_message_new_error_printf (
+      message,
+      DBUS_ERROR_INVALID_ARGS,
+      "Bad argument for '%s'. Expected either a uint32 or a string option",
+        arg_name);
+};
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_hashcode (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    struct GNUNET_HashCode *hc)
+{
+  const char *hc_in;
+  DBusMessage *ret = GNUNET_DBUS_message_iter_pop_string (message, iter, 
arg_name, &hc_in);
+  if (ret)
+    return ret;
+
+  int err = GNUNET_CRYPTO_hash_from_string2 (hc_in, strlen(hc_in), hc);
+  if (GNUNET_OK != err)
+  {
+    return dbus_message_new_error_printf (
+        message,
+        DBUS_ERROR_INVALID_ARGS,
+        "Bad argument for '%s'. Malformed hash string. 
GNUNET_CRYPTO_hash_from_string2 returned %d",
+          arg_name,
+          err);
+  };
+
+  return NULL;
+};
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_socket (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    struct GNUNET_NETWORK_Handle **socket_handle)
+{
+  const char *address;
+
+  DBusMessage *ret = GNUNET_DBUS_message_iter_pop_string (message, iter, 
arg_name, &address);
+  if (ret)
+    return ret;
+
+  *socket_handle = GNUNET_DBUS_create_socket_from_dbus_address (address);
+  if (! *socket_handle)
+  {
+    return dbus_message_new_error_printf (
+        message,
+        DBUS_ERROR_INVALID_ARGS,
+        "Bad argument for '%s'. Malformed address",
+          arg_name);
+  };
+
+  return NULL;
+};
+
+DBusMessage *
+GNUNET_DBUS_message_iter_pop_absolute_time (
+    DBusMessage *message,
+    DBusMessageIter *iter,
+    const char *arg_name,
+    struct GNUNET_TIME_Absolute *value)
+{
+  const char *time;
+  DBusMessage *ret = GNUNET_DBUS_message_iter_pop_string (message, iter, 
arg_name, &time);
+  if (ret)
+    return ret;
+
+  int err = GNUNET_STRINGS_fancy_time_to_absolute (time, value);
+  if (GNUNET_OK != err)
+  {
+    return dbus_message_new_error_printf (
+        message,
+        DBUS_ERROR_INVALID_ARGS,
+        "Bad argument for '%s'. Malformed time string. 
GNUNET_STRINGS_fancy_time_to_absolute returned %d",
+          arg_name,
+          err);
+  };
+
+  return NULL;
+};
+
+

Added: gnunet-dbus/src/lib/gnunet_xstring_lib.c
===================================================================
--- gnunet-dbus/src/lib/gnunet_xstring_lib.c                            (rev 0)
+++ gnunet-dbus/src/lib/gnunet_xstring_lib.c    2013-12-24 03:07:27 UTC (rev 
31728)
@@ -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/lib/gnunet_xstring_lib.h
===================================================================
--- gnunet-dbus/src/lib/gnunet_xstring_lib.h                            (rev 0)
+++ gnunet-dbus/src/lib/gnunet_xstring_lib.h    2013-12-24 03:07:27 UTC (rev 
31728)
@@ -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
+




reply via email to

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