summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-03 20:41:05 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-03 20:41:05 +0000
commitf9b6dfb41e151628673595fd880318ec502ae4ed (patch)
tree5eae6a86b2eb69f3b0405fa79a950deda232a0be
parent229ebca4f9566b5f46beff710e88ffc45c89787e (diff)
fix #1746
-rw-r--r--TODO8
-rw-r--r--src/block/Makefile.am7
-rw-r--r--src/block/block.c83
-rw-r--r--src/block/block.conf2
4 files changed, 46 insertions, 54 deletions
diff --git a/TODO b/TODO
index 5d81b35d8..3607193e3 100644
--- 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:
diff --git a/src/block/Makefile.am b/src/block/Makefile.am
index 96b66c3ee..5549104e0 100644
--- a/src/block/Makefile.am
+++ b/src/block/Makefile.am
@@ -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
diff --git a/src/block/block.c b/src/block/block.c
index 8efb0d477..582c13eb3 100644
--- a/src/block/block.c
+++ b/src/block/block.c
@@ -54,11 +54,16 @@ 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.
*/
const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -84,6 +89,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.
*
* @param cfg configuration to use
@@ -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
index dbae438b7..000000000
--- a/src/block/block.conf
+++ /dev/null
@@ -1,2 +0,0 @@
-[block]
-PLUGINS = fs dht test dns \ No newline at end of file