24 #include <utils/system/dynamic_module/module.h>
25 #include <utils/system/file.h>
58 const char * Module::FILE_EXTENSION = SOEXT;
66 __filename = filename;
71 __is_resident =
false;
91 if ( __handle != NULL )
return;
94 std::string full_filename =
"";
95 full_filename = __filename;
97 if ( full_filename.find(
"."SOEXT, 0) != (full_filename.length() - 1 - strlen(FILE_EXTENSION)) ) {
99 full_filename +=
"."SOEXT;
112 if ( full_filename ==
"") {
113 __handle = dlopen (NULL, tflags);
116 __is_resident =
true;
123 __handle = dlopen(full_filename.c_str(), tflags);
125 if ( NULL == __handle) {
126 const char *err = dlerror();
131 e.
append(
"dlerror: %s", err);
135 __is_resident =
false;
140 e.
append(
"File '%s' does not exist", full_filename.c_str());
153 if ( __handle == NULL )
return true;
155 if ( __ref_count > 0 ) --__ref_count;
157 if ( (__ref_count == 0) && ! __is_resident ) {
158 if ( dlclose(__handle) != 0 ) {
181 if ( __ref_count > 0 ) {
194 return (__ref_count == 0);
216 return (__filename == cmod.__filename);
232 if( symbol_name == NULL ) {
235 if ( __handle == NULL ) {
239 return ( dlsym( __handle, symbol_name ) != NULL );
255 if( symbol_name == NULL )
return NULL;
256 if ( __handle == NULL )
return NULL;
258 return dlsym( __handle, symbol_name );
270 return FILE_EXTENSION;
291 if ( __filename.find(
"/", 0) != std::string::npos ) {
292 std::string rv = __filename.substr(__filename.rfind(
"/", __filename.length()) + 1, __filename.length());
295 return __filename.c_str();