[Freeswitch-svn] [commit] r10267 - in freeswitch/branches/gmaruzz: src/mod/endpoints/mod_skypiax stuff

Freeswitch SVN gmaruzz at freeswitch.org
Fri Nov 7 11:40:48 PST 2008


Author: gmaruzz
Date: Thu Nov  6 07:59:10 2008
New Revision: 10267

Modified:
   freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
   freeswitch/branches/gmaruzz/stuff/skypiax.conf.xml

Log:
skypiax: continue to parse nested configuration, eg: multiple interfaces

Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c	(original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c	Thu Nov  6 07:59:10 2008
@@ -2207,6 +2207,8 @@
 #ifdef MOD_SKYPIAX
 #include <switch.h>
 
+#define SKYPIAX_MAX_INTERFACES 64
+
 SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load);
 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown);
 //SWITCH_MODULE_RUNTIME_FUNCTION(mod_skypiax_runtime);
@@ -2251,7 +2253,6 @@
 	int calls;
 	char hold_music[256];
 	switch_mutex_t *mutex;
-	//analog_option_t analog_options;
 } globals;
 
 struct private_object {
@@ -2269,6 +2270,22 @@
 
 typedef struct private_object private_t;
 
+struct skypiax_config {
+	char dialplan[80];
+	char context[80];
+	char dial_regex[256];
+	char fail_dial_regex[256];
+	char hold_music[256];
+	char type[256];
+};
+
+typedef struct skypiax_config skypiax_config_t;
+
+//static struct skypiax_config SKYPIAX_CONFIGS[SKYPIAX_MAX_INTERFACES] = {{0}};
+skypiax_config_t SKYPIAX_CONFIGS[SKYPIAX_MAX_INTERFACES];
+
+
+
 
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan);
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string);
@@ -2654,7 +2671,6 @@
 	/*.receive_event */ channel_receive_event
 };
 
-#ifndef NOTDEF
 static switch_status_t load_config(void)
 {
 	char *cf = "skypiax.conf";
@@ -2750,12 +2766,16 @@
 				
 			}
 				
-			if (!id && !name) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "span missing BOTH required param 'id' AND 'name'\n");
+			if (!id) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "span missing REQUIRED param 'id'\n");
 				continue;
 			}
 
 			
+			if (!name) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "span missing param 'name', not nice, but works\n");
+				//continue;
+			}
 			
 			if (!tonegroup) {
 				tonegroup = "us";
@@ -2771,13 +2791,25 @@
 
 			if (name) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "name=%s\n", name);
-			} else {
-				if (switch_is_number(id)) {
+			}
+
+			if (switch_is_number(id)) {
 					span_id = atoi(id);
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "span_id=%d\n", span_id);
-				}
 			}
 
+			if(span_id) {
+				struct skypiax_config newconf;
+				//skypax_config_t newconf;
+				memset(&newconf, '\0', sizeof(newconf));
+				SKYPIAX_CONFIGS[span_id]=newconf;
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CONFIGURING span_id=%d\n", span_id);
+				switch_set_string(SKYPIAX_CONFIGS[span_id].context, context);
+				switch_set_string(SKYPIAX_CONFIGS[span_id].dialplan, dialplan);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "span_id=%d SKYPIAX_CONFIGS[span_id].context=%s\n", span_id, SKYPIAX_CONFIGS[span_id].context);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "span_id=%d SKYPIAX_CONFIGS[span_id].dialplan=%s\n", span_id, SKYPIAX_CONFIGS[span_id].dialplan);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "STARTING span_id=%d\n", span_id);
+			}
 //FIXME 
 			/*
 			if (zstatus != ZAP_SUCCESS) {
@@ -2825,62 +2857,7 @@
 
 	return SWITCH_STATUS_SUCCESS;
 }
-#endif /* NOTDEF */
-
-
-#ifdef NOTDEF
-static switch_status_t load_config(void)
-{
-	char *cf = "skypiax.conf";
-	switch_xml_t cfg, xml, settings, param;
-
-	memset(&globals, 0, sizeof(globals));
-	switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
-	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf);
-		return SWITCH_STATUS_TERM;
-	}
-
-	if ((settings = switch_xml_child(cfg, "settings"))) {
-		for (param = switch_xml_child(settings, "param"); param; param = param->next) {
-			char *var = (char *) switch_xml_attr_soft(param, "name");
-			char *val = (char *) switch_xml_attr_soft(param, "value");
 
-			if (!strcmp(var, "debug")) {
-				globals.debug = atoi(val);
-			} else if (!strcmp(var, "port")) {
-				globals.port = atoi(val);
-			} else if (!strcmp(var, "ip")) {
-				set_global_ip(val);
-			} else if (!strcmp(var, "codec-master")) {
-				if (!strcasecmp(val, "us")) {
-					switch_set_flag(&globals, GFLAG_MY_CODEC_PREFS);
-				}
-			} else if (!strcmp(var, "dialplan")) {
-				set_global_dialplan(val);
-			} else if (!strcmp(var, "codec-prefs")) {
-				set_global_codec_string(val);
-				globals.codec_order_last = switch_separate_string(globals.codec_string, ',', globals.codec_order, SWITCH_MAX_CODECS);
-			} else if (!strcmp(var, "codec-rates")) {
-				set_global_codec_rates_string(val);
-				globals.codec_rates_last = switch_separate_string(globals.codec_rates_string, ',', globals.codec_rates, SWITCH_MAX_CODECS);
-			}
-		}
-	}
-
-	if (!globals.dialplan) {
-		set_global_dialplan("default");
-	}
-
-	if (!globals.port) {
-		globals.port = 4569;
-	}
-
-	switch_xml_free(xml);
-
-	return SWITCH_STATUS_SUCCESS;
-}
-#endif /* NOTDEF */
 
 SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load)
 {

Modified: freeswitch/branches/gmaruzz/stuff/skypiax.conf.xml
==============================================================================
--- freeswitch/branches/gmaruzz/stuff/skypiax.conf.xml	(original)
+++ freeswitch/branches/gmaruzz/stuff/skypiax.conf.xml	Thu Nov  6 07:59:10 2008
@@ -22,7 +22,18 @@
 	  <param name="dial-regex" value="9996"/> 
 	  <param name="dial-regex-fail" value="9996"/>
     </span>
-    <span id="2">
+    <span name="ciapalo">
+      <param name="hold-music" value="$${moh_uri}"/>
+      <param name="tonegroup" value="us"/>
+      <param name="digit-timeout" value="2000"/>
+      <param name="max-digits" value="11"/>
+      <param name="dialplan" value="XML"/>
+      <param name="context" value="default"/>
+      <param name="enable-callerid" value="true"/>
+	  <param name="dial-regex" value="9996"/> 
+	  <param name="dial-regex-fail" value="9996"/>
+    </span>
+    <span>
       <param name="hold-music" value="$${moh_uri}"/>
       <param name="tonegroup" value="us"/>
       <param name="digit-timeout" value="2000"/>



More information about the Freeswitch-svn mailing list