fix #1746
authorChristian Grothoff <christian@grothoff.org>
Thu, 3 Nov 2011 20:41:05 +0000 (20:41 +0000)
committerChristian Grothoff <christian@grothoff.org>
Thu, 3 Nov 2011 20:41:05 +0000 (20:41 +0000)
TODO
src/block/Makefile.am
src/block/block.c
src/block/block.conf [deleted file]

diff --git a/TODO b/TODO
index 5d81b35d81901d81bf05e6367adf6580fa55a3b3..3607193e34fd9f0e3eb99abc13447b3eb04a9632 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,9 +1,7 @@
-0.9.0pre4:
+0.9.0:
 * GNUNET-GTK: [CG]
   - provide context menus to allow aborts of downloads/uploads
   - provide way to handle errors (search, download, publish errors)
-
-0.9.0:
 * new webpage:
   - write chapter on DHT/block [Nate] 
   - make a NICE download page 
@@ -17,6 +15,8 @@
     + insert
     + download
     + search
+* blocks:
+  + should block plugins live in block/ or with fs/dht/vpn?
 
 0.9.1:
 * TRANSPORT: [MW]
@@ -24,7 +24,7 @@
     queue of size > 2), might be better to have at MOST one message pending
     per plugin/target and only send the next one after the continuation was
     called (or use 'notify_transmit_ready-style API?)
-  - WLAN transport backend [DB]
+  - WLAN transport backend (code cleanup) [MW]
   - need to periodically probe latency/transport cost changes & possibly switch transport 
     (working ATS)
 * DV: 
index 96b66c3eebfa6a205959ba06e49917f78c6b5454..5549104e0dee56c10853426f5560194b7d35aa3d 100644 (file)
@@ -2,11 +2,6 @@ INCLUDES = -I$(top_srcdir)/src/include
 
 plugindir = $(libdir)/gnunet
 
-pkgcfgdir= $(pkgdatadir)/config.d/
-
-dist_pkgcfg_DATA = \
-  block.conf
-
 if MINGW
   WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols
 endif
@@ -45,7 +40,7 @@ libgnunet_plugin_block_fs_la_LDFLAGS = \
  $(GN_PLUGIN_LDFLAGS)
 libgnunet_plugin_block_fs_la_DEPENDENCIES = \
   libgnunetblock.la
-                                           
+
 
 libgnunet_plugin_block_dns_la_SOURCES = \
   plugin_block_dns.c
index 8efb0d477ba25c8d163828c6cc5115c06f823fc3..582c13eb3d9156e9c491dcbc013f3f3a03ccdf74 100644 (file)
@@ -54,10 +54,15 @@ struct Plugin
 struct GNUNET_BLOCK_Context
 {
   /**
-   * NULL-terminated array of our plugins.
+   * Array of our plugins.
    */
   struct Plugin **plugins;
 
+  /**
+   * Size of the 'plugins' array.
+   */
+  unsigned int num_plugins;
+
   /**
    * Our configuration.
    */
@@ -83,6 +88,33 @@ GNUNET_BLOCK_mingle_hash (const GNUNET_HashCode * in, uint32_t mingle_number,
 }
 
 
+/**
+ * Add a plugin to the list managed by the block library.
+ *
+ * @param cls the block context
+ * @param library_name name of the plugin
+ * @param lib_ret the plugin API
+ */
+static void
+add_plugin (void *cls,
+           const char *library_name,
+           void *lib_ret)
+{
+  struct GNUNET_BLOCK_Context *ctx = cls;
+  struct GNUNET_BLOCK_PluginFunctions *api = lib_ret;
+  struct Plugin *plugin;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, 
+             _("Loading block plugin `%s'\n"),
+             library_name);
+  plugin = GNUNET_malloc (sizeof (struct Plugin));
+  plugin->api = api;
+  plugin->library_name = GNUNET_strdup (library_name);
+  GNUNET_array_append (ctx->plugins, ctx->num_plugins, plugin);
+}
+
+
+
 /**
  * Create a block context.  Loads the block plugins.
  *
@@ -93,44 +125,13 @@ struct GNUNET_BLOCK_Context *
 GNUNET_BLOCK_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct GNUNET_BLOCK_Context *ctx;
-  struct GNUNET_BLOCK_PluginFunctions *api;
-  struct Plugin *plugin;
-  unsigned int num_plugins;
-  char *plugs;
-  char *pos;
-  char *libname;
 
   ctx = GNUNET_malloc (sizeof (struct GNUNET_BLOCK_Context));
   ctx->cfg = cfg;
-  num_plugins = 0;
-  if (GNUNET_OK ==
-      GNUNET_CONFIGURATION_get_value_string (cfg, "block", "PLUGINS", &plugs))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading block plugins `%s'\n"),
-                plugs);
-    pos = strtok (plugs, " ");
-    while (pos != NULL)
-    {
-      GNUNET_asprintf (&libname, "libgnunet_plugin_block_%s", pos);
-      api = GNUNET_PLUGIN_load (libname, NULL);
-      if (api == NULL)
-      {
-        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                    _("Failed to load block plugin `%s'\n"), pos);
-        GNUNET_free (libname);
-      }
-      else
-      {
-        plugin = GNUNET_malloc (sizeof (struct Plugin));
-        plugin->api = api;
-        plugin->library_name = libname;
-        GNUNET_array_append (ctx->plugins, num_plugins, plugin);
-      }
-      pos = strtok (NULL, " ");
-    }
-    GNUNET_free (plugs);
-  }
-  GNUNET_array_append (ctx->plugins, num_plugins, NULL);
+  GNUNET_PLUGIN_load_all ("libgnunet_plugin_block_",
+                         NULL,
+                         &add_plugin,
+                         ctx);
   return ctx;
 }
 
@@ -146,14 +147,13 @@ GNUNET_BLOCK_context_destroy (struct GNUNET_BLOCK_Context *ctx)
   unsigned int i;
   struct Plugin *plugin;
 
-  i = 0;
-  while (NULL != (plugin = ctx->plugins[i]))
+  for (i = 0; i<ctx->num_plugins;i++)
   {
+    plugin = ctx->plugins[i];
     GNUNET_break (NULL ==
                   GNUNET_PLUGIN_unload (plugin->library_name, plugin->api));
     GNUNET_free (plugin->library_name);
     GNUNET_free (plugin);
-    i++;
   }
   GNUNET_free (ctx->plugins);
   GNUNET_free (ctx);
@@ -174,9 +174,9 @@ find_plugin (struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type)
   unsigned int i;
   unsigned int j;
 
-  i = 0;
-  while (NULL != (plugin = ctx->plugins[i]))
+  for (i=0;i<ctx->num_plugins;i++)
   {
+    plugin = ctx->plugins[i];
     j = 0;
     while (0 != (plugin->api->types[j]))
     {
@@ -184,7 +184,6 @@ find_plugin (struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type)
         return plugin->api;
       j++;
     }
-    i++;
   }
   return NULL;
 }
diff --git a/src/block/block.conf b/src/block/block.conf
deleted file mode 100644 (file)
index dbae438..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-[block]
-PLUGINS = fs dht test dns
\ No newline at end of file