Data Structures | |
| struct | switch_loadable_module_interface |
| The abstraction of a loadable module. More... | |
Defines | |
| #define | SWITCH_ADD_API(api_int, int_name, descript, funcptr, syntax_string) |
| #define | SWITCH_ADD_CHAT(chat_int, int_name, funcptr) |
| #define | SWITCH_ADD_APP(app_int, int_name, short_descript, long_descript, funcptr, syntax_string, app_flags) |
| #define | SWITCH_ADD_DIALPLAN(dp_int, int_name, funcptr) |
| #define | SWITCH_ADD_CODEC(codec_int, int_name) |
Functions | |
| switch_status_t | switch_loadable_module_init (void) |
| Initilize the module backend and load all the modules. | |
| void | switch_loadable_module_shutdown (void) |
| Shutdown the module backend and call the shutdown routine in all loaded modules. | |
| switch_endpoint_interface_t * | switch_loadable_module_get_endpoint_interface (const char *name) |
| Retrieve the endpoint interface by it's registered name. | |
| switch_codec_interface_t * | switch_loadable_module_get_codec_interface (const char *name) |
| Retrieve the codec interface by it's registered name. | |
| switch_dialplan_interface_t * | switch_loadable_module_get_dialplan_interface (const char *name) |
| Retrieve the dialplan interface by it's registered name. | |
| switch_status_t | switch_loadable_module_build_dynamic (char *filename, switch_module_load_t switch_module_load, switch_module_runtime_t switch_module_runtime, switch_module_shutdown_t switch_module_shutdown, switch_bool_t runtime) |
| build a dynamic module object and register it (for use in double embeded modules) | |
| switch_timer_interface_t * | switch_loadable_module_get_timer_interface (const char *name) |
| Retrieve the timer interface by it's registered name. | |
| switch_application_interface_t * | switch_loadable_module_get_application_interface (const char *name) |
| Retrieve the application interface by it's registered name. | |
| switch_api_interface_t * | switch_loadable_module_get_api_interface (const char *name) |
| Retrieve the API interface by it's registered name. | |
| switch_file_interface_t * | switch_loadable_module_get_file_interface (const char *name) |
| Retrieve the file format interface by it's registered name. | |
| switch_speech_interface_t * | switch_loadable_module_get_speech_interface (const char *name) |
| Retrieve the speech interface by it's registered name. | |
| switch_asr_interface_t * | switch_loadable_module_get_asr_interface (const char *name) |
| Retrieve the asr interface by it's registered name. | |
| switch_directory_interface_t * | switch_loadable_module_get_directory_interface (const char *name) |
| Retrieve the directory interface by it's registered name. | |
| switch_chat_interface_t * | switch_loadable_module_get_chat_interface (const char *name) |
| Retrieve the chat interface by it's registered name. | |
| switch_say_interface_t * | switch_loadable_module_get_say_interface (const char *name) |
| Retrieve the say interface by it's registered name. | |
| switch_management_interface_t * | switch_loadable_module_get_management_interface (const char *relative_oid) |
| Retrieve the management interface by it's registered name. | |
| int | switch_loadable_module_get_codecs (const switch_codec_implementation_t **array, int arraylen) |
| Retrieve the list of loaded codecs into an array. | |
| int | switch_loadable_module_get_codecs_sorted (const switch_codec_implementation_t **array, int arraylen, char **prefs, int preflen) |
| Retrieve the list of loaded codecs into an array based on another array showing the sorted order. | |
| switch_status_t | switch_api_execute (const char *cmd, const char *arg, switch_core_session_t *session, switch_stream_handle_t *stream) |
| Execute a registered API command. | |
| switch_status_t | switch_loadable_module_load_module (char *dir, char *fname, switch_bool_t runtime, const char **err) |
| Load a module. | |
| switch_status_t | switch_loadable_module_exists (const char *mod) |
| Check if a module is loaded. | |
| switch_status_t | switch_loadable_module_unload_module (char *dir, char *fname, const char **err) |
| Unoad a module. | |
| switch_status_t | switch_module_load (switch_loadable_module_interface_t **module_interface, char *filename) |
| Load a module. | |
| switch_status_t | switch_module_runtime (void) |
| switch_status_t | switch_module_shutdown (void) |
| Shutdown a module. | |
| uint32_t | switch_core_codec_next_id (void) |
|
|
Value: for (;;) { \ api_int = (switch_api_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_API_INTERFACE); \ api_int->interface_name = int_name; \ api_int->desc = descript; \ api_int->function = funcptr; \ api_int->syntax = syntax_string; \ break; \ } |
|
|
Value: for (;;) { \ app_int = (switch_application_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE); \ app_int->interface_name = int_name; \ app_int->application_function = funcptr; \ app_int->short_desc = short_descript; \ app_int->long_desc = long_descript; \ app_int->syntax = syntax_string; \ app_int->flags = app_flags; \ break; \ } |
|
|
Value: for (;;) { \ chat_int = (switch_chat_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_CHAT_INTERFACE); \ chat_int->chat_send = funcptr; \ chat_int->interface_name = int_name; \ break; \ } |
|
|
Value: for (;;) { \ codec_int = (switch_codec_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_CODEC_INTERFACE); \ codec_int->interface_name = switch_core_strdup(pool, int_name); \ codec_int->codec_id = switch_core_codec_next_id(); \ break; \ } |
|
|
Value: for (;;) { \ dp_int = (switch_dialplan_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_DIALPLAN_INTERFACE); \ dp_int->hunt_function = funcptr; \ dp_int->interface_name = int_name; \ break; \ } |
|
||||||||||||||||||||
|
Execute a registered API command.
01405 {
01406 switch_api_interface_t *api;
01407 switch_status_t status;
01408
01409 switch_assert(stream != NULL);
01410 switch_assert(stream->data != NULL);
01411 switch_assert(stream->write_function != NULL);
01412
01413 if (!stream->param_event) {
01414 switch_event_create(&stream->param_event, SWITCH_EVENT_API);
01415 }
01416
01417 if (stream->param_event) {
01418 if (cmd) {
01419 switch_event_add_header_string(stream->param_event, SWITCH_STACK_BOTTOM, "API-Command", cmd);
01420 }
01421 if (arg) {
01422 switch_event_add_header_string(stream->param_event, SWITCH_STACK_BOTTOM, "API-Command-Argument", arg);
01423 }
01424 }
01425
01426
01427 if (cmd && (api = switch_loadable_module_get_api_interface(cmd)) != 0) {
01428 switch_thread_rwlock_rdlock(api->rwlock);
01429 if ((status = api->function(arg, session, stream)) != SWITCH_STATUS_SUCCESS) {
01430 stream->write_function(stream, "COMMAND RETURNED ERROR!\n");
01431 }
01432 switch_thread_rwlock_unlock(api->rwlock);
01433 } else {
01434 status = SWITCH_STATUS_FALSE;
01435 stream->write_function(stream, "INVALID COMMAND!\n");
01436 }
01437
01438 if (stream->param_event) {
01439 switch_event_fire(&stream->param_event);
01440 }
01441
01442
01443 return status;
01444 }
|
Here is the call graph for this function:

|
|
00041 {
00042 return CODEC_ID++;
00043 }
|
|
||||||||||||||||||||||||
|
build a dynamic module object and register it (for use in double embeded modules)
00899 {
00900 switch_loadable_module_t *module = NULL;
00901 switch_module_load_t load_func_ptr = NULL;
00902 int loading = 1;
00903 const char *err = NULL;
00904 switch_loadable_module_interface_t *module_interface = NULL;
00905 switch_memory_pool_t *pool;
00906
00907
00908 if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
00909 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
00910 abort();
00911 }
00912
00913 if ((module = switch_core_alloc(pool, sizeof(switch_loadable_module_t))) == 0) {
00914 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Couldn't allocate memory\n");
00915 abort();
00916 }
00917
00918
00919
00920 while (loading) {
00921 switch_status_t status;
00922 load_func_ptr = (switch_module_load_t) switch_module_load;
00923
00924 if (load_func_ptr == NULL) {
00925 err = "Cannot Load";
00926 break;
00927 }
00928
00929 status = load_func_ptr(&module_interface, pool);
00930
00931 if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_NOUNLOAD) {
00932 err = "Module load routine returned an error";
00933 module_interface = NULL;
00934 break;
00935 }
00936
00937 if ((module = switch_core_alloc(pool, sizeof(switch_loadable_module_t))) == 0) {
00938 err = "Could not allocate memory\n";
00939 abort();
00940 }
00941
00942 if (status == SWITCH_STATUS_NOUNLOAD) {
00943 module->perm++;
00944 }
00945
00946 loading = 0;
00947 }
00948
00949 if (err) {
00950 switch_core_destroy_memory_pool(&pool);
00951 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Error Loading module %s\n**%s**\n", filename, err);
00952 return SWITCH_STATUS_GENERR;
00953 }
00954
00955 module->pool = pool;
00956 module->filename = switch_core_strdup(module->pool, filename);
00957 module->module_interface = module_interface;
00958 module->switch_module_load = load_func_ptr;
00959
00960 if (switch_module_shutdown) {
00961 module->switch_module_shutdown = switch_module_shutdown;
00962 }
00963 if (switch_module_runtime) {
00964 module->switch_module_runtime = switch_module_runtime;
00965 }
00966 if (runtime && module->switch_module_runtime) {
00967 switch_core_launch_thread(switch_loadable_module_exec, module, module->pool);
00968 }
00969 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Successfully Loaded [%s]\n", module_interface->module_name);
00970 return switch_loadable_module_process((char *) module->filename, module);
00971 }
|
Here is the call graph for this function:

|
|
Check if a module is loaded.
00850 {
00851 switch_status_t status;
00852
00853 if (switch_strlen_zero(mod)) {
00854 return SWITCH_STATUS_FALSE;
00855 }
00856
00857 switch_mutex_lock(loadable_modules.mutex);
00858 if (switch_core_hash_find(loadable_modules.module_hash, mod)) {
00859 status = SWITCH_STATUS_SUCCESS;
00860 } else {
00861 status = SWITCH_STATUS_FALSE;
00862 }
00863 switch_mutex_unlock(loadable_modules.mutex);
00864
00865 return status;
00866 }
|
Here is the call graph for this function:

|
|
Retrieve the API interface by it's registered name.
01238 {
01239 return switch_core_hash_find_locked(loadable_modules.api_hash, name, loadable_modules.mutex);
01240 }
|
Here is the call graph for this function:

|
|
Retrieve the application interface by it's registered name.
01233 {
01234 return switch_core_hash_find_locked(loadable_modules.application_hash, name, loadable_modules.mutex);
01235 }
|
Here is the call graph for this function:

|
|
Retrieve the asr interface by it's registered name.
01253 {
01254 return switch_core_hash_find_locked(loadable_modules.asr_hash, name, loadable_modules.mutex);
01255 }
|
Here is the call graph for this function:

|
|
Retrieve the chat interface by it's registered name.
01263 {
01264 return switch_core_hash_find_locked(loadable_modules.chat_hash, name, loadable_modules.mutex);
01265 }
|
Here is the call graph for this function:

|
|
Retrieve the codec interface by it's registered name.
01201 {
01202 char altname[256] = "";
01203 switch_codec_interface_t *codec;
01204 switch_size_t x;
01205
01206 switch_mutex_lock(loadable_modules.mutex);
01207 if (!(codec = switch_core_hash_find(loadable_modules.codec_hash, name))) {
01208 for (x = 0; x < strlen(name); x++) {
01209 altname[x] = (char) toupper((int) name[x]);
01210 }
01211 if (!(codec = switch_core_hash_find(loadable_modules.codec_hash, altname))) {
01212 for (x = 0; x < strlen(name); x++) {
01213 altname[x] = (char) tolower((int) name[x]);
01214 }
01215 codec = switch_core_hash_find(loadable_modules.codec_hash, altname);
01216 }
01217 }
01218 switch_mutex_unlock(loadable_modules.mutex);
01219 return codec;
01220 }
|
Here is the call graph for this function:

|
||||||||||||
|
Retrieve the list of loaded codecs into an array.
01278 {
01279 switch_hash_index_t *hi;
01280 void *val;
01281 switch_codec_interface_t *codec_interface;
01282 int i = 0;
01283 const switch_codec_implementation_t *imp;
01284
01285 switch_mutex_lock(loadable_modules.mutex);
01286 for (hi = switch_hash_first(NULL, loadable_modules.codec_hash); hi; hi = switch_hash_next(hi)) {
01287 switch_hash_this(hi, NULL, NULL, &val);
01288 codec_interface = (switch_codec_interface_t *) val;
01289 /* Look for a 20ms implementation because it's the safest choice */
01290 for (imp = codec_interface->implementations; imp; imp = imp->next) {
01291 if (imp->microseconds_per_frame / 1000 == 20) {
01292 array[i++] = imp;
01293 goto found;
01294 }
01295 }
01296 /* oh well we will use what we have */
01297 array[i++] = codec_interface->implementations;
01298
01299 found:
01300
01301 if (i > arraylen) {
01302 break;
01303 }
01304 }
01305
01306 switch_mutex_unlock(loadable_modules.mutex);
01307
01308 return i;
01309
01310 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Retrieve the list of loaded codecs into an array based on another array showing the sorted order.
01313 {
01314 int x, i = 0;
01315 switch_codec_interface_t *codec_interface;
01316 const switch_codec_implementation_t *imp;
01317
01318 switch_mutex_lock(loadable_modules.mutex);
01319
01320 for (x = 0; x < preflen; x++) {
01321 char *cur, *last = NULL, *next = NULL, *name, *p, buf[256];
01322 uint32_t interval = 0, rate = 8000;
01323
01324 switch_copy_string(buf, prefs[x], sizeof(buf));
01325 last = name = next = cur = buf;
01326
01327 for (;;) {
01328 if (!next) {
01329 break;
01330 }
01331
01332 if ((p = strchr(next, '@'))) {
01333 *p++ = '\0';
01334 }
01335 next = p;
01336
01337 if (cur != name) {
01338 if (strchr(cur, 'i')) {
01339 interval = atoi(cur);
01340 } else if ((strchr(cur, 'k') || strchr(cur, 'h'))) {
01341 rate = atoi(cur);
01342 }
01343 }
01344 cur = next;
01345 }
01346
01347 if ((codec_interface = switch_loadable_module_get_codec_interface(name)) != 0) {
01348 /* If no specific codec interval is requested opt for 20ms above all else because lots of stuff assumes it */
01349 if (!interval) {
01350 for (imp = codec_interface->implementations; imp; imp = imp->next) {
01351 uint8_t match = 1;
01352
01353 if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) {
01354 if ((uint32_t) (imp->microseconds_per_frame / 1000) != 20) {
01355 match = 0;
01356 }
01357
01358 if (match && rate && (uint32_t) imp->samples_per_second != rate) {
01359 match = 0;
01360 }
01361 }
01362
01363 if (match) {
01364 array[i++] = imp;
01365 goto found;
01366 }
01367 }
01368 }
01369
01370 /* Either looking for a specific interval or there was no interval specified and there wasn't one @20ms available */
01371 for (imp = codec_interface->implementations; imp; imp = imp->next) {
01372 uint8_t match = 1;
01373
01374 if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) {
01375 if (interval && (uint32_t) (imp->microseconds_per_frame / 1000) != interval) {
01376 match = 0;
01377 }
01378
01379 if (match && rate && (uint32_t) imp->samples_per_second != rate) {
01380 match = 0;
01381 }
01382 }
01383
01384 if (match) {
01385 array[i++] = imp;
01386 goto found;
01387 }
01388 }
01389
01390 found:
01391
01392 if (i > arraylen) {
01393 break;
01394 }
01395 }
01396 }
01397
01398 switch_mutex_unlock(loadable_modules.mutex);
01399
01400
01401 return i;
01402 }
|
Here is the call graph for this function:

|
|
Retrieve the dialplan interface by it's registered name.
01223 {
01224 return switch_core_hash_find_locked(loadable_modules.dialplan_hash, name, loadable_modules.mutex);
01225 }
|
Here is the call graph for this function:

|
|
Retrieve the directory interface by it's registered name.
01258 {
01259 return switch_core_hash_find_locked(loadable_modules.directory_hash, name, loadable_modules.mutex);
01260 }
|
Here is the call graph for this function:

|
|
Retrieve the endpoint interface by it's registered name.
01190 {
01191 switch_endpoint_interface_t *ptr;
01192
01193 switch_mutex_lock(loadable_modules.mutex);
01194 ptr = switch_core_hash_find(loadable_modules.endpoint_hash, name);
01195 switch_mutex_unlock(loadable_modules.mutex);
01196
01197 return ptr;
01198 }
|
Here is the call graph for this function:

|
|
Retrieve the file format interface by it's registered name.
01243 {
01244 return switch_core_hash_find_locked(loadable_modules.file_hash, name, loadable_modules.mutex);
01245 }
|
Here is the call graph for this function:

|
|
Retrieve the management interface by it's registered name.
01273 {
01274 return switch_core_hash_find_locked(loadable_modules.management_hash, relative_oid, loadable_modules.mutex);
01275 }
|
Here is the call graph for this function:

|
|
Retrieve the say interface by it's registered name.
01268 {
01269 return switch_core_hash_find_locked(loadable_modules.say_hash, name, loadable_modules.mutex);
01270 }
|
Here is the call graph for this function:

|
|
Retrieve the speech interface by it's registered name.
01248 {
01249 return switch_core_hash_find_locked(loadable_modules.speech_hash, name, loadable_modules.mutex);
01250 }
|
Here is the call graph for this function:

|
|
Retrieve the timer interface by it's registered name.
01228 {
01229 return switch_core_hash_find_locked(loadable_modules.timer_hash, name, loadable_modules.mutex);
01230 }
|
Here is the call graph for this function:

