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;
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")) {
}
-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;
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);
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;
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);
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;
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");
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;
}
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");
}
-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;
}
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");
}
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;
}
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");
}
}
-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;
}
}
-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;
}
}
-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;
}
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;
}
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;
}
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;
}
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;
}
}
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;
}
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;
}
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);
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");
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;
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;
}
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;
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 };
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;
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;
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];
}
// 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 {
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);
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;