/*! * Unload the plugin registry. This will unload the DLLs and free * the nodes in the data structure containing them. * * \param reg The registry * \param error An error to populate on failure * \return 1 on success, 0 on failure * */ NITFPRIV(NITF_BOOL) unloadDSO(nitf_DLL* dll, nitf_Error * error) { NITF_BOOL ok = NITF_SUCCESS; if (nitf_DLL_isValid(dll)) { doCleanup(dll, error); /* destroy the lib */ ok &= nitf_DLL_unload(dll, error); if ( dll->libname ) { #ifdef NITF_DEBUG_PLUGIN_REG printf("Unloaded dll with name [%s]\n", dll->libname); #endif NITF_FREE( dll->libname ); dll->libname = NULL; } nitf_DLL_destruct(&dll); } return ok; }
NITFPRIV(NITF_BOOL) insertCreator(nitf_DLL* dso, nitf_HashTable* hash, const char* ident, const char* suffix, nitf_Error* error) { /* We are trying to find tre_main */ NITF_DLL_FUNCTION_PTR dsoMain = NULL; /* Get the name of the handler */ char name[NITF_MAX_PATH]; char* p = NULL; if (!nitf_DLL_isValid(dso)) { nitf_Error_initf(error, NITF_CTXT, NITF_ERR_INVALID_PARAMETER, "DSO is not valid for [%s]", ident); } memset(name, 0, NITF_MAX_PATH); NITF_SNPRINTF(name, NITF_MAX_PATH, "%s%s", ident, suffix); nitf_Utils_replace(name, ' ', '_'); /* No error has occurred (yet) */ #if NITF_DEBUG_PLUGIN_REG printf("Loading function [%s] in dso at [%p]\n", name, dso); #endif /* Retrieve the main */ dsoMain = nitf_DLL_retrieve(dso, name, error); if (!dsoMain) { /* If it didnt work, we are done */ return NITF_FAILURE; } #if NITF_DEBUG_PLUGIN_REG if (nitf_HashTable_exists(hash, ident)) { printf("Warning, overriding [%s] hook", ident); } #endif return nitf_HashTable_insert(hash, ident, dsoMain, error); }