int check_module( rng_type * rng , const char * lib_name ) { analysis_module_load_status_enum load_status; analysis_module_type * module = analysis_module_alloc_external__( rng , lib_name , false , &load_status); if (module != NULL) { printf("Module loaded successfully\n"); analysis_module_free( module ); return 0; } else { if (load_status == DLOPEN_FAILURE) { printf("\ndlerror(): %s\n\n",dlerror()); printf("The runtime linker could not open the library:%s.\n", lib_name); printf("For the runtime linker to succesfully open your library\n"); printf("at least one of two must be satisfied: \n\n"); printf(" 1. You give the FULL PATH to library - including .so extension\n\n"); printf(" 2. The path containing the library is in LD_LIBRARY_PATH.\n\n"); printf("In addition all libraries needed by your module must be found\n"); } else if (load_status == LOAD_SYMBOL_TABLE_NOT_FOUND) { printf("\nThe library %s was loaded successfully, however\n",lib_name); printf("the symbol table:\'%s\' was not found. You must make sure\n",EXTERNAL_MODULE_NAME); printf("that the \'analysis_table_type\' structure at the bottom\n"); printf("of the source file is named exactly: \'analysis_table\'.\n"); printf("See documentation of \'symbol_table\' in modules.txt.\n\n"); } } return 1; }
static analysis_module_type * analysis_module_alloc__( rng_type * rng , const analysis_table_type * table , const char * symbol_table , const char * lib_name , const char * user_name , void * lib_handle ) { analysis_module_type * module = analysis_module_alloc_empty( user_name , symbol_table , lib_name ); module->lib_handle = lib_handle; module->initX = table->initX; module->updateA = table->updateA; module->init_update = table->init_update; module->complete_update = table->complete_update; module->set_int = table->set_int; module->set_double = table->set_double; module->set_string = table->set_string; module->set_bool = table->set_bool; module->alloc = table->alloc; module->freef = table->freef; module->get_options = table->get_options; module->has_var = table->has_var; module->get_int = table->get_int; module->get_double = table->get_double; module->get_bool = table->get_bool; module->get_ptr = table->get_ptr; if (module->alloc) module->module_data = module->alloc( rng ); if (!analysis_module_internal_check( module )) { fprintf(stderr,"** Warning loading module: %s failed - internal inconsistency\n", module->user_name); analysis_module_free( module ); module = NULL; } return module; }
void analysis_module_free__( void * arg) { analysis_module_type * module = analysis_module_safe_cast( arg ); analysis_module_free( module ); }