[Freeswitch-trunk] [commit] r6430 - in freeswitch/trunk: libs/js src src/include src/mod/applications/mod_commands src/mod/applications/mod_dptools src/mod/applications/mod_voicemail src/mod/endpoints/mod_sofia src/mod/languages/mod_spidermonkey src/mod/xml_int/mod_xml_rpc
Freeswitch SVN
anthm at freeswitch.org
Wed Nov 28 21:48:45 EST 2007
Author: anthm
Date: Wed Nov 28 21:48:44 2007
New Revision: 6430
Modified:
freeswitch/trunk/libs/js/.update
freeswitch/trunk/libs/js/configure.ac
freeswitch/trunk/src/include/switch_xml.h
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey/sm.mak
freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c
freeswitch/trunk/src/switch_xml.cpp
Log:
add some stuff
Modified: freeswitch/trunk/libs/js/.update
==============================================================================
--- freeswitch/trunk/libs/js/.update (original)
+++ freeswitch/trunk/libs/js/.update Wed Nov 28 21:48:44 2007
@@ -1 +1 @@
-Mon Apr 23 14:11:42 EDT 2007
+Wed Nov 28 21:37:06 EST 2007
Modified: freeswitch/trunk/libs/js/configure.ac
==============================================================================
--- freeswitch/trunk/libs/js/configure.ac (original)
+++ freeswitch/trunk/libs/js/configure.ac Wed Nov 28 21:48:44 2007
@@ -141,6 +141,15 @@
CPPFLAGS="$CPPFLAGS -DJS_HAS_FILE_OBJECT=1"
fi
+dnl # configure option --without-xml
+AC_ARG_WITH([xml],
+ AS_HELP_STRING([--without-xml], [build without XML object]),
+ [ac_cv_with_xml=$withval], [ac_cv_with_xml=yes])
+AC_CACHE_CHECK([whether to build with the XML object], [ac_cv_with_xml], [ac_cv_with_xml=yes])
+if test ".$ac_cv_with_xml" = ".yes"; then
+ CPPFLAGS="$CPPFLAGS -DJS_HAS_XML_SUPPORT=1"
+fi
+
dnl # configure option --with-dso
AC_ARG_WITH([dso],
AS_HELP_STRING([--with-dso], [build without DSO object (allows run-time process extending)]),
Modified: freeswitch/trunk/src/include/switch_xml.h
==============================================================================
--- freeswitch/trunk/src/include/switch_xml.h (original)
+++ freeswitch/trunk/src/include/switch_xml.h Wed Nov 28 21:48:44 2007
@@ -319,7 +319,9 @@
const char *params);
SWITCH_DECLARE(switch_status_t) switch_xml_locate_domain(const char *domain_name, char *params, switch_xml_t *root, switch_xml_t *domain);
-SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(const char *user_name, const char *domain_name,
+SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(const char *key,
+ const char *user_name,
+ const char *domain_name,
const char *ip,
switch_xml_t *root,
switch_xml_t *domain,
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 Wed Nov 28 21:48:44 2007
@@ -41,6 +41,66 @@
SWITCH_MODULE_DEFINITION(mod_commands, mod_commands_load, NULL, NULL);
+SWITCH_STANDARD_API(find_user_function)
+{
+ switch_xml_t x_domain, x_user, xml = NULL;
+ int argc;
+ char *mydata = NULL, *argv[3];
+ char *key, *user, *domain;
+ char *xmlstr, *xs;
+
+ if (!cmd) {
+ stream->write_function(stream, "bad args\n");
+ goto end;
+ }
+
+ mydata = strdup(cmd);
+ assert(mydata);
+
+ argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+
+ if (argc < 3) {
+ stream->write_function(stream, "bad args\n");
+ goto end;
+ }
+
+ key = argv[0];
+ user = argv[1];
+ domain = argv[2];
+
+ if (!(key && user && domain)) {
+ stream->write_function(stream, "bad args\n");
+ goto end;
+ }
+
+ if (switch_xml_locate_user(key, user, domain, NULL, &xml, &x_domain, &x_user, NULL) != SWITCH_STATUS_SUCCESS) {
+ stream->write_function(stream, "can't find user [%s@%s]\n", user, domain);
+ goto end;
+ }
+
+
+ end:
+
+ if (xml) {
+ xmlstr = switch_xml_toxml(x_user);
+ assert(xmlstr);
+ if ((xs = strstr(xmlstr, "?>"))) {
+ xs += 2;
+ } else {
+ xs = xmlstr;
+ }
+ stream->write_function(stream, "%s", xs);
+ free(xmlstr);
+ switch_xml_free(xml);
+
+ }
+
+ free(mydata);
+ return SWITCH_STATUS_SUCCESS;
+
+}
+
+
SWITCH_STANDARD_API(regex_function)
{
switch_regex_t *re = NULL;
@@ -1782,6 +1842,7 @@
SWITCH_ADD_API(commands_api_interface, "qq", "Eval a conditional", cond_function, "<expr> ? <true val> : <false val>");
SWITCH_ADD_API(commands_api_interface, "regex", "Eval a regex", regex_function, "<data>|<pattern>[|<subst string>]");
SWITCH_ADD_API(commands_api_interface, "uuid_chat", "Send a chat message", uuid_chat, UUID_CHAT_SYNTAX);
+ SWITCH_ADD_API(commands_api_interface, "find_user_xml", "find a usere", find_user_function, "<key> <user>@<domain>");
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_NOUNLOAD;
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Wed Nov 28 21:48:44 2007
@@ -109,7 +109,7 @@
*domain++ = '\0';
- if (switch_xml_locate_user(user, domain, NULL, &xml, &x_domain, &x_user, NULL) != SWITCH_STATUS_SUCCESS) {
+ if (switch_xml_locate_user("id", user, domain, NULL, &xml, &x_domain, &x_user, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", user, domain);
goto done;
}
Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c Wed Nov 28 21:48:44 2007
@@ -1570,7 +1570,7 @@
assert(xtra);
- if (switch_xml_locate_user(myid, domain_name, switch_channel_get_variable(channel, "network_addr"),
+ if (switch_xml_locate_user("id", myid, domain_name, switch_channel_get_variable(channel, "network_addr"),
&x_domain_root, &x_domain, &x_user, xtra) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", myid, domain_name);
ok = 0;
@@ -1753,7 +1753,7 @@
assert(xtra);
x_user = x_domain = x_domain_root = NULL;
- if (switch_xml_locate_user(id, domain_name, switch_channel_get_variable(channel, "network_addr"),
+ if (switch_xml_locate_user("id", id, domain_name, switch_channel_get_variable(channel, "network_addr"),
&x_domain_root, &x_domain, &x_user, xtra) == SWITCH_STATUS_SUCCESS) {
if ((x_params = switch_xml_child(x_user, "params"))) {
for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Wed Nov 28 21:48:44 2007
@@ -893,7 +893,7 @@
domain_name = realm;
}
- if (switch_xml_locate_user(username, domain_name, ip, &xml, &domain, &user, pbuf) != SWITCH_STATUS_SUCCESS) {
+ if (switch_xml_locate_user("id", username, domain_name, ip, &xml, &domain, &user, pbuf) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", username, domain_name);
ret = AUTH_FORBIDDEN;
goto end;
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/sm.mak
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/sm.mak (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/sm.mak Wed Nov 28 21:48:44 2007
@@ -2,7 +2,7 @@
JS_DIR=$(switch_srcdir)/libs/js
JSLA=$(JS_DIR)/libjs.la
-LOCAL_CFLAGS+=-I$(JS_DIR)/src -I$(JS_DIR)/nsprpub/dist/include/nspr -DXP_UNIX -I../mod_spidermonkey -DJS_THREADSAFE -DJS_HAS_FILE_OBJECT=1
+LOCAL_CFLAGS+=-I$(JS_DIR)/src -I$(JS_DIR)/nsprpub/dist/include/nspr -DXP_UNIX -I../mod_spidermonkey -DJS_THREADSAFE -DJS_HAS_FILE_OBJECT=1 -DJS_HAS_XML_SUPPORT=1
LOCAL_LDFLAGS+=-L$(JS_DIR)/nsprpub/pr/src -L$(JS_DIR)/nsprpub/dist/lib -lnspr4
LOCAL_LIBADD+=$(JSLA)
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 Nov 28 21:48:44 2007
@@ -172,7 +172,7 @@
*pass++ = '\0';
}
- if (switch_xml_locate_user(user, domain_name, NULL, &x_domain_root, &x_domain, &x_user, "mailbox=check") != SWITCH_STATUS_SUCCESS) {
+ if (switch_xml_locate_user("id", user, domain_name, NULL, &x_domain_root, &x_domain, &x_user, "mailbox=check") != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", user, domain_name);
goto fail;
}
Modified: freeswitch/trunk/src/switch_xml.cpp
==============================================================================
--- freeswitch/trunk/src/switch_xml.cpp (original)
+++ freeswitch/trunk/src/switch_xml.cpp Wed Nov 28 21:48:44 2007
@@ -1296,7 +1296,8 @@
}
-SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(const char *user_name,
+SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(const char *key,
+ const char *user_name,
const char *domain_name,
const char *ip,
switch_xml_t *root,
@@ -1311,10 +1312,10 @@
*domain = NULL;
if (!switch_strlen_zero(xtra_params)) {
- snprintf(params, sizeof(params), "user=%s&domain=%s&ip=%s&%s",
+ snprintf(params, sizeof(params), "key=%s&user=%s&domain=%s&ip=%s&%s", key,
switch_str_nil(user_name), switch_str_nil(domain_name), switch_str_nil(ip), xtra_params);
} else {
- snprintf(params, sizeof(params), "user=%s&domain=%s&ip=%s",
+ snprintf(params, sizeof(params), "key=%s&user=%s&domain=%s&ip=%s", key,
switch_str_nil(user_name), switch_str_nil(domain_name), switch_str_nil(ip));
xtra_params = "";
}
@@ -1336,7 +1337,7 @@
}
}
- if ((*user = switch_xml_find_child(*domain, "user", "id", user_name))) {
+ if ((*user = switch_xml_find_child(*domain, "user", key, user_name))) {
return SWITCH_STATUS_SUCCESS;
}
More information about the Freeswitch-trunk
mailing list