SWITCH_DECLARE(switch_status_t) switch_loadable_module_load_module(char *dir, char *fname) { switch_size_t len = 0; char *path; char *file; switch_loadable_module_t *new_module = NULL; switch_status_t status; #ifdef WIN32 const char *ext = ".dll"; #elif defined (MACOSX) || defined (DARWIN) const char *ext = ".dylib"; #else const char *ext = ".so"; #endif if ((file = switch_core_strdup(loadable_modules.pool, fname)) == 0) { return SWITCH_STATUS_FALSE; } if (*file == '/') { path = switch_core_strdup(loadable_modules.pool, file); } else { if (strchr(file, '.')) { len = strlen(dir); len += strlen(file); len += 4; path = (char *) switch_core_alloc(loadable_modules.pool, len); snprintf(path, len, "%s%s%s", dir, SWITCH_PATH_SEPARATOR, file); } else { len = strlen(dir); len += strlen(file); len += 8; path = (char *) switch_core_alloc(loadable_modules.pool, len); snprintf(path, len, "%s%s%s%s", dir, SWITCH_PATH_SEPARATOR, file, ext); } } if ((status = switch_loadable_module_load_file(path, &new_module) == SWITCH_STATUS_SUCCESS)) { return switch_loadable_module_process((char *) file, new_module); } else { return status; } }