change xml_lookups to take an event as params instead of url string this will break your xml_curl scripts please update

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7333 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2008-01-23 20:59:25 +00:00
parent 14ba0b9999
commit 1424b6c73b
16 changed files with 286 additions and 103 deletions

View File

@@ -50,7 +50,7 @@ SWITCH_STANDARD_API(user_data_function)
char delim = ' ';
const char *err = NULL;
const char *container = "params", *elem = "param";
char *params = NULL;
switch_event_t *params = NULL;
if (!cmd) {
err = "bad args";
@@ -77,7 +77,13 @@ SWITCH_STANDARD_API(user_data_function)
domain = "cluecon.com";
}
params = switch_mprintf("user=%s&domain=%s&type=%s&key=%s", user, domain, type, key);
switch_event_create(&params, SWITCH_EVENT_MESSAGE);
switch_assert(params);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "user", user);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "domain", domain);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "type", type);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "key", key);
if (switch_xml_locate_user("id", user, domain, NULL, &xml, &x_domain, &x_user, params) != SWITCH_STATUS_SUCCESS) {
err = "can't find user";
@@ -87,6 +93,9 @@ SWITCH_STANDARD_API(user_data_function)
end:
switch_event_destroy(&params);
if (xml) {
if (err) {
//stream->write_function(stream, "-Error %s\n", err);
@@ -217,7 +226,8 @@ SWITCH_STANDARD_API(xml_locate_function)
switch_xml_t xml = NULL, obj = NULL;
int argc;
char *mydata = NULL, *argv[4];
char *section, *tag, *tag_attr_name, *tag_attr_val, *params = NULL;
char *section, *tag, *tag_attr_name, *tag_attr_val;
switch_event_t *params = NULL;
char *xmlstr;
char *path_info, delim = ' ';
char *host = NULL;
@@ -259,8 +269,13 @@ SWITCH_STANDARD_API(xml_locate_function)
tag_attr_name = argv[2];
tag_attr_val = argv[3];
params = switch_mprintf("section=%s&tag=%s&tag_attr_name=%s&tag_attr_val=%s", section, tag, tag_attr_name, tag_attr_val);
switch_event_create(&params, SWITCH_EVENT_MESSAGE);
switch_assert(params);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "section", section);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "tag", tag);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "tag_attr_name", tag_attr_name);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "tag_attr_val", tag_attr_val);
if (switch_xml_locate(section, tag, tag_attr_name, tag_attr_val, &xml, &obj, params) != SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "can't find anything\n");
goto end;
@@ -269,6 +284,8 @@ SWITCH_STANDARD_API(xml_locate_function)
end:
switch_event_destroy(&params);
if (err) {
if (host) {
stream->write_function(stream, "<error>%s</error>\n", err);