mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-14 00:00:44 +00:00
add initial bits of show api command. This still needs some work.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1350 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
c1a255075b
commit
81c4e9f959
@ -129,12 +129,64 @@ static switch_status_t pause_function(char *cmd, char *out, size_t outlen)
|
|||||||
return SWITCH_STATUS_SUCCESS;
|
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 api_return *) pArg;
|
||||||
|
char temp[1024];
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
printf("%s\n", argv[1]);
|
||||||
|
|
||||||
|
sprintf(temp, "%s\n", argv[1]);
|
||||||
|
len = strlen(temp);
|
||||||
|
|
||||||
|
if (len < returnval->remaining) {
|
||||||
|
strcpy(returnval->out, temp);
|
||||||
|
returnval->remaining -= len;
|
||||||
|
returnval->out += len;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static switch_status_t show_function(char *cmd, char *out, size_t outlen)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (errmsg) {
|
||||||
|
snprintf(out, outlen, "SQL ERR [%s]\n",errmsg);
|
||||||
|
switch_core_db_free(errmsg);
|
||||||
|
errmsg = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_core_db_close(db);
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static switch_api_interface_t show_api_interface = {
|
||||||
|
/*.interface_name */ "show",
|
||||||
|
/*.desc */ "Show",
|
||||||
|
/*.function */ show_function,
|
||||||
|
/*.next */ NULL
|
||||||
|
};
|
||||||
static switch_api_interface_t pause_api_interface = {
|
static switch_api_interface_t pause_api_interface = {
|
||||||
/*.interface_name */ "pause",
|
/*.interface_name */ "pause",
|
||||||
/*.desc */ "Pause",
|
/*.desc */ "Pause",
|
||||||
/*.function */ pause_function,
|
/*.function */ pause_function,
|
||||||
/*.next */ NULL
|
/*.next */ &show_api_interface
|
||||||
};
|
};
|
||||||
|
|
||||||
static switch_api_interface_t transfer_api_interface = {
|
static switch_api_interface_t transfer_api_interface = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user