diff --git a/src/include/switch_loadable_module.h b/src/include/switch_loadable_module.h index 098179e0ee..e957dde468 100644 --- a/src/include/switch_loadable_module.h +++ b/src/include/switch_loadable_module.h @@ -295,6 +295,14 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void); break; \ } +#define SWITCH_ADD_DIALPLAN(dp_int, int_name, funcptr) \ + for (;;) { \ + dp_int = switch_loadable_module_create_interface(*module_interface, SWITCH_DIALPLAN_INTERFACE); \ + dp_int->hunt_function = funcptr; \ + dp_int->interface_name = int_name; \ + break; \ + } + ///\} SWITCH_END_EXTERN_C diff --git a/src/mod/applications/mod_enum/mod_enum.c b/src/mod/applications/mod_enum/mod_enum.c index afd29058cf..09f8d578e2 100644 --- a/src/mod/applications/mod_enum/mod_enum.c +++ b/src/mod/applications/mod_enum/mod_enum.c @@ -111,13 +111,6 @@ static switch_status_t load_config(void) switch_xml_t cfg, xml = NULL, param, settings, route, routes; switch_status_t status = SWITCH_STATUS_SUCCESS; - memset(&globals, 0, sizeof(globals)); - if (switch_core_new_memory_pool(&globals.pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n"); - status = SWITCH_STATUS_TERM; - goto done; - } - switch_core_hash_init(&globals.routes, globals.pool); if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { @@ -564,7 +557,7 @@ static switch_caller_extension_t *enum_dialplan_hunt(switch_core_session_t *sess } -static void enum_app_function(switch_core_session_t *session, char *data) +SWITCH_STANDARD_APP(enum_app_function) { int argc = 0; char *argv[4] = { 0 }; @@ -685,54 +678,26 @@ SWITCH_STANDARD_API(enum_function) } -static switch_dialplan_interface_t enum_dialplan_interface = { - /*.interface_name = */ "enum", - /*.hunt_function = */ enum_dialplan_hunt - /*.next = NULL */ -}; - -static switch_application_interface_t enum_application_interface = { - /*.interface_name */ "enum", - /*.application_function */ enum_app_function, - /* long_desc */ "Perform an ENUM lookup", - /* short_desc */ "Perform an ENUM lookup", - /* syntax */ " []", - /* flags */ SAF_SUPPORT_NOMEDIA, - /*.next */ NULL -}; - -static switch_api_interface_t enum_api_interface = { - /*.interface_name */ "enum", - /*.desc */ "ENUM", - /*.function */ enum_function, - /*.syntax */ "", - /*.next */ NULL -}; - -static switch_loadable_module_interface_t enum_module_interface = { - /*.module_name */ modname, - /*.endpoint_interface */ NULL, - /*.timer_interface */ NULL, - /*.dialplan_interface */ &enum_dialplan_interface, - /*.codec_interface */ NULL, - /*.application_interface */ &enum_application_interface, - /*.api_interface */ &enum_api_interface, - /*.file_interface */ NULL, - /*.speech_interface */ NULL, - /*.directory_interface */ NULL -}; - SWITCH_MODULE_LOAD_FUNCTION(mod_enum_load) { + switch_api_interface_t *api_interface; + switch_application_interface_t *app_interface; + switch_dialplan_interface_t *dp_interface; if (dns_init(0) < 0) { return SWITCH_STATUS_FALSE; } + memset(&globals, 0, sizeof(globals)); + globals.pool = pool; + load_config(); /* connect my internal structure to the blank pointer passed to me */ - *module_interface = &enum_module_interface; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + SWITCH_ADD_API(api_interface, "enum", "ENUM", enum_function, ""); + SWITCH_ADD_APP(app_interface, "enum", "Perform an ENUM lookup", "Perform an ENUM lookup", enum_app_function, " []", SAF_SUPPORT_NOMEDIA); + SWITCH_ADD_DIALPLAN(dp_interface, "enum", enum_dialplan_hunt); /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; diff --git a/src/mod/applications/mod_esf/mod_esf.c b/src/mod/applications/mod_esf/mod_esf.c index 336ad0899d..43d9b8d7dc 100644 --- a/src/mod/applications/mod_esf/mod_esf.c +++ b/src/mod/applications/mod_esf/mod_esf.c @@ -54,7 +54,7 @@ typedef enum { SEND_TYPE_NOMEDIA = 3 } ls_how_t; -static void bcast_function(switch_core_session_t *session, char *data) +SWITCH_STANDARD_APP(bcast_function) { switch_channel_t *channel; switch_socket_t *socket; @@ -228,36 +228,18 @@ static void bcast_function(switch_core_session_t *session, char *data) } -static switch_application_interface_t bcast_application_interface = { - /*.interface_name */ "esf_ls_page_group", - /*.application_function */ bcast_function, - NULL, NULL, NULL, - /* flags */ SAF_NONE, - /*.next */ NULL -}; - -static switch_loadable_module_interface_t mod_ivrtest_module_interface = { - /*.module_name = */ modname, - /*.endpoint_interface = */ NULL, - /*.timer_interface = */ NULL, - /*.dialplan_interface = */ NULL, - /*.codec_interface = */ NULL, - /*.application_interface */ &bcast_application_interface -}; - SWITCH_MODULE_LOAD_FUNCTION(mod_esf_load) { + switch_application_interface_t *app_interface; /* connect my internal structure to the blank pointer passed to me */ - *module_interface = &mod_ivrtest_module_interface; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + SWITCH_ADD_APP(app_interface, "esf_ls_page_group", NULL, NULL, bcast_function, NULL, SAF_NONE); /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; } - -//switch_status_t switch_module_runtime(void) - /* For Emacs: * Local Variables: * mode:c diff --git a/src/mod/applications/mod_rss/mod_rss.c b/src/mod/applications/mod_rss/mod_rss.c index 693d3d99c3..9b57c01ede 100644 --- a/src/mod/applications/mod_rss/mod_rss.c +++ b/src/mod/applications/mod_rss/mod_rss.c @@ -152,7 +152,7 @@ static switch_status_t on_dtmf(switch_core_session_t *session, void *input, swit return SWITCH_STATUS_SUCCESS; } -static void rss_function(switch_core_session_t *session, char *data) +SWITCH_STANDARD_APP(rss_function) { switch_channel_t *channel; switch_status_t status; @@ -613,33 +613,14 @@ static void rss_function(switch_core_session_t *session, char *data) switch_core_session_reset(session); } -static switch_application_interface_t rss_application_interface = { - /*.interface_name */ "rss", - /*.application_function */ rss_function, - NULL, NULL, NULL, - /* flags */ SAF_NONE, - /*.next */ NULL -}; - - -static switch_loadable_module_interface_t rss_module_interface = { - /*.module_name */ modname, - /*.endpoint_interface */ NULL, - /*.timer_interface */ NULL, - /*.dialplan_interface */ NULL, - /*.codec_interface */ NULL, - /*.application_interface */ &rss_application_interface, - /*.api_interface */ NULL, - /*.file_interface */ NULL, - /*.speech_interface */ NULL, - /*.directory_interface */ NULL -}; - SWITCH_MODULE_LOAD_FUNCTION(mod_rss_load) { + switch_application_interface_t *app_interface; + /* connect my internal structure to the blank pointer passed to me */ - *module_interface = &rss_module_interface; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + SWITCH_ADD_APP(app_interface, "rss", NULL, NULL, rss_function, NULL, SAF_NONE); /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS;