diff options
Diffstat (limited to 'src/util/plugin.c')
-rw-r--r-- | src/util/plugin.c | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/util/plugin.c b/src/util/plugin.c index 4b922340d..19169f070 100644 --- a/src/util/plugin.c +++ b/src/util/plugin.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <ltdl.h> | 28 | #include <ltdl.h> |
29 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
30 | 30 | ||
31 | #define LOG(kind,...) GNUNET_log_from (kind, "util-plugin", __VA_ARGS__) | 31 | #define LOG(kind, ...) GNUNET_log_from (kind, "util-plugin", __VA_ARGS__) |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * Linked list of active plugins. | 34 | * Linked list of active plugins. |
@@ -82,8 +82,8 @@ plugin_init () | |||
82 | err = lt_dlinit (); | 82 | err = lt_dlinit (); |
83 | if (err > 0) | 83 | if (err > 0) |
84 | { | 84 | { |
85 | FPRINTF (stderr, | 85 | fprintf (stderr, |
86 | _("Initialization of plugin mechanism failed: %s!\n"), | 86 | _ ("Initialization of plugin mechanism failed: %s!\n"), |
87 | lt_dlerror ()); | 87 | lt_dlerror ()); |
88 | return; | 88 | return; |
89 | } | 89 | } |
@@ -133,24 +133,21 @@ plugin_fini () | |||
133 | * @return NULL if the symbol was not found | 133 | * @return NULL if the symbol was not found |
134 | */ | 134 | */ |
135 | static GNUNET_PLUGIN_Callback | 135 | static GNUNET_PLUGIN_Callback |
136 | resolve_function (struct PluginList *plug, | 136 | resolve_function (struct PluginList *plug, const char *name) |
137 | const char *name) | ||
138 | { | 137 | { |
139 | char *initName; | 138 | char *initName; |
140 | void *mptr; | 139 | void *mptr; |
141 | 140 | ||
142 | GNUNET_asprintf (&initName, | 141 | GNUNET_asprintf (&initName, "_%s_%s", plug->name, name); |
143 | "_%s_%s", | ||
144 | plug->name, | ||
145 | name); | ||
146 | mptr = lt_dlsym (plug->handle, &initName[1]); | 142 | mptr = lt_dlsym (plug->handle, &initName[1]); |
147 | if (NULL == mptr) | 143 | if (NULL == mptr) |
148 | mptr = lt_dlsym (plug->handle, initName); | 144 | mptr = lt_dlsym (plug->handle, initName); |
149 | if (NULL == mptr) | 145 | if (NULL == mptr) |
150 | LOG (GNUNET_ERROR_TYPE_ERROR, | 146 | LOG (GNUNET_ERROR_TYPE_ERROR, |
151 | _("`%s' failed to resolve method '%s' with error: %s\n"), | 147 | _ ("`%s' failed to resolve method '%s' with error: %s\n"), |
152 | "lt_dlsym", | 148 | "lt_dlsym", |
153 | &initName[1], lt_dlerror ()); | 149 | &initName[1], |
150 | lt_dlerror ()); | ||
154 | GNUNET_free (initName); | 151 | GNUNET_free (initName); |
155 | return mptr; | 152 | return mptr; |
156 | } | 153 | } |
@@ -214,7 +211,7 @@ GNUNET_PLUGIN_load (const char *library_name, void *arg) | |||
214 | GNUNET_PLUGIN_Callback init; | 211 | GNUNET_PLUGIN_Callback init; |
215 | void *ret; | 212 | void *ret; |
216 | 213 | ||
217 | if (!initialized) | 214 | if (! initialized) |
218 | { | 215 | { |
219 | initialized = GNUNET_YES; | 216 | initialized = GNUNET_YES; |
220 | plugin_init (); | 217 | plugin_init (); |
@@ -223,9 +220,10 @@ GNUNET_PLUGIN_load (const char *library_name, void *arg) | |||
223 | if (libhandle == NULL) | 220 | if (libhandle == NULL) |
224 | { | 221 | { |
225 | LOG (GNUNET_ERROR_TYPE_ERROR, | 222 | LOG (GNUNET_ERROR_TYPE_ERROR, |
226 | _("`%s' failed for library `%s' with error: %s\n"), | 223 | _ ("`%s' failed for library `%s' with error: %s\n"), |
227 | "lt_dlopenext", | 224 | "lt_dlopenext", |
228 | library_name, lt_dlerror ()); | 225 | library_name, |
226 | lt_dlerror ()); | ||
229 | return NULL; | 227 | return NULL; |
230 | } | 228 | } |
231 | plug = GNUNET_new (struct PluginList); | 229 | plug = GNUNET_new (struct PluginList); |
@@ -255,8 +253,7 @@ GNUNET_PLUGIN_load (const char *library_name, void *arg) | |||
255 | * @return whatever the shutdown function returned | 253 | * @return whatever the shutdown function returned |
256 | */ | 254 | */ |
257 | void * | 255 | void * |
258 | GNUNET_PLUGIN_unload (const char *library_name, | 256 | GNUNET_PLUGIN_unload (const char *library_name, void *arg) |
259 | void *arg) | ||
260 | { | 257 | { |
261 | struct PluginList *pos; | 258 | struct PluginList *pos; |
262 | struct PluginList *prev; | 259 | struct PluginList *prev; |
@@ -345,9 +342,9 @@ find_libraries (void *cls, const char *filename) | |||
345 | libname = slashpos + 1; | 342 | libname = slashpos + 1; |
346 | n = strlen (libname); | 343 | n = strlen (libname); |
347 | if (0 != strncmp (lac->basename, libname, strlen (lac->basename))) | 344 | if (0 != strncmp (lac->basename, libname, strlen (lac->basename))) |
348 | return GNUNET_OK; /* wrong name */ | 345 | return GNUNET_OK; /* wrong name */ |
349 | if ((n > 3) && (0 == strcmp (&libname[n - 3], ".la"))) | 346 | if ((n > 3) && (0 == strcmp (&libname[n - 3], ".la"))) |
350 | return GNUNET_OK; /* .la file */ | 347 | return GNUNET_OK; /* .la file */ |
351 | basename = GNUNET_strdup (libname); | 348 | basename = GNUNET_strdup (libname); |
352 | if (NULL != (dot = strstr (basename, "."))) | 349 | if (NULL != (dot = strstr (basename, "."))) |
353 | *dot = '\0'; | 350 | *dot = '\0'; |
@@ -372,8 +369,10 @@ find_libraries (void *cls, const char *filename) | |||
372 | * @param cb_cls closure for @a cb | 369 | * @param cb_cls closure for @a cb |
373 | */ | 370 | */ |
374 | void | 371 | void |
375 | GNUNET_PLUGIN_load_all (const char *basename, void *arg, | 372 | GNUNET_PLUGIN_load_all (const char *basename, |
376 | GNUNET_PLUGIN_LoaderCallback cb, void *cb_cls) | 373 | void *arg, |
374 | GNUNET_PLUGIN_LoaderCallback cb, | ||
375 | void *cb_cls) | ||
377 | { | 376 | { |
378 | struct LoadAllContext lac; | 377 | struct LoadAllContext lac; |
379 | char *path; | 378 | char *path; |
@@ -382,7 +381,7 @@ GNUNET_PLUGIN_load_all (const char *basename, void *arg, | |||
382 | if (NULL == path) | 381 | if (NULL == path) |
383 | { | 382 | { |
384 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 383 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
385 | _("Could not determine plugin installation path.\n")); | 384 | _ ("Could not determine plugin installation path.\n")); |
386 | return; | 385 | return; |
387 | } | 386 | } |
388 | lac.basename = basename; | 387 | lac.basename = basename; |