add more modules to new mod loader macros/api.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5405 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2007-06-20 08:18:18 +00:00
parent ae02cbef83
commit 4e434aff7f
7 changed files with 34 additions and 161 deletions

View File

@ -79,29 +79,6 @@ static void perl_function(switch_core_session_t *session, char *data)
destroy_perl(&my_perl);
}
static switch_application_interface_t perl_application_interface = {
/*.interface_name */ "perl",
/*.application_function */ perl_function,
NULL, NULL, NULL,
/* flags */ SAF_NONE,
/* should we support no media mode here? If so, we need to detect the mode, and either disable the media functions or indicate media if/when we need */
/*.next */ NULL
};
static switch_loadable_module_interface_t perl_module_interface = {
/*.module_name */ modname,
/*.endpoint_interface */ NULL,
/*.timer_interface */ NULL,
/*.dialplan_interface */ NULL,
/*.codec_interface */ NULL,
/*.application_interface */ &perl_application_interface,
/*.api_interface */ NULL,
/*.file_interface */ NULL,
/*.speech_interface */ NULL,
/*.directory_interface */ NULL
};
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_perl_shutdown)
{
if (globals.my_perl) {
@ -115,7 +92,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_perl_shutdown)
SWITCH_MODULE_LOAD_FUNCTION(mod_perl_load)
{
switch_application_interface_t *app_interface;
PerlInterpreter *my_perl;
char code[1024];
@ -135,7 +112,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_perl_load)
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &perl_module_interface;
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_APP(app_interface, "perl", NULL, NULL, perl_function, NULL, SAF_NONE);
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;

View File

@ -2914,7 +2914,6 @@ SWITCH_STANDARD_API(jsapi_function)
return SWITCH_STATUS_SUCCESS;
}
SWITCH_STANDARD_API(launch_async)
{
@ -2928,48 +2927,6 @@ SWITCH_STANDARD_API(launch_async)
return SWITCH_STATUS_SUCCESS;
}
static switch_application_interface_t ivrtest_application_interface = {
/*.interface_name */ "javascript",
/*.application_function */ js_dp_function,
/* long_desc */ "Run a javascript ivr on a channel",
/* short_desc */ "Launch JS ivr.",
/* syntax */ "<script> [additional_vars [...]]",
/* flags */ SAF_NONE,
/* should we support no media mode here? If so, we need to detect the mode, and either disable the media functions or indicate media if/when we need */
/*.next */ NULL
};
static switch_api_interface_t jsapi_interface = {
/*.interface_name */ "jsapi",
/*.desc */ "execute an api call",
/*.function */ jsapi_function,
/*.syntax */ "jsapi <script> [additional_vars [...]]",
/*.next */ NULL
};
static switch_api_interface_t js_run_interface = {
/*.interface_name */ "jsrun",
/*.desc */ "run a script",
/*.function */ launch_async,
/*.syntax */ "jsrun <script> [additional_vars [...]]",
/*.next */ &jsapi_interface
};
static switch_loadable_module_interface_t spidermonkey_module_interface = {
/*.module_name */ modname,
/*.endpoint_interface */ NULL,
/*.timer_interface */ NULL,
/*.dialplan_interface */ NULL,
/*.codec_interface */ NULL,
/*.application_interface */ &ivrtest_application_interface,
/*.api_interface */ &js_run_interface,
/*.file_interface */ NULL,
/*.speech_interface */ NULL,
/*.directory_interface */ NULL
};
static void message_query_handler(switch_event_t *event)
{
char *account = switch_event_get_header(event, "message-account");
@ -2994,6 +2951,8 @@ static void message_query_handler(switch_event_t *event)
SWITCH_MODULE_LOAD_FUNCTION(mod_spidermonkey_load)
{
switch_api_interface_t *api_interface;
switch_application_interface_t *app_interface;
switch_status_t status;
if ((status = init_js()) != SWITCH_STATUS_SUCCESS) {
@ -3007,7 +2966,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spidermonkey_load)
}
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &spidermonkey_module_interface;
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_API(api_interface, "jsrun", "run a script", launch_async, "jsrun <script> [additional_vars [...]]");
SWITCH_ADD_API(api_interface, "jsapi", "execute an api call", jsapi_function, "jsapi <script> [additional_vars [...]]");
SWITCH_ADD_APP(app_interface, "javascript", "Launch JS ivr", "Run a javascript ivr on a channel", js_dp_function, "<script> [additional_vars [...]]", SAF_NONE);
curl_global_init(CURL_GLOBAL_ALL);

View File

@ -510,37 +510,18 @@ static switch_status_t en_say(switch_core_session_t *session, char *tosay, switc
return SWITCH_STATUS_FALSE;
}
static switch_say_interface_t es_say_interface = {
/*.name */ "es",
/*.say_function */ en_say,
};
static switch_say_interface_t en_say_interface = {
/*.name */ "en",
/*.say_function */ en_say,
/*.next */ &es_say_interface
};
static switch_loadable_module_interface_t say_en_module_interface = {
/*.module_name */ modname,
/*.endpoint_interface */ NULL,
/*.timer_interface */ NULL,
/*.dialplan_interface */ NULL,
/*.codec_interface */ NULL,
/*.application_interface */ NULL,
/*.api_interface */ NULL,
/*.file_interface */ NULL,
/*.speech_interface */ NULL,
/*.directory_interface */ NULL,
/*.chat_interface */ NULL,
/*.say_inteface */ &en_say_interface,
/*.asr_interface */ NULL
};
SWITCH_MODULE_LOAD_FUNCTION(mod_say_en_load)
{
switch_say_interface_t *say_interface;
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &say_en_module_interface;
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
say_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_SAY_INTERFACE);
say_interface->interface_name = "en";
say_interface->say_function = en_say;
say_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_SAY_INTERFACE);
say_interface->interface_name = "es";
say_interface->say_function = en_say;
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;