|
|
Initilize the module backend and load all the modules.
00990 {
00991
00992 apr_finfo_t finfo = { 0 };
00993 apr_dir_t *module_dir_handle = NULL;
00994 apr_int32_t finfo_flags = APR_FINFO_DIRENT | APR_FINFO_TYPE | APR_FINFO_NAME;
00995 char *cf = "modules.conf";
00996 char *pcf = "post_load_modules.conf";
00997 switch_xml_t cfg, xml;
00998 unsigned char all = 0;
00999 unsigned int count = 0;
01000 const char *err;
01001
01002
01003 #ifdef WIN32
01004 const char *ext = ".dll";
01005 const char *EXT = ".DLL";
01006 #elif defined (MACOSX) || defined (DARWIN)
01007 const char *ext = ".dylib";
01008 const char *EXT = ".DYLIB";
01009 #else
01010 const char *ext = ".so";
01011 const char *EXT = ".SO";
01012 #endif
01013
01014 memset(&loadable_modules, 0, sizeof(loadable_modules));
01015 switch_core_new_memory_pool(&loadable_modules.pool);
01016
01017
01018 #ifdef WIN32
01019 switch_loadable_module_path_init();
01020 #endif
01021
01022 switch_core_hash_init(&loadable_modules.module_hash, loadable_modules.pool);
01023 switch_core_hash_init(&loadable_modules.endpoint_hash, loadable_modules.pool);
01024 switch_core_hash_init(&loadable_modules.codec_hash, loadable_modules.pool);
01025 switch_core_hash_init(&loadable_modules.timer_hash, loadable_modules.pool);
01026 switch_core_hash_init(&loadable_modules.application_hash, loadable_modules.pool);
01027 switch_core_hash_init(&loadable_modules.api_hash, loadable_modules.pool);
01028 switch_core_hash_init(&loadable_modules.file_hash, loadable_modules.pool);
01029 switch_core_hash_init(&loadable_modules.speech_hash, loadable_modules.pool);
01030 switch_core_hash_init(&loadable_modules.asr_hash, loadable_modules.pool);
01031 switch_core_hash_init(&loadable_modules.directory_hash, loadable_modules.pool);
01032 switch_core_hash_init(&loadable_modules.chat_hash, loadable_modules.pool);
01033 switch_core_hash_init(&loadable_modules.say_hash, loadable_modules.pool);
01034 switch_core_hash_init(&loadable_modules.management_hash, loadable_modules.pool);
01035 switch_core_hash_init(&loadable_modules.dialplan_hash, loadable_modules.pool);
01036 switch_mutex_init(&loadable_modules.mutex, SWITCH_MUTEX_NESTED, loadable_modules.pool);
01037
01038 switch_loadable_module_load_module("", "CORE_SOFTTIMER_MODULE", SWITCH_FALSE, &err);
01039 switch_loadable_module_load_module("", "CORE_PCM_MODULE", SWITCH_FALSE, &err);
01040
01041 if ((xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
01042 switch_xml_t mods, ld;
01043 if ((mods = switch_xml_child(cfg, "modules"))) {
01044 for (ld = switch_xml_child(mods, "load"); ld; ld = ld->next) {
01045 const char *val = switch_xml_attr_soft(ld, "module");
01046 if (switch_strlen_zero(val) || (strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT))) {
01047 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Invalid extension for %s\n", val);
01048 continue;
01049 }
01050 switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) val, SWITCH_FALSE, &err);
01051 count++;
01052 }
01053 }
01054 switch_xml_free(xml);
01055
01056 } else {
01057 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "open of %s failed\n", cf);
01058 }
01059
01060 if ((xml = switch_xml_open_cfg(pcf, &cfg, NULL))) {
01061 switch_xml_t mods, ld;
01062
01063 if ((mods = switch_xml_child(cfg, "modules"))) {
01064 for (ld = switch_xml_child(mods, "load"); ld; ld = ld->next) {
01065 const char *val = switch_xml_attr_soft(ld, "module");
01066 if (switch_strlen_zero(val) || (strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT))) {
01067 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Invalid extension for %s\n", val);
01068 continue;
01069 }
01070 switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) val, SWITCH_FALSE, &err);
01071 count++;
01072 }
01073 }
01074 switch_xml_free(xml);
01075
01076 } else {
01077 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "open of %s failed\n", pcf);
01078 }
01079
01080 if (!count) {
01081 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "No modules loaded, assuming 'load all'\n");
01082 all = 1;
01083 }
01084
01085 if (all) {
01086 if (apr_dir_open(&module_dir_handle, SWITCH_GLOBAL_dirs.mod_dir, loadable_modules.pool) != APR_SUCCESS) {
01087 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Can't open directory: %s\n", SWITCH_GLOBAL_dirs.mod_dir);
01088 return SWITCH_STATUS_GENERR;
01089 }
01090
01091 while (apr_dir_read(&finfo, finfo_flags, module_dir_handle) == APR_SUCCESS) {
01092 const char *fname = finfo.fname;
01093
01094 if (finfo.filetype != APR_REG) {
01095 continue;
01096 }
01097
01098 if (!fname) {
01099 fname = finfo.name;
01100 }
01101
01102 if (!fname) {
01103 continue;
01104 }
01105
01106 if (switch_strlen_zero(fname) || (!strstr(fname, ext) && !strstr(fname, EXT))) {
01107 continue;
01108 }
01109
01110 switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) fname, SWITCH_FALSE, &err);
01111 }
01112 apr_dir_close(module_dir_handle);
01113 }
01114
01115 switch_loadable_module_runtime();
01116
01117 return SWITCH_STATUS_SUCCESS;
01118 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Load a module.
00796 {
00797 switch_size_t len = 0;
00798 char *path;
00799 char *file, *dot;
00800 switch_loadable_module_t *new_module = NULL;
00801 switch_status_t status;
00802
00803 #ifdef WIN32
00804 const char *ext = ".dll";
00805 #else
00806 const char *ext = ".so";
00807 #endif
00808
00809
00810 if ((file = switch_core_strdup(loadable_modules.pool, fname)) == 0) {
00811 return SWITCH_STATUS_FALSE;
00812 }
00813
00814 if (switch_is_file_path(file)) {
00815 path = switch_core_strdup(loadable_modules.pool, file);
00816 file = (char *) switch_cut_path(file);
00817 if ((dot = strchr(file, '.'))) {
00818 dot = '\0';
00819 }
00820 } else {
00821 if ((dot = strchr(file, '.'))) {
00822 dot = '\0';
00823 }
00824 len = strlen(dir);
00825 len += strlen(file);
00826 len += 8;
00827 path = (char *) switch_core_alloc(loadable_modules.pool, len);
00828 switch_snprintf(path, len, "%s%s%s%s", dir, SWITCH_PATH_SEPARATOR, file, ext);
00829 }
00830
00831 switch_mutex_lock(loadable_modules.mutex);
00832 if (switch_core_hash_find(loadable_modules.module_hash, file)) {
00833 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Module %s Already Loaded!\n", file);
00834 *err = "Module already loaded";
00835 status = SWITCH_STATUS_FALSE;
00836 } else if ((status = switch_loadable_module_load_file(path, file, &new_module) == SWITCH_STATUS_SUCCESS)) {
00837 if ((status = switch_loadable_module_process(file, new_module)) == SWITCH_STATUS_SUCCESS && runtime) {
00838 if (new_module->switch_module_runtime) {
00839 switch_core_launch_thread(switch_loadable_module_exec, new_module, new_module->pool);
00840 }
00841 }
00842 }
00843 switch_mutex_unlock(loadable_modules.mutex);
00844
00845 return status;
00846
00847 }
|
Here is the call graph for this function:

|
|
Shutdown the module backend and call the shutdown routine in all loaded modules.
01149 {
01150 switch_hash_index_t *hi;
01151 void *val;
01152 switch_loadable_module_t *module;
01153
01154 for (hi = switch_hash_first(NULL, loadable_modules.module_hash); hi; hi = switch_hash_next(hi)) {
01155 switch_hash_this(hi, NULL, NULL, &val);
01156 module = (switch_loadable_module_t *) val;
01157 if (!module->perm) {
01158 do_shutdown(module, SWITCH_TRUE, SWITCH_FALSE);
01159 }
01160 }
01161
01162 switch_yield(1000000);
01163
01164 for (hi = switch_hash_first(NULL, loadable_modules.module_hash); hi; hi = switch_hash_next(hi)) {
01165 switch_hash_this(hi, NULL, NULL, &val);
01166 module = (switch_loadable_module_t *) val;
01167 if (!module->perm) {
01168 do_shutdown(module, SWITCH_FALSE, SWITCH_TRUE);
01169 }
01170 }
01171
01172 switch_core_hash_destroy(&loadable_modules.module_hash);
01173 switch_core_hash_destroy(&loadable_modules.endpoint_hash);
01174 switch_core_hash_destroy(&loadable_modules.codec_hash);
01175 switch_core_hash_destroy(&loadable_modules.timer_hash);
01176 switch_core_hash_destroy(&loadable_modules.application_hash);
01177 switch_core_hash_destroy(&loadable_modules.api_hash);
01178 switch_core_hash_destroy(&loadable_modules.file_hash);
01179 switch_core_hash_destroy(&loadable_modules.speech_hash);
01180 switch_core_hash_destroy(&loadable_modules.asr_hash);
01181 switch_core_hash_destroy(&loadable_modules.directory_hash);
01182 switch_core_hash_destroy(&loadable_modules.chat_hash);
01183 switch_core_hash_destroy(&loadable_modules.say_hash);
01184 switch_core_hash_destroy(&loadable_modules.management_hash);
01185 switch_core_hash_destroy(&loadable_modules.dialplan_hash);
01186
01187 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Unoad a module.
00869 {
00870 switch_loadable_module_t *module = NULL;
00871 switch_status_t status = SWITCH_STATUS_SUCCESS;
00872
00873 switch_mutex_lock(loadable_modules.mutex);
00874 if ((module = switch_core_hash_find(loadable_modules.module_hash, fname))) {
00875 if (module->perm) {
00876 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Module is not unloadable.\n");
00877 *err = "Module is not unloadable";
00878 status = SWITCH_STATUS_NOUNLOAD;
00879 goto end;
00880 } else {
00881 do_shutdown(module, SWITCH_TRUE, SWITCH_TRUE);
00882 }
00883 switch_core_hash_delete(loadable_modules.module_hash, fname);
00884 } else {
00885 *err = "No such module!";
00886 status = SWITCH_STATUS_FALSE;
00887 }
00888 end:
00889 switch_mutex_unlock(loadable_modules.mutex);
00890
00891 return status;
00892
00893 }
|
Here is the call graph for this function:

|
||||||||||||
|
Load a module.
|
|
|
|
|
|
Shutdown a module.
|
1.3.9.1