git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7422 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2008-01-29 18:01:19 +00:00
parent 1e691217f3
commit d5081d0b3e

View File

@ -102,12 +102,11 @@ end:
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t _find_user(const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream, switch_bool_t tf) static switch_status_t _find_user(const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream, switch_bool_t tf)
{ {
switch_xml_t x_domain = NULL, x_user = NULL, xml = NULL; switch_xml_t x_domain = NULL, x_user = NULL, xml = NULL;
int argc; int argc;
char *mydata = NULL, *argv[3]; char *mydata = NULL, *argv[3];
char *key, *user, *domain; char *key, *user, *domain;
char *xmlstr; char *xmlstr;
char *path_info = NULL; char *path_info = NULL;
@ -123,29 +122,29 @@ static switch_status_t _find_user(const char *cmd, switch_core_session_t *sessio
} }
} }
if (!cmd) { if (!cmd) {
err = "bad args"; err = "bad args";
goto end; goto end;
} }
mydata = strdup(cmd); mydata = strdup(cmd);
switch_assert(mydata); switch_assert(mydata);
argc = switch_separate_string(mydata, delim, argv, (sizeof(argv) / sizeof(argv[0]))); argc = switch_separate_string(mydata, delim, argv, (sizeof(argv) / sizeof(argv[0])));
if (argc < 3) { if (argc < 3) {
err = "bad args"; err = "bad args";
goto end; goto end;
} }
key = argv[0]; key = argv[0];
user = argv[1]; user = argv[1];
domain = argv[2]; domain = argv[2];
if (!(key && user && domain)) { if (!(key && user && domain)) {
err = "bad args"; err = "bad args";
goto end; goto end;
} }
if (switch_xml_locate_user(key, user, domain, NULL, &xml, &x_domain, &x_user, NULL) != SWITCH_STATUS_SUCCESS) { if (switch_xml_locate_user(key, user, domain, NULL, &xml, &x_domain, &x_user, NULL) != SWITCH_STATUS_SUCCESS) {
err = "can't find user"; err = "can't find user";
@ -177,7 +176,6 @@ end:
free(mydata); free(mydata);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
SWITCH_STANDARD_API(user_exists_function) SWITCH_STANDARD_API(user_exists_function)
@ -194,7 +192,7 @@ SWITCH_STANDARD_API(xml_locate_function)
{ {
switch_xml_t xml = NULL, obj = NULL; switch_xml_t xml = NULL, obj = NULL;
int argc; int argc;
char *mydata = NULL, *argv[4]; char *mydata = NULL, *argv[4];
char *section, *tag, *tag_attr_name, *tag_attr_val; char *section, *tag, *tag_attr_name, *tag_attr_val;
switch_event_t *params = NULL; switch_event_t *params = NULL;
char *xmlstr; char *xmlstr;
@ -210,27 +208,27 @@ SWITCH_STANDARD_API(xml_locate_function)
} }
} }
if (!cmd) { if (!cmd) {
err = "bad args"; err = "bad args";
goto end; goto end;
} }
mydata = strdup(cmd); mydata = strdup(cmd);
switch_assert(mydata); switch_assert(mydata);
argc = switch_separate_string(mydata, delim, argv, (sizeof(argv) / sizeof(argv[0]))); argc = switch_separate_string(mydata, delim, argv, (sizeof(argv) / sizeof(argv[0])));
if (argc == 1 && !strcasecmp(argv[0], "root")) { if (argc == 1 && !strcasecmp(argv[0], "root")) {
const char *error; const char *error;
xml = switch_xml_open_root(0, &error); xml = switch_xml_open_root(0, &error);
obj = xml; obj = xml;
goto end; goto end;
} }
if (argc < 4) { if (argc < 4) {
err = "bad args"; err = "bad args";
goto end; goto end;
} }
section = argv[0]; section = argv[0];
tag = argv[1]; tag = argv[1];
@ -250,8 +248,6 @@ SWITCH_STANDARD_API(xml_locate_function)
} }
end: end:
switch_event_destroy(&params);
if (err) { if (err) {
if (host) { if (host) {
stream->write_function(stream, "<error>%s</error>\n", err); stream->write_function(stream, "<error>%s</error>\n", err);
@ -260,8 +256,6 @@ end:
} }
} }
switch_safe_free(params);
if (xml && obj) { if (xml && obj) {
xmlstr = switch_xml_toxml(obj, SWITCH_FALSE); xmlstr = switch_xml_toxml(obj, SWITCH_FALSE);
switch_assert(xmlstr); switch_assert(xmlstr);
@ -272,9 +266,9 @@ end:
} }
switch_event_destroy(&params);
free(mydata); free(mydata);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
SWITCH_STANDARD_API(regex_function) SWITCH_STANDARD_API(regex_function)
@ -282,23 +276,23 @@ SWITCH_STANDARD_API(regex_function)
switch_regex_t *re = NULL; switch_regex_t *re = NULL;
int ovector[30]; int ovector[30];
int argc; int argc;
char *mydata = NULL, *argv[3]; char *mydata = NULL, *argv[3];
size_t len = 0; size_t len = 0;
char *substituted = NULL; char *substituted = NULL;
int proceed = 0; int proceed = 0;
if (!cmd) { if (!cmd) {
goto error; goto error;
} }
mydata = strdup(cmd); mydata = strdup(cmd);
switch_assert(mydata); switch_assert(mydata);
argc = switch_separate_string(mydata, '|', argv, (sizeof(argv) / sizeof(argv[0]))); argc = switch_separate_string(mydata, '|', argv, (sizeof(argv) / sizeof(argv[0])));
if (argc < 2) { if (argc < 2) {
goto error; goto error;
} }
if ((proceed = switch_regex_perform(argv[0], argv[1], &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) { if ((proceed = switch_regex_perform(argv[0], argv[1], &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
if (argc > 2) { if (argc > 2) {
@ -317,146 +311,141 @@ SWITCH_STANDARD_API(regex_function)
} else { } else {
stream->write_function(stream, "false"); stream->write_function(stream, "false");
} }
goto ok; goto ok;
error: error:
stream->write_function(stream, "-ERR"); stream->write_function(stream, "-ERR");
ok: ok:
switch_regex_safe_free(re); switch_regex_safe_free(re);
switch_safe_free(mydata); switch_safe_free(mydata);
return SWITCH_STATUS_SUCCESS;
return SWITCH_STATUS_SUCCESS;
} }
typedef enum { typedef enum {
O_NONE, O_NONE,
O_EQ, O_EQ,
O_NE, O_NE,
O_GT, O_GT,
O_GE, O_GE,
O_LT, O_LT,
O_LE O_LE
} o_t; } o_t;
SWITCH_STANDARD_API(cond_function) SWITCH_STANDARD_API(cond_function)
{ {
int argc; int argc;
char *mydata = NULL, *argv[3]; char *mydata = NULL, *argv[3];
char *expr; char *expr;
char *a, *b; char *a, *b;
double a_f = 0.0, b_f = 0.0; double a_f = 0.0, b_f = 0.0;
o_t o = O_NONE; o_t o = O_NONE;
int is_true = 0; int is_true = 0;
char *p; char *p;
if (!cmd) { if (!cmd) {
goto error; goto error;
} }
mydata = strdup(cmd); mydata = strdup(cmd);
switch_assert(mydata); switch_assert(mydata);
if ((p = strchr(mydata, '?'))) { if ((p = strchr(mydata, '?'))) {
*p = ':'; *p = ':';
} else { } else {
goto error; goto error;
} }
argc = switch_separate_string(mydata, ':', argv, (sizeof(argv) / sizeof(argv[0]))); argc = switch_separate_string(mydata, ':', argv, (sizeof(argv) / sizeof(argv[0])));
if (argc != 3) { if (argc != 3) {
goto error; goto error;
} }
a = argv[0]; a = argv[0];
if ((expr = strchr(a, '!'))) { if ((expr = strchr(a, '!'))) {
*expr++ = '\0'; *expr++ = '\0';
if (*expr == '=') { if (*expr == '=') {
o = O_NE; o = O_NE;
} }
} else if ((expr = strchr(a, '>'))) { } else if ((expr = strchr(a, '>'))) {
if (*(expr+1) == '=') { if (*(expr+1) == '=') {
*expr++ = '\0'; *expr++ = '\0';
o = O_GE; o = O_GE;
} else { } else {
o = O_GT; o = O_GT;
} }
} else if ((expr = strchr(a, '<'))) { } else if ((expr = strchr(a, '<'))) {
if (*(expr+1) == '=') { if (*(expr+1) == '=') {
*expr++ = '\0'; *expr++ = '\0';
o = O_LE; o = O_LE;
} else { } else {
o = O_LT; o = O_LT;
} }
} else if ((expr = strchr(a, '='))) { } else if ((expr = strchr(a, '='))) {
*expr++ = '\0'; *expr++ = '\0';
if (*expr == '=') { if (*expr == '=') {
o = O_EQ; o = O_EQ;
} }
} }
if (o) {
char *s_a = NULL, *s_b = NULL;
int a_is_num, b_is_num;
*expr++ = '\0';
b = expr;
s_a = switch_strip_spaces(a);
s_b = switch_strip_spaces(b);
a_is_num = switch_is_number(s_a);
b_is_num = switch_is_number(s_b);
if (o) { a_f = a_is_num ? atof(s_a) : (float) strlen(s_a);
char *s_a = NULL, *s_b = NULL; b_f = b_is_num ? atof(s_b) : (float) strlen(s_b);
int a_is_num, b_is_num;
*expr++ = '\0';
b = expr;
s_a = switch_strip_spaces(a);
s_b = switch_strip_spaces(b);
a_is_num = switch_is_number(s_a);
b_is_num = switch_is_number(s_b);
a_f = a_is_num ? atof(s_a) : (float) strlen(s_a); switch (o) {
b_f = b_is_num ? atof(s_b) : (float) strlen(s_b); case O_EQ:
if (!a_is_num && !b_is_num) {
is_true = !strcmp(s_a, s_b);
} else {
is_true = a_f == b_f;
}
break;
case O_NE:
if (!a_is_num && !b_is_num) {
is_true = strcmp(s_a, s_b);
} else {
is_true = a_f != b_f;
}
break;
case O_GT:
is_true = a_f > b_f;
break;
case O_GE:
is_true = a_f >= b_f;
break;
case O_LT:
is_true = a_f < b_f;
break;
case O_LE:
is_true = a_f <= b_f;
break;
default:
break;
}
switch_safe_free(s_a);
switch_safe_free(s_b);
stream->write_function(stream, "%s", is_true ? argv[1] : argv[2]);
goto ok;
}
switch (o) { error:
case O_EQ: stream->write_function(stream, "-ERR");
if (!a_is_num && !b_is_num) { ok:
is_true = !strcmp(s_a, s_b);
} else {
is_true = a_f == b_f;
}
break;
case O_NE:
if (!a_is_num && !b_is_num) {
is_true = strcmp(s_a, s_b);
} else {
is_true = a_f != b_f;
}
break;
case O_GT:
is_true = a_f > b_f;
break;
case O_GE:
is_true = a_f >= b_f;
break;
case O_LT:
is_true = a_f < b_f;
break;
case O_LE:
is_true = a_f <= b_f;
break;
default:
break;
}
switch_safe_free(s_a);
switch_safe_free(s_b);
stream->write_function(stream, "%s", is_true ? argv[1] : argv[2]);
goto ok;
}
error: switch_safe_free(mydata);
stream->write_function(stream, "-ERR"); return SWITCH_STATUS_SUCCESS;
ok:
switch_safe_free(mydata);
return SWITCH_STATUS_SUCCESS;
} }
SWITCH_STANDARD_API(lan_addr_function) SWITCH_STANDARD_API(lan_addr_function)
{ {
stream->write_function(stream, "%s", switch_is_lan_addr(cmd) ? "yes" : "no"); stream->write_function(stream, "%s", switch_is_lan_addr(cmd) ? "yes" : "no");
@ -486,11 +475,11 @@ SWITCH_STANDARD_API(status_function)
} }
stream->write_function(stream, stream->write_function(stream,
"UP %u year%s, %u day%s, %u hour%s, %u minute%s, %u second%s, %u millisecond%s, %u microsecond%s\n", "UP %u year%s, %u day%s, %u hour%s, %u minute%s, %u second%s, %u millisecond%s, %u microsecond%s\n",
duration.yr, duration.yr == 1 ? "" : "s", duration.day, duration.day == 1 ? "" : "s", duration.yr, duration.yr == 1 ? "" : "s", duration.day, duration.day == 1 ? "" : "s",
duration.hr, duration.hr == 1 ? "" : "s", duration.min, duration.min == 1 ? "" : "s", duration.hr, duration.hr == 1 ? "" : "s", duration.min, duration.min == 1 ? "" : "s",
duration.sec, duration.sec == 1 ? "" : "s", duration.ms, duration.ms == 1 ? "" : "s", duration.mms, duration.sec, duration.sec == 1 ? "" : "s", duration.ms, duration.ms == 1 ? "" : "s", duration.mms,
duration.mms == 1 ? "" : "s"); duration.mms == 1 ? "" : "s");
stream->write_function(stream, "%"SWITCH_SIZE_T_FMT" session(s) since startup\n", switch_core_session_id() - 1 ); stream->write_function(stream, "%"SWITCH_SIZE_T_FMT" session(s) since startup\n", switch_core_session_id() - 1 );
switch_core_session_ctl(SCSC_LAST_SPS, &last_sps); switch_core_session_ctl(SCSC_LAST_SPS, &last_sps);
@ -589,14 +578,13 @@ SWITCH_STANDARD_API(ctl_function)
} }
stream->write_function(stream, "+OK\n"); stream->write_function(stream, "+OK\n");
end: end:
free(mydata); free(mydata);
} else { } else {
stream->write_function(stream, "-ERR Memory error\n"); stream->write_function(stream, "-ERR Memory error\n");
} }
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
#define LOAD_SYNTAX "<mod_name>" #define LOAD_SYNTAX "<mod_name>"
@ -685,7 +673,6 @@ SWITCH_STANDARD_API(kill_function)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
#define PARK_SYNTAX "<uuid>" #define PARK_SYNTAX "<uuid>"
SWITCH_STANDARD_API(park_function) SWITCH_STANDARD_API(park_function)
{ {
@ -788,7 +775,6 @@ SWITCH_STANDARD_API(tone_detect_session_function)
time_t to = 0; time_t to = 0;
switch_core_session_t *rsession; switch_core_session_t *rsession;
if (!cmd) { if (!cmd) {
stream->write_function(stream, "-USAGE: %s\n", TONE_DETECT_SYNTAX); stream->write_function(stream, "-USAGE: %s\n", TONE_DETECT_SYNTAX);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
@ -802,13 +788,11 @@ SWITCH_STANDARD_API(tone_detect_session_function)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
if (!(rsession = switch_core_session_locate(argv[0]))) { if (!(rsession = switch_core_session_locate(argv[0]))) {
stream->write_function(stream, "-ERR Error Cannot locate session!\n"); stream->write_function(stream, "-ERR Error Cannot locate session!\n");
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
if (argv[4]) { if (argv[4]) {
uint32_t mto; uint32_t mto;
if (*argv[4] == '+') { if (*argv[4] == '+') {
@ -830,7 +814,7 @@ SWITCH_STANDARD_API(tone_detect_session_function)
switch_ivr_tone_detect_session(rsession, argv[1], argv[2], argv[3], to, argv[5], argv[6]); switch_ivr_tone_detect_session(rsession, argv[1], argv[2], argv[3], to, argv[5], argv[6]);
stream->write_function(stream, "+OK Enabling tone detection '%s' '%s' '%s'\n", argv[1], argv[2], argv[3]); stream->write_function(stream, "+OK Enabling tone detection '%s' '%s' '%s'\n", argv[1], argv[2], argv[3]);
done: done:
free(mydata); free(mydata);
switch_core_session_rwunlock(rsession); switch_core_session_rwunlock(rsession);
@ -838,14 +822,13 @@ SWITCH_STANDARD_API(tone_detect_session_function)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
SWITCH_STANDARD_API(uuid_function) SWITCH_STANDARD_API(uuid_function)
{ {
switch_uuid_t uuid; switch_uuid_t uuid;
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1]; char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
switch_uuid_get(&uuid); switch_uuid_get(&uuid);
switch_uuid_format(uuid_str, &uuid); switch_uuid_format(uuid_str, &uuid);
stream->write_function(stream, "%s", uuid_str); stream->write_function(stream, "%s", uuid_str);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
@ -886,8 +869,6 @@ SWITCH_STANDARD_API(uuid_chat)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
#define SCHED_TRANSFER_SYNTAX "[+]<time> <uuid> <extension> [<dialplan>] [<context>]" #define SCHED_TRANSFER_SYNTAX "[+]<time> <uuid> <extension> [<dialplan>] [<context>]"
SWITCH_STANDARD_API(sched_transfer_function) SWITCH_STANDARD_API(sched_transfer_function)
{ {
@ -1209,14 +1190,11 @@ SWITCH_STANDARD_API(session_record_function)
goto done; goto done;
usage: usage:
stream->write_function(stream, "-USAGE: %s\n", SESS_REC_SYNTAX); stream->write_function(stream, "-USAGE: %s\n", SESS_REC_SYNTAX);
switch_safe_free(mycmd); switch_safe_free(mycmd);
done:
done:
if (rsession) { if (rsession) {
switch_core_session_rwunlock(rsession); switch_core_session_rwunlock(rsession);
} }
@ -1225,7 +1203,7 @@ SWITCH_STANDARD_API(session_record_function)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
#define DISPLACE_SYNTAX "<uuid> [start|stop] <path> [<limit>] [mux]"
SWITCH_STANDARD_API(session_displace_function) SWITCH_STANDARD_API(session_displace_function)
{ {
switch_core_session_t *rsession = NULL; switch_core_session_t *rsession = NULL;
@ -1239,11 +1217,7 @@ SWITCH_STANDARD_API(session_displace_function)
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
if (switch_strlen_zero(cmd)) { if (switch_strlen_zero(cmd) || !(mycmd = strdup(cmd))) {
goto usage;
}
if (!(mycmd = strdup(cmd))) {
goto usage; goto usage;
} }
@ -1276,14 +1250,11 @@ SWITCH_STANDARD_API(session_displace_function)
goto done; goto done;
usage: usage:
stream->write_function(stream, "-USAGE: %s\n", DISPLACE_SYNTAX);
stream->write_function(stream, "-ERR INVALID SYNTAX\n");
switch_safe_free(mycmd); switch_safe_free(mycmd);
done:
done:
if (rsession) { if (rsession) {
switch_core_session_rwunlock(rsession); switch_core_session_rwunlock(rsession);
} }
@ -1316,7 +1287,6 @@ SWITCH_STANDARD_API(break_function)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
#define PAUSE_SYNTAX "<uuid> <on|off>" #define PAUSE_SYNTAX "<uuid> <on|off>"
SWITCH_STANDARD_API(pause_function) SWITCH_STANDARD_API(pause_function)
{ {
@ -1385,7 +1355,6 @@ SWITCH_STANDARD_API(originate_function)
goto done; goto done;
} }
for (x = 0; x < argc && argv[x]; x++) { for (x = 0; x < argc && argv[x]; x++) {
if (!strcasecmp(argv[x], "undef")) { if (!strcasecmp(argv[x], "undef")) {
argv[x] = NULL; argv[x] = NULL;
@ -1462,7 +1431,7 @@ SWITCH_STANDARD_API(originate_function)
switch_core_session_rwunlock(caller_session); switch_core_session_rwunlock(caller_session);
} }
done: done:
switch_safe_free(mycmd); switch_safe_free(mycmd);
return status; return status;
} }
@ -1549,13 +1518,13 @@ SWITCH_STANDARD_API(xml_wrap_api_function)
} }
stream->write_function(stream, stream->write_function(stream,
"<result>\n" "<result>\n"
" <row id=\"1\">\n" " <row id=\"1\">\n"
" <data>%s</data>\n" " <data>%s</data>\n"
" </row>\n" " </row>\n"
"</result>\n", "</result>\n",
send ? send : "ERROR" send ? send : "ERROR"
); );
switch_safe_free(mystream.data); switch_safe_free(mystream.data);
switch_safe_free(edata); switch_safe_free(edata);
free(dcommand); free(dcommand);
@ -1598,14 +1567,11 @@ SWITCH_STANDARD_API(sched_api_function)
stream->write_function(stream, "-ERR Invalid syntax\n"); stream->write_function(stream, "-ERR Invalid syntax\n");
good: good:
switch_safe_free(tm); switch_safe_free(tm);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
struct bg_job { struct bg_job {
char *cmd; char *cmd;
char *arg; char *arg;
@ -1615,7 +1581,6 @@ struct bg_job {
static void *SWITCH_THREAD_FUNC bgapi_exec(switch_thread_t *thread, void *obj) static void *SWITCH_THREAD_FUNC bgapi_exec(switch_thread_t *thread, void *obj)
{ {
struct bg_job *job = (struct bg_job *) obj; struct bg_job *job = (struct bg_job *) obj;
switch_stream_handle_t stream = { 0 }; switch_stream_handle_t stream = { 0 };
switch_status_t status; switch_status_t status;
@ -1693,7 +1658,6 @@ SWITCH_STANDARD_API(bgapi_function)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
struct holder { struct holder {
switch_stream_handle_t *stream; switch_stream_handle_t *stream;
char *http; char *http;
@ -1750,7 +1714,6 @@ static int show_callback(void *pArg, int argc, char **argv, char **columnNames)
struct holder *holder = (struct holder *) pArg; struct holder *holder = (struct holder *) pArg;
int x; int x;
if (holder->print_title && holder->count == 0) { if (holder->print_title && holder->count == 0) {
if (holder->http) { if (holder->http) {
holder->stream->write_function(holder->stream, "\n<tr>"); holder->stream->write_function(holder->stream, "\n<tr>");
@ -1758,8 +1721,6 @@ static int show_callback(void *pArg, int argc, char **argv, char **columnNames)
for (x = 0; x < argc; x++) { for (x = 0; x < argc; x++) {
char *name = columnNames[x]; char *name = columnNames[x];
if (!name) { if (!name) {
name = "undefined"; name = "undefined";
} }
@ -1832,8 +1793,8 @@ SWITCH_STANDARD_API(show_function)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
// If you changes the field qty or order of any of these select /* If you changes the field qty or order of any of these select /*
// statmements, you must also change show_callback and friends to match! /* statmements, you must also change show_callback and friends to match! */
if (!command) { if (!command) {
stream->write_function(stream, "-USAGE: %s\n", SHOW_SYNTAX); stream->write_function(stream, "-USAGE: %s\n", SHOW_SYNTAX);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
@ -2045,13 +2006,11 @@ SWITCH_STANDARD_API(uuid_getvar_function)
stream->write_function(stream, "-USAGE: %s\n", GETVAR_SYNTAX); stream->write_function(stream, "-USAGE: %s\n", GETVAR_SYNTAX);
done: done:
switch_safe_free(mycmd); switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
#define DUMP_SYNTAX "<uuid> [format]" #define DUMP_SYNTAX "<uuid> [format]"
SWITCH_STANDARD_API(uuid_dump_function) SWITCH_STANDARD_API(uuid_dump_function)
{ {
@ -2081,8 +2040,8 @@ SWITCH_STANDARD_API(uuid_dump_function)
switch_channel_event_set_data(channel, event); switch_channel_event_set_data(channel, event);
if (format && !strcasecmp(format, "xml")) { if (format && !strcasecmp(format, "xml")) {
if ((xml = switch_event_xmlize(event, "%s", ""))) { if ((xml = switch_event_xmlize(event, "%s", ""))) {
buf = switch_xml_toxml(xml, SWITCH_FALSE); buf = switch_xml_toxml(xml, SWITCH_FALSE);
switch_xml_free(xml); switch_xml_free(xml);
} else { } else {
stream->write_function(stream, "-ERR Unable to create xml!\n"); stream->write_function(stream, "-ERR Unable to create xml!\n");
switch_core_session_rwunlock(psession); switch_core_session_rwunlock(psession);
@ -2111,15 +2070,11 @@ SWITCH_STANDARD_API(uuid_dump_function)
stream->write_function(stream, "-USAGE: %s\n", DUMP_SYNTAX); stream->write_function(stream, "-USAGE: %s\n", DUMP_SYNTAX);
done: done:
switch_safe_free(mycmd); switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
#define GLOBAL_SETVAR_SYNTAX "<var> <value>" #define GLOBAL_SETVAR_SYNTAX "<var> <value>"
SWITCH_STANDARD_API(global_setvar_function) SWITCH_STANDARD_API(global_setvar_function)
{ {
@ -2158,7 +2113,7 @@ SWITCH_STANDARD_API(global_getvar_function)
} }
stream->write_function(stream, "-USAGE: %s\n", GLOBAL_GETVAR_SYNTAX); stream->write_function(stream, "-USAGE: %s\n", GLOBAL_GETVAR_SYNTAX);
done: done:
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
@ -2187,8 +2142,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
SWITCH_ADD_API(commands_api_interface, "uuid_dump", "uuid_dump", uuid_dump_function, DUMP_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_dump", "uuid_dump", uuid_dump_function, DUMP_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "global_setvar", "global_setvar", global_setvar_function, GLOBAL_SETVAR_SYNTAX); SWITCH_ADD_API(commands_api_interface, "global_setvar", "global_setvar", global_setvar_function, GLOBAL_SETVAR_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "global_getvar", "global_getvar", global_getvar_function, GLOBAL_GETVAR_SYNTAX); SWITCH_ADD_API(commands_api_interface, "global_getvar", "global_getvar", global_getvar_function, GLOBAL_GETVAR_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "session_displace", "session displace (depricated)", SWITCH_ADD_API(commands_api_interface, "session_displace", "session displace (depricated)", session_displace_function, DISPLACE_SYNTAX);
session_displace_function, "<uuid> [start|stop] <path> [<limit>] [mux]");
SWITCH_ADD_API(commands_api_interface, "uuid_displace", "session displace", session_displace_function, "<uuid> [start|stop] <path> [<limit>] [mux]"); SWITCH_ADD_API(commands_api_interface, "uuid_displace", "session displace", session_displace_function, "<uuid> [start|stop] <path> [<limit>] [mux]");
SWITCH_ADD_API(commands_api_interface, "session_record", "session record (depricated)", session_record_function, SESS_REC_SYNTAX); SWITCH_ADD_API(commands_api_interface, "session_record", "session record (depricated)", session_record_function, SESS_REC_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_record", "session record", session_record_function, SESS_REC_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_record", "session record", session_record_function, SESS_REC_SYNTAX);
@ -2211,8 +2165,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
SWITCH_ADD_API(commands_api_interface, "xml_wrap", "Wrap another api command in xml", xml_wrap_api_function, "<command> <args>"); SWITCH_ADD_API(commands_api_interface, "xml_wrap", "Wrap another api command in xml", xml_wrap_api_function, "<command> <args>");
SWITCH_ADD_API(commands_api_interface, "is_lan_addr", "see if an ip is a lan addr", lan_addr_function, "<ip>"); SWITCH_ADD_API(commands_api_interface, "is_lan_addr", "see if an ip is a lan addr", lan_addr_function, "<ip>");
SWITCH_ADD_API(commands_api_interface, "cond", "Eval a conditional", cond_function, "<expr> ? <true val> : <false val>"); SWITCH_ADD_API(commands_api_interface, "cond", "Eval a conditional", cond_function, "<expr> ? <true val> : <false val>");
// remove me before final release
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, "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, "uuid_chat", "Send a chat message", uuid_chat, UUID_CHAT_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "find_user_xml", "find a user", find_user_function, "<key> <user> <domain>"); SWITCH_ADD_API(commands_api_interface, "find_user_xml", "find a user", find_user_function, "<key> <user> <domain>");