[Freeswitch-svn] [commit] r9971 - freeswitch/trunk/src/mod/applications/mod_commands

Freeswitch SVN brian at freeswitch.org
Sat Oct 11 17:59:48 EDT 2008


Author: brian
Date: Sat Oct 11 17:59:48 2008
New Revision: 9971

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

Log:
add domain_exists api I mentioned it and Math wrote it as an exercise

Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	Sat Oct 11 17:59:48 2008
@@ -248,13 +248,28 @@
 			stream->write_function(stream, "true");
 		} else {
 			stream->write_function(stream, "false");
-
 		}		
 	}
 
     return SWITCH_STATUS_SUCCESS;
 }
 
+SWITCH_STANDARD_API(domain_exists_function)
+{
+	switch_xml_t root, domain;
+	
+	if (!switch_strlen_zero(cmd)) {	
+		if (switch_xml_locate_domain(cmd, NULL, &root, &domain) == SWITCH_STATUS_SUCCESS) {
+			stream->write_function(stream, "true");
+		} else {
+			stream->write_function(stream, "false");
+		}
+	}
+	switch_xml_free(root); 
+	
+	return SWITCH_STATUS_SUCCESS;
+}
+
 SWITCH_STANDARD_API(url_encode_function)
 {
 	char *reply = "";
@@ -2784,6 +2799,7 @@
 	SWITCH_ADD_API(commands_api_interface, "url_encode", "url encode a string", url_encode_function, "<string>");
 	SWITCH_ADD_API(commands_api_interface, "url_decode", "url decode a string", url_decode_function, "<string>");
 	SWITCH_ADD_API(commands_api_interface, "module_exists", "check if module exists", module_exists_function, "<module>");
+	SWITCH_ADD_API(commands_api_interface, "domain_exists", "check if a domain exists", domain_exists_function, "<module>");
 	SWITCH_ADD_API(commands_api_interface, "uuid_send_dtmf", "send dtmf digits", uuid_send_dtmf_function, UUID_SEND_DTMF_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "eval", "eval (noop)", eval_function, "<expression>");
 	SWITCH_ADD_API(commands_api_interface, "system", "Execute a system command", system_function, SYSTEM_SYNTAX);



More information about the Freeswitch-svn mailing list