create macro to define api command prototypes.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5167 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
493fdf5ba8
commit
521eac756e
|
@ -1018,7 +1018,11 @@ typedef void (*switch_scheduler_func_t) (switch_scheduler_task_t *task);
|
|||
typedef switch_status_t (*switch_state_handler_t) (switch_core_session_t *);
|
||||
typedef struct switch_stream_handle switch_stream_handle_t;
|
||||
typedef switch_status_t (*switch_stream_handle_write_function_t) (switch_stream_handle_t *handle, const char *fmt, ...);
|
||||
typedef switch_status_t (*switch_api_function_t) (const char *in, switch_core_session_t *session, switch_stream_handle_t *stream);
|
||||
|
||||
typedef switch_status_t (*switch_api_function_t) (const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream);
|
||||
|
||||
#define SWITCH_STANDARD_API(name) static switch_status_t name (const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
|
||||
typedef switch_status_t (*switch_input_callback_function_t) (switch_core_session_t *session, void *input,
|
||||
switch_input_type_t input_type, void *buf, unsigned int buflen);
|
||||
typedef struct switch_say_interface switch_say_interface_t;
|
||||
|
|
|
@ -57,7 +57,7 @@ static switch_api_interface_t sched_broadcast_api_interface;
|
|||
static switch_api_interface_t sched_transfer_api_interface;
|
||||
static switch_api_interface_t sched_hangup_api_interface;
|
||||
|
||||
static switch_status_t status_function(const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(status_function)
|
||||
{
|
||||
uint8_t html = 0;
|
||||
switch_core_time_duration_t duration;
|
||||
|
@ -107,18 +107,18 @@ static switch_status_t status_function(const char *cmd, switch_core_session_t *s
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t ctl_function(const char *data, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(ctl_function)
|
||||
{
|
||||
int argc;
|
||||
char *mydata, *argv[5];
|
||||
uint32_t arg = 0;
|
||||
|
||||
if (switch_strlen_zero(data)) {
|
||||
if (switch_strlen_zero(cmd)) {
|
||||
stream->write_function(stream, "USAGE: %s\n", ctl_api_interface.syntax);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if ((mydata = strdup(data))) {
|
||||
if ((mydata = strdup(cmd))) {
|
||||
argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
if (!strcmp(argv[0], "hupall")) {
|
||||
|
@ -149,7 +149,7 @@ static switch_status_t ctl_function(const char *data, switch_core_session_t *ses
|
|||
|
||||
}
|
||||
|
||||
static switch_status_t load_function(const char *mod, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(load_function)
|
||||
{
|
||||
const char *err;
|
||||
|
||||
|
@ -157,12 +157,12 @@ static switch_status_t load_function(const char *mod, switch_core_session_t *ses
|
|||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (switch_strlen_zero(mod)) {
|
||||
if (switch_strlen_zero(cmd)) {
|
||||
stream->write_function(stream, "USAGE: %s\n", load_api_interface.syntax);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) mod, SWITCH_TRUE, &err) == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) cmd, SWITCH_TRUE, &err) == SWITCH_STATUS_SUCCESS) {
|
||||
stream->write_function(stream, "OK\n");
|
||||
} else {
|
||||
stream->write_function(stream, "ERROR [%s]\n", err);
|
||||
|
@ -171,7 +171,7 @@ static switch_status_t load_function(const char *mod, switch_core_session_t *ses
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t unload_function(const char *mod, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(unload_function)
|
||||
{
|
||||
const char *err;
|
||||
|
||||
|
@ -179,12 +179,12 @@ static switch_status_t unload_function(const char *mod, switch_core_session_t *s
|
|||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (switch_strlen_zero(mod)) {
|
||||
if (switch_strlen_zero(cmd)) {
|
||||
stream->write_function(stream, "USAGE: %s\n", unload_api_interface.syntax);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (switch_loadable_module_unload_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) mod, &err) == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_loadable_module_unload_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) cmd, &err) == SWITCH_STATUS_SUCCESS) {
|
||||
stream->write_function(stream, "OK\n");
|
||||
} else {
|
||||
stream->write_function(stream, "ERROR [%s]\n", err);
|
||||
|
@ -193,7 +193,7 @@ static switch_status_t unload_function(const char *mod, switch_core_session_t *s
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t reload_function(const char *args, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(reload_function)
|
||||
{
|
||||
const char *err;
|
||||
switch_xml_t xml_root;
|
||||
|
@ -211,20 +211,20 @@ static switch_status_t reload_function(const char *args, switch_core_session_t *
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t kill_function(const char *dest, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(kill_function)
|
||||
{
|
||||
switch_core_session_t *session = NULL;
|
||||
switch_core_session_t *ksession = NULL;
|
||||
|
||||
if (isession) {
|
||||
if (session) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (!dest) {
|
||||
if (!cmd) {
|
||||
stream->write_function(stream, "USAGE: %s\n", kill_api_interface.syntax);
|
||||
} else if ((session = switch_core_session_locate(dest))) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
} else if ((ksession = switch_core_session_locate(cmd))) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(ksession);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
|
||||
switch_core_session_rwunlock(session);
|
||||
switch_core_session_rwunlock(ksession);
|
||||
stream->write_function(stream, "OK\n");
|
||||
} else {
|
||||
stream->write_function(stream, "No Such Channel!\n");
|
||||
|
@ -233,13 +233,13 @@ static switch_status_t kill_function(const char *dest, switch_core_session_t *is
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t transfer_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(transfer_function)
|
||||
{
|
||||
switch_core_session_t *session = NULL;
|
||||
switch_core_session_t *tsession = NULL;
|
||||
char *mycmd = NULL, *argv[4] = { 0 };
|
||||
int argc = 0;
|
||||
|
||||
if (isession) {
|
||||
if (session) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -251,15 +251,15 @@ static switch_status_t transfer_function(const char *cmd, switch_core_session_t
|
|||
char *dp = argv[2];
|
||||
char *context = argv[3];
|
||||
|
||||
if ((session = switch_core_session_locate(uuid))) {
|
||||
if ((tsession = switch_core_session_locate(uuid))) {
|
||||
|
||||
if (switch_ivr_session_transfer(session, dest, dp, context) == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_ivr_session_transfer(tsession, dest, dp, context) == SWITCH_STATUS_SUCCESS) {
|
||||
stream->write_function(stream, "OK\n");
|
||||
} else {
|
||||
stream->write_function(stream, "ERROR\n");
|
||||
}
|
||||
|
||||
switch_core_session_rwunlock(session);
|
||||
switch_core_session_rwunlock(tsession);
|
||||
|
||||
} else {
|
||||
stream->write_function(stream, "No Such Channel!\n");
|
||||
|
@ -276,13 +276,13 @@ done:
|
|||
}
|
||||
|
||||
|
||||
static switch_status_t sched_transfer_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(sched_transfer_function)
|
||||
{
|
||||
switch_core_session_t *session = NULL;
|
||||
switch_core_session_t *tsession = NULL;
|
||||
char *mycmd = NULL, *argv[6] = { 0 };
|
||||
int argc = 0;
|
||||
|
||||
if (isession) {
|
||||
if (session) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -305,10 +305,10 @@ static switch_status_t sched_transfer_function(const char *cmd, switch_core_sess
|
|||
when = atol(argv[0]);
|
||||
}
|
||||
|
||||
if ((session = switch_core_session_locate(uuid))) {
|
||||
if ((tsession = switch_core_session_locate(uuid))) {
|
||||
switch_ivr_schedule_transfer(when, uuid, dest, dp, context);
|
||||
stream->write_function(stream, "OK\n");
|
||||
switch_core_session_rwunlock(session);
|
||||
switch_core_session_rwunlock(tsession);
|
||||
} else {
|
||||
stream->write_function(stream, "No Such Channel!\n");
|
||||
}
|
||||
|
@ -318,13 +318,13 @@ static switch_status_t sched_transfer_function(const char *cmd, switch_core_sess
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t sched_hangup_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(sched_hangup_function)
|
||||
{
|
||||
switch_core_session_t *session = NULL;
|
||||
switch_core_session_t *hsession = NULL;
|
||||
char *mycmd = NULL, *argv[4] = { 0 };
|
||||
int argc = 0;
|
||||
|
||||
if (isession) {
|
||||
if (session) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -350,10 +350,10 @@ static switch_status_t sched_hangup_function(const char *cmd, switch_core_sessio
|
|||
cause = switch_channel_str2cause(cause_str);
|
||||
}
|
||||
|
||||
if ((session = switch_core_session_locate(uuid))) {
|
||||
if ((hsession = switch_core_session_locate(uuid))) {
|
||||
switch_ivr_schedule_hangup(when, uuid, cause, SWITCH_FALSE);
|
||||
stream->write_function(stream, "OK\n");
|
||||
switch_core_session_rwunlock(session);
|
||||
switch_core_session_rwunlock(hsession);
|
||||
} else {
|
||||
stream->write_function(stream, "No Such Channel!\n");
|
||||
}
|
||||
|
@ -364,13 +364,13 @@ static switch_status_t sched_hangup_function(const char *cmd, switch_core_sessio
|
|||
}
|
||||
|
||||
|
||||
static switch_status_t uuid_media_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(uuid_media_function)
|
||||
{
|
||||
char *mycmd = NULL, *argv[4] = { 0 };
|
||||
int argc = 0;
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
|
||||
if (isession) {
|
||||
if (session) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -399,13 +399,13 @@ static switch_status_t uuid_media_function(const char *cmd, switch_core_session_
|
|||
}
|
||||
|
||||
|
||||
static switch_status_t uuid_broadcast_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(uuid_broadcast_function)
|
||||
{
|
||||
char *mycmd = NULL, *argv[4] = { 0 };
|
||||
int argc = 0;
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
|
||||
if (isession) {
|
||||
if (session) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -439,13 +439,13 @@ static switch_status_t uuid_broadcast_function(const char *cmd, switch_core_sess
|
|||
}
|
||||
|
||||
|
||||
static switch_status_t sched_broadcast_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(sched_broadcast_function)
|
||||
{
|
||||
char *mycmd = NULL, *argv[4] = { 0 };
|
||||
int argc = 0;
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
|
||||
if (isession) {
|
||||
if (session) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -485,13 +485,13 @@ static switch_status_t sched_broadcast_function(const char *cmd, switch_core_ses
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t uuid_hold_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(uuid_hold_function)
|
||||
{
|
||||
char *mycmd = NULL, *argv[4] = { 0 };
|
||||
int argc = 0;
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
|
||||
if (isession) {
|
||||
if (session) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -519,12 +519,12 @@ static switch_status_t uuid_hold_function(const char *cmd, switch_core_session_t
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t uuid_bridge_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(uuid_bridge_function)
|
||||
{
|
||||
char *mycmd = NULL, *argv[4] = { 0 };
|
||||
int argc = 0;
|
||||
|
||||
if (isession) {
|
||||
if (session) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -544,14 +544,14 @@ static switch_status_t uuid_bridge_function(const char *cmd, switch_core_session
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t session_record_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(session_record_function)
|
||||
{
|
||||
switch_core_session_t *session = NULL;
|
||||
switch_core_session_t *rsession = NULL;
|
||||
char *mycmd = NULL, *argv[4] = { 0 };
|
||||
char *uuid = NULL, *action = NULL, *path = NULL;
|
||||
int argc = 0;
|
||||
|
||||
if (isession) {
|
||||
if (session) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -571,7 +571,7 @@ static switch_status_t session_record_function(const char *cmd, switch_core_sess
|
|||
action = argv[1];
|
||||
path = argv[2];
|
||||
|
||||
if (!(session = switch_core_session_locate(uuid))) {
|
||||
if (!(rsession = switch_core_session_locate(uuid))) {
|
||||
stream->write_function(stream, "-Error Cannot locate session!\n");
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -581,9 +581,9 @@ static switch_status_t session_record_function(const char *cmd, switch_core_sess
|
|||
}
|
||||
|
||||
if (!strcasecmp(action, "start")) {
|
||||
switch_ivr_record_session(session, path, NULL);
|
||||
switch_ivr_record_session(rsession, path, NULL);
|
||||
} else if (!strcasecmp(action, "stop")) {
|
||||
switch_ivr_stop_record_session(session, path);
|
||||
switch_ivr_stop_record_session(rsession, path);
|
||||
} else {
|
||||
goto usage;
|
||||
}
|
||||
|
@ -599,20 +599,20 @@ static switch_status_t session_record_function(const char *cmd, switch_core_sess
|
|||
done:
|
||||
|
||||
if (session) {
|
||||
switch_core_session_rwunlock(session);
|
||||
switch_core_session_rwunlock(rsession);
|
||||
}
|
||||
|
||||
switch_safe_free(mycmd);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t pause_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(pause_function)
|
||||
{
|
||||
switch_core_session_t *session = NULL;
|
||||
switch_core_session_t *psession = NULL;
|
||||
char *mycmd = NULL, *argv[4] = { 0 };
|
||||
int argc = 0;
|
||||
|
||||
if (isession) {
|
||||
if (session) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -626,8 +626,8 @@ static switch_status_t pause_function(const char *cmd, switch_core_session_t *is
|
|||
char *uuid = argv[0];
|
||||
char *dest = argv[1];
|
||||
|
||||
if ((session = switch_core_session_locate(uuid))) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
if ((psession = switch_core_session_locate(uuid))) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(psession);
|
||||
|
||||
if (!strcasecmp(dest, "on")) {
|
||||
switch_channel_set_flag(channel, CF_HOLD);
|
||||
|
@ -635,7 +635,7 @@ static switch_status_t pause_function(const char *cmd, switch_core_session_t *is
|
|||
switch_channel_clear_flag(channel, CF_HOLD);
|
||||
}
|
||||
|
||||
switch_core_session_rwunlock(session);
|
||||
switch_core_session_rwunlock(psession);
|
||||
|
||||
} else {
|
||||
stream->write_function(stream, "No Such Channel!\n");
|
||||
|
@ -646,7 +646,7 @@ static switch_status_t pause_function(const char *cmd, switch_core_session_t *is
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t originate_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(originate_function)
|
||||
{
|
||||
switch_channel_t *caller_channel;
|
||||
switch_core_session_t *caller_session = NULL;
|
||||
|
@ -657,7 +657,7 @@ static switch_status_t originate_function(const char *cmd, switch_core_session_t
|
|||
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
|
||||
uint8_t machine = 1;
|
||||
|
||||
if (isession) {
|
||||
if (session) {
|
||||
stream->write_function(stream, "Illegal Usage\n");
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -775,7 +775,7 @@ static void sch_api_callback(switch_scheduler_task_t *task)
|
|||
switch_safe_free(stream.data);
|
||||
}
|
||||
|
||||
static switch_status_t sched_del_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(sched_del_function)
|
||||
{
|
||||
uint32_t cnt = 0;
|
||||
|
||||
|
@ -794,7 +794,7 @@ static switch_status_t sched_del_function(const char *cmd, switch_core_session_t
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t xml_wrap_api_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(xml_wrap_api_function)
|
||||
{
|
||||
char *dcommand, *edata = NULL, *send = NULL, *command, *arg = NULL;
|
||||
switch_stream_handle_t mystream = { 0 };
|
||||
|
@ -843,7 +843,7 @@ static switch_status_t xml_wrap_api_function(const char *cmd, switch_core_sessio
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t sched_api_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(sched_api_function)
|
||||
{
|
||||
char *tm = NULL, *dcmd, *group;
|
||||
time_t when;
|
||||
|
@ -979,7 +979,7 @@ static int show_callback(void *pArg, int argc, char **argv, char **columnNames)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static switch_status_t show_function(const char *data, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(show_function)
|
||||
{
|
||||
char sql[1024];
|
||||
char *errmsg;
|
||||
|
@ -988,15 +988,15 @@ static switch_status_t show_function(const char *data, switch_core_session_t *se
|
|||
int help = 0;
|
||||
char *mydata = NULL, *argv[6] = {0};
|
||||
int argc;
|
||||
char *cmd = NULL, *as = NULL;
|
||||
char *command = NULL, *as = NULL;
|
||||
|
||||
if (session) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (data && (mydata = strdup(data))) {
|
||||
if (cmd && (mydata = strdup(cmd))) {
|
||||
argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
cmd = argv[0];
|
||||
command = argv[0];
|
||||
if (argv[2] && !strcasecmp(argv[1], "as")) {
|
||||
as = argv[2];
|
||||
}
|
||||
|
@ -1010,25 +1010,25 @@ static switch_status_t show_function(const char *data, switch_core_session_t *se
|
|||
|
||||
// If you changes the field qty or order of any of these select
|
||||
// statmements, you must also change show_callback and friends to match!
|
||||
if (!cmd) {
|
||||
if (!command) {
|
||||
stream->write_function(stream, "USAGE: %s\n", show_api_interface.syntax);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
} else if (!strcmp(cmd, "codec") || !strcmp(cmd, "dialplan") || !strcmp(cmd, "file") || !strcmp(cmd, "timer")) {
|
||||
sprintf(sql, "select type, name from interfaces where type = '%s'", cmd);
|
||||
} else if (!strcmp(cmd, "tasks")) {
|
||||
sprintf(sql, "select * from %s", cmd);
|
||||
} else if (!strcmp(cmd, "application") || !strcmp(cmd, "api")) {
|
||||
sprintf(sql, "select name, description, syntax from interfaces where type = '%s' and description != ''", cmd);
|
||||
} else if (!strcmp(cmd, "calls")) {
|
||||
} else if (!strcmp(command, "codec") || !strcmp(command, "dialplan") || !strcmp(command, "file") || !strcmp(command, "timer")) {
|
||||
sprintf(sql, "select type, name from interfaces where type = '%s'", command);
|
||||
} else if (!strcmp(command, "tasks")) {
|
||||
sprintf(sql, "select * from %s", command);
|
||||
} else if (!strcmp(command, "application") || !strcmp(command, "api")) {
|
||||
sprintf(sql, "select name, description, syntax from interfaces where type = '%s' and description != ''", command);
|
||||
} else if (!strcmp(command, "calls")) {
|
||||
sprintf(sql, "select * from calls");
|
||||
} else if (!strcmp(cmd, "channels")) {
|
||||
} else if (!strcmp(command, "channels")) {
|
||||
sprintf(sql, "select * from channels");
|
||||
} else if (!strncasecmp(cmd, "help", 4)) {
|
||||
} else if (!strncasecmp(command, "help", 4)) {
|
||||
char *cmdname = NULL;
|
||||
|
||||
help = 1;
|
||||
holder.print_title = 0;
|
||||
if ((cmdname = strchr(cmd, ' ')) != 0) {
|
||||
if ((cmdname = strchr(command, ' ')) != 0) {
|
||||
*cmdname++ = '\0';
|
||||
snprintf(sql, sizeof(sql) - 1, "select name, syntax, description from interfaces where type = 'api' and name = '%s'", cmdname);
|
||||
} else {
|
||||
|
@ -1100,7 +1100,7 @@ static switch_status_t show_function(const char *data, switch_core_session_t *se
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t version_function(const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(version_function)
|
||||
{
|
||||
char version_string[1024];
|
||||
snprintf(version_string, sizeof(version_string) - 1, "FreeSwitch Version %s\n", SWITCH_VERSION_FULL);
|
||||
|
@ -1109,7 +1109,7 @@ static switch_status_t version_function(const char *cmd, switch_core_session_t *
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t help_function(const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(help_function)
|
||||
{
|
||||
char showcmd[1024];
|
||||
int all = 0;
|
||||
|
|
|
@ -3445,7 +3445,7 @@ switch_status_t conf_api_dispatch(conference_obj_t * conference, switch_stream_h
|
|||
}
|
||||
|
||||
/* API Interface Function */
|
||||
static switch_status_t conf_api_main(const char *buf, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(conf_api_main)
|
||||
{
|
||||
char *lbuf = NULL;
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
|
@ -3453,8 +3453,8 @@ static switch_status_t conf_api_main(const char *buf, switch_core_session_t *ses
|
|||
int argc;
|
||||
char *argv[25] = { 0 };
|
||||
|
||||
if (!buf) {
|
||||
buf = "help";
|
||||
if (!cmd) {
|
||||
cmd = "help";
|
||||
}
|
||||
|
||||
if (session) {
|
||||
|
@ -3470,7 +3470,7 @@ static switch_status_t conf_api_main(const char *buf, switch_core_session_t *ses
|
|||
stream->write_function(stream, "<pre>\n");
|
||||
}
|
||||
|
||||
if (!(lbuf = strdup(buf))) {
|
||||
if (!(lbuf = strdup(cmd))) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -3486,7 +3486,7 @@ static switch_status_t conf_api_main(const char *buf, switch_core_session_t *ses
|
|||
goto done;
|
||||
}
|
||||
if (argc >= 2) {
|
||||
conf_api_dispatch(conference, stream, argc, argv, (const char *) buf, 1);
|
||||
conf_api_dispatch(conference, stream, argc, argv, cmd, 1);
|
||||
} else {
|
||||
stream->write_function(stream, "Conference command, not specified.\nTry 'help'\n");
|
||||
}
|
||||
|
|
|
@ -502,14 +502,14 @@ static void strftime_function(switch_core_session_t *session, char *data)
|
|||
}
|
||||
|
||||
|
||||
static switch_status_t strepoch_api_function(const char *data, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(strepoch_api_function)
|
||||
{
|
||||
switch_time_t out;
|
||||
|
||||
if (switch_strlen_zero(data)) {
|
||||
if (switch_strlen_zero(cmd)) {
|
||||
out = switch_time_now();
|
||||
} else {
|
||||
out = switch_str_time(data);
|
||||
out = switch_str_time(cmd);
|
||||
}
|
||||
|
||||
stream->write_function(stream, "%d", (uint32_t) ((out) / (int64_t) (1000000)));
|
||||
|
@ -517,7 +517,7 @@ static switch_status_t strepoch_api_function(const char *data, switch_core_sessi
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t strftime_api_function(const char *fmt, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(strftime_api_function)
|
||||
{
|
||||
|
||||
switch_size_t retsize;
|
||||
|
@ -525,20 +525,20 @@ static switch_status_t strftime_api_function(const char *fmt, switch_core_sessio
|
|||
char date[80] = "";
|
||||
|
||||
switch_time_exp_lt(&tm, switch_time_now());
|
||||
switch_strftime(date, &retsize, sizeof(date), fmt ? fmt : "%Y-%m-%d %T", &tm);
|
||||
switch_strftime(date, &retsize, sizeof(date), cmd ? cmd : "%Y-%m-%d %T", &tm);
|
||||
stream->write_function(stream, "%s", date);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t presence_api_function(const char *fmt, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(presence_api_function)
|
||||
{
|
||||
switch_event_t *event;
|
||||
char *lbuf, *argv[4];
|
||||
int argc = 0;
|
||||
switch_event_types_t type = SWITCH_EVENT_PRESENCE_IN;
|
||||
|
||||
if (fmt && (lbuf = strdup(fmt))
|
||||
if (cmd && (lbuf = strdup(cmd))
|
||||
&& (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) > 0) {
|
||||
if (!strcasecmp(argv[0], "out")) {
|
||||
type = SWITCH_EVENT_PRESENCE_OUT;
|
||||
|
@ -568,12 +568,12 @@ static switch_status_t presence_api_function(const char *fmt, switch_core_sessio
|
|||
}
|
||||
|
||||
|
||||
static switch_status_t chat_api_function(const char *fmt, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(chat_api_function)
|
||||
{
|
||||
char *lbuf, *argv[4];
|
||||
int argc = 0;
|
||||
|
||||
if (fmt && (lbuf = strdup(fmt))
|
||||
if (cmd && (lbuf = strdup(cmd))
|
||||
&& (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
|
||||
switch_chat_interface_t *ci;
|
||||
|
||||
|
|
|
@ -625,7 +625,7 @@ static void enum_app_function(switch_core_session_t *session, char *data)
|
|||
|
||||
}
|
||||
|
||||
static switch_status_t enum_function(const char *data, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(enum_function)
|
||||
{
|
||||
|
||||
int argc = 0;
|
||||
|
@ -640,7 +640,7 @@ static switch_status_t enum_function(const char *data, switch_core_session_t *se
|
|||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (!(mydata = strdup(data))) {
|
||||
if (!cmd || !(mydata = strdup(cmd))) {
|
||||
stream->write_function(stream, "Error!\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
|
|
@ -1522,7 +1522,7 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t pa_cmd(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(pa_cmd)
|
||||
{
|
||||
char *argv[1024] = { 0 };
|
||||
int argc = 0;
|
||||
|
|
|
@ -2028,7 +2028,7 @@ static void set_profile_val(mdl_profile_t *profile, char *var, char *val)
|
|||
}
|
||||
}
|
||||
|
||||
static switch_status_t dl_debug(const char *tf, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(dl_debug)
|
||||
{
|
||||
int on, cur;
|
||||
|
||||
|
@ -2036,8 +2036,8 @@ static switch_status_t dl_debug(const char *tf, switch_core_session_t *session,
|
|||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (tf) {
|
||||
on = switch_true(tf);
|
||||
if (cmd) {
|
||||
on = switch_true(cmd);
|
||||
cur = ldl_global_debug(on);
|
||||
} else {
|
||||
cur = ldl_global_debug(-1);
|
||||
|
@ -2049,7 +2049,7 @@ static switch_status_t dl_debug(const char *tf, switch_core_session_t *session,
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t dl_pres(const char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(dl_pres)
|
||||
{
|
||||
mdl_profile_t *profile;
|
||||
|
||||
|
@ -2057,26 +2057,26 @@ static switch_status_t dl_pres(const char *profile_name, switch_core_session_t *
|
|||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (!profile_name) {
|
||||
if (!cmd) {
|
||||
stream->write_function(stream, "USAGE: %s\n", pres_api_interface.syntax);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if ((profile = switch_core_hash_find(globals.profile_hash, profile_name))) {
|
||||
if ((profile = switch_core_hash_find(globals.profile_hash, cmd))) {
|
||||
if (profile->user_flags & LDL_FLAG_COMPONENT) {
|
||||
sign_on(profile);
|
||||
stream->write_function(stream, "OK\n");
|
||||
} else {
|
||||
stream->write_function(stream, "NO PROFILE %s NOT A COMPONENT\n", profile_name);
|
||||
stream->write_function(stream, "NO PROFILE %s NOT A COMPONENT\n", cmd);
|
||||
}
|
||||
} else {
|
||||
stream->write_function(stream, "NO SUCH PROFILE %s\n", profile_name);
|
||||
stream->write_function(stream, "NO SUCH PROFILE %s\n", cmd);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t dl_logout(const char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(dl_logout)
|
||||
{
|
||||
mdl_profile_t *profile;
|
||||
|
||||
|
@ -2084,22 +2084,22 @@ static switch_status_t dl_logout(const char *profile_name, switch_core_session_t
|
|||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (!profile_name) {
|
||||
if (!cmd) {
|
||||
stream->write_function(stream, "USAGE: %s\n", logout_api_interface.syntax);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if ((profile = switch_core_hash_find(globals.profile_hash, profile_name))) {
|
||||
if ((profile = switch_core_hash_find(globals.profile_hash, cmd))) {
|
||||
ldl_handle_stop(profile->handle);
|
||||
stream->write_function(stream, "OK\n");
|
||||
} else {
|
||||
stream->write_function(stream, "NO SUCH PROFILE %s\n", profile_name);
|
||||
stream->write_function(stream, "NO SUCH PROFILE %s\n", cmd);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t dl_login(const char *arg, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(dl_login)
|
||||
{
|
||||
char *argv[10] = { 0 };
|
||||
int argc = 0;
|
||||
|
@ -2111,16 +2111,16 @@ static switch_status_t dl_login(const char *arg, switch_core_session_t *session,
|
|||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (switch_strlen_zero(arg)) {
|
||||
if (switch_strlen_zero(cmd)) {
|
||||
stream->write_function(stream, "USAGE: %s\n", login_api_interface.syntax);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
myarg = strdup(arg);
|
||||
myarg = strdup(cmd);
|
||||
|
||||
argc = switch_separate_string(myarg, ';', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
if (switch_strlen_zero(arg) || argc != 1) {
|
||||
if (switch_strlen_zero(cmd) || argc != 1) {
|
||||
stream->write_function(stream, "USAGE: %s\n", login_api_interface.syntax);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -1711,13 +1711,13 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t padep(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(padep)
|
||||
{
|
||||
stream->write_function(stream, "This command no longer exists (try 'pa help')\n");
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t pa_cmd(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(pa_cmd)
|
||||
{
|
||||
char *argv[1024] = { 0 };
|
||||
int argc = 0;
|
||||
|
|
|
@ -1175,7 +1175,7 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t sofia_function(const char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(sofia_function)
|
||||
{
|
||||
char *argv[1024] = { 0 };
|
||||
int argc = 0;
|
||||
|
@ -1190,7 +1190,7 @@ static switch_status_t sofia_function(const char *cmd, switch_core_session_t *is
|
|||
"sofia status [[profile | gateway] <name>]\n"
|
||||
"--------------------------------------------------------------------------------\n";
|
||||
|
||||
if (isession) {
|
||||
if (session) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
|||
return RUNNING ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
static switch_status_t modcdr_reload(const char *dest=0, switch_core_session_t *isession=0, switch_stream_handle_t *stream=0)
|
||||
SWITCH_STANDARD_API(modcdr_reload)
|
||||
{
|
||||
#ifdef SWITCH_QUEUE_ENHANCED
|
||||
switch_thread_rwlock_wrlock(cdr_rwlock);
|
||||
|
@ -164,7 +164,7 @@ static switch_status_t modcdr_reload(const char *dest=0, switch_core_session_t *
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t modcdr_queue_pause(const char *dest=0, switch_core_session_t *isession=0, switch_stream_handle_t *stream=0)
|
||||
SWITCH_STANDARD_API(modcdr_queue_pause)
|
||||
{
|
||||
#ifdef SWITCH_QUEUE_ENHANCED
|
||||
newcdrcontainer->queue_pause(stream);
|
||||
|
@ -174,7 +174,7 @@ static switch_status_t modcdr_queue_pause(const char *dest=0, switch_core_sessio
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t modcdr_queue_resume(const char *dest=0, switch_core_session_t *isession=0, switch_stream_handle_t *stream=0)
|
||||
SWITCH_STANDARD_API(modcdr_queue_resume)
|
||||
{
|
||||
#ifdef SWITCH_QUEUE_ENHANCED
|
||||
newcdrcontainer->queue_resume(stream);
|
||||
|
@ -184,13 +184,13 @@ static switch_status_t modcdr_queue_resume(const char *dest=0, switch_core_sessi
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t modcdr_show_active(const char *dest=0, switch_core_session_t *isession=0, switch_stream_handle_t *stream=0)
|
||||
SWITCH_STANDARD_API(modcdr_show_active)
|
||||
{
|
||||
newcdrcontainer->active(stream);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t modcdr_show_available(const char *dest=0, switch_core_session_t *isession=0, switch_stream_handle_t *stream=0)
|
||||
SWITCH_STANDARD_API(modcdr_show_available)
|
||||
{
|
||||
newcdrcontainer->available(stream);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
|
|
@ -161,14 +161,14 @@ static void *SWITCH_THREAD_FUNC py_thread_run(switch_thread_t *thread, void *obj
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static switch_status_t launch_python(const char *text, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(launch_python)
|
||||
{
|
||||
switch_thread_t *thread;
|
||||
switch_threadattr_t *thd_attr = NULL;
|
||||
switch_memory_pool_t *pool;
|
||||
struct switch_py_thread *pt;
|
||||
|
||||
if (switch_strlen_zero(text)) {
|
||||
if (switch_strlen_zero(cmd)) {
|
||||
stream->write_function(stream, "USAGE: %s\n", python_run_interface.syntax);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ static switch_status_t launch_python(const char *text, switch_core_session_t *se
|
|||
assert(pt != NULL);
|
||||
|
||||
pt->pool = pool;
|
||||
pt->args = switch_core_strdup(pt->pool, text);
|
||||
pt->args = switch_core_strdup(pt->pool, cmd);
|
||||
|
||||
switch_threadattr_create(&thd_attr, pt->pool);
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
|
|
|
@ -2739,15 +2739,15 @@ static void js_thread_launch(const char *text)
|
|||
}
|
||||
|
||||
|
||||
static switch_status_t launch_async(const char *text, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
SWITCH_STANDARD_API(launch_async)
|
||||
{
|
||||
|
||||
if (switch_strlen_zero(text)) {
|
||||
if (switch_strlen_zero(cmd)) {
|
||||
stream->write_function(stream, "USAGE: %s\n", js_run_interface.syntax);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
js_thread_launch(text);
|
||||
js_thread_launch(cmd);
|
||||
stream->write_function(stream, "OK\n");
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue