[Freeswitch-svn] [commit] r11070 - freeswitch/trunk/src/mod/applications/mod_easyroute

FreeSWITCH SVN silik0n at freeswitch.org
Fri Jan 9 22:38:59 PST 2009


Author: silik0n
Date: Sat Jan 10 01:38:59 2009
New Revision: 11070

Log:
add option to return a specific field for API usage

Modified:
   freeswitch/trunk/src/mod/applications/mod_easyroute/mod_easyroute.c

Modified: freeswitch/trunk/src/mod/applications/mod_easyroute/mod_easyroute.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_easyroute/mod_easyroute.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_easyroute/mod_easyroute.c	Sat Jan 10 01:38:59 2009
@@ -319,14 +319,43 @@
 	
 	if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
 		destnum = argv[0];
+		if (argc < 1 || argc > 2){
+			stream->write_function(stream, "Invalid Input!\n");
+			return SWITCH_STATUS_SUCCESS;
+		} 
 		
 		if (!route_lookup(destnum, &results) == SWITCH_STATUS_SUCCESS) {
 			stream->write_function(stream, "No Match!\n");
 			return SWITCH_STATUS_SUCCESS;
 		}
-		
-		stream->write_function(stream, "Number    \tLimit     \tGroup    \tAcctCode  \tDialstring\n");
-		stream->write_function(stream, "%-10s\t%-10s\t%-10s\t%-10s\t%s\n", destnum, results.limit, results.group, results.acctcode, results.dialstring);
+		if (argc != 2){
+			stream->write_function(stream, "Number    \tLimit     \tGroup    \tAcctCode  \tDialstring\n");
+			stream->write_function(stream, "%-10s\t%-10s\t%-10s\t%-10s\t%s\n", destnum, results.limit, results.group, results.acctcode, results.dialstring);
+		} else {
+
+			/*      char    limit[16];
+        			char    destnum[16];
+        			char    dialstring[256];
+        			char    group[16];
+        			char    acctcode[17];
+        			char    translated[17];
+			*/
+
+			if (!strncasecmp(argv[1], "dialstring", 10)) {
+				stream->write_function(stream, "%s", results.dialstring);
+			} else if (!strncasecmp(argv[1], "translated", 10)) {
+				stream->write_function(stream, "%s", results.translated);
+			} else if (!strncasecmp(argv[1], "limit", 5)) {
+				stream->write_function(stream, "%s", results.limit);
+			} else if (!strncasecmp(argv[1], "group", 5)) {
+				stream->write_function(stream, "%s", results.group);
+			} else if (!strncasecmp(argv[1], "acctcode", 8)) {
+				stream->write_function(stream, "%s", results.acctcode);
+			} else {
+				stream->write_function(stream, "Invalid Input!\n");
+				return SWITCH_STATUS_SUCCESS;
+			}
+		} 
 	} else {
 		stream->write_function(stream, "Invalid Input!\n");
 	}



More information about the Freeswitch-svn mailing list