]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add more modules to new mod loader macros/api.
authorMichael Jerris <mike@jerris.com>
Wed, 20 Jun 2007 08:18:18 +0000 (08:18 +0000)
committerMichael Jerris <mike@jerris.com>
Wed, 20 Jun 2007 08:18:18 +0000 (08:18 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5405 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/languages/mod_perl/mod_perl.c
src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
src/mod/say/mod_say_en/mod_say_en.c
src/mod/timers/mod_softtimer/mod_softtimer.c
src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c
src/mod/xml_int/mod_xml_curl/mod_xml_curl.c
src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c

index ec8655c3feda32b5161fa4d31b90fa4e43be6db8..e9759b2e5ba891e20b32b694914a6daf09c841a4 100644 (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;
index c6acdac950e830e7a3aef5d084c8686fce657c82..f7c935a96f36155a521724f3e735c9cfa957d571 100644 (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);
 
index 48b126b92eca0928cdb6b5670c43249998cf5cee..639b840b72e9849d59e90b23180326ae2a2d857d 100644 (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;
index 8e98e119c74220d253329a5ec68267945845f45a..35e817eb4d7fd14d989179ccde243a5a74e8fc7d 100644 (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;
index 53d7609c99d18b7e9ddf1a0252dd399bc8b28fb0..629f01023e5455f27e4d64757bf2c89ad76201f6 100644 (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;
index 9d44400e01ef1b815154eda8a228b6f065936254..6559da33bd79b1031c94c562f69443a747ecaf94 100644 (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);
index 9861774454b1dcb3ef3862cad1f3f59679411c44..c09ed1e9f0a56cc3817a4aa400dd88606ebd99c0 100644 (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));