View File

@ -186,31 +186,20 @@ static inline switch_status_t timer_destroy(switch_timer_t *timer)
return SWITCH_STATUS_SUCCESS;
}
static switch_timer_interface_t timer_interface = {
/*.interface_name */ "soft",
/*.timer_init */ timer_init,
/*.timer_next */ timer_next,
/*.timer_step */ timer_step,
/*.timer_check */ timer_check,
/*.timer_destroy */ timer_destroy
};
static switch_loadable_module_interface_t softtimer_module_interface = {
/*.module_name */ modname,
/*.endpoint_interface */ NULL,
/*.timer_interface */ &timer_interface
};
SWITCH_MODULE_LOAD_FUNCTION(mod_softtimer_load)
{
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
return SWITCH_STATUS_MEMERR;
}
switch_timer_interface_t *timer_interface;
module_pool = pool;
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &softtimer_module_interface;
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
timer_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_TIMER_INTERFACE);
timer_interface->interface_name = "soft";
timer_interface->timer_init = timer_init;
timer_interface->timer_next = timer_next;
timer_interface->timer_step = timer_step;
timer_interface->timer_check = timer_check;
timer_interface->timer_destroy = timer_destroy;
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;

View File

@ -91,22 +91,12 @@ static switch_state_handler_table_t state_handlers = {
/*.on_transmit */ NULL
};
static switch_loadable_module_interface_t xml_cdr_module_interface = {
/*.module_name = */ modname,
/*.endpoint_interface = */ NULL,
/*.timer_interface = */ NULL,
/*.dialplan_interface = */ NULL,
/*.codec_interface = */ NULL,
/*.application_interface */ NULL
};
SWITCH_MODULE_LOAD_FUNCTION(mod_xml_cdr_load)
{
/* test global state handlers */
switch_core_add_state_handler(&state_handlers);
*module_interface = &xml_cdr_module_interface;
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;

View File

@ -143,20 +143,6 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
return xml;
}
static switch_loadable_module_interface_t xml_curl_module_interface = {
/*.module_name */ modname,
/*.endpoint_interface */ NULL,
/*.timer_interface */ NULL,
/*.dialplan_interface */ NULL,
/*.codec_interface */ NULL,
/*.application_interface */ NULL,
/*.api_interface */ NULL,
/*.file_interface */ NULL,
/*.speech_interface */ NULL,
/*.directory_interface */ NULL
};
static switch_status_t do_config(void)
{
char *cf = "xml_curl.conf";
@ -234,7 +220,7 @@ static switch_status_t do_config(void)
SWITCH_MODULE_LOAD_FUNCTION(mod_xml_curl_load)
{
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &xml_curl_module_interface;
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
if (do_config() == SWITCH_STATUS_SUCCESS) {
curl_global_init(CURL_GLOBAL_ALL);

View File

@ -47,19 +47,6 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_rpc_shutdown);
SWITCH_MODULE_RUNTIME_FUNCTION(mod_xml_rpc_runtime);
SWITCH_MODULE_DEFINITION(mod_xml_rpc, mod_xml_rpc_load, mod_xml_rpc_shutdown, mod_xml_rpc_runtime);
static switch_loadable_module_interface_t xml_rpc_module_interface = {
/*.module_name */ modname,
/*.endpoint_interface */ NULL,
/*.timer_interface */ NULL,
/*.dialplan_interface */ NULL,
/*.codec_interface */ NULL,
/*.application_interface */ NULL,
/*.api_interface */ NULL,
/*.file_interface */ NULL,
/*.speech_interface */ NULL,
/*.directory_interface */ NULL
};
static struct {
uint16_t port;
uint8_t running;
@ -69,10 +56,10 @@ static struct {
} globals;
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_realm, globals.realm)
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_user, globals.user)
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_pass, globals.pass)
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_user, globals.user)
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_pass, globals.pass)
static switch_status_t do_config(void)
static switch_status_t do_config(void)
{
char *cf = "xml_rpc.conf";
switch_xml_t cfg, xml, settings, param;
@ -118,7 +105,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_realm, globals.realm)
SWITCH_MODULE_LOAD_FUNCTION(mod_xml_rpc_load)
{
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &xml_rpc_module_interface;
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
memset(&globals, 0, sizeof(globals));