summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/app_mixmonitor.c48
-rw-r--r--apps/app_osplookup.c72
-rw-r--r--apps/app_rpt.c269
3 files changed, 207 insertions, 182 deletions
diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c
index 614adcba1..ca775f163 100644
--- a/apps/app_mixmonitor.c
+++ b/apps/app_mixmonitor.c
@@ -362,46 +362,44 @@ static int stop_mixmonitor_exec(struct ast_channel *chan, void *data)
return 0;
}
-static int mixmonitor_cli(int fd, int argc, char **argv)
+static char *handle_cli_mixmonitor(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct ast_channel *chan;
- if (argc < 3)
- return RESULT_SHOWUSAGE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "mixmonitor [start|stop]";
+ e->usage =
+ "Usage: mixmonitor <start|stop> <chan_name> [args]\n"
+ " The optional arguments are passed to the MixMonitor\n"
+ " application when the 'start' command is used.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return ast_complete_channels(a->line, a->word, a->pos, a->n, 2);
+ }
+
+ if (a->argc < 3)
+ return CLI_SHOWUSAGE;
- if (!(chan = ast_get_channel_by_name_prefix_locked(argv[2], strlen(argv[2])))) {
- ast_cli(fd, "No channel matching '%s' found.\n", argv[2]);
- return RESULT_SUCCESS;
+ if (!(chan = ast_get_channel_by_name_prefix_locked(a->argv[2], strlen(a->argv[2])))) {
+ ast_cli(a->fd, "No channel matching '%s' found.\n", a->argv[2]);
+ /* Technically this is a failure, but we don't want 2 errors printing out */
+ return CLI_SUCCESS;
}
- if (!strcasecmp(argv[1], "start")) {
- mixmonitor_exec(chan, argv[3]);
+ if (!strcasecmp(a->argv[1], "start")) {
+ mixmonitor_exec(chan, a->argv[3]);
ast_channel_unlock(chan);
} else {
ast_channel_unlock(chan);
ast_audiohook_detach_source(chan, mixmonitor_spy_type);
}
- return RESULT_SUCCESS;
-}
-
-static char *complete_mixmonitor_cli(const char *line, const char *word, int pos, int state)
-{
- char *options[] = {"start", "stop", NULL};
-
- if (pos == 1)
- return ast_cli_complete (word, options, state);
-
- return ast_complete_channels(line, word, pos, state, 2);
+ return CLI_SUCCESS;
}
static struct ast_cli_entry cli_mixmonitor[] = {
- { { "mixmonitor", NULL, NULL },
- mixmonitor_cli, "Execute a MixMonitor command.",
- "mixmonitor <start|stop> <chan_name> [args]\n\n"
- "The optional arguments are passed to the\n"
- "MixMonitor application when the 'start' command is used.\n",
- complete_mixmonitor_cli },
+ NEW_CLI(handle_cli_mixmonitor, "Execute a MixMonitor command")
};
static int unload_module(void)
diff --git a/apps/app_osplookup.c b/apps/app_osplookup.c
index 25b3fb518..5c4e2402b 100644
--- a/apps/app_osplookup.c
+++ b/apps/app_osplookup.c
@@ -1861,10 +1861,7 @@ static int osp_unload(void)
return 0;
}
-static int osp_show(
- int fd,
- int argc,
- char* argv[])
+static char *handle_cli_osp_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
int i;
int found = 0;
@@ -1872,12 +1869,21 @@ static int osp_show(
const char* provider = NULL;
const char* tokenalgo;
- if ((argc < 2) || (argc > 3)) {
- return RESULT_SHOWUSAGE;
- }
- if (argc > 2) {
- provider = argv[2];
- }
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "osp show";
+ e->usage =
+ "Usage: osp show\n"
+ " Displays information on Open Settlement Protocol support\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if ((a->argc < 2) || (a->argc > 3))
+ return CLI_SHOWUSAGE;
+ if (a->argc > 2)
+ provider = a->argv[2];
if (!provider) {
switch (osp_tokenformat) {
case TOKEN_ALGO_BOTH:
@@ -1891,7 +1897,7 @@ static int osp_show(
tokenalgo = "Signed";
break;
}
- ast_cli(fd, "OSP: %s %s %s\n",
+ ast_cli(a->fd, "OSP: %s %s %s\n",
osp_initialized ? "Initialized" : "Uninitialized", osp_hardware ? "Accelerated" : "Normal", tokenalgo);
}
@@ -1900,25 +1906,25 @@ static int osp_show(
while(p) {
if (!provider || !strcasecmp(p->name, provider)) {
if (found) {
- ast_cli(fd, "\n");
+ ast_cli(a->fd, "\n");
}
- ast_cli(fd, " == OSP Provider '%s' == \n", p->name);
- ast_cli(fd, "Local Private Key: %s\n", p->privatekey);
- ast_cli(fd, "Local Certificate: %s\n", p->localcert);
+ ast_cli(a->fd, " == OSP Provider '%s' == \n", p->name);
+ ast_cli(a->fd, "Local Private Key: %s\n", p->privatekey);
+ ast_cli(a->fd, "Local Certificate: %s\n", p->localcert);
for (i = 0; i < p->cacount; i++) {
- ast_cli(fd, "CA Certificate %d: %s\n", i + 1, p->cacerts[i]);
+ ast_cli(a->fd, "CA Certificate %d: %s\n", i + 1, p->cacerts[i]);
}
for (i = 0; i < p->spcount; i++) {
- ast_cli(fd, "Service Point %d: %s\n", i + 1, p->srvpoints[i]);
+ ast_cli(a->fd, "Service Point %d: %s\n", i + 1, p->srvpoints[i]);
}
- ast_cli(fd, "Max Connections: %d\n", p->maxconnections);
- ast_cli(fd, "Retry Delay: %d seconds\n", p->retrydelay);
- ast_cli(fd, "Retry Limit: %d\n", p->retrylimit);
- ast_cli(fd, "Timeout: %d milliseconds\n", p->timeout);
- ast_cli(fd, "Source: %s\n", strlen(p->source) ? p->source : "<unspecified>");
- ast_cli(fd, "Auth Policy %d\n", p->authpolicy);
- ast_cli(fd, "Default protocol %s\n", p->defaultprotocol);
- ast_cli(fd, "OSP Handle: %d\n", p->handle);
+ ast_cli(a->fd, "Max Connections: %d\n", p->maxconnections);
+ ast_cli(a->fd, "Retry Delay: %d seconds\n", p->retrydelay);
+ ast_cli(a->fd, "Retry Limit: %d\n", p->retrylimit);
+ ast_cli(a->fd, "Timeout: %d milliseconds\n", p->timeout);
+ ast_cli(a->fd, "Source: %s\n", strlen(p->source) ? p->source : "<unspecified>");
+ ast_cli(a->fd, "Auth Policy %d\n", p->authpolicy);
+ ast_cli(a->fd, "Default protocol %s\n", p->defaultprotocol);
+ ast_cli(a->fd, "OSP Handle: %d\n", p->handle);
found++;
}
p = p->next;
@@ -1927,12 +1933,12 @@ static int osp_show(
if (!found) {
if (provider) {
- ast_cli(fd, "Unable to find OSP provider '%s'\n", provider);
+ ast_cli(a->fd, "Unable to find OSP provider '%s'\n", provider);
} else {
- ast_cli(fd, "No OSP providers configured\n");
- }
+ ast_cli(a->fd, "No OSP providers configured\n");
+ }
}
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
static const char* app1= "OSPAuth";
@@ -1993,14 +1999,8 @@ static const char* descrip4 =
" OSPFINISHSTATUS The status of the OSP Finish attempt as a text string, one of\n"
" SUCCESS | FAILED | ERROR \n";
-static const char osp_usage[] =
-"Usage: osp show\n"
-" Displays information on Open Settlement Protocol support\n";
-
static struct ast_cli_entry cli_osp[] = {
- { {"osp", "show", NULL},
- osp_show, "Displays OSP information",
- osp_usage },
+ NEW_CLI(handle_cli_osp_show, "Displays OSF information")
};
static int load_module(void)
diff --git a/apps/app_rpt.c b/apps/app_rpt.c
index 77e4ee4ef..1f77cee3a 100644
--- a/apps/app_rpt.c
+++ b/apps/app_rpt.c
@@ -300,7 +300,6 @@ static char *remote_rig_rbi = "rbi";
STANDARD_LOCAL_USER;
#endif
-
#define MSWAIT 200
#define HANGTIME 5000
#define TOTIME 180000
@@ -699,60 +698,20 @@ static void _rpt_mutex_unlock(ast_mutex_t *lockp, struct rpt *myrpt, int line)
*/
/* Debug mode */
-static int rpt_do_debug(int fd, int argc, char *argv[]);
-static int rpt_do_dump(int fd, int argc, char *argv[]);
-static int rpt_do_stats(int fd, int argc, char *argv[]);
-static int rpt_do_lstats(int fd, int argc, char *argv[]);
-static int rpt_do_reload(int fd, int argc, char *argv[]);
-static int rpt_do_restart(int fd, int argc, char *argv[]);
-
-static char debug_usage[] =
-"Usage: rpt debug level {0-7}\n"
-" Enables debug messages in app_rpt\n";
-
-static char dump_usage[] =
-"Usage: rpt dump <nodename>\n"
-" Dumps struct debug info to log\n";
-
-static char dump_stats[] =
-"Usage: rpt stats <nodename>\n"
-" Dumps node statistics to console\n";
-
-static char dump_lstats[] =
-"Usage: rpt lstats <nodename>\n"
-" Dumps link statistics to console\n";
-
-static char reload_usage[] =
-"Usage: rpt reload\n"
-" Reloads app_rpt running config parameters\n";
-
-static char restart_usage[] =
-"Usage: rpt restart\n"
-" Restarts app_rpt\n";
+static char *handle_cli_rpt_debug_level(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
+static char *handle_cli_rpt_dump(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
+static char *handle_cli_rpt_stats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
+static char *handle_cli_rpt_lstats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
+static char *handle_cli_rpt_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
+static char *handle_cli_rpt_restart(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
static struct ast_cli_entry cli_rpt[] = {
- { { "rpt", "debug", "level" },
- rpt_do_debug, "Enable app_rpt debugging",
- debug_usage },
-
- { { "rpt", "dump" },
- rpt_do_dump, "Dump app_rpt structs for debugging",
- dump_usage },
-
- { { "rpt", "stats" },
- rpt_do_stats, "Dump node statistics",
- dump_stats },
- { { "rpt", "lstats" },
- rpt_do_lstats, "Dump link statistics",
- dump_lstats },
-
- { { "rpt", "reload" },
- rpt_do_reload, "Reload app_rpt config",
- reload_usage },
-
- { { "rpt", "restart" },
- rpt_do_restart, "Restart app_rpt",
- restart_usage },
+ NEW_CLI(handle_cli_rpt_debug_level, "Enable app_rpt debuggin"),
+ NEW_CLI(handle_cli_rpt_dump, "Dump app_rpt structs for debugging"),
+ NEW_CLI(handle_cli_rpt_stats, "Dump node statistics"),
+ NEW_CLI(handle_cli_rpt_lstats, "Dump link statistics"),
+ NEW_CLI(handle_cli_rpt_reload, "Reload app_rpt config"),
+ NEW_CLI(handle_cli_rpt_restart, "Restart app_rpt")
};
/*
@@ -1130,48 +1089,70 @@ static void load_rpt_vars(int n, int init)
/*
* Enable or disable debug output at a given level at the console
*/
-static int rpt_do_debug(int fd, int argc, char *argv[])
+static char *handle_cli_rpt_debug_level(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
int newlevel;
- if (argc != 4)
- return RESULT_SHOWUSAGE;
- newlevel = myatoi(argv[3]);
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "rpt debug level";
+ e->usage =
+ "Usage: rpt debug level {0-7}\n"
+ " Enables debug messages in app_rpt\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+ if (a->argc != 4)
+ return CLI_SHOWUSAGE;
+ newlevel = myatoi(a->argv[3]);
if ((newlevel < 0) || (newlevel > 7))
- return RESULT_SHOWUSAGE;
+ return CLI_SHOWUSAGE;
if (newlevel)
- ast_cli(fd, "app_rpt Debugging enabled, previous level: %d, new level: %d\n", debug, newlevel);
+ ast_cli(a->fd, "app_rpt Debugging enabled, previous level: %d, new level: %d\n", debug, newlevel);
else
- ast_cli(fd, "app_rpt Debugging disabled\n");
+ ast_cli(a->fd, "app_rpt Debugging disabled\n");
+
+ debug = newlevel;
- debug = newlevel;
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
/*
* Dump rpt struct debugging onto console
*/
-static int rpt_do_dump(int fd, int argc, char *argv[])
+static char *handle_cli_rpt_dump(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
int i;
- if (argc != 3)
- return RESULT_SHOWUSAGE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "rpt dump";
+ e->usage =
+ "Usage: rpt dump <nodename>\n"
+ " Dumps struct debug info to log\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != 3)
+ return CLI_SHOWUSAGE;
for (i = 0; i < nrpts; i++) {
- if (!strcmp(argv[2], rpt_vars[i].name)) {
+ if (!strcmp(a->argv[2], rpt_vars[i].name)) {
rpt_vars[i].disgorgetime = time(NULL) + 10; /* Do it 10 seconds later */
- ast_cli(fd, "app_rpt struct dump requested for node %s\n", argv[2]);
- return RESULT_SUCCESS;
+ ast_cli(a->fd, "app_rpt struct dump requested for node %s\n", a->argv[2]);
+ return CLI_SUCCESS;
}
}
- return RESULT_FAILURE;
+ return CLI_FAILURE;
}
/*
* Dump statistics onto console
*/
-static int rpt_do_stats(int fd, int argc, char *argv[])
+static char *handle_cli_rpt_stats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
int i, j;
int dailytxtime, dailykerchunks;
@@ -1187,8 +1168,19 @@ static int rpt_do_stats(int fd, int argc, char *argv[])
static char *not_applicable = "N/A";
- if (argc != 3)
- return RESULT_SHOWUSAGE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "rpt stats";
+ e->usage =
+ "Usage: rpt stats <nodename>\n"
+ " Dumps node statistics to console\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != 3)
+ return CLI_SHOWUSAGE;
for (i = 0 ; i <= MAX_STAT_LINKS; i++)
listoflinks[i] = NULL;
@@ -1199,7 +1191,7 @@ static int rpt_do_stats(int fd, int argc, char *argv[])
lastdtmfcommand = not_applicable;
for (i = 0; i < nrpts; i++) {
- if (!strcmp(argv[2], rpt_vars[i].name)) {
+ if (!strcmp(a->argv[2], rpt_vars[i].name)) {
/* Make a copy of all stat variables while locked */
myrpt = &rpt_vars[i];
rpt_mutex_lock(&myrpt->lock); /* LOCK */
@@ -1283,19 +1275,19 @@ static int rpt_do_stats(int fd, int argc, char *argv[])
rpt_mutex_unlock(&myrpt->lock); /* UNLOCK */
- ast_cli(fd, "************************ NODE %s STATISTICS *************************\n\n", myrpt->name);
- ast_cli(fd, "Signal on input..................................: %s\n", input_signal);
- ast_cli(fd, "Transmitter enabled..............................: %s\n", enable_state);
- ast_cli(fd, "Time out timer state.............................: %s\n", tot_state);
- ast_cli(fd, "Time outs since system initialization............: %d\n", timeouts);
- ast_cli(fd, "Identifier state.................................: %s\n", ider_state);
- ast_cli(fd, "Kerchunks today..................................: %d\n", dailykerchunks);
- ast_cli(fd, "Kerchunks since system initialization............: %d\n", totalkerchunks);
- ast_cli(fd, "Keyups today.....................................: %d\n", dailykeyups);
- ast_cli(fd, "Keyups since system initialization...............: %d\n", totalkeyups);
- ast_cli(fd, "DTMF commands today..............................: %d\n", dailyexecdcommands);
- ast_cli(fd, "DTMF commands since system initialization........: %d\n", totalexecdcommands);
- ast_cli(fd, "Last DTMF command executed.......................: %s\n", lastdtmfcommand);
+ ast_cli(a->fd, "************************ NODE %s STATISTICS *************************\n\n", myrpt->name);
+ ast_cli(a->fd, "Signal on input..................................: %s\n", input_signal);
+ ast_cli(a->fd, "Transmitter enabled..............................: %s\n", enable_state);
+ ast_cli(a->fd, "Time out timer state.............................: %s\n", tot_state);
+ ast_cli(a->fd, "Time outs since system initialization............: %d\n", timeouts);
+ ast_cli(a->fd, "Identifier state.................................: %s\n", ider_state);
+ ast_cli(a->fd, "Kerchunks today..................................: %d\n", dailykerchunks);
+ ast_cli(a->fd, "Kerchunks since system initialization............: %d\n", totalkerchunks);
+ ast_cli(a->fd, "Keyups today.....................................: %d\n", dailykeyups);
+ ast_cli(a->fd, "Keyups since system initialization...............: %d\n", totalkeyups);
+ ast_cli(a->fd, "DTMF commands today..............................: %d\n", dailyexecdcommands);
+ ast_cli(a->fd, "DTMF commands since system initialization........: %d\n", totalexecdcommands);
+ ast_cli(a->fd, "Last DTMF command executed.......................: %s\n", lastdtmfcommand);
hours = dailytxtime / 3600000;
dailytxtime %= 3600000;
@@ -1304,7 +1296,7 @@ static int rpt_do_stats(int fd, int argc, char *argv[])
seconds = dailytxtime / 1000;
dailytxtime %= 1000;
- ast_cli(fd, "TX time today ...................................: %02d:%02d:%02d.%d\n",
+ ast_cli(a->fd, "TX time today ...................................: %02d:%02d:%02d.%d\n",
hours, minutes, seconds, dailytxtime);
hours = (int) totaltxtime / 3600000;
@@ -1314,57 +1306,69 @@ static int rpt_do_stats(int fd, int argc, char *argv[])
seconds = (int) totaltxtime / 1000;
totaltxtime %= 1000;
- ast_cli(fd, "TX time since system initialization..............: %02d:%02d:%02d.%d\n",
+ ast_cli(a->fd, "TX time since system initialization..............: %02d:%02d:%02d.%d\n",
hours, minutes, seconds, (int) totaltxtime);
- ast_cli(fd, "Nodes currently connected to us..................: ");
+ ast_cli(a->fd, "Nodes currently connected to us..................: ");
for (j = 0;; j++) {
if (!listoflinks[j]) {
if (!j) {
- ast_cli(fd, "<NONE>");
+ ast_cli(a->fd, "<NONE>");
}
break;
}
- ast_cli(fd, "%s", listoflinks[j]);
+ ast_cli(a->fd, "%s", listoflinks[j]);
if (j % 4 == 3) {
- ast_cli(fd, "\n");
- ast_cli(fd, " : ");
+ ast_cli(a->fd, "\n");
+ ast_cli(a->fd, " : ");
} else {
if (listoflinks[j + 1])
- ast_cli(fd, ", ");
+ ast_cli(a->fd, ", ");
}
}
- ast_cli(fd, "\n");
+ ast_cli(a->fd, "\n");
- ast_cli(fd, "Last node which transmitted to us................: %s\n", lastnodewhichkeyedusup);
- ast_cli(fd, "Autopatch state..................................: %s\n", patch_state);
- ast_cli(fd, "Autopatch called number..........................: %s\n", called_number);
- ast_cli(fd, "Reverse patch/IAXRPT connected...................: %s\n\n", reverse_patch_state);
+ ast_cli(a->fd, "Last node which transmitted to us................: %s\n", lastnodewhichkeyedusup);
+ ast_cli(a->fd, "Autopatch state..................................: %s\n", patch_state);
+ ast_cli(a->fd, "Autopatch called number..........................: %s\n", called_number);
+ ast_cli(a->fd, "Reverse patch/IAXRPT connected...................: %s\n\n", reverse_patch_state);
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
}
- return RESULT_FAILURE;
+ return CLI_FAILURE;
}
/*
* Link stats function
*/
-static int rpt_do_lstats(int fd, int argc, char *argv[])
+static char *handle_cli_rpt_lstats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
int i, j;
struct rpt *myrpt;
struct rpt_link *l;
struct rpt_lstat *s, *t;
struct rpt_lstat s_head;
- if (argc != 3)
- return RESULT_SHOWUSAGE;
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "rpt lstats";
+ e->usage =
+ "Usage: rpt lstats <nodename>\n"
+ " Dumps link statistics to console\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != 3)
+ return CLI_SHOWUSAGE;
s = NULL;
s_head.next = &s_head;
s_head.prev = &s_head;
for (i = 0; i < nrpts; i++) {
- if (!strcmp(argv[2], rpt_vars[i].name)) {
+ if (!strcmp(a->argv[2], rpt_vars[i].name)) {
/* Make a copy of all stat variables while locked */
myrpt = &rpt_vars[i];
rpt_mutex_lock(&myrpt->lock); /* LOCK */
@@ -1379,7 +1383,7 @@ static int rpt_do_lstats(int fd, int argc, char *argv[])
if ((s = ast_calloc(1, sizeof(*s))) == NULL) {
ast_log(LOG_ERROR, "Malloc failed in rpt_do_lstats\n");
rpt_mutex_unlock(&myrpt->lock); /* UNLOCK */
- return RESULT_FAILURE;
+ return CLI_FAILURE;
}
ast_copy_string(s->name, l->name, MAXREMSTR);
pbx_substitute_variables_helper(l->chan, "${IAXPEER(CURRENTCHANNEL)}", s->peer, MAXPEERSTR - 1);
@@ -1391,8 +1395,8 @@ static int rpt_do_lstats(int fd, int argc, char *argv[])
l = l->next;
}
rpt_mutex_unlock(&myrpt->lock); /* UNLOCK */
- ast_cli(fd, "NODE PEER RECONNECTS DIRECTION CONNECT TIME\n");
- ast_cli(fd, "---- ---- ---------- --------- ------------\n");
+ ast_cli(a->fd, "NODE PEER RECONNECTS DIRECTION CONNECT TIME\n");
+ ast_cli(a->fd, "---- ---- ---------- --------- ------------\n");
for (s = s_head.next; s != &s_head; s = s->next) {
int hours, minutes, seconds;
@@ -1406,7 +1410,7 @@ static int rpt_do_lstats(int fd, int argc, char *argv[])
connecttime %= 1000;
snprintf(conntime, sizeof(conntime), "%02d:%02d:%02d.%d",
hours, minutes, seconds, (int) connecttime);
- ast_cli(fd, "%-10s%-20s%-12d%-11s%-30s\n",
+ ast_cli(a->fd, "%-10s%-20s%-12d%-11s%-30s\n",
s->name, s->peer, s->reconnects, (s->outbound)? "OUT":"IN", conntime);
}
/* destroy our local link queue */
@@ -1417,42 +1421,65 @@ static int rpt_do_lstats(int fd, int argc, char *argv[])
remque((struct qelem *)t);
ast_free(t);
}
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
}
- return RESULT_FAILURE;
+
+ return CLI_FAILURE;
}
/*
* reload vars
*/
-static int rpt_do_reload(int fd, int argc, char *argv[])
+static char *handle_cli_rpt_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
int n;
- if (argc > 2)
- return RESULT_SHOWUSAGE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "rpt reload";
+ e->usage =
+ "Usage: rpt reload\n"
+ " Reloads app_rpt running config parameters\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc > 2)
+ return CLI_SHOWUSAGE;
for (n = 0; n < nrpts; n++)
rpt_vars[n].reload = 1;
- return RESULT_FAILURE;
+ return CLI_SUCCESS;
}
/*
* restart app_rpt
*/
-static int rpt_do_restart(int fd, int argc, char *argv[])
+static char *handle_cli_rpt_restart(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
int i;
- if (argc > 2)
- return RESULT_SHOWUSAGE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "rpt restart";
+ e->usage =
+ "Usage: rpt restart\n"
+ " Restarts app_rpt\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc > 2)
+ return CLI_SHOWUSAGE;
for (i = 0; i < nrpts; i++) {
if (rpt_vars[i].rxchannel)
ast_softhangup(rpt_vars[i].rxchannel, AST_SOFTHANGUP_DEV);
}
- return RESULT_FAILURE;
+ return CLI_SUCCESS;
}
static int play_tone_pair(struct ast_channel *chan, int f1, int f2, int duration, int amplitude)
@@ -4627,7 +4654,7 @@ static int function_remote(struct rpt *myrpt, char *param, char *digitbuf, int c
char multimode = 0;
char oc;
char tmp[20], freq[20] = "", savestr[20] = "";
- int mhz, decimals;
+ int mhz = 0, decimals = 0;
struct ast_channel *mychannel;
AST_DECLARE_APP_ARGS(args1,
AST_APP_ARG(freq);
@@ -6800,7 +6827,7 @@ static int rpt_exec(struct ast_channel *chan, void *data)
{
int res = -1, i, rem_totx, n, phone_mode = 0;
char *tmp, keyed = 0;
- char *options, *tele, c;
+ char *options = NULL, *tele, c;
struct rpt *myrpt;
struct ast_frame *f;
struct ast_channel *who;