[Freeswitch-svn] [commit] r5405 - in freeswitch/trunk/src/mod: languages/mod_perl languages/mod_spidermonkey say/mod_say_en timers/mod_softtimer xml_int/mod_xml_cdr xml_int/mod_xml_curl xml_int/mod_xml_rpc

Freeswitch SVN mikej at freeswitch.org
Wed Jun 20 04:18:18 EDT 2007


Author: mikej
Date: Wed Jun 20 04:18:18 2007
New Revision: 5405

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

Log:
add more modules to new mod loader macros/api.

Modified: freeswitch/trunk/src/mod/languages/mod_perl/mod_perl.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/mod_perl.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/mod_perl.c	Wed Jun 20 04:18:18 2007
@@ -79,29 +79,6 @@
 	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_LOAD_FUNCTION(mod_perl_load)
 {
-
+	switch_application_interface_t *app_interface;
 	PerlInterpreter *my_perl;
 	char code[1024];
 
@@ -135,7 +112,8 @@
 
 
 	/* 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;

Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	Wed Jun 20 04:18:18 2007
@@ -2914,7 +2914,6 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-
 SWITCH_STANDARD_API(launch_async)
 {
 
@@ -2928,48 +2927,6 @@
 	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 @@
 
 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 @@
 	}
 
 	/* 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);
 

Modified: freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c
==============================================================================
--- freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c	(original)
+++ freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c	Wed Jun 20 04:18:18 2007
@@ -510,37 +510,18 @@
 	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;

Modified: freeswitch/trunk/src/mod/timers/mod_softtimer/mod_softtimer.c
==============================================================================
--- freeswitch/trunk/src/mod/timers/mod_softtimer/mod_softtimer.c	(original)
+++ freeswitch/trunk/src/mod/timers/mod_softtimer/mod_softtimer.c	Wed Jun 20 04:18:18 2007
@@ -186,31 +186,20 @@
 	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;

Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c
==============================================================================
--- freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c	(original)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c	Wed Jun 20 04:18:18 2007
@@ -91,22 +91,12 @@
 	/*.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;

Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c
==============================================================================
--- freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c	(original)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c	Wed Jun 20 04:18:18 2007
@@ -143,20 +143,6 @@
 	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 @@
 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);

Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c
==============================================================================
--- freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c	(original)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c	Wed Jun 20 04:18:18 2007
@@ -47,19 +47,6 @@
 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 @@
 } 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_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));
 



More information about the Freeswitch-svn mailing list