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,7 +102,6 @@ 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;
@ -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)
@ -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)
@ -317,16 +311,13 @@ 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;
} }
@ -398,7 +389,6 @@ SWITCH_STANDARD_API(cond_function)
} }
} }
if (o) { if (o) {
char *s_a = NULL, *s_b = NULL; char *s_a = NULL, *s_b = NULL;
int a_is_num, b_is_num; int a_is_num, b_is_num;
@ -456,7 +446,6 @@ SWITCH_STANDARD_API(cond_function)
return SWITCH_STATUS_SUCCESS; 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");
@ -596,7 +585,6 @@ SWITCH_STANDARD_API(ctl_function)
} }
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] == '+') {
@ -838,7 +822,6 @@ 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;
@ -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)
{ {
@ -1210,13 +1191,10 @@ 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;
} }
@ -1277,13 +1251,10 @@ 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;
@ -1599,13 +1568,10 @@ 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;
@ -2050,8 +2011,6 @@ SWITCH_STANDARD_API(uuid_getvar_function)
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)
{ {
@ -2116,10 +2075,6 @@ SWITCH_STANDARD_API(uuid_dump_function)
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)
{ {
@ -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>");