From 86c1904cce96ba149bb9b01525a564a4d07aa34f Mon Sep 17 00:00:00 2001 From: Anthony Minessale <anthony.minessale@gmail.com> Date: Fri, 9 Dec 2005 19:33:21 +0000 Subject: [PATCH] update git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@101 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_loadable_module.h | 2 ++ src/include/switch_types.h | 1 + src/switch_loadable_module.c | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/src/include/switch_loadable_module.h b/src/include/switch_loadable_module.h index 20de1ff294..3ab1acd9a0 100644 --- a/src/include/switch_loadable_module.h +++ b/src/include/switch_loadable_module.h @@ -46,6 +46,7 @@ struct switch_loadable_module_interface { const switch_dialplan_interface *dialplan_interface; const switch_codec_interface *codec_interface; const switch_application_interface *application_interface; + const switch_api_interface *api_interface; }; SWITCH_DECLARE(switch_status) switch_loadable_module_init(void); @@ -54,6 +55,7 @@ SWITCH_DECLARE(switch_codec_interface *) loadable_module_get_codec_interface(cha SWITCH_DECLARE(switch_dialplan_interface *) loadable_module_get_dialplan_interface(char *name); SWITCH_DECLARE(switch_timer_interface *) loadable_module_get_timer_interface(char *name); SWITCH_DECLARE(switch_application_interface *) loadable_module_get_application_interface(char *name); +SWITCH_DECLARE(switch_application_interface *) loadable_module_get_api_interface(char *name); SWITCH_DECLARE(int) loadable_module_get_codecs(switch_memory_pool *pool, switch_codec_interface **array, int arraylen); SWITCH_DECLARE(int) loadable_module_get_codecs_sorted(switch_memory_pool *pool, switch_codec_interface **array, int arraylen, char **prefs, int preflen); SWITCH_DECLARE(void) loadable_module_shutdown(void); diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 14574c03b7..b74dec9c83 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -130,6 +130,7 @@ typedef struct switch_timer_interface switch_timer_interface; typedef struct switch_dialplan_interface switch_dialplan_interface; typedef struct switch_codec_interface switch_codec_interface; typedef struct switch_application_interface switch_application_interface; +typedef struct switch_api_interface switch_api_interface; typedef struct switch_core_session switch_core_session; typedef struct switch_loadable_module_interface switch_loadable_module_interface; typedef struct switch_caller_profile switch_caller_profile; diff --git a/src/switch_loadable_module.c b/src/switch_loadable_module.c index a8e473dea2..42e439de8f 100644 --- a/src/switch_loadable_module.c +++ b/src/switch_loadable_module.c @@ -60,6 +60,7 @@ struct switch_loadable_module_container { switch_hash *dialplan_hash; switch_hash *timer_hash; switch_hash *application_hash; + switch_hash *api_hash; switch_memory_pool *pool; }; @@ -205,6 +206,7 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init() switch_core_hash_init(&loadable_modules.codec_hash, loadable_modules.pool); switch_core_hash_init(&loadable_modules.timer_hash, loadable_modules.pool); switch_core_hash_init(&loadable_modules.application_hash, loadable_modules.pool); + switch_core_hash_init(&loadable_modules.api_hash, loadable_modules.pool); switch_core_hash_init(&loadable_modules.dialplan_hash, loadable_modules.pool); while (apr_dir_read(&finfo, finfo_flags, module_dir_handle) == APR_SUCCESS) { @@ -297,6 +299,17 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init() } } + if (new_module->interface->api_interface) { + const switch_api_interface *ptr; + + for(ptr = new_module->interface->api_interface; ptr; ptr = ptr->next) { + switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Adding API Function '%s'\n", ptr->interface_name); + switch_core_hash_insert(loadable_modules.api_hash, + (char *) ptr->interface_name, + (void *) ptr); + } + } + } } @@ -350,6 +363,11 @@ SWITCH_DECLARE(switch_application_interface *) loadable_module_get_application_i return switch_core_hash_find(loadable_modules.application_hash, name); } +SWITCH_DECLARE(switch_application_interface *) loadable_module_get_api_interface(char *name) +{ + return switch_core_hash_find(loadable_modules.api_hash, name); +} + SWITCH_DECLARE(int) loadable_module_get_codecs(switch_memory_pool *pool, switch_codec_interface **array, int arraylen) { apr_hash_index_t* hi;