From a1bda52bb6dd5d7805f133dd9433c6b7f5402a1e Mon Sep 17 00:00:00 2001 From: Brian West Date: Sat, 11 Oct 2008 21:59:48 +0000 Subject: [PATCH] add domain_exists api I mentioned it and Math wrote it as an exercise git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9971 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../applications/mod_commands/mod_commands.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index c3ec672142..a4e1a26f40 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -248,13 +248,28 @@ SWITCH_STANDARD_API(module_exists_function) 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_MODULE_LOAD_FUNCTION(mod_commands_load) SWITCH_ADD_API(commands_api_interface, "url_encode", "url encode a string", url_encode_function, ""); SWITCH_ADD_API(commands_api_interface, "url_decode", "url decode a string", url_decode_function, ""); SWITCH_ADD_API(commands_api_interface, "module_exists", "check if module exists", module_exists_function, ""); + SWITCH_ADD_API(commands_api_interface, "domain_exists", "check if a domain exists", domain_exists_function, ""); 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, ""); SWITCH_ADD_API(commands_api_interface, "system", "Execute a system command", system_function, SYSTEM_SYNTAX);