diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-10-11 09:43:04 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-10-11 09:43:04 +0000 |
commit | d9d94d0e53d26af75ec8241383d166544ebd79f3 (patch) | |
tree | 9080b73624389403a198257fe0547bb4634e64d2 /src/util/plugin.c | |
parent | 2d792ee2e9cc0c993b8907e2c8edb0c2b8465343 (diff) | |
download | gnunet-d9d94d0e53d26af75ec8241383d166544ebd79f3.tar.gz gnunet-d9d94d0e53d26af75ec8241383d166544ebd79f3.zip |
converting to GNUNET_LOG_from*
Diffstat (limited to 'src/util/plugin.c')
-rw-r--r-- | src/util/plugin.c | 118 |
1 files changed, 60 insertions, 58 deletions
diff --git a/src/util/plugin.c b/src/util/plugin.c index dbd3519aa..77631410c 100644 --- a/src/util/plugin.c +++ b/src/util/plugin.c | |||
@@ -30,6 +30,8 @@ | |||
30 | #include "gnunet_os_lib.h" | 30 | #include "gnunet_os_lib.h" |
31 | #include "gnunet_plugin_lib.h" | 31 | #include "gnunet_plugin_lib.h" |
32 | 32 | ||
33 | #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) | ||
34 | |||
33 | /** | 35 | /** |
34 | * Linked list of active plugins. | 36 | * Linked list of active plugins. |
35 | */ | 37 | */ |
@@ -83,30 +85,30 @@ plugin_init () | |||
83 | 85 | ||
84 | err = lt_dlinit (); | 86 | err = lt_dlinit (); |
85 | if (err > 0) | 87 | if (err > 0) |
86 | { | 88 | { |
87 | fprintf (stderr, _("Initialization of plugin mechanism failed: %s!\n"), | 89 | fprintf (stderr, _("Initialization of plugin mechanism failed: %s!\n"), |
88 | lt_dlerror ()); | 90 | lt_dlerror ()); |
89 | return; | 91 | return; |
90 | } | 92 | } |
91 | opath = lt_dlgetsearchpath (); | 93 | opath = lt_dlgetsearchpath (); |
92 | if (opath != NULL) | 94 | if (opath != NULL) |
93 | old_dlsearchpath = GNUNET_strdup (opath); | 95 | old_dlsearchpath = GNUNET_strdup (opath); |
94 | path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LIBDIR); | 96 | path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LIBDIR); |
95 | if (path != NULL) | 97 | if (path != NULL) |
96 | { | ||
97 | if (opath != NULL) | ||
98 | { | 98 | { |
99 | GNUNET_asprintf (&cpath, "%s:%s", opath, path); | 99 | if (opath != NULL) |
100 | lt_dlsetsearchpath (cpath); | 100 | { |
101 | GNUNET_free (path); | 101 | GNUNET_asprintf (&cpath, "%s:%s", opath, path); |
102 | GNUNET_free (cpath); | 102 | lt_dlsetsearchpath (cpath); |
103 | GNUNET_free (path); | ||
104 | GNUNET_free (cpath); | ||
105 | } | ||
106 | else | ||
107 | { | ||
108 | lt_dlsetsearchpath (path); | ||
109 | GNUNET_free (path); | ||
110 | } | ||
103 | } | 111 | } |
104 | else | ||
105 | { | ||
106 | lt_dlsetsearchpath (path); | ||
107 | GNUNET_free (path); | ||
108 | } | ||
109 | } | ||
110 | } | 112 | } |
111 | 113 | ||
112 | 114 | ||
@@ -118,10 +120,10 @@ plugin_fini () | |||
118 | { | 120 | { |
119 | lt_dlsetsearchpath (old_dlsearchpath); | 121 | lt_dlsetsearchpath (old_dlsearchpath); |
120 | if (old_dlsearchpath != NULL) | 122 | if (old_dlsearchpath != NULL) |
121 | { | 123 | { |
122 | GNUNET_free (old_dlsearchpath); | 124 | GNUNET_free (old_dlsearchpath); |
123 | old_dlsearchpath = NULL; | 125 | old_dlsearchpath = NULL; |
124 | } | 126 | } |
125 | lt_dlexit (); | 127 | lt_dlexit (); |
126 | } | 128 | } |
127 | 129 | ||
@@ -140,9 +142,9 @@ resolve_function (struct PluginList *plug, const char *name) | |||
140 | if (mptr == NULL) | 142 | if (mptr == NULL) |
141 | mptr = lt_dlsym (plug->handle, initName); | 143 | mptr = lt_dlsym (plug->handle, initName); |
142 | if (mptr == NULL) | 144 | if (mptr == NULL) |
143 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 145 | LOG (GNUNET_ERROR_TYPE_ERROR, |
144 | _("`%s' failed to resolve method '%s' with error: %s\n"), | 146 | _("`%s' failed to resolve method '%s' with error: %s\n"), |
145 | "lt_dlsym", &initName[1], lt_dlerror ()); | 147 | "lt_dlsym", &initName[1], lt_dlerror ()); |
146 | GNUNET_free (initName); | 148 | GNUNET_free (initName); |
147 | return mptr; | 149 | return mptr; |
148 | } | 150 | } |
@@ -164,10 +166,10 @@ GNUNET_PLUGIN_test (const char *library_name) | |||
164 | struct PluginList plug; | 166 | struct PluginList plug; |
165 | 167 | ||
166 | if (!initialized) | 168 | if (!initialized) |
167 | { | 169 | { |
168 | initialized = GNUNET_YES; | 170 | initialized = GNUNET_YES; |
169 | plugin_init (); | 171 | plugin_init (); |
170 | } | 172 | } |
171 | libhandle = lt_dlopenext (library_name); | 173 | libhandle = lt_dlopenext (library_name); |
172 | if (libhandle == NULL) | 174 | if (libhandle == NULL) |
173 | return GNUNET_NO; | 175 | return GNUNET_NO; |
@@ -175,11 +177,11 @@ GNUNET_PLUGIN_test (const char *library_name) | |||
175 | plug.name = (char *) library_name; | 177 | plug.name = (char *) library_name; |
176 | init = resolve_function (&plug, "init"); | 178 | init = resolve_function (&plug, "init"); |
177 | if (init == NULL) | 179 | if (init == NULL) |
178 | { | 180 | { |
179 | GNUNET_break (0); | 181 | GNUNET_break (0); |
180 | lt_dlclose (libhandle); | 182 | lt_dlclose (libhandle); |
181 | return GNUNET_NO; | 183 | return GNUNET_NO; |
182 | } | 184 | } |
183 | lt_dlclose (libhandle); | 185 | lt_dlclose (libhandle); |
184 | return GNUNET_YES; | 186 | return GNUNET_YES; |
185 | } | 187 | } |
@@ -206,18 +208,18 @@ GNUNET_PLUGIN_load (const char *library_name, void *arg) | |||
206 | void *ret; | 208 | void *ret; |
207 | 209 | ||
208 | if (!initialized) | 210 | if (!initialized) |
209 | { | 211 | { |
210 | initialized = GNUNET_YES; | 212 | initialized = GNUNET_YES; |
211 | plugin_init (); | 213 | plugin_init (); |
212 | } | 214 | } |
213 | libhandle = lt_dlopenext (library_name); | 215 | libhandle = lt_dlopenext (library_name); |
214 | if (libhandle == NULL) | 216 | if (libhandle == NULL) |
215 | { | 217 | { |
216 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 218 | LOG (GNUNET_ERROR_TYPE_ERROR, |
217 | _("`%s' failed for library `%s' with error: %s\n"), | 219 | _("`%s' failed for library `%s' with error: %s\n"), |
218 | "lt_dlopenext", library_name, lt_dlerror ()); | 220 | "lt_dlopenext", library_name, lt_dlerror ()); |
219 | return NULL; | 221 | return NULL; |
220 | } | 222 | } |
221 | plug = GNUNET_malloc (sizeof (struct PluginList)); | 223 | plug = GNUNET_malloc (sizeof (struct PluginList)); |
222 | plug->handle = libhandle; | 224 | plug->handle = libhandle; |
223 | plug->name = GNUNET_strdup (library_name); | 225 | plug->name = GNUNET_strdup (library_name); |
@@ -225,13 +227,13 @@ GNUNET_PLUGIN_load (const char *library_name, void *arg) | |||
225 | plugins = plug; | 227 | plugins = plug; |
226 | init = resolve_function (plug, "init"); | 228 | init = resolve_function (plug, "init"); |
227 | if ((init == NULL) || (NULL == (ret = init (arg)))) | 229 | if ((init == NULL) || (NULL == (ret = init (arg)))) |
228 | { | 230 | { |
229 | lt_dlclose (libhandle); | 231 | lt_dlclose (libhandle); |
230 | GNUNET_free (plug->name); | 232 | GNUNET_free (plug->name); |
231 | plugins = plug->next; | 233 | plugins = plug->next; |
232 | GNUNET_free (plug); | 234 | GNUNET_free (plug); |
233 | return NULL; | 235 | return NULL; |
234 | } | 236 | } |
235 | return ret; | 237 | return ret; |
236 | } | 238 | } |
237 | 239 | ||
@@ -255,10 +257,10 @@ GNUNET_PLUGIN_unload (const char *library_name, void *arg) | |||
255 | prev = NULL; | 257 | prev = NULL; |
256 | pos = plugins; | 258 | pos = plugins; |
257 | while ((pos != NULL) && (0 != strcmp (pos->name, library_name))) | 259 | while ((pos != NULL) && (0 != strcmp (pos->name, library_name))) |
258 | { | 260 | { |
259 | prev = pos; | 261 | prev = pos; |
260 | pos = pos->next; | 262 | pos = pos->next; |
261 | } | 263 | } |
262 | if (pos == NULL) | 264 | if (pos == NULL) |
263 | return NULL; | 265 | return NULL; |
264 | 266 | ||
@@ -274,10 +276,10 @@ GNUNET_PLUGIN_unload (const char *library_name, void *arg) | |||
274 | GNUNET_free (pos->name); | 276 | GNUNET_free (pos->name); |
275 | GNUNET_free (pos); | 277 | GNUNET_free (pos); |
276 | if (plugins == NULL) | 278 | if (plugins == NULL) |
277 | { | 279 | { |
278 | plugin_fini (); | 280 | plugin_fini (); |
279 | initialized = GNUNET_NO; | 281 | initialized = GNUNET_NO; |
280 | } | 282 | } |
281 | return ret; | 283 | return ret; |
282 | } | 284 | } |
283 | 285 | ||