aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 @@
10.9.0pre4: 10.9.0:
2* GNUNET-GTK: [CG] 2* GNUNET-GTK: [CG]
3 - provide context menus to allow aborts of downloads/uploads 3 - provide context menus to allow aborts of downloads/uploads
4 - provide way to handle errors (search, download, publish errors) 4 - provide way to handle errors (search, download, publish errors)
5
60.9.0:
7* new webpage: 5* new webpage:
8 - write chapter on DHT/block [Nate] 6 - write chapter on DHT/block [Nate]
9 - make a NICE download page 7 - make a NICE download page
@@ -17,6 +15,8 @@
17 + insert 15 + insert
18 + download 16 + download
19 + search 17 + search
18* blocks:
19 + should block plugins live in block/ or with fs/dht/vpn?
20 20
210.9.1: 210.9.1:
22* TRANSPORT: [MW] 22* TRANSPORT: [MW]
@@ -24,7 +24,7 @@
24 queue of size > 2), might be better to have at MOST one message pending 24 queue of size > 2), might be better to have at MOST one message pending
25 per plugin/target and only send the next one after the continuation was 25 per plugin/target and only send the next one after the continuation was
26 called (or use 'notify_transmit_ready-style API?) 26 called (or use 'notify_transmit_ready-style API?)
27 - WLAN transport backend [DB] 27 - WLAN transport backend (code cleanup) [MW]
28 - need to periodically probe latency/transport cost changes & possibly switch transport 28 - need to periodically probe latency/transport cost changes & possibly switch transport
29 (working ATS) 29 (working ATS)
30* DV: 30* 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
2 2
3plugindir = $(libdir)/gnunet 3plugindir = $(libdir)/gnunet
4 4
5pkgcfgdir= $(pkgdatadir)/config.d/
6
7dist_pkgcfg_DATA = \
8 block.conf
9
10if MINGW 5if MINGW
11 WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols 6 WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols
12endif 7endif
@@ -45,7 +40,7 @@ libgnunet_plugin_block_fs_la_LDFLAGS = \
45 $(GN_PLUGIN_LDFLAGS) 40 $(GN_PLUGIN_LDFLAGS)
46libgnunet_plugin_block_fs_la_DEPENDENCIES = \ 41libgnunet_plugin_block_fs_la_DEPENDENCIES = \
47 libgnunetblock.la 42 libgnunetblock.la
48 43
49 44
50libgnunet_plugin_block_dns_la_SOURCES = \ 45libgnunet_plugin_block_dns_la_SOURCES = \
51 plugin_block_dns.c 46 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
54struct GNUNET_BLOCK_Context 54struct GNUNET_BLOCK_Context
55{ 55{
56 /** 56 /**
57 * NULL-terminated array of our plugins. 57 * Array of our plugins.
58 */ 58 */
59 struct Plugin **plugins; 59 struct Plugin **plugins;
60 60
61 /** 61 /**
62 * Size of the 'plugins' array.
63 */
64 unsigned int num_plugins;
65
66 /**
62 * Our configuration. 67 * Our configuration.
63 */ 68 */
64 const struct GNUNET_CONFIGURATION_Handle *cfg; 69 const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -84,6 +89,33 @@ GNUNET_BLOCK_mingle_hash (const GNUNET_HashCode * in, uint32_t mingle_number,
84 89
85 90
86/** 91/**
92 * Add a plugin to the list managed by the block library.
93 *
94 * @param cls the block context
95 * @param library_name name of the plugin
96 * @param lib_ret the plugin API
97 */
98static void
99add_plugin (void *cls,
100 const char *library_name,
101 void *lib_ret)
102{
103 struct GNUNET_BLOCK_Context *ctx = cls;
104 struct GNUNET_BLOCK_PluginFunctions *api = lib_ret;
105 struct Plugin *plugin;
106
107 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
108 _("Loading block plugin `%s'\n"),
109 library_name);
110 plugin = GNUNET_malloc (sizeof (struct Plugin));
111 plugin->api = api;
112 plugin->library_name = GNUNET_strdup (library_name);
113 GNUNET_array_append (ctx->plugins, ctx->num_plugins, plugin);
114}
115
116
117
118/**
87 * Create a block context. Loads the block plugins. 119 * Create a block context. Loads the block plugins.
88 * 120 *
89 * @param cfg configuration to use 121 * @param cfg configuration to use
@@ -93,44 +125,13 @@ struct GNUNET_BLOCK_Context *
93GNUNET_BLOCK_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg) 125GNUNET_BLOCK_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg)
94{ 126{
95 struct GNUNET_BLOCK_Context *ctx; 127 struct GNUNET_BLOCK_Context *ctx;
96 struct GNUNET_BLOCK_PluginFunctions *api;
97 struct Plugin *plugin;
98 unsigned int num_plugins;
99 char *plugs;
100 char *pos;
101 char *libname;
102 128
103 ctx = GNUNET_malloc (sizeof (struct GNUNET_BLOCK_Context)); 129 ctx = GNUNET_malloc (sizeof (struct GNUNET_BLOCK_Context));
104 ctx->cfg = cfg; 130 ctx->cfg = cfg;
105 num_plugins = 0; 131 GNUNET_PLUGIN_load_all ("libgnunet_plugin_block_",
106 if (GNUNET_OK == 132 NULL,
107 GNUNET_CONFIGURATION_get_value_string (cfg, "block", "PLUGINS", &plugs)) 133 &add_plugin,
108 { 134 ctx);
109 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading block plugins `%s'\n"),
110 plugs);
111 pos = strtok (plugs, " ");
112 while (pos != NULL)
113 {
114 GNUNET_asprintf (&libname, "libgnunet_plugin_block_%s", pos);
115 api = GNUNET_PLUGIN_load (libname, NULL);
116 if (api == NULL)
117 {
118 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
119 _("Failed to load block plugin `%s'\n"), pos);
120 GNUNET_free (libname);
121 }
122 else
123 {
124 plugin = GNUNET_malloc (sizeof (struct Plugin));
125 plugin->api = api;
126 plugin->library_name = libname;
127 GNUNET_array_append (ctx->plugins, num_plugins, plugin);
128 }
129 pos = strtok (NULL, " ");
130 }
131 GNUNET_free (plugs);
132 }
133 GNUNET_array_append (ctx->plugins, num_plugins, NULL);
134 return ctx; 135 return ctx;
135} 136}
136 137
@@ -146,14 +147,13 @@ GNUNET_BLOCK_context_destroy (struct GNUNET_BLOCK_Context *ctx)
146 unsigned int i; 147 unsigned int i;
147 struct Plugin *plugin; 148 struct Plugin *plugin;
148 149
149 i = 0; 150 for (i = 0; i<ctx->num_plugins;i++)
150 while (NULL != (plugin = ctx->plugins[i]))
151 { 151 {
152 plugin = ctx->plugins[i];
152 GNUNET_break (NULL == 153 GNUNET_break (NULL ==
153 GNUNET_PLUGIN_unload (plugin->library_name, plugin->api)); 154 GNUNET_PLUGIN_unload (plugin->library_name, plugin->api));
154 GNUNET_free (plugin->library_name); 155 GNUNET_free (plugin->library_name);
155 GNUNET_free (plugin); 156 GNUNET_free (plugin);
156 i++;
157 } 157 }
158 GNUNET_free (ctx->plugins); 158 GNUNET_free (ctx->plugins);
159 GNUNET_free (ctx); 159 GNUNET_free (ctx);
@@ -174,9 +174,9 @@ find_plugin (struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type)
174 unsigned int i; 174 unsigned int i;
175 unsigned int j; 175 unsigned int j;
176 176
177 i = 0; 177 for (i=0;i<ctx->num_plugins;i++)
178 while (NULL != (plugin = ctx->plugins[i]))
179 { 178 {
179 plugin = ctx->plugins[i];
180 j = 0; 180 j = 0;
181 while (0 != (plugin->api->types[j])) 181 while (0 != (plugin->api->types[j]))
182 { 182 {
@@ -184,7 +184,6 @@ find_plugin (struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type)
184 return plugin->api; 184 return plugin->api;
185 j++; 185 j++;
186 } 186 }
187 i++;
188 } 187 }
189 return NULL; 188 return NULL;
190} 189}
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 @@
1[block]
2PLUGINS = fs dht test dns \ No newline at end of file