#include "gmodule.h"#include "gmoduleconf.h"#include <errno.h>#include <string.h>#include "gmodule-dl.c"Go to the source code of this file.
|
|
Definition at line 129 of file gmodule.c. Referenced by g_module_close(), g_module_open(), g_module_supported(), and g_module_symbol(). |
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
Definition at line 412 of file gmodule.c. References _g_module_build_path(), g_return_val_if_fail, and NULL. 00414 { 00415 g_return_val_if_fail (module_name != NULL, NULL); 00416 00417 return _g_module_build_path (directory, module_name); 00418 }
|
|
|
Definition at line 291 of file gmodule.c. References _g_module_close(), FALSE, _GModule::file_name, g_free(), G_LOCK, g_module_error(), g_return_val_if_fail, G_UNLOCK, _GModule::handle, _GModule::is_resident, _GModule::next, NULL, _GModule::ref_count, SUPPORT_OR_RETURN, and _GModule::unload. Referenced by g_module_open(), and main(). 00292 { 00293 SUPPORT_OR_RETURN (FALSE); 00294 00295 g_return_val_if_fail (module != NULL, FALSE); 00296 g_return_val_if_fail (module->ref_count > 0, FALSE); 00297 00298 module->ref_count--; 00299 00300 if (!module->ref_count && !module->is_resident && module->unload) 00301 { 00302 GModuleUnload unload; 00303 00304 unload = module->unload; 00305 module->unload = NULL; 00306 unload (module); 00307 } 00308 00309 if (!module->ref_count && !module->is_resident) 00310 { 00311 GModule *last; 00312 GModule *node; 00313 00314 last = NULL; 00315 00316 G_LOCK (GModule); 00317 node = modules; 00318 while (node) 00319 { 00320 if (node == module) 00321 { 00322 if (last) 00323 last->next = node->next; 00324 else 00325 modules = node->next; 00326 break; 00327 } 00328 last = node; 00329 node = last->next; 00330 } 00331 module->next = NULL; 00332 G_UNLOCK (GModule); 00333 00334 _g_module_close (module->handle, FALSE); 00335 g_free (module->file_name); 00336 00337 g_free (module); 00338 } 00339 00340 return g_module_error() == NULL; 00341 }
|
|
|
Definition at line 352 of file gmodule.c. References g_static_private_get(). Referenced by g_module_close(), g_module_open(), g_module_symbol(), gplugin_a_module_func(), and main(). 00353 { 00354 return g_static_private_get (&module_error_private); 00355 }
|
|
|
Definition at line 82 of file gmodule.c. References G_LOCK, G_UNLOCK, _GModule::handle, _GModule::next, and NULL. Referenced by g_module_open(). 00083 { 00084 GModule *module; 00085 GModule *retval = NULL; 00086 00087 G_LOCK (GModule); 00088 if (main_module && main_module->handle == handle) 00089 retval = main_module; 00090 else 00091 for (module = modules; module; module = module->next) 00092 if (handle == module->handle) 00093 { 00094 retval = module; 00095 break; 00096 } 00097 G_UNLOCK (GModule); 00098 00099 return retval; 00100 }
|
|
|
Definition at line 103 of file gmodule.c. References _GModule::file_name, G_LOCK, G_UNLOCK, _GModule::next, and NULL. Referenced by g_module_open(). 00104 { 00105 GModule *module; 00106 GModule *retval = NULL; 00107 00108 G_LOCK (GModule); 00109 for (module = modules; module; module = module->next) 00110 if (strcmp (name, module->file_name) == 0) 00111 { 00112 retval = module; 00113 break; 00114 } 00115 G_UNLOCK (GModule); 00116 00117 return retval; 00118 }
|
|
|
Definition at line 344 of file gmodule.c. References g_return_if_fail, _GModule::is_resident, NULL, and TRUE. 00345 { 00346 g_return_if_fail (module != NULL); 00347 00348 module->is_resident = TRUE; 00349 }
|
|
|
Definition at line 401 of file gmodule.c. References _GModule::file_name, g_return_val_if_fail, and NULL. Referenced by gplugin_a_module_func(), and main(). 00402 { 00403 g_return_val_if_fail (module != NULL, NULL); 00404 00405 if (module == main_module) 00406 return "main"; 00407 00408 return module->file_name; 00409 }
|
|
||||||||||||
|
Definition at line 191 of file gmodule.c. References _g_module_close(), _g_module_open(), _g_module_self(), FALSE, _GModule::file_name, g_free(), G_LOCK, G_MODULE_BIND_LAZY, g_module_close(), g_module_error(), g_module_find_by_handle(), g_module_find_by_name(), g_module_set_error(), g_module_symbol(), g_new, g_strconcat(), g_strdup(), G_UNLOCK, _GModule::handle, _GModule::is_resident, _GModule::next, NULL, _GModule::ref_count, SUPPORT_OR_RETURN, TRUE, and _GModule::unload. Referenced by main(). 00193 { 00194 GModule *module; 00195 gpointer handle; 00196 00197 SUPPORT_OR_RETURN (NULL); 00198 00199 if (!file_name) 00200 { 00201 G_LOCK (GModule); 00202 if (!main_module) 00203 { 00204 handle = _g_module_self (); 00205 if (handle) 00206 { 00207 main_module = g_new (GModule, 1); 00208 main_module->file_name = NULL; 00209 main_module->handle = handle; 00210 main_module->ref_count = 1; 00211 main_module->is_resident = TRUE; 00212 main_module->unload = NULL; 00213 main_module->next = NULL; 00214 } 00215 } 00216 G_UNLOCK (GModule); 00217 00218 return main_module; 00219 } 00220 00221 /* we first search the module list by name */ 00222 module = g_module_find_by_name (file_name); 00223 if (module) 00224 { 00225 module->ref_count++; 00226 00227 return module; 00228 } 00229 00230 /* open the module */ 00231 handle = _g_module_open (file_name, (flags & G_MODULE_BIND_LAZY) != 0); 00232 if (handle) 00233 { 00234 gchar *saved_error; 00235 GModuleCheckInit check_init; 00236 const gchar *check_failed = NULL; 00237 00238 /* search the module list by handle, since file names are not unique */ 00239 module = g_module_find_by_handle (handle); 00240 if (module) 00241 { 00242 _g_module_close (module->handle, TRUE); 00243 module->ref_count++; 00244 g_module_set_error (NULL); 00245 00246 return module; 00247 } 00248 00249 saved_error = g_strdup (g_module_error ()); 00250 g_module_set_error (NULL); 00251 00252 module = g_new (GModule, 1); 00253 module->file_name = g_strdup (file_name); 00254 module->handle = handle; 00255 module->ref_count = 1; 00256 module->is_resident = FALSE; 00257 module->unload = NULL; 00258 G_LOCK (GModule); 00259 module->next = modules; 00260 modules = module; 00261 G_UNLOCK (GModule); 00262 00263 /* check initialization */ 00264 if (g_module_symbol (module, "g_module_check_init", (gpointer) &check_init)) 00265 check_failed = check_init (module); 00266 00267 /* we don't call unload() if the initialization check failed. */ 00268 if (!check_failed) 00269 g_module_symbol (module, "g_module_unload", (gpointer) &module->unload); 00270 00271 if (check_failed) 00272 { 00273 gchar *error; 00274 00275 error = g_strconcat ("GModule initialization check failed: ", check_failed, NULL); 00276 g_module_close (module); 00277 module = NULL; 00278 g_module_set_error (error); 00279 g_free (error); 00280 } 00281 else 00282 g_module_set_error (saved_error); 00283 00284 g_free (saved_error); 00285 } 00286 00287 return module; 00288 }
|
|
|
Definition at line 121 of file gmodule.c. References g_free(), g_static_private_set(), and g_strdup(). Referenced by _g_module_close(), _g_module_open(), _g_module_self(), _g_module_symbol(), g_module_open(), and g_module_symbol(). 00122 { 00123 g_static_private_set (&module_error_private, g_strdup (error), g_free); 00124 errno = 0; 00125 }
|
|
|
Definition at line 183 of file gmodule.c. References FALSE, SUPPORT_OR_RETURN, and TRUE. 00184 { 00185 SUPPORT_OR_RETURN (FALSE); 00186 00187 return TRUE; 00188 }
|
|
||||||||||||||||
|
Definition at line 358 of file gmodule.c. References _g_module_symbol(), FALSE, g_free(), g_module_error(), g_module_set_error(), g_return_val_if_fail, g_strconcat(), _GModule::handle, NULL, SUPPORT_OR_RETURN, and TRUE. Referenced by g_module_open(), gplugin_a_module_func(), and main(). 00361 { 00362 gchar *module_error; 00363 00364 if (symbol) 00365 *symbol = NULL; 00366 SUPPORT_OR_RETURN (FALSE); 00367 00368 g_return_val_if_fail (module != NULL, FALSE); 00369 g_return_val_if_fail (symbol_name != NULL, FALSE); 00370 g_return_val_if_fail (symbol != NULL, FALSE); 00371 00372 #ifdef G_MODULE_NEED_USCORE 00373 { 00374 gchar *name; 00375 00376 name = g_strconcat ("_", symbol_name, NULL); 00377 *symbol = _g_module_symbol (module->handle, name); 00378 g_free (name); 00379 } 00380 #else /* !G_MODULE_NEED_USCORE */ 00381 *symbol = _g_module_symbol (module->handle, symbol_name); 00382 #endif /* !G_MODULE_NEED_USCORE */ 00383 00384 module_error = g_module_error (); 00385 if (module_error) 00386 { 00387 gchar *error; 00388 00389 error = g_strconcat ("`", symbol_name, "': ", module_error, NULL); 00390 g_module_set_error (error); 00391 g_free (error); 00392 *symbol = NULL; 00393 00394 return FALSE; 00395 } 00396 00397 return TRUE; 00398 }
|
|
|
|
|
|
|
|
|
|