mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 09:36:46 +00:00
XMLification (wave 4)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1412 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -33,15 +33,31 @@
|
||||
|
||||
static const char modname[] = "mod_commands";
|
||||
|
||||
|
||||
static switch_status_t load_function(char *mod, char *out, size_t outlen)
|
||||
static switch_status_t status_function(char *cmd, switch_stream_handle_t *stream)
|
||||
{
|
||||
switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) mod);
|
||||
snprintf(out, outlen, "OK\n");
|
||||
switch_core_time_duration_t duration;
|
||||
switch_core_measure_time(switch_core_uptime(), &duration);
|
||||
|
||||
stream->write_function(stream, "<b>UP %u year(s), %u day(s), %u hour(s), %u minute(s), %u second(s), %u millisecond(s), %u microsecond(s)</b>\n",
|
||||
duration.yr,
|
||||
duration.day,
|
||||
duration.hr,
|
||||
duration.min,
|
||||
duration.sec,
|
||||
duration.ms,
|
||||
duration.mms
|
||||
);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t kill_function(char *dest, char *out, size_t outlen)
|
||||
static switch_status_t load_function(char *mod, switch_stream_handle_t *stream)
|
||||
{
|
||||
switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) mod);
|
||||
stream->write_function(stream, "OK\n");
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t kill_function(char *dest, switch_stream_handle_t *stream)
|
||||
{
|
||||
switch_core_session_t *session = NULL;
|
||||
|
||||
@@ -50,16 +66,16 @@ static switch_status_t kill_function(char *dest, char *out, size_t outlen)
|
||||
switch_core_session_kill_channel(session, SWITCH_SIG_KILL);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
|
||||
switch_core_session_rwunlock(session);
|
||||
snprintf(out, outlen, "OK\n");
|
||||
stream->write_function(stream, "OK\n");
|
||||
} else {
|
||||
snprintf(out, outlen, "No Such Channel!\n");
|
||||
stream->write_function(stream, "No Such Channel!\n");
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t transfer_function(char *cmd, char *out, size_t outlen)
|
||||
static switch_status_t transfer_function(char *cmd, switch_stream_handle_t *stream)
|
||||
{
|
||||
switch_core_session_t *session = NULL;
|
||||
char *argv[4] = {0};
|
||||
@@ -68,7 +84,7 @@ static switch_status_t transfer_function(char *cmd, char *out, size_t outlen)
|
||||
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
if (argc < 2 || argc > 4) {
|
||||
snprintf(out, outlen, "Invalid Parameters\n");
|
||||
stream->write_function(stream, "Invalid Parameters\n");
|
||||
} else {
|
||||
char *uuid = argv[0];
|
||||
char *dest = argv[1];
|
||||
@@ -78,15 +94,15 @@ static switch_status_t transfer_function(char *cmd, char *out, size_t outlen)
|
||||
if ((session = switch_core_session_locate(uuid))) {
|
||||
|
||||
if (switch_ivr_session_transfer(session, dest, dp, context) == SWITCH_STATUS_SUCCESS) {
|
||||
snprintf(out, outlen, "OK\n");
|
||||
stream->write_function(stream, "OK\n");
|
||||
} else {
|
||||
snprintf(out, outlen, "ERROR\n");
|
||||
stream->write_function(stream, "ERROR\n");
|
||||
}
|
||||
|
||||
switch_core_session_rwunlock(session);
|
||||
|
||||
} else {
|
||||
snprintf(out, outlen, "No Such Channel!\n");
|
||||
stream->write_function(stream, "No Such Channel!\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +112,7 @@ static switch_status_t transfer_function(char *cmd, char *out, size_t outlen)
|
||||
|
||||
|
||||
|
||||
static switch_status_t pause_function(char *cmd, char *out, size_t outlen)
|
||||
static switch_status_t pause_function(char *cmd, switch_stream_handle_t *stream)
|
||||
{
|
||||
switch_core_session_t *session = NULL;
|
||||
char *argv[4] = {0};
|
||||
@@ -105,7 +121,7 @@ static switch_status_t pause_function(char *cmd, char *out, size_t outlen)
|
||||
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
if (argc < 2) {
|
||||
snprintf(out, outlen, "Invalid Parameters\n");
|
||||
stream->write_function(stream, "Invalid Parameters\n");
|
||||
} else {
|
||||
char *uuid = argv[0];
|
||||
char *dest = argv[1];
|
||||
@@ -122,66 +138,32 @@ static switch_status_t pause_function(char *cmd, char *out, size_t outlen)
|
||||
switch_core_session_rwunlock(session);
|
||||
|
||||
} else {
|
||||
snprintf(out, outlen, "No Such Channel!\n");
|
||||
stream->write_function(stream, "No Such Channel!\n");
|
||||
}
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
struct show_return {
|
||||
char *out;
|
||||
size_t remaining;
|
||||
};
|
||||
|
||||
static int show_callback(void *pArg, int argc, char **argv, char **columnNames){
|
||||
struct show_return *returnval = (struct show_return *) pArg;
|
||||
char temp[1024];
|
||||
size_t len;
|
||||
switch_stream_handle_t *stream = (switch_stream_handle_t *) pArg;
|
||||
|
||||
sprintf(temp, "%s\n", argv[1]);
|
||||
len = strlen(temp);
|
||||
|
||||
if (len < returnval->remaining) {
|
||||
strcpy(returnval->out, temp);
|
||||
returnval->remaining -= len;
|
||||
returnval->out += len;
|
||||
}
|
||||
stream->write_function(stream, "%s\n", argv[1]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static switch_status_t status_function(char *cmd, char *out, size_t outlen)
|
||||
{
|
||||
switch_core_time_duration_t duration;
|
||||
switch_core_measure_time(switch_core_uptime(), &duration);
|
||||
|
||||
snprintf(out, outlen, "<b>UP %u year(s), %u day(s), %u hour(s), %u minute(s), %u second(s), %u millisecond(s), %u microsecond(s)</b>\n",
|
||||
duration.yr,
|
||||
duration.day,
|
||||
duration.hr,
|
||||
duration.min,
|
||||
duration.sec,
|
||||
duration.ms,
|
||||
duration.mms
|
||||
);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t show_function(char *cmd, char *out, size_t outlen)
|
||||
static switch_status_t show_function(char *cmd, switch_stream_handle_t *stream)
|
||||
{
|
||||
char sql[1024];
|
||||
char *errmsg;
|
||||
struct show_return returnval;
|
||||
switch_core_db_t *db = switch_core_db_handle();
|
||||
|
||||
sprintf (sql, "select * from interfaces");
|
||||
returnval.out = out;
|
||||
returnval.remaining = outlen;
|
||||
|
||||
switch_core_db_exec(db, sql, show_callback, &returnval, &errmsg);
|
||||
switch_core_db_exec(db, sql, show_callback, stream, &errmsg);
|
||||
|
||||
if (errmsg) {
|
||||
snprintf(out, outlen, "SQL ERR [%s]\n",errmsg);
|
||||
stream->write_function(stream, "SQL ERR [%s]\n",errmsg);
|
||||
switch_core_db_free(errmsg);
|
||||
errmsg = NULL;
|
||||
}
|
||||
@@ -234,7 +216,6 @@ static switch_api_interface_t commands_api_interface = {
|
||||
/*.next */ &load_api_interface
|
||||
};
|
||||
|
||||
|
||||
static const switch_loadable_module_interface_t mod_commands_module_interface = {
|
||||
/*.module_name */ modname,
|
||||
/*.endpoint_interface */ NULL,
|
||||
|
Reference in New Issue
Block a user