aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-09-18 19:54:18 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-09-18 19:54:18 +0000
commit5aacb6a82d4cf625774fa1ea39ca193a3be73b35 (patch)
treecf63baa167f81c95d3dbf417f83681851decad80
parent4de5810a0530bca0665eadcfb06ef06fd2e86758 (diff)
merge qwell's CLI verbification work
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@43212 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--apps/app_meetme.c59
-rw-r--r--apps/app_mixmonitor.c17
-rw-r--r--apps/app_osplookup.c15
-rw-r--r--apps/app_playback.c8
-rw-r--r--apps/app_queue.c103
-rw-r--r--apps/app_realtime.c34
-rw-r--r--apps/app_rpt.c61
-rw-r--r--apps/app_voicemail.c46
-rw-r--r--channels/chan_agent.c42
-rw-r--r--channels/chan_alsa.c270
-rw-r--r--channels/chan_features.c19
-rw-r--r--channels/chan_h323.c76
-rw-r--r--channels/chan_iax2.c276
-rw-r--r--channels/chan_local.c19
-rw-r--r--channels/chan_mgcp.c138
-rw-r--r--channels/chan_misdn.c4
-rw-r--r--channels/chan_oss.c429
-rw-r--r--channels/chan_sip.c237
-rw-r--r--channels/chan_skinny.c80
-rw-r--r--channels/chan_zap.c87
-rw-r--r--channels/iax2-provision.c18
-rw-r--r--include/asterisk/cli.h7
-rw-r--r--main/asterisk.c165
-rw-r--r--main/astmm.c31
-rw-r--r--main/cdr.c12
-rw-r--r--main/channel.c31
-rw-r--r--main/cli.c517
-rw-r--r--main/config.c16
-rw-r--r--main/db.c39
-rw-r--r--main/dnsmgr.c18
-rw-r--r--main/file.c20
-rw-r--r--main/frame.c159
-rw-r--r--main/http.c20
-rw-r--r--main/image.c35
-rw-r--r--main/logger.c28
-rw-r--r--main/manager.c65
-rw-r--r--main/pbx.c403
-rw-r--r--main/rtp.c231
-rw-r--r--main/translate.c86
-rw-r--r--main/udptl.c41
-rw-r--r--pbx/pbx_ael.c35
-rw-r--r--pbx/pbx_config.c1031
-rw-r--r--pbx/pbx_dundi.c137
-rw-r--r--res/res_agi.c70
-rw-r--r--res/res_clioriginate.c12
-rw-r--r--res/res_config_pgsql.c14
-rw-r--r--res/res_convert.c21
-rw-r--r--res/res_crypto.c29
-rw-r--r--res/res_features.c27
-rw-r--r--res/res_indications.c40
-rw-r--r--res/res_jabber.c30
-rw-r--r--res/res_musiconhold.c32
-rw-r--r--res/res_odbc.c51
53 files changed, 4269 insertions, 1222 deletions
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index 4fc0206ed..4f3ee3051 100644
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -661,13 +661,6 @@ static struct ast_conference *build_conf(char *confno, char *pin, char *pinadmin
return cnf;
}
-static int confs_show(int fd, int argc, char **argv)
-{
- ast_cli(fd, "Deprecated! Please use 'meetme' instead.\n");
-
- return RESULT_SUCCESS;
-}
-
/*! \brief CLI command for showing SLAs */
static int sla_show(int fd, int argc, char *argv[])
{
@@ -693,23 +686,7 @@ static int sla_show(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static char show_confs_usage[] =
-"Deprecated! Please use 'meetme' instead.\n";
-
-static struct ast_cli_entry cli_show_confs = {
- { "show", "conferences", NULL }, confs_show,
- "Show status of conferences", show_confs_usage, NULL };
-
-
-static char sla_show_usage[] =
-"Usage: sla show\n"
-" Lists status of all shared line appearances\n";
-
-static struct ast_cli_entry cli_sla_show = {
- { "sla", "show", NULL }, sla_show,
- "Show status of Shared Line Appearances", sla_show_usage, NULL };
-
-static int conf_cmd(int fd, int argc, char **argv)
+static int meetme_cmd(int fd, int argc, char **argv)
{
/* Process the command */
struct ast_conference *cnf;
@@ -853,7 +830,7 @@ static int conf_cmd(int fd, int argc, char **argv)
return 0;
}
-static char *complete_confcmd(const char *line, const char *word, int pos, int state)
+static char *complete_meetmecmd(const char *line, const char *word, int pos, int state)
{
static char *cmds[] = {"lock", "unlock", "mute", "unmute", "kick", "list", NULL};
@@ -915,13 +892,23 @@ static char *complete_confcmd(const char *line, const char *word, int pos, int s
return NULL;
}
-static char conf_usage[] =
-"Usage: meetme (un)lock|(un)mute|kick|list [concise] <confno> <usernumber>\n"
+static char meetme_usage[] =
+"Usage: meetme (un)lock|(un)mute|kick|list [concise] <confno> <usernumber>\n"
" Executes a command for the conference or on a conferee\n";
-static struct ast_cli_entry cli_conf = {
- {"meetme", NULL, NULL }, conf_cmd,
- "Execute a command on a conference or conferee", conf_usage, complete_confcmd};
+static char sla_show_usage[] =
+"Usage: sla show\n"
+" Lists status of all shared line appearances\n";
+
+static struct ast_cli_entry cli_meetme[] = {
+ { { "sla", "show", NULL },
+ sla_show, "Show status of Shared Line Appearances",
+ sla_show_usage, NULL },
+
+ { { "meetme", NULL, NULL },
+ meetme_cmd, "Execute a command on a conference or conferee",
+ meetme_usage, complete_meetmecmd },
+};
static void conf_flush(int fd, struct ast_channel *chan)
{
@@ -3072,10 +3059,8 @@ static int unload_module(void)
{
int res = 0;
- res |= ast_cli_unregister(&cli_show_confs);
- res |= ast_cli_unregister(&cli_sla_show);
- res |= ast_cli_unregister(&cli_conf);
- res |= ast_manager_unregister("MeetmeMute");
+ ast_cli_unregister_multiple(cli_meetme, sizeof(cli_meetme) / sizeof(struct ast_cli_entry));
+ res = ast_manager_unregister("MeetmeMute");
res |= ast_manager_unregister("MeetmeUnmute");
res |= ast_unregister_application(app3);
res |= ast_unregister_application(app2);
@@ -3095,10 +3080,8 @@ static int load_module(void)
int res;
ASTOBJ_CONTAINER_INIT(&slas);
- res = ast_cli_register(&cli_show_confs);
- res |= ast_cli_register(&cli_sla_show);
- res |= ast_cli_register(&cli_conf);
- res |= ast_manager_register("MeetmeMute", EVENT_FLAG_CALL, action_meetmemute, "Mute a Meetme user");
+ ast_cli_register_multiple(cli_meetme, sizeof(cli_meetme) / sizeof(struct ast_cli_entry));
+ res = ast_manager_register("MeetmeMute", EVENT_FLAG_CALL, action_meetmemute, "Mute a Meetme user");
res |= ast_manager_register("MeetmeUnmute", EVENT_FLAG_CALL, action_meetmeunmute, "Unmute a Meetme user");
res |= ast_register_application(app3, admin_exec, synopsis3, descrip3);
res |= ast_register_application(app2, count_exec, synopsis2, descrip2);
diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c
index 5038776a3..1530920b1 100644
--- a/apps/app_mixmonitor.c
+++ b/apps/app_mixmonitor.c
@@ -421,22 +421,21 @@ static char *complete_mixmonitor_cli(const char *line, const char *word, int pos
return ast_complete_channels(line, word, pos, state, 2);
}
-static struct ast_cli_entry cli_mixmonitor = {
- { "mixmonitor", NULL, NULL },
- mixmonitor_cli,
- "Execute a MixMonitor command.",
+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
+ complete_mixmonitor_cli },
};
static int unload_module(void)
{
int res;
- res = ast_cli_unregister(&cli_mixmonitor);
- res |= ast_unregister_application(stop_app);
+ ast_cli_unregister_multiple(cli_mixmonitor, sizeof(cli_mixmonitor) / sizeof(struct ast_cli_entry));
+ res = ast_unregister_application(stop_app);
res |= ast_unregister_application(app);
ast_module_user_hangup_all();
@@ -448,8 +447,8 @@ static int load_module(void)
{
int res;
- res = ast_cli_register(&cli_mixmonitor);
- res |= ast_register_application(app, mixmonitor_exec, synopsis, desc);
+ ast_cli_register_multiple(cli_mixmonitor, sizeof(cli_mixmonitor) / sizeof(struct ast_cli_entry));
+ res = ast_register_application(app, mixmonitor_exec, synopsis, desc);
res |= ast_register_application(stop_app, stop_mixmonitor_exec, stop_synopsis, stop_desc);
return res;
diff --git a/apps/app_osplookup.c b/apps/app_osplookup.c
index e5fcf9a51..f4f7d8cc6 100644
--- a/apps/app_osplookup.c
+++ b/apps/app_osplookup.c
@@ -1596,11 +1596,10 @@ static const char osp_usage[] =
"Usage: osp show\n"
" Displays information on Open Settlement Protocol support\n";
-static struct ast_cli_entry osp_cli = {
- {"osp", "show", NULL},
- osp_show,
- "Displays OSP information",
- osp_usage
+static struct ast_cli_entry cli_osp[] = {
+ { { "osp", "show", NULL},
+ osp_show, "Displays OSP information",
+ osp_usage },
};
static int load_module(void)
@@ -1610,8 +1609,8 @@ static int load_module(void)
if(!osp_load())
return AST_MODULE_LOAD_DECLINE;
- res = ast_cli_register(&osp_cli);
- res |= ast_register_application(app1, ospauth_exec, synopsis1, descrip1);
+ ast_cli_register_multiple(cli_osp, sizeof(cli_osp) / sizeof(struct ast_cli_entry));
+ res = ast_register_application(app1, ospauth_exec, synopsis1, descrip1);
res |= ast_register_application(app2, osplookup_exec, synopsis2, descrip2);
res |= ast_register_application(app3, ospnext_exec, synopsis3, descrip3);
res |= ast_register_application(app4, ospfinished_exec, synopsis4, descrip4);
@@ -1627,7 +1626,7 @@ static int unload_module(void)
res |= ast_unregister_application(app3);
res |= ast_unregister_application(app2);
res |= ast_unregister_application(app1);
- res |= ast_cli_unregister(&osp_cli);
+ ast_cli_unregister_multiple(cli_osp, sizeof(cli_osp) / sizeof(struct ast_cli_entry));
osp_unload();
ast_module_user_hangup_all();
diff --git a/apps/app_playback.c b/apps/app_playback.c
index f3788c351..87b06b02e 100644
--- a/apps/app_playback.c
+++ b/apps/app_playback.c
@@ -371,8 +371,10 @@ static int __say_init(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static struct ast_cli_entry myclis[] = {
- { { "say", "load", NULL }, __say_init, "set/show the say mode", "say load new|old" },
+static struct ast_cli_entry cli_playback[] = {
+ { { "say", "load", NULL },
+ __say_init, "set/show the say mode",
+ "say load new|old" },
};
static int playback_exec(struct ast_channel *chan, void *data)
@@ -478,7 +480,7 @@ static int unload_module(void)
static int load_module(void)
{
reload();
- ast_cli_register_multiple(myclis, sizeof(myclis)/sizeof(struct ast_cli_entry));
+ ast_cli_register_multiple(cli_playback, sizeof(cli_playback) / sizeof(struct ast_cli_entry));
return ast_register_application(app, playback_exec, synopsis, descrip);
}
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 579f80951..4726257f4 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -3941,7 +3941,7 @@ static int __queues_show(struct mansession *s, int manager, int fd, int argc, ch
return RESULT_SUCCESS;
}
-static int queues_show(int fd, int argc, char **argv)
+static int queue_list(int fd, int argc, char **argv)
{
return __queues_show(NULL, 0, fd, argc, argv, 0);
}
@@ -3975,7 +3975,7 @@ static char *complete_queue(const char *line, const char *word, int pos, int sta
*/
static int manager_queues_show( struct mansession *s, struct message *m )
{
- char *a[] = { "show", "queues" };
+ char *a[] = { "queue", "list" };
__queues_show(s, 1, -1, 2, a, 0);
astman_append(s, "\r\n\r\n"); /* Properly terminate Manager output */
@@ -4175,7 +4175,7 @@ static int manager_pause_queue_member(struct mansession *s, struct message *m)
return 0;
}
-static int handle_add_queue_member(int fd, int argc, char *argv[])
+static int handle_queue_add_member(int fd, int argc, char *argv[])
{
char *queuename, *interface;
int penalty;
@@ -4222,9 +4222,9 @@ static int handle_add_queue_member(int fd, int argc, char *argv[])
}
}
-static char *complete_add_queue_member(const char *line, const char *word, int pos, int state)
+static char *complete_queue_add_member(const char *line, const char *word, int pos, int state)
{
- /* 0 - add; 1 - queue; 2 - member; 3 - <member>; 4 - to; 5 - <queue>; 6 - penalty; 7 - <penalty> */
+ /* 0 - queue; 1 - add; 2 - member; 3 - <member>; 4 - to; 5 - <queue>; 6 - penalty; 7 - <penalty> */
switch (pos) {
case 3: /* Don't attempt to complete name of member (infinite possibilities) */
return NULL;
@@ -4249,7 +4249,7 @@ static char *complete_add_queue_member(const char *line, const char *word, int p
}
}
-static int handle_remove_queue_member(int fd, int argc, char *argv[])
+static int handle_queue_remove_member(int fd, int argc, char *argv[])
{
char *queuename, *interface;
@@ -4280,13 +4280,13 @@ static int handle_remove_queue_member(int fd, int argc, char *argv[])
}
}
-static char *complete_remove_queue_member(const char *line, const char *word, int pos, int state)
+static char *complete_queue_remove_member(const char *line, const char *word, int pos, int state)
{
int which = 0;
struct call_queue *q;
struct member *m;
- /* 0 - add; 1 - queue; 2 - member; 3 - <member>; 4 - from; 5 - <queue> */
+ /* 0 - queue; 1 - remove; 2 - member; 3 - <member>; 4 - from; 5 - <queue> */
if (pos > 5 || pos < 3)
return NULL;
if (pos == 4) /* only one possible match, 'from' */
@@ -4312,44 +4312,64 @@ static char *complete_remove_queue_member(const char *line, const char *word, in
return NULL;
}
-static char show_queues_usage[] =
-"Usage: show queues\n"
+static char queue_list_usage[] =
+"Usage: queue list\n"
" Provides summary information on call queues.\n";
-static struct ast_cli_entry cli_show_queues = {
- { "show", "queues", NULL }, queues_show,
- "Show status of queues", show_queues_usage, NULL };
-
-static char show_queue_usage[] =
-"Usage: show queue\n"
+static char queue_show_usage[] =
+"Usage: queue show\n"
" Provides summary information on a specified queue.\n";
-static struct ast_cli_entry cli_show_queue = {
- { "show", "queue", NULL }, queue_show,
- "Show status of a specified queue", show_queue_usage, complete_queue };
+static char qam_cmd_usage[] =
+"Usage: queue add member <channel> to <queue> [penalty <penalty>]\n";
+
+static char qrm_cmd_usage[] =
+"Usage: queue remove member <channel> from <queue>\n";
+
+static struct ast_cli_entry cli_show_queues_deprecated = {
+ { "show", "queues", NULL },
+ queue_list, NULL,
+ NULL, NULL };
+
+static struct ast_cli_entry cli_show_queue_deprecated = {
+ { "show", "queue", NULL },
+ queue_show, NULL,
+ NULL, complete_queue };
+
+static struct ast_cli_entry cli_add_queue_member_deprecated = {
+ { "add", "queue", "member", NULL },
+ handle_queue_add_member, NULL,
+ NULL, complete_queue_add_member };
-static char aqm_cmd_usage[] =
-"Usage: add queue member <channel> to <queue> [penalty <penalty>]\n";
+static struct ast_cli_entry cli_remove_queue_member_deprecated = {
+ { "remove", "queue", "member", NULL },
+ handle_queue_remove_member, NULL,
+ NULL, complete_queue_remove_member };
-static struct ast_cli_entry cli_add_queue_member = {
- { "add", "queue", "member", NULL }, handle_add_queue_member,
- "Add a channel to a specified queue", aqm_cmd_usage, complete_add_queue_member };
+static struct ast_cli_entry cli_queue[] = {
+ { { "queue", "list", NULL },
+ queue_list, "Show status of queues",
+ queue_list_usage, NULL, &cli_show_queues_deprecated },
-static char rqm_cmd_usage[] =
-"Usage: remove queue member <channel> from <queue>\n";
+ { { "queue", "show", NULL },
+ queue_show, "Show status of a specified queue",
+ queue_show_usage, complete_queue, &cli_show_queue_deprecated },
-static struct ast_cli_entry cli_remove_queue_member = {
- { "remove", "queue", "member", NULL }, handle_remove_queue_member,
- "Removes a channel from a specified queue", rqm_cmd_usage, complete_remove_queue_member };
+ { { "queue", "add", "member", NULL },
+ handle_queue_add_member, "Add a channel to a specified queue",
+ qam_cmd_usage, complete_queue_add_member, &cli_add_queue_member_deprecated },
+
+ { { "queue", "remove", "member", NULL },
+ handle_queue_remove_member, "Removes a channel from a specified queue",
+ qrm_cmd_usage, complete_queue_remove_member, &cli_remove_queue_member_deprecated },
+};
static int unload_module(void)
{
int res;
- res = ast_cli_unregister(&cli_show_queue);
- res |= ast_cli_unregister(&cli_show_queues);
- res |= ast_cli_unregister(&cli_add_queue_member);
- res |= ast_cli_unregister(&cli_remove_queue_member);
+ ast_cli_unregister_multiple(cli_queue, sizeof(cli_queue) / sizeof(struct ast_cli_entry));
+ res = ast_manager_unregister("QueueStatus");
res |= ast_manager_unregister("Queues");
res |= ast_manager_unregister("QueueStatus");
res |= ast_manager_unregister("QueueAdd");
@@ -4360,11 +4380,11 @@ static int unload_module(void)
res |= ast_unregister_application(app_pqm);
res |= ast_unregister_application(app_upqm);
res |= ast_unregister_application(app_ql);
+ res |= ast_unregister_application(app);
res |= ast_custom_function_unregister(&queueagentcount_function);
res |= ast_custom_function_unregister(&queuemembercount_function);
res |= ast_custom_function_unregister(&queuememberlist_function);
res |= ast_custom_function_unregister(&queuewaitingcount_function);
- res |= ast_unregister_application(app);
ast_module_user_hangup_all();
@@ -4380,21 +4400,18 @@ static int load_module(void)
return AST_MODULE_LOAD_DECLINE;
if (queue_persistent_members)
reload_queue_members();
+ ast_cli_register_multiple(cli_queue, sizeof(cli_queue) / sizeof(struct ast_cli_entry));
res = ast_register_application(app, queue_exec, synopsis, descrip);
- res |= ast_cli_register(&cli_show_queue);
- res |= ast_cli_register(&cli_show_queues);
- res |= ast_cli_register(&cli_add_queue_member);
- res |= ast_cli_register(&cli_remove_queue_member);
- res |= ast_manager_register("Queues", 0, manager_queues_show, "Queues");
- res |= ast_manager_register("QueueStatus", 0, manager_queues_status, "Queue Status");
- res |= ast_manager_register("QueueAdd", EVENT_FLAG_AGENT, manager_add_queue_member, "Add interface to queue.");
- res |= ast_manager_register("QueueRemove", EVENT_FLAG_AGENT, manager_remove_queue_member, "Remove interface from queue.");
- res |= ast_manager_register("QueuePause", EVENT_FLAG_AGENT, manager_pause_queue_member, "Makes a queue member temporarily unavailable");
res |= ast_register_application(app_aqm, aqm_exec, app_aqm_synopsis, app_aqm_descrip);
res |= ast_register_application(app_rqm, rqm_exec, app_rqm_synopsis, app_rqm_descrip);
res |= ast_register_application(app_pqm, pqm_exec, app_pqm_synopsis, app_pqm_descrip);
res |= ast_register_application(app_upqm, upqm_exec, app_upqm_synopsis, app_upqm_descrip);
res |= ast_register_application(app_ql, ql_exec, app_ql_synopsis, app_ql_descrip);
+ res |= ast_manager_register("Queues", 0, manager_queues_show, "Queues");
+ res |= ast_manager_register("QueueStatus", 0, manager_queues_status, "Queue Status");
+ res |= ast_manager_register("QueueAdd", EVENT_FLAG_AGENT, manager_add_queue_member, "Add interface to queue.");
+ res |= ast_manager_register("QueueRemove", EVENT_FLAG_AGENT, manager_remove_queue_member, "Remove interface from queue.");
+ res |= ast_manager_register("QueuePause", EVENT_FLAG_AGENT, manager_pause_queue_member, "Makes a queue member temporarily unavailable");
res |= ast_custom_function_register(&queueagentcount_function);
res |= ast_custom_function_register(&queuemembercount_function);
res |= ast_custom_function_register(&queuememberlist_function);
diff --git a/apps/app_realtime.c b/apps/app_realtime.c
index cc7ad7dd4..48e1dca5b 100644
--- a/apps/app_realtime.c
+++ b/apps/app_realtime.c
@@ -69,7 +69,7 @@ static char *udesc = "Use the RealTime config handler system to update a value\n
"updated or -1 if an error occurs.\n";
-static int cli_load_realtime(int fd, int argc, char **argv)
+static int cli_realtime_load(int fd, int argc, char **argv)
{
char *header_format = "%30s %-30s\n";
struct ast_variable *var=NULL;
@@ -94,7 +94,7 @@ static int cli_load_realtime(int fd, int argc, char **argv)
return RESULT_SUCCESS;
}
-static int cli_update_realtime(int fd, int argc, char **argv) {
+static int cli_realtime_update(int fd, int argc, char **argv) {
int res = 0;
if(argc<7) {
@@ -115,21 +115,23 @@ static int cli_update_realtime(int fd, int argc, char **argv) {
return RESULT_SUCCESS;
}
-static char cli_load_realtime_usage[] =
+static char cli_realtime_load_usage[] =
"Usage: realtime load <family> <colmatch> <value>\n"
" Prints out a list of variables using the RealTime driver.\n";
-static struct ast_cli_entry cli_load_realtime_cmd = {
- { "realtime", "load", NULL, NULL }, cli_load_realtime,
- "Used to print out RealTime variables.", cli_load_realtime_usage, NULL };
-
-static char cli_update_realtime_usage[] =
+static char cli_realtime_update_usage[] =
"Usage: realtime update <family> <colmatch> <value>\n"
" Update a single variable using the RealTime driver.\n";
-static struct ast_cli_entry cli_update_realtime_cmd = {
- { "realtime", "update", NULL, NULL }, cli_update_realtime,
- "Used to update RealTime variables.", cli_update_realtime_usage, NULL };
+static struct ast_cli_entry cli_realtime[] = {
+ { { "realtime", "load", NULL, NULL },
+ cli_realtime_load, "Used to print out RealTime variables.",
+ cli_realtime_load_usage, NULL },
+
+ { { "realtime", "update", NULL, NULL },
+ cli_realtime_update, "Used to update RealTime variables.",
+ cli_realtime_update_usage, NULL },
+};
static int realtime_update_exec(struct ast_channel *chan, void *data)
{
@@ -236,9 +238,8 @@ static int unload_module(void)
{
int res;
- res = ast_cli_unregister(&cli_load_realtime_cmd);
- res |= ast_cli_unregister(&cli_update_realtime_cmd);
- res |= ast_unregister_application(uapp);
+ ast_cli_unregister_multiple(cli_realtime, sizeof(cli_realtime) / sizeof(struct ast_cli_entry));
+ res = ast_unregister_application(uapp);
res |= ast_unregister_application(app);
ast_module_user_hangup_all();
@@ -250,9 +251,8 @@ static int load_module(void)
{
int res;
- res = ast_cli_register(&cli_load_realtime_cmd);
- res |= ast_cli_register(&cli_update_realtime_cmd);
- res |= ast_register_application(uapp, realtime_update_exec, usynopsis, udesc);
+ ast_cli_register_multiple(cli_realtime, sizeof(cli_realtime) / sizeof(struct ast_cli_entry));
+ res = ast_register_application(uapp, realtime_update_exec, usynopsis, udesc);
res |= ast_register_application(app, realtime_exec, synopsis, desc);
return res;
diff --git a/apps/app_rpt.c b/apps/app_rpt.c
index 858525a58..d9895320e 100644
--- a/apps/app_rpt.c
+++ b/apps/app_rpt.c
@@ -726,29 +726,30 @@ static char restart_usage[] =
"Usage: rpt restart\n"
" Restarts app_rpt\n";
-static struct ast_cli_entry cli_debug =
- { { "rpt", "debug", "level" }, rpt_do_debug,
- "Enable app_rpt debugging", debug_usage };
-
-static struct ast_cli_entry cli_dump =
- { { "rpt", "dump" }, rpt_do_dump,
- "Dump app_rpt structs for debugging", dump_usage };
-
-static struct ast_cli_entry cli_stats =
- { { "rpt", "stats" }, rpt_do_stats,
- "Dump node statistics", dump_stats };
-
-static struct ast_cli_entry cli_lstats =
- { { "rpt", "lstats" }, rpt_do_lstats,
- "Dump link statistics", dump_lstats };
-
-static struct ast_cli_entry cli_reload =
- { { "rpt", "reload" }, rpt_do_reload,
- "Reload app_rpt config", reload_usage };
-
-static struct ast_cli_entry cli_restart =
- { { "rpt", "restart" }, rpt_do_restart,
- "Restart app_rpt", restart_usage };
+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 },
+};
/*
* Telemetry defaults
@@ -8018,12 +8019,7 @@ static int unload_module(void)
i = ast_unregister_application(app);
/* Unregister cli extensions */
- ast_cli_unregister(&cli_debug);
- ast_cli_unregister(&cli_dump);
- ast_cli_unregister(&cli_stats);
- ast_cli_unregister(&cli_lstats);
- ast_cli_unregister(&cli_reload);
- ast_cli_unregister(&cli_restart);
+ ast_cli_unregister_multiple(cli_rpt, sizeof(cli_rpt) / sizeof(struct ast_cli_entry));
return i;
}
@@ -8038,12 +8034,7 @@ static int load_module(void)
ast_pthread_create(&rpt_master_thread,NULL,rpt_master,cfg);
/* Register cli extensions */
- ast_cli_register(&cli_debug);
- ast_cli_register(&cli_dump);
- ast_cli_register(&cli_stats);
- ast_cli_register(&cli_lstats);
- ast_cli_register(&cli_reload);
- ast_cli_register(&cli_restart);
+ ast_cli_register_multiple(cli_rpt, sizeof(cli_rpt) / sizeof(struct ast_cli_entry));
return ast_register_application(app, rpt_exec, synopsis, descrip);
}
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 70ebc9f1d..f0c9d985f 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -6710,15 +6710,15 @@ static int vmauthenticate(struct ast_channel *chan, void *data)
return res;
}
-static char show_voicemail_users_help[] =
-"Usage: show voicemail users [for <context>]\n"
+static char voicemail_show_users_help[] =
+"Usage: voicemail list users [for <context>]\n"
" Lists all mailboxes currently set up\n";
-static char show_voicemail_zones_help[] =
-"Usage: show voicemail zones\n"
+static char voicemail_show_zones_help[] =
+"Usage: voicemail list zones\n"
" Lists zone message formats\n";
-static int handle_show_voicemail_users(int fd, int argc, char *argv[])
+static int handle_voicemail_show_users(int fd, int argc, char *argv[])
{
struct ast_vm_user *vmu;
char *output_format = "%-10s %-5s %-25s %-10s %6s\n";
@@ -6773,7 +6773,7 @@ static int handle_show_voicemail_users(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static int handle_show_voicemail_zones(int fd, int argc, char *argv[])
+static int handle_voicemail_show_zones(int fd, int argc, char *argv[])
{
struct vm_zone *zone;
char *output_format = "%-15s %-20s %-45s\n";
@@ -6797,7 +6797,7 @@ static int handle_show_voicemail_zones(int fd, int argc, char *argv[])
return res;
}
-static char *complete_show_voicemail_users(const char *line, const char *word, int pos, int state)
+static char *complete_voicemail_show_users(const char *line, const char *word, int pos, int state)
{
int which = 0;
int wordlen;
@@ -6821,15 +6821,25 @@ static char *complete_show_voicemail_users(const char *line, const char *word, i
return NULL;
}
-static struct ast_cli_entry show_voicemail_users_cli =
- { { "show", "voicemail", "users", NULL },
- handle_show_voicemail_users, "List defined voicemail boxes",
- show_voicemail_users_help, complete_show_voicemail_users };
+static struct ast_cli_entry cli_show_voicemail_users_deprecated = {
+ { "show", "voicemail", "users", NULL },
+ handle_voicemail_show_users, NULL,
+ NULL, complete_voicemail_show_users };
-static struct ast_cli_entry show_voicemail_zones_cli =
- { { "show", "voicemail", "zones", NULL },
- handle_show_voicemail_zones, "List zone message formats",
- show_voicemail_zones_help, NULL };
+static struct ast_cli_entry cli_show_voicemail_zones_deprecated = {
+ { "show", "voicemail", "zones", NULL },
+ handle_voicemail_show_zones, NULL,
+ NULL, NULL };
+
+static struct ast_cli_entry cli_voicemail[] = {
+ { { "voicemail", "list", "users", NULL },
+ handle_voicemail_show_users, "List defined voicemail boxes",
+ voicemail_show_users_help, complete_voicemail_show_users, &cli_show_voicemail_users_deprecated },
+
+ { { "voicemail", "list", "zones", NULL },
+ handle_voicemail_show_zones, "List zone message formats",
+ voicemail_show_zones_help, NULL, &cli_show_voicemail_zones_deprecated },
+};
static int load_config(void)
{
@@ -7359,8 +7369,7 @@ static int unload_module(void)
res |= ast_unregister_application(app2);
res |= ast_unregister_application(app3);
res |= ast_unregister_application(app4);
- res |= ast_cli_unregister(&show_voicemail_users_cli);
- res |= ast_cli_unregister(&show_voicemail_zones_cli);
+ ast_cli_unregister_multiple(cli_voicemail, sizeof(cli_voicemail) / sizeof(struct ast_cli_entry));
ast_uninstall_vm_functions();
ast_module_user_hangup_all();
@@ -7382,8 +7391,7 @@ static int load_module(void)
return(res);
}
- ast_cli_register(&show_voicemail_users_cli);
- ast_cli_register(&show_voicemail_zones_cli);
+ ast_cli_register_multiple(cli_voicemail, sizeof(cli_voicemail) / sizeof(struct ast_cli_entry));
/* compute the location of the voicemail spool directory */
snprintf(VM_SPOOL_DIR, sizeof(VM_SPOOL_DIR), "%s/voicemail/", ast_config_AST_SPOOL_DIR);
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index 18f1f6250..d5c327965 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -1682,11 +1682,11 @@ static int agents_show_online(int fd, int argc, char **argv)
static char show_agents_usage[] =
-"Usage: show agents\n"
+"Usage: agent list\n"
" Provides summary information on agents.\n";
static char show_agents_online_usage[] =
-"Usage: show agents\n"
+"Usage: agent list online\n"
" Provides a list of all online agents.\n";
static char agent_logoff_usage[] =
@@ -1694,17 +1694,29 @@ static char agent_logoff_usage[] =
" Sets an agent as no longer logged in.\n"
" If 'soft' is specified, do not hangup existing calls.\n";
-static struct ast_cli_entry cli_show_agents = {
- { "show", "agents", NULL }, agents_show,
- "Show status of agents", show_agents_usage, NULL };
+static struct ast_cli_entry cli_show_agents_deprecated = {
+ { "show", "agents", NULL },
+ agents_show, NULL,
+ NULL, NULL };
-static struct ast_cli_entry cli_show_agents_online = {
- { "show", "agents", "online" }, agents_show_online,
- "Show all online agents", show_agents_online_usage, NULL };
+static struct ast_cli_entry cli_show_agents_online_deprecated = {
+ { "show", "agents", "online" },
+ agents_show_online, NULL,
+ NULL, NULL };
-static struct ast_cli_entry cli_agent_logoff = {
- { "agent", "logoff", NULL }, agent_logoff_cmd,
- "Sets an agent offline", agent_logoff_usage, complete_agent_logoff_cmd };
+static struct ast_cli_entry cli_agents[] = {
+ { { "agent", "list", NULL },
+ agents_show, "Show status of agents",
+ show_agents_usage, NULL, &cli_show_agents_deprecated },
+
+ { { "agent", "list", "online" },
+ agents_show_online, "Show all online agents",
+ show_agents_online_usage, NULL, &cli_show_agents_online_deprecated },
+
+ { { "agent", "logoff", NULL },
+ agent_logoff_cmd, "Sets an agent offline",
+ agent_logoff_usage, complete_agent_logoff_cmd },
+};
/*!
* \brief Log in agent application.
@@ -2560,9 +2572,7 @@ static int load_module(void)
ast_manager_register2("AgentCallbackLogin", EVENT_FLAG_AGENT, action_agent_callback_login, "Sets an agent as logged in by callback", mandescr_agent_callback_login);
/* CLI Commands */
- ast_cli_register(&cli_show_agents);
- ast_cli_register(&cli_show_agents_online);
- ast_cli_register(&cli_agent_logoff);
+ ast_cli_register_multiple(cli_agents, sizeof(cli_agents) / sizeof(struct ast_cli_entry));
/* Dialplan Functions */
ast_custom_function_register(&agent_function);
@@ -2586,9 +2596,7 @@ static int unload_module(void)
/* Unregister dialplan functions */
ast_custom_function_unregister(&agent_function);
/* Unregister CLI commands */
- ast_cli_unregister(&cli_show_agents);
- ast_cli_unregister(&cli_show_agents_online);
- ast_cli_unregister(&cli_agent_logoff);
+ ast_cli_unregister_multiple(cli_agents, sizeof(cli_agents) / sizeof(struct ast_cli_entry));
/* Unregister dialplan applications */
ast_unregister_application(app);
ast_unregister_application(app2);
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c
index 7dfd55df7..c3a4315e7 100644
--- a/channels/chan_alsa.c
+++ b/channels/chan_alsa.c
@@ -841,7 +841,7 @@ static struct ast_channel *alsa_request(const char *type, int format, void *data
return tmp;
}
-static int console_autoanswer(int fd, int argc, char *argv[])
+static int console_autoanswer_deprecated(int fd, int argc, char *argv[])
{
int res = RESULT_SUCCESS;
@@ -866,6 +866,26 @@ static int console_autoanswer(int fd, int argc, char *argv[])
return res;
}
+static int console_autoanswer(int fd, int argc, char *argv[])
+{
+ int res = RESULT_SUCCESS;;
+ if ((argc != 2) && (argc != 3))
+ return RESULT_SHOWUSAGE;
+ ast_mutex_lock(&alsalock);
+ if (argc == 2) {
+ ast_cli(fd, "Auto answer is %s.\n", autoanswer ? "on" : "off");
+ } else {
+ if (!strcasecmp(argv[2], "on"))
+ autoanswer = -1;
+ else if (!strcasecmp(argv[2], "off"))
+ autoanswer = 0;
+ else
+ res = RESULT_SHOWUSAGE;
+ }
+ ast_mutex_unlock(&alsalock);
+ return res;
+}
+
static char *autoanswer_complete(const char *line, const char *word, int pos, int state)
{
#ifndef MIN
@@ -885,11 +905,12 @@ static char *autoanswer_complete(const char *line, const char *word, int pos, in
}
static const char autoanswer_usage[] =
- "Usage: autoanswer [on|off]\n"
+ "Usage: console autoanswer [on|off]\n"
" Enables or disables autoanswer feature. If used without\n"
- " argument, displays the current on/off status of autoanswer.\n" " The default value of autoanswer is in 'alsa.conf'.\n";
+ " argument, displays the current on/off status of autoanswer.\n"
+ " The default value of autoanswer is in 'alsa.conf'.\n";
-static int console_answer(int fd, int argc, char *argv[])
+static int console_answer_deprecated(int fd, int argc, char *argv[])
{
int res = RESULT_SUCCESS;
@@ -921,9 +942,43 @@ static int console_answer(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static char sendtext_usage[] = "Usage: send text <message>\n" " Sends a text message for display on the remote terminal.\n";
+static int console_answer(int fd, int argc, char *argv[])
+{
+ int res = RESULT_SUCCESS;
-static int console_sendtext(int fd, int argc, char *argv[])
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
+
+ ast_mutex_lock(&alsalock);
+
+ if (!alsa.owner) {
+ ast_cli(fd, "No one is calling us\n");
+ res = RESULT_FAILURE;
+ } else {
+ hookstate = 1;
+ cursound = -1;
+ grab_owner();
+ if (alsa.owner) {
+ struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
+ ast_queue_frame(alsa.owner, &f);
+ ast_mutex_unlock(&alsa.owner->lock);
+ }
+ answer_sound();
+ }
+
+ snd_pcm_prepare(alsa.icard);
+ snd_pcm_start(alsa.icard);
+
+ ast_mutex_unlock(&alsalock);
+
+ return RESULT_SUCCESS;
+}
+
+static char sendtext_usage[] =
+ "Usage: console send text <message>\n"
+ " Sends a text message for display on the remote terminal.\n";
+
+static int console_sendtext_deprecated(int fd, int argc, char *argv[])
{
int tmparg = 2;
int res = RESULT_SUCCESS;
@@ -964,9 +1019,52 @@ static int console_sendtext(int fd, int argc, char *argv[])
return res;
}
-static char answer_usage[] = "Usage: answer\n" " Answers an incoming call on the console (ALSA) channel.\n";
+static int console_sendtext(int fd, int argc, char *argv[])
+{
+ int tmparg = 3;
+ int res = RESULT_SUCCESS;
-static int console_hangup(int fd, int argc, char *argv[])
+ if (argc < 3)
+ return RESULT_SHOWUSAGE;
+
+ ast_mutex_lock(&alsalock);
+
+ if (!alsa.owner) {
+ ast_cli(fd, "No one is calling us\n");
+ res = RESULT_FAILURE;
+ } else {
+ struct ast_frame f = { AST_FRAME_TEXT, 0 };
+ char text2send[256] = "";
+ text2send[0] = '\0';
+ while (tmparg < argc) {
+ strncat(text2send, argv[tmparg++], sizeof(text2send) - strlen(text2send) - 1);
+ strncat(text2send, " ", sizeof(text2send) - strlen(text2send) - 1);
+ }
+ text2send[strlen(text2send) - 1] = '\n';
+ f.data = text2send;
+ f.datalen = strlen(text2send) + 1;
+ grab_owner();
+ if (alsa.owner) {
+ ast_queue_frame(alsa.owner, &f);
+ f.frametype = AST_FRAME_CONTROL;
+ f.subclass = AST_CONTROL_ANSWER;
+ f.data = NULL;
+ f.datalen = 0;
+ ast_queue_frame(alsa.owner, &f);
+ ast_mutex_unlock(&alsa.owner->lock);
+ }
+ }
+
+ ast_mutex_unlock(&alsalock);
+
+ return res;
+}
+
+static char answer_usage[] =
+ "Usage: console answer\n"
+ " Answers an incoming call on the console (ALSA) channel.\n";
+
+static int console_hangup_deprecated(int fd, int argc, char *argv[])
{
int res = RESULT_SUCCESS;
@@ -994,10 +1092,39 @@ static int console_hangup(int fd, int argc, char *argv[])
return res;
}
-static char hangup_usage[] = "Usage: hangup\n" " Hangs up any call currently placed on the console.\n";
+static int console_hangup(int fd, int argc, char *argv[])
+{
+ int res = RESULT_SUCCESS;
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
-static int console_dial(int fd, int argc, char *argv[])
+ cursound = -1;
+
+ ast_mutex_lock(&alsalock);
+
+ if (!alsa.owner && !hookstate) {
+ ast_cli(fd, "No call to hangup up\n");
+ res = RESULT_FAILURE;
+ } else {
+ hookstate = 0;
+ grab_owner();
+ if (alsa.owner) {
+ ast_queue_hangup(alsa.owner);
+ ast_mutex_unlock(&alsa.owner->lock);
+ }
+ }
+
+ ast_mutex_unlock(&alsalock);
+
+ return res;
+}
+
+static char hangup_usage[] =
+ "Usage: console hangup\n"
+ " Hangs up any call currently placed on the console.\n";
+
+static int console_dial_deprecated(int fd, int argc, char *argv[])
{
char tmp[256], *tmp2;
char *mye, *myc;
@@ -1054,20 +1181,117 @@ static int console_dial(int fd, int argc, char *argv[])
return res;
}
-static char dial_usage[] = "Usage: dial [extension[@context]]\n" " Dials a given extension (and context if specified)\n";
+static int console_dial(int fd, int argc, char *argv[])
+{
+ char tmp[256], *tmp2;
+ char *mye, *myc;
+ char *d;
+ int res = RESULT_SUCCESS;
+
+ if ((argc != 2) && (argc != 3))
+ return RESULT_SHOWUSAGE;
+ ast_mutex_lock(&alsalock);
-static struct ast_cli_entry myclis[] = {
- {{"answer", NULL}, console_answer, "Answer an incoming console call", answer_usage},
- {{"hangup", NULL}, console_hangup, "Hangup a call on the console", hangup_usage},
- {{"dial", NULL}, console_dial, "Dial an extension on the console", dial_usage},
- {{"send", "text", NULL}, console_sendtext, "Send text to the remote device", sendtext_usage},
- {{"autoanswer", NULL}, console_autoanswer, "Sets/displays autoanswer", autoanswer_usage, autoanswer_complete}
+ if (alsa.owner) {
+ if (argc == 3) {
+ d = argv[2];
+ grab_owner();
+ if (alsa.owner) {
+ struct ast_frame f = { AST_FRAME_DTMF };
+ while (*d) {
+ f.subclass = *d;
+ ast_queue_frame(alsa.owner, &f);
+ d++;
+ }
+ ast_mutex_unlock(&alsa.owner->lock);
+ }
+ } else {
+ ast_cli(fd, "You're already in a call. You can use this only to dial digits until you hangup\n");
+ res = RESULT_FAILURE;
+ }
+ } else {
+ mye = exten;
+ myc = context;
+ if (argc == 3) {
+ char *stringp = NULL;
+ strncpy(tmp, argv[2], sizeof(tmp) - 1);
+ stringp = tmp;
+ strsep(&stringp, "@");
+ tmp2 = strsep(&stringp, "@");
+ if (!ast_strlen_zero(tmp))
+ mye = tmp;
+ if (!ast_strlen_zero(tmp2))
+ myc = tmp2;
+ }
+ if (ast_exists_extension(NULL, myc, mye, 1, NULL)) {
+ strncpy(alsa.exten, mye, sizeof(alsa.exten) - 1);
+ strncpy(alsa.context, myc, sizeof(alsa.context) - 1);
+ hookstate = 1;
+ alsa_new(&alsa, AST_STATE_RINGING);
+ } else
+ ast_cli(fd, "No such extension '%s' in context '%s'\n", mye, myc);
+ }
+
+ ast_mutex_unlock(&alsalock);
+
+ return res;
+}
+
+static char dial_usage[] =
+ "Usage: console dial [extension[@context]]\n"
+ " Dials a given extension (and context if specified)\n";
+
+static struct ast_cli_entry cli_alsa_answer_deprecated = {
+ { "answer", NULL },
+ console_answer_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_alsa_hangup_deprecated = {
+ { "hangup", NULL },
+ console_hangup_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_alsa_dial_deprecated = {
+ { "dial", NULL },
+ console_dial_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_alsa_send_text_deprecated = {
+ { "send", "text", NULL },
+ console_sendtext_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_alsa_autoanswer_deprecated = {
+ { "autoanswer", NULL },
+ console_autoanswer_deprecated, NULL,
+ NULL, autoanswer_complete };
+
+static struct ast_cli_entry cli_alsa[] = {
+ { { "console", "answer", NULL },
+ console_answer, "Answer an incoming console call",
+ answer_usage, NULL, &cli_alsa_answer_deprecated },
+
+ { { "console", "hangup", NULL },
+ console_hangup, "Hangup a call on the console",
+ hangup_usage, NULL, &cli_alsa_hangup_deprecated },
+
+ { { "console", "dial", NULL },
+ console_dial, "Dial an extension on the console",
+ dial_usage, NULL, &cli_alsa_dial_deprecated },
+
+ { { "console", "send", "text", NULL },
+ console_sendtext, "Send text to the remote device",
+ sendtext_usage, NULL, &cli_alsa_send_text_deprecated },
+
+ { { "console", "autoanswer", NULL },
+ console_autoanswer, "Sets/displays autoanswer",
+ autoanswer_usage, autoanswer_complete, &cli_alsa_autoanswer_deprecated },
};
static int load_module(void)
{
- int res, x;
+ int res;
struct ast_config *cfg;
struct ast_variable *v;
@@ -1123,8 +1347,8 @@ static int load_module(void)
ast_log(LOG_ERROR, "Unable to register channel class 'Console'\n");
return -1;
}
- for (x = 0; x < sizeof(myclis) / sizeof(struct ast_cli_entry); x++)
- ast_cli_register(myclis + x);
+ ast_cli_register_multiple(cli_alsa, sizeof(cli_alsa) / sizeof(struct ast_cli_entry));
+
ast_pthread_create(&sthread, NULL, sound_thread, NULL);
#ifdef ALSA_MONITOR
if (alsa_monitor_start())
@@ -1135,11 +1359,9 @@ static int load_module(void)
static int unload_module(void)
{
- int x;
-
ast_channel_unregister(&alsa_tech);
- for (x = 0; x < sizeof(myclis) / sizeof(struct ast_cli_entry); x++)
- ast_cli_unregister(myclis + x);
+ ast_cli_unregister_multiple(cli_alsa, sizeof(cli_alsa) / sizeof(struct ast_cli_entry));
+
if (alsa.icard)
snd_pcm_close(alsa.icard);
if (alsa.ocard)
diff --git a/channels/chan_features.c b/channels/chan_features.c
index 66b6da3e3..5f01738d2 100644
--- a/channels/chan_features.c
+++ b/channels/chan_features.c
@@ -530,12 +530,19 @@ static int features_show(int fd, int argc, char **argv)
}
static char show_features_usage[] =
-"Usage: feature show channels\n"
+"Usage: feature list channels\n"
" Provides summary information on feature channels.\n";
-static struct ast_cli_entry cli_show_features = {
- { "feature", "show", "channels", NULL }, features_show,
- "Show status of feature channels", show_features_usage, NULL };
+static struct ast_cli_entry cli_features_show_channels_deprecated = {
+ { "feature", "show", "channels", NULL },
+ features_show, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_features[] = {
+ { { "feature", "list", "channels", NULL },
+ features_show, "List status of feature channels",
+ show_features_usage, NULL, &cli_features_show_channels_deprecated },
+};
static int load_module(void)
{
@@ -544,7 +551,7 @@ static int load_module(void)
ast_log(LOG_ERROR, "Unable to register channel class 'Feature'\n");
return -1;
}
- ast_cli_register(&cli_show_features);
+ ast_cli_register_multiple(cli_features, sizeof(cli_features) / sizeof(struct ast_cli_entry));
return 0;
}
@@ -553,7 +560,7 @@ static int unload_module(void)
struct feature_pvt *p;
/* First, take us out of the channel loop */
- ast_cli_unregister(&cli_show_features);
+ ast_cli_unregister_multiple(cli_features, sizeof(cli_features) / sizeof(struct ast_cli_entry));
ast_channel_unregister(&features_tech);
if (!AST_LIST_LOCK(&features))
diff --git a/channels/chan_h323.c b/channels/chan_h323.c
index ded2afbd5..c4e44fddd 100644
--- a/channels/chan_h323.c
+++ b/channels/chan_h323.c
@@ -1821,22 +1821,43 @@ static char h323_reload_usage[] =
"Usage: h323 reload\n"
" Reloads H.323 configuration from sip.conf\n";
-static struct ast_cli_entry cli_trace =
- { { "h.323", "trace", NULL }, h323_do_trace, "Enable H.323 Stack Tracing", trace_usage };
-static struct ast_cli_entry cli_no_trace =
- { { "h.323", "no", "trace", NULL }, h323_no_trace, "Disable H.323 Stack Tracing", no_trace_usage };
-static struct ast_cli_entry cli_debug =
- { { "h.323", "debug", NULL }, h323_do_debug, "Enable H.323 debug", debug_usage };
-static struct ast_cli_entry cli_no_debug =
- { { "h.323", "no", "debug", NULL }, h323_no_debug, "Disable H.323 debug", no_debug_usage };
-static struct ast_cli_entry cli_show_codecs =
- { { "h.323", "show", "codecs", NULL }, h323_show_codec, "Show enabled codecs", show_codec_usage };
-static struct ast_cli_entry cli_gk_cycle =
- { { "h.323", "gk", "cycle", NULL }, h323_gk_cycle, "Manually re-register with the Gatekeper", show_cycle_usage };
-static struct ast_cli_entry cli_hangup_call =
- { { "h.323", "hangup", NULL }, h323_ep_hangup, "Manually try to hang up a call", show_hangup_usage };
-static struct ast_cli_entry cli_show_tokens =
- { { "h.323", "show", "tokens", NULL }, h323_tokens_show, "Show all active call tokens", show_tokens_usage };
+static struct ast_cli_entry cli_h323[] = {
+ { { "h.323", "trace", NULL },
+ h323_do_trace, "Enable H.323 Stack Tracing",
+ trace_usage },
+
+ { { "h.323", "no", "trace", NULL },
+ h323_no_trace, "Disable H.323 Stack Tracing",
+ no_trace_usage },
+
+ { { "h.323", "debug", NULL },
+ h323_do_debug, "Enable H.323 debug",
+ debug_usage },
+
+ { { "h.323", "no", "debug", NULL },
+ h323_no_debug, "Disable H.323 debug",
+ no_debug_usage },
+
+ { { "h.323", "show", "codecs", NULL },
+ h323_show_codec, "Show enabled codecs",
+ show_codec_usage },
+
+ { { "h.323", "gk", "cycle", NULL },
+ h323_gk_cycle, "Manually re-register with the Gatekeper",
+ show_cycle_usage },
+
+ { { "h.323", "hangup", NULL },
+ h323_ep_hangup, "Manually try to hang up a call",
+ show_hangup_usage },
+
+ { { "h.323", "show", "tokens", NULL },
+ h323_tokens_show, "Show all active call tokens",
+ show_tokens_usage },
+
+ { { "h.323", "reload", NULL },
+ h323_reload, "Reload H.323 configuration",
+ h323_reload_usage },
+};
static int update_common_options(struct ast_variable *v, struct call_options *options)
{
@@ -2298,9 +2319,6 @@ static int reload(void *mod)
return h323_reload(0, 0, NULL);
}
-static struct ast_cli_entry cli_h323_reload =
- { { "h.323", "reload", NULL }, h323_reload, "Reload H.323 configuration", h323_reload_usage };
-
static struct ast_rtp *oh323_get_rtp_peer(struct ast_channel *chan)
{
struct oh323_pvt *pvt;
@@ -2397,15 +2415,7 @@ static int load_module(void *mod)
h323_end_process();
return -1;
}
- ast_cli_register(&cli_debug);
- ast_cli_register(&cli_no_debug);
- ast_cli_register(&cli_trace);
- ast_cli_register(&cli_no_trace);
- ast_cli_register(&cli_show_codecs);
- ast_cli_register(&cli_gk_cycle);
- ast_cli_register(&cli_hangup_call);
- ast_cli_register(&cli_show_tokens);
- ast_cli_register(&cli_h323_reload);
+ ast_cli_register_multiple(cli_h323, sizeof(cli_h323) / sizeof(struct ast_cli_entry));
ast_rtp_proto_register(&oh323_rtp);
@@ -2446,15 +2456,7 @@ static int unload_module(void *mod)
struct oh323_pvt *p, *pl;
/* unregister commands */
- ast_cli_unregister(&cli_debug);
- ast_cli_unregister(&cli_no_debug);
- ast_cli_unregister(&cli_trace);
- ast_cli_unregister(&cli_no_trace);
- ast_cli_unregister(&cli_show_codecs);
- ast_cli_unregister(&cli_gk_cycle);
- ast_cli_unregister(&cli_hangup_call);
- ast_cli_unregister(&cli_show_tokens);
- ast_cli_unregister(&cli_h323_reload);
+ ast_cli_unregister_multiple(cli_h323, sizeof(cli_h323) / sizeof(struct ast_cli_entry));
ast_rtp_proto_unregister(&oh323_rtp);
ast_channel_unregister(&oh323_tech);
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 501f28d02..1fa4c8784 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -4441,7 +4441,7 @@ static int iax2_do_jb_debug(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static int iax2_no_debug(int fd, int argc, char *argv[])
+static int iax2_no_debug_deprecated(int fd, int argc, char *argv[])
{
if (argc != 3)
return RESULT_SHOWUSAGE;
@@ -4450,7 +4450,16 @@ static int iax2_no_debug(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static int iax2_no_trunk_debug(int fd, int argc, char *argv[])
+static int iax2_no_debug(int fd, int argc, char *argv[])
+{
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
+ iaxdebug = 0;
+ ast_cli(fd, "IAX2 Debugging Disabled\n");
+ return RESULT_SUCCESS;
+}
+
+static int iax2_no_trunk_debug_deprecated(int fd, int argc, char *argv[])
{
if (argc != 4)
return RESULT_SHOWUSAGE;
@@ -4459,7 +4468,16 @@ static int iax2_no_trunk_debug(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static int iax2_no_jb_debug(int fd, int argc, char *argv[])
+static int iax2_no_trunk_debug(int fd, int argc, char *argv[])
+{
+ if (argc != 3)
+ return RESULT_SHOWUSAGE;
+ iaxtrunkdebug = 0;
+ ast_cli(fd, "IAX2 Trunk Debugging Disabled\n");
+ return RESULT_SUCCESS;
+}
+
+static int iax2_no_jb_debug_deprecated(int fd, int argc, char *argv[])
{
if (argc != 4)
return RESULT_SHOWUSAGE;
@@ -4469,6 +4487,16 @@ static int iax2_no_jb_debug(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int iax2_no_jb_debug(int fd, int argc, char *argv[])
+{
+ if (argc != 3)
+ return RESULT_SHOWUSAGE;
+ jb_setoutput(jb_error_output, jb_warning_output, NULL);
+ jb_debug_output("\n");
+ ast_cli(fd, "IAX2 Jitterbuffer Debugging Disabled\n");
+ return RESULT_SUCCESS;
+}
+
static int iax2_write(struct ast_channel *c, struct ast_frame *f)
{
unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
@@ -9625,15 +9653,15 @@ static struct ast_switch iax2_switch =
};
static char show_stats_usage[] =
-"Usage: iax show stats\n"
+"Usage: iax2 list stats\n"
" Display statistics on IAX channel driver.\n";
static char show_cache_usage[] =
-"Usage: iax show cache\n"
+"Usage: iax2 list cache\n"
" Display currently cached IAX Dialplan results.\n";
static char show_peer_usage[] =
-"Usage: iax show peer <name>\n"
+"Usage: iax2 show peer <name>\n"
" Display details on specific IAX peer\n";
static char prune_realtime_usage[] =
@@ -9652,34 +9680,34 @@ static char show_prov_usage[] =
" fields will be provisioned as empty fields.\n";
static char show_users_usage[] =
-"Usage: iax2 show users [like <pattern>]\n"
+"Usage: iax2 list users [like <pattern>]\n"
" Lists all known IAX2 users.\n"
" Optional regular expression pattern is used to filter the user list.\n";
static char show_channels_usage[] =
-"Usage: iax2 show channels\n"
+"Usage: iax2 list channels\n"
" Lists all currently active IAX channels.\n";
static char show_netstats_usage[] =
-"Usage: iax2 show netstats\n"
+"Usage: iax2 list netstats\n"
" Lists network status for all currently active IAX channels.\n";
static char show_threads_usage[] =
-"Usage: iax2 show threads\n"
+"Usage: iax2 list threads\n"
" Lists status of IAX helper threads\n";
static char show_peers_usage[] =
-"Usage: iax2 show peers [registered] [like <pattern>]\n"
+"Usage: iax2 list peers [registered] [like <pattern>]\n"
" Lists all known IAX2 peers.\n"
" Optional 'registered' argument lists only peers with known addresses.\n"
" Optional regular expression pattern is used to filter the peer list.\n";
static char show_firmware_usage[] =
-"Usage: iax2 show firmware\n"
+"Usage: iax2 list firmware\n"
" Lists all known IAX firmware images.\n";
static char show_reg_usage[] =
-"Usage: iax2 show registry\n"
+"Usage: iax2 list registry\n"
" Lists all registration requests and status.\n";
static char debug_usage[] =
@@ -9687,23 +9715,23 @@ static char debug_usage[] =
" Enables dumping of IAX packets for debugging purposes\n";
static char no_debug_usage[] =
-"Usage: iax2 no debug\n"
+"Usage: iax2 nodebug\n"
" Disables dumping of IAX packets for debugging purposes\n";
static char debug_trunk_usage[] =
-"Usage: iax2 trunk debug\n"
+"Usage: iax2 debug trunk\n"
" Requests current status of IAX trunking\n";
static char no_debug_trunk_usage[] =
-"Usage: iax2 no trunk debug\n"
+"Usage: iax2 nodebug trunk\n"
" Requests current status of IAX trunking\n";
static char debug_jb_usage[] =
-"Usage: iax2 jb debug\n"
+"Usage: iax2 debug jb\n"
" Enables jitterbuffer debugging information\n";
static char no_debug_jb_usage[] =
-"Usage: iax2 no jb debug\n"
+"Usage: iax2 nodebug jb\n"
" Disables jitterbuffer debugging information\n";
static char iax2_test_losspct_usage[] =
@@ -9724,54 +9752,168 @@ static char iax2_test_jitter_usage[] =
" For testing, simulate maximum jitter of +/- <ms> on <pct> percentage of packets. If <pct> is not specified, adds jitter to all packets.\n";
#endif /* IAXTESTS */
-static struct ast_cli_entry iax2_cli[] = {
- { { "iax2", "show", "stats", NULL }, iax2_show_stats,
- "Display IAX statistics", show_stats_usage },
- { { "iax2", "show", "cache", NULL }, iax2_show_cache,
- "Display IAX cached dialplan", show_cache_usage },
- { { "iax2", "show", "peer", NULL }, iax2_show_peer,
- "Show details on specific IAX peer", show_peer_usage, complete_iax2_show_peer },
- { { "iax2", "prune", "realtime", NULL }, iax2_prune_realtime,
- "Prune a cached realtime lookup", prune_realtime_usage, complete_iax2_show_peer },
- { { "iax2", "reload", NULL }, iax2_reload,
- "Reload IAX configuration", iax2_reload_usage },
- { { "iax2", "show", "users", NULL }, iax2_show_users,
- "Show defined IAX users", show_users_usage },
- { { "iax2", "show", "firmware", NULL }, iax2_show_firmware,
- "Show available IAX firmwares", show_firmware_usage },
- { { "iax2", "show", "channels", NULL }, iax2_show_channels,
- "Show active IAX channels", show_channels_usage },
- { { "iax2", "show", "netstats", NULL }, iax2_show_netstats,
- "Show active IAX channel netstats", show_netstats_usage },
- { { "iax2", "show", "peers", NULL }, iax2_show_peers,
- "Show defined IAX peers", show_peers_usage },
- { { "iax2", "show", "threads", NULL }, iax2_show_threads,
- "Show IAX helper thread info", show_threads_usage },
- { { "iax2", "show", "registry", NULL }, iax2_show_registry,
- "Show IAX registration status", show_reg_usage },
- { { "iax2", "debug", NULL }, iax2_do_debug,
- "Enable IAX debugging", debug_usage },
- { { "iax2", "trunk", "debug", NULL }, iax2_do_trunk_debug,
- "Enable IAX trunk debugging", debug_trunk_usage },
- { { "iax2", "jb", "debug", NULL }, iax2_do_jb_debug,
- "Enable IAX jitterbuffer debugging", debug_jb_usage },
- { { "iax2", "no", "debug", NULL }, iax2_no_debug,
- "Disable IAX debugging", no_debug_usage },
- { { "iax2", "no", "trunk", "debug", NULL }, iax2_no_trunk_debug,
- "Disable IAX trunk debugging", no_debug_trunk_usage },
- { { "iax2", "no", "jb", "debug", NULL }, iax2_no_jb_debug,
- "Disable IAX jitterbuffer debugging", no_debug_jb_usage },
- { { "iax2", "test", "losspct", NULL }, iax2_test_losspct,
- "Set IAX2 incoming frame loss percentage", iax2_test_losspct_usage },
- { { "iax2", "provision", NULL }, iax2_prov_cmd,
- "Provision an IAX device", show_prov_usage, iax2_prov_complete_template_3rd },
+static struct ast_cli_entry cli_iax2_trunk_debug_deprecated = {
+ { "iax2", "trunk", "debug", NULL },
+ iax2_do_trunk_debug, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_iax2_jb_debug_deprecated = {
+ { "iax2", "jb", "debug", NULL },
+ iax2_do_jb_debug, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_iax2_no_debug_deprecated = {
+ { "iax2", "no", "debug", NULL },
+ iax2_no_debug_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_iax2_no_trunk_debug_deprecated = {
+ { "iax2", "no", "trunk", "debug", NULL },
+ iax2_no_trunk_debug_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_iax2_no_jb_debug_deprecated = {
+ { "iax2", "no", "jb", "debug", NULL },
+ iax2_no_jb_debug_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_iax2_show_cache_deprecated = {
+ { "iax2", "show", "cache", NULL },
+ iax2_show_cache, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_iax2_show_peers_deprecated = {
+ { "iax2", "show", "peers", NULL },
+ iax2_show_peers, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_iax2_show_stats_deprecated = {
+ { "iax2", "show", "stats", NULL },
+ iax2_show_stats, NULL };
+
+static struct ast_cli_entry cli_iax2_show_firmware_deprecated = {
+ { "iax2", "show", "firmware", NULL },
+ iax2_show_firmware, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_iax2_show_channels_deprecated = {
+ { "iax2", "show", "channels", NULL },
+ iax2_show_channels, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_iax2_show_netstats_deprecated = {
+ { "iax2", "show", "netstats", NULL },
+ iax2_show_netstats, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_iax2_show_users_deprecated = {
+ { "iax2", "show", "users", NULL },
+ iax2_show_users, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_iax2_show_threads_deprecated = {
+ { "iax2", "show", "threads", NULL },
+ iax2_show_threads, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_iax2_show_registry_deprecated = {
+ { "iax2", "show", "registry", NULL },
+ iax2_show_registry, "Show IAX registration status",
+ show_reg_usage };
+
+static struct ast_cli_entry cli_iax2[] = {
+ { { "iax2", "list", "cache", NULL },
+ iax2_show_cache, "Display IAX cached dialplan",
+ show_cache_usage, NULL, &cli_iax2_show_cache_deprecated },
+
+ { { "iax2", "list", "channels", NULL },
+ iax2_show_channels, "List active IAX channels",
+ show_channels_usage, NULL, &cli_iax2_show_channels_deprecated },
+
+ { { "iax2", "list", "firmware", NULL },
+ iax2_show_firmware, "List available IAX firmwares",
+ show_firmware_usage, NULL, &cli_iax2_show_firmware_deprecated },
+
+ { { "iax2", "list", "netstats", NULL },
+ iax2_show_netstats, "List active IAX channel netstats",
+ show_netstats_usage, NULL, &cli_iax2_show_netstats_deprecated },
+
+ { { "iax2", "list", "peers", NULL },
+ iax2_show_peers, "List defined IAX peers",
+ show_peers_usage, NULL, &cli_iax2_show_peers_deprecated },
+
+ { { "iax2", "list", "registry", NULL },
+ iax2_show_registry, "Display IAX registration status",
+ show_reg_usage, NULL, &cli_iax2_show_registry_deprecated },
+
+ { { "iax2", "list", "stats", NULL },
+ iax2_show_stats, "Display IAX statistics",
+ show_stats_usage, NULL, &cli_iax2_show_stats_deprecated },
+
+ { { "iax2", "list", "threads", NULL },
+ iax2_show_threads, "Display IAX helper thread info",
+ show_threads_usage, NULL, &cli_iax2_show_threads_deprecated },
+
+ { { "iax2", "list", "users", NULL },
+ iax2_show_users, "List defined IAX users",
+ show_users_usage, NULL, &cli_iax2_show_users_deprecated },
+
+ { { "iax2", "prune", "realtime", NULL },
+ iax2_prune_realtime, "Prune a cached realtime lookup",
+ prune_realtime_usage, complete_iax2_show_peer },
+
+ { { "iax2", "reload", NULL },
+ iax2_reload, "Reload IAX configuration",
+ iax2_reload_usage },
+
+ { { "iax2", "show", "peer", NULL },
+ iax2_show_peer, "Show details on specific IAX peer",
+ show_peer_usage, complete_iax2_show_peer },
+
+ { { "iax2", "debug", NULL },
+ iax2_do_debug, "Enable IAX debugging",
+ debug_usage },
+
+ { { "iax2", "debug", "trunk", NULL },
+ iax2_do_trunk_debug, "Enable IAX trunk debugging",
+ debug_trunk_usage, NULL, &cli_iax2_trunk_debug_deprecated },
+
+ { { "iax2", "debug", "jb", NULL },
+ iax2_do_jb_debug, "Enable IAX jitterbuffer debugging",
+ debug_jb_usage, NULL, &cli_iax2_jb_debug_deprecated },
+
+ { { "iax2", "nodebug", NULL },
+ iax2_no_debug, "Disable IAX debugging",
+ no_debug_usage, NULL, &cli_iax2_no_debug_deprecated },
+
+ { { "iax2", "nodebug", "trunk", NULL },
+ iax2_no_trunk_debug, "Disable IAX trunk debugging",
+ no_debug_trunk_usage, NULL, &cli_iax2_no_trunk_debug_deprecated },
+
+ { { "iax2", "nodebug", "jb", NULL },
+ iax2_no_jb_debug, "Disable IAX jitterbuffer debugging",
+ no_debug_jb_usage, NULL, &cli_iax2_no_jb_debug_deprecated },
+
+ { { "iax2", "test", "losspct", NULL },
+ iax2_test_losspct, "Set IAX2 incoming frame loss percentage",
+ iax2_test_losspct_usage },
+
+ { { "iax2", "provision", NULL },
+ iax2_prov_cmd, "Provision an IAX device",
+ show_prov_usage, iax2_prov_complete_template_3rd },
+
#ifdef IAXTESTS
- { { "iax2", "test", "late", NULL }, iax2_test_late,
- "Test the receipt of a late frame", iax2_test_late_usage },
- { { "iax2", "test", "resync", NULL }, iax2_test_resync,
- "Test a resync in received timestamps", iax2_test_resync_usage },
- { { "iax2", "test", "jitter", NULL }, iax2_test_jitter,
- "Simulates jitter for testing", iax2_test_jitter_usage },
+ { { "iax2", "test", "late", NULL },
+ iax2_test_late, "Test the receipt of a late frame",
+ iax2_test_late_usage },
+
+ { { "iax2", "test", "resync", NULL },
+ iax2_test_resync, "Test a resync in received timestamps",
+ iax2_test_resync_usage },
+
+ { { "iax2", "test", "jitter", NULL },
+ iax2_test_jitter, "Simulates jitter for testing",
+ iax2_test_jitter_usage },
#endif /* IAXTESTS */
};
@@ -9836,7 +9978,7 @@ static int __unload_module(void)
ast_manager_unregister( "IAXpeers" );
ast_manager_unregister( "IAXnetstats" );
ast_unregister_application(papp);
- ast_cli_unregister_multiple(iax2_cli, sizeof(iax2_cli) / sizeof(iax2_cli[0]));
+ ast_cli_unregister_multiple(cli_iax2, sizeof(cli_iax2) / sizeof(struct ast_cli_entry));
ast_unregister_switch(&iax2_switch);
ast_channel_unregister(&iax2_tech);
delete_users();
@@ -9900,7 +10042,7 @@ static int load_module(void)
ast_mutex_init(&waresl.lock);
- ast_cli_register_multiple(iax2_cli, sizeof(iax2_cli) / sizeof(iax2_cli[0]));
+ ast_cli_register_multiple(cli_iax2, sizeof(cli_iax2) / sizeof(struct ast_cli_entry));
ast_register_application(papp, iax2_prov_app, psyn, pdescrip);
diff --git a/channels/chan_local.c b/channels/chan_local.c
index 3420ebb1a..99b3177b2 100644
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -622,12 +622,19 @@ static int locals_show(int fd, int argc, char **argv)
}
static char show_locals_usage[] =
-"Usage: local show channels\n"
+"Usage: local list channels\n"
" Provides summary information on active local proxy channels.\n";
-static struct ast_cli_entry cli_show_locals = {
- { "local", "show", "channels", NULL }, locals_show,
- "Show status of local channels", show_locals_usage, NULL };
+static struct ast_cli_entry cli_local_show_channels_deprecated = {
+ { "local", "show", "channels", NULL },
+ locals_show, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_local[] = {
+ { { "local", "list", "channels", NULL },
+ locals_show, "List status of local channels",
+ show_locals_usage, NULL, &cli_local_show_channels_deprecated },
+};
/*! \brief Load module into PBX, register channel */
static int load_module(void)
@@ -637,7 +644,7 @@ static int load_module(void)
ast_log(LOG_ERROR, "Unable to register channel class 'Local'\n");
return -1;
}
- ast_cli_register(&cli_show_locals);
+ ast_cli_register_multiple(cli_local, sizeof(cli_local) / sizeof(struct ast_cli_entry));
return 0;
}
@@ -647,7 +654,7 @@ static int unload_module(void)
struct local_pvt *p = NULL;
/* First, take us out of the channel loop */
- ast_cli_unregister(&cli_show_locals);
+ ast_cli_unregister_multiple(cli_local, sizeof(cli_local) / sizeof(struct ast_cli_entry));
ast_channel_unregister(&local_tech);
if (!AST_LIST_LOCK(&locals)) {
/* Hangup all interfaces if they have an owner */
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 1a27fc8f0..9ae00b837 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -1040,11 +1040,25 @@ static int mgcp_show_endpoints(int fd, int argc, char *argv[])
}
static char show_endpoints_usage[] =
-"Usage: mgcp show endpoints\n"
+"Usage: mgcp endpoint list\n"
" Lists all endpoints known to the MGCP (Media Gateway Control Protocol) subsystem.\n";
-static struct ast_cli_entry cli_show_endpoints =
- { { "mgcp", "show", "endpoints", NULL }, mgcp_show_endpoints, "Show defined MGCP endpoints", show_endpoints_usage };
+static char audit_endpoint_usage[] =
+"Usage: mgcp endpoint audit <endpointid>\n"
+" Lists the capabilities of an endpoint in the MGCP (Media Gateway Control Protocol) subsystem.\n"
+" mgcp debug MUST be on to see the results of this command.\n";
+
+static char debug_usage[] =
+"Usage: mgcp debug\n"
+" Enables dumping of MGCP packets for debugging purposes\n";
+
+static char no_debug_usage[] =
+"Usage: mgcp nodebug\n"
+" Disables dumping of MGCP packets for debugging purposes\n";
+
+static char mgcp_reload_usage[] =
+"Usage: mgcp reload\n"
+" Reloads MGCP configuration from mgcp.conf\n";
static int mgcp_audit_endpoint(int fd, int argc, char *argv[])
{
@@ -1099,13 +1113,69 @@ static int mgcp_audit_endpoint(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static char audit_endpoint_usage[] =
-"Usage: mgcp audit endpoint <endpointid>\n"
-" Lists the capabilities of an endpoint in the MGCP (Media Gateway Control Protocol) subsystem.\n"
-" mgcp debug MUST be on to see the results of this command.\n";
+static int mgcp_do_debug(int fd, int argc, char *argv[])
+{
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
+ mgcpdebug = 1;
+ ast_cli(fd, "MGCP Debugging Enabled\n");
+ return RESULT_SUCCESS;
+}
+
+static int mgcp_no_debug_deprecated(int fd, int argc, char *argv[])
+{
+ if (argc != 3)
+ return RESULT_SHOWUSAGE;
+ mgcpdebug = 0;
+ ast_cli(fd, "MGCP Debugging Disabled\n");
+ return RESULT_SUCCESS;
+}
+
+static int mgcp_no_debug(int fd, int argc, char *argv[])
+{
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
+ mgcpdebug = 0;
+ ast_cli(fd, "MGCP Debugging Disabled\n");
+ return RESULT_SUCCESS;
+}
-static struct ast_cli_entry cli_audit_endpoint =
- { { "mgcp", "audit", "endpoint", NULL }, mgcp_audit_endpoint, "Audit specified MGCP endpoint", audit_endpoint_usage };
+static struct ast_cli_entry cli_mgcp_no_debug_deprecated = {
+ { "mgcp", "no", "debug", NULL },
+ mgcp_no_debug_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_mgcp_audit_endpoint_deprecated = {
+ { "mgcp", "audit", "endpoint", NULL },
+ mgcp_audit_endpoint, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_mgcp_show_endpoints_deprecated = {
+ { "mgcp", "show", "endpoints", NULL },
+ mgcp_show_endpoints, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_mgcp[] = {
+ { { "mgcp", "endpoint", "audit", NULL },
+ mgcp_audit_endpoint, "Audit specified MGCP endpoint",
+ audit_endpoint_usage, NULL, &cli_mgcp_audit_endpoint_deprecated },
+
+ { { "mgcp", "endpoint", "list", NULL },
+ mgcp_show_endpoints, "List defined MGCP endpoints",
+ show_endpoints_usage, NULL, &cli_mgcp_show_endpoints_deprecated },
+
+ { { "mgcp", "debug", NULL },
+ mgcp_do_debug, "Enable MGCP debugging",
+ debug_usage },
+
+ { { "mgcp", "nodebug", NULL },
+ mgcp_no_debug, "Disable MGCP debugging",
+ no_debug_usage, NULL, &cli_mgcp_no_debug_deprecated },
+
+ { { "mgcp", "reload", NULL },
+ mgcp_reload, "Reload MGCP configuration",
+ mgcp_reload_usage },
+};
static int mgcp_answer(struct ast_channel *ast)
{
@@ -3917,44 +3987,6 @@ static struct ast_rtp_protocol mgcp_rtp = {
.set_rtp_peer = mgcp_set_rtp_peer,
};
-static int mgcp_do_debug(int fd, int argc, char *argv[])
-{
- if (argc != 2)
- return RESULT_SHOWUSAGE;
- mgcpdebug = 1;
- ast_cli(fd, "MGCP Debugging Enabled\n");
- return RESULT_SUCCESS;
-}
-
-static int mgcp_no_debug(int fd, int argc, char *argv[])
-{
- if (argc != 3)
- return RESULT_SHOWUSAGE;
- mgcpdebug = 0;
- ast_cli(fd, "MGCP Debugging Disabled\n");
- return RESULT_SUCCESS;
-}
-
-static char debug_usage[] =
-"Usage: mgcp debug\n"
-" Enables dumping of MGCP packets for debugging purposes\n";
-
-static char no_debug_usage[] =
-"Usage: mgcp no debug\n"
-" Disables dumping of MGCP packets for debugging purposes\n";
-
-static char mgcp_reload_usage[] =
-"Usage: mgcp reload\n"
-" Reloads MGCP configuration from mgcp.conf\n";
-
-static struct ast_cli_entry cli_debug =
- { { "mgcp", "debug", NULL }, mgcp_do_debug, "Enable MGCP debugging", debug_usage };
-static struct ast_cli_entry cli_no_debug =
- { { "mgcp", "no", "debug", NULL }, mgcp_no_debug, "Disable MGCP debugging", no_debug_usage };
-static struct ast_cli_entry cli_mgcp_reload =
- { { "mgcp", "reload", NULL }, mgcp_reload, "Reload MGCP configuration", mgcp_reload_usage };
-
-
static void destroy_endpoint(struct mgcp_endpoint *e)
{
struct mgcp_subchannel *sub = e->sub->next, *s;
@@ -4254,11 +4286,7 @@ static int load_module(void)
return -1;
}
ast_rtp_proto_register(&mgcp_rtp);
- ast_cli_register(&cli_show_endpoints);
- ast_cli_register(&cli_audit_endpoint);
- ast_cli_register(&cli_debug);
- ast_cli_register(&cli_no_debug);
- ast_cli_register(&cli_mgcp_reload);
+ ast_cli_register_multiple(cli_mgcp, sizeof(cli_mgcp) / sizeof(struct ast_cli_entry));
/* And start the monitor for the first time */
restart_monitor();
@@ -4350,11 +4378,7 @@ static int unload_module(void)
close(mgcpsock);
ast_rtp_proto_unregister(&mgcp_rtp);
- ast_cli_unregister(&cli_show_endpoints);
- ast_cli_unregister(&cli_audit_endpoint);
- ast_cli_unregister(&cli_debug);
- ast_cli_unregister(&cli_no_debug);
- ast_cli_unregister(&cli_mgcp_reload);
+ ast_cli_unregister_multiple(cli_mgcp, sizeof(cli_mgcp) / sizeof(struct ast_cli_entry));
sched_context_destroy(sched);
return 0;
diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c
index 66c459b35..6987542ce 100644
--- a/channels/chan_misdn.c
+++ b/channels/chan_misdn.c
@@ -4464,7 +4464,7 @@ static int unload_module(void)
if (!g_config_initialized) return 0;
- ast_cli_unregister_multiple(chan_misdn_clis, sizeof(chan_misdn_clis) / sizeof(chan_misdn_clis[0]));
+ ast_cli_unregister_multiple(chan_misdn_clis, sizeof(chan_misdn_clis) / sizeof(struct ast_cli_entry));
/* ast_unregister_application("misdn_crypt"); */
ast_unregister_application("misdn_set_opt");
@@ -4566,7 +4566,7 @@ static int load_module(void)
}
}
- ast_cli_register_multiple(chan_misdn_clis, sizeof(chan_misdn_clis) / sizeof(chan_misdn_clis[0]));
+ ast_cli_register_multiple(chan_misdn_clis, sizeof(chan_misdn_clis) / sizeof(struct ast_cli_entry));
ast_register_application("misdn_set_opt", misdn_set_opt_exec, "misdn_set_opt",
"misdn_set_opt(:<opt><optarg>:<opt><optarg>..):\n"
diff --git a/channels/chan_oss.c b/channels/chan_oss.c
index 6b31c0e24..876e247dc 100644
--- a/channels/chan_oss.c
+++ b/channels/chan_oss.c
@@ -1068,7 +1068,7 @@ static struct ast_channel *oss_request(const char *type, int format, void *data,
return c;
}
-static int console_autoanswer(int fd, int argc, char *argv[])
+static int console_autoanswer_deprecated(int fd, int argc, char *argv[])
{
struct chan_oss_pvt *o = find_desc(oss_active);
@@ -1091,22 +1091,54 @@ static int console_autoanswer(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int console_autoanswer(int fd, int argc, char *argv[])
+{
+ struct chan_oss_pvt *o = find_desc(oss_active);
+
+ if (argc == 2) {
+ ast_cli(fd, "Auto answer is %s.\n", o->autoanswer ? "on" : "off");
+ return RESULT_SUCCESS;
+ }
+ if (argc != 3)
+ return RESULT_SHOWUSAGE;
+ if (o == NULL) {
+ ast_log(LOG_WARNING, "Cannot find device %s (should not happen!)\n",
+ oss_active);
+ return RESULT_FAILURE;
+ }
+ if (!strcasecmp(argv[2], "on"))
+ o->autoanswer = -1;
+ else if (!strcasecmp(argv[2], "off"))
+ o->autoanswer = 0;
+ else
+ return RESULT_SHOWUSAGE;
+ return RESULT_SUCCESS;
+}
+
+static char *autoanswer_complete_deprecated(const char *line, const char *word, int pos, int state)
+{
+ static char *choices[] = { "on", "off", NULL };
+
+ return (pos != 2) ? NULL : ast_cli_complete(word, choices, state);
+}
+
static char *autoanswer_complete(const char *line, const char *word, int pos, int state)
{
static char *choices[] = { "on", "off", NULL };
- return (pos != 1) ? NULL : ast_cli_complete(word, choices, state);
+ return (pos != 3) ? NULL : ast_cli_complete(word, choices, state);
}
static char autoanswer_usage[] =
- "Usage: autoanswer [on|off]\n"
+ "Usage: console autoanswer [on|off]\n"
" Enables or disables autoanswer feature. If used without\n"
- " argument, displays the current on/off status of autoanswer.\n" " The default value of autoanswer is in 'oss.conf'.\n";
+ " argument, displays the current on/off status of autoanswer.\n"
+ " The default value of autoanswer is in 'oss.conf'.\n";
/*
* answer command from the console
*/
-static int console_answer(int fd, int argc, char *argv[])
+static int console_answer_deprecated(int fd, int argc, char *argv[])
{
struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
struct chan_oss_pvt *o = find_desc(oss_active);
@@ -1128,13 +1160,37 @@ static int console_answer(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static char sendtext_usage[] = "Usage: send text <message>\n" " Sends a text message for display on the remote terminal.\n";
+static int console_answer(int fd, int argc, char *argv[])
+{
+ struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
+ struct chan_oss_pvt *o = find_desc(oss_active);
+
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
+ if (!o->owner) {
+ ast_cli(fd, "No one is calling us\n");
+ return RESULT_FAILURE;
+ }
+ o->hookstate = 1;
+ o->cursound = -1;
+ o->nosound = 0;
+ ast_queue_frame(o->owner, &f);
+#if 0
+ /* XXX do we really need it ? considering we shut down immediately... */
+ ring(o, AST_CONTROL_ANSWER);
+#endif
+ return RESULT_SUCCESS;
+}
+
+static char answer_usage[] =
+ "Usage: console answer\n"
+ " Answers an incoming call on the console (OSS) channel.\n";
/*
* concatenate all arguments into a single string. argv is NULL-terminated
* so we can use it right away
*/
-static int console_sendtext(int fd, int argc, char *argv[])
+static int console_sendtext_deprecated(int fd, int argc, char *argv[])
{
struct chan_oss_pvt *o = find_desc(oss_active);
char buf[TEXT_SIZE];
@@ -1159,9 +1215,36 @@ static int console_sendtext(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static char answer_usage[] = "Usage: answer\n" " Answers an incoming call on the console (OSS) channel.\n";
+static int console_sendtext(int fd, int argc, char *argv[])
+{
+ struct chan_oss_pvt *o = find_desc(oss_active);
+ char buf[TEXT_SIZE];
-static int console_hangup(int fd, int argc, char *argv[])
+ if (argc < 3)
+ return RESULT_SHOWUSAGE;
+ if (!o->owner) {
+ ast_cli(fd, "Not in a call\n");
+ return RESULT_FAILURE;
+ }
+ ast_join(buf, sizeof(buf) - 1, argv + 3);
+ if (!ast_strlen_zero(buf)) {
+ struct ast_frame f = { 0, };
+ int i = strlen(buf);
+ buf[i] = '\n';
+ f.frametype = AST_FRAME_TEXT;
+ f.subclass = 0;
+ f.data = buf;
+ f.datalen = i + 1;
+ ast_queue_frame(o->owner, &f);
+ }
+ return RESULT_SUCCESS;
+}
+
+static char sendtext_usage[] =
+ "Usage: console send text <message>\n"
+ " Sends a text message for display on the remote terminal.\n";
+
+static int console_hangup_deprecated(int fd, int argc, char *argv[])
{
struct chan_oss_pvt *o = find_desc(oss_active);
@@ -1169,7 +1252,7 @@ static int console_hangup(int fd, int argc, char *argv[])
return RESULT_SHOWUSAGE;
o->cursound = -1;
o->nosound = 0;
- if (!o->owner && !o->hookstate) { /* XXX maybe only one ? */
+ if (!o->owner && !o->hookstate) { /* XXX maybe only one ? */
ast_cli(fd, "No call to hang up\n");
return RESULT_FAILURE;
}
@@ -1180,10 +1263,30 @@ static int console_hangup(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static char hangup_usage[] = "Usage: hangup\n" " Hangs up any call currently placed on the console.\n";
+static int console_hangup(int fd, int argc, char *argv[])
+{
+ struct chan_oss_pvt *o = find_desc(oss_active);
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
+ o->cursound = -1;
+ o->nosound = 0;
+ if (!o->owner && !o->hookstate) { /* XXX maybe only one ? */
+ ast_cli(fd, "No call to hang up\n");
+ return RESULT_FAILURE;
+ }
+ o->hookstate = 0;
+ if (o->owner)
+ ast_queue_hangup(o->owner);
+ setformat(o, O_CLOSE);
+ return RESULT_SUCCESS;
+}
-static int console_flash(int fd, int argc, char *argv[])
+static char hangup_usage[] =
+ "Usage: console hangup\n"
+ " Hangs up any call currently placed on the console.\n";
+
+static int console_flash_deprecated(int fd, int argc, char *argv[])
{
struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_FLASH };
struct chan_oss_pvt *o = find_desc(oss_active);
@@ -1191,6 +1294,25 @@ static int console_flash(int fd, int argc, char *argv[])
if (argc != 1)
return RESULT_SHOWUSAGE;
o->cursound = -1;
+ o->nosound = 0; /* when cursound is -1 nosound must be 0 */
+ if (!o->owner) { /* XXX maybe !o->hookstate too ? */
+ ast_cli(fd, "No call to flash\n");
+ return RESULT_FAILURE;
+ }
+ o->hookstate = 0;
+ if (o->owner) /* XXX must be true, right ? */
+ ast_queue_frame(o->owner, &f);
+ return RESULT_SUCCESS;
+}
+
+static int console_flash(int fd, int argc, char *argv[])
+{
+ struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_FLASH };
+ struct chan_oss_pvt *o = find_desc(oss_active);
+
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
+ o->cursound = -1;
o->nosound = 0; /* when cursound is -1 nosound must be 0 */
if (!o->owner) { /* XXX maybe !o->hookstate too ? */
ast_cli(fd, "No call to flash\n");
@@ -1202,23 +1324,22 @@ static int console_flash(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static char flash_usage[] =
+ "Usage: console flash\n"
+ " Flashes the call currently placed on the console.\n";
-static char flash_usage[] = "Usage: flash\n" " Flashes the call currently placed on the console.\n";
-
-
-
-static int console_dial(int fd, int argc, char *argv[])
+static int console_dial_deprecated(int fd, int argc, char *argv[])
{
char *s = NULL, *mye = NULL, *myc = NULL;
struct chan_oss_pvt *o = find_desc(oss_active);
if (argc != 1 && argc != 2)
return RESULT_SHOWUSAGE;
- if (o->owner) { /* already in a call */
+ if (o->owner) { /* already in a call */
int i;
struct ast_frame f = { AST_FRAME_DTMF, 0 };
- if (argc == 1) { /* argument is mandatory here */
+ if (argc == 1) { /* argument is mandatory here */
ast_cli(fd, "Already in a call. You can only dial digits until you hangup.\n");
return RESULT_FAILURE;
}
@@ -1248,29 +1369,125 @@ static int console_dial(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static char dial_usage[] = "Usage: dial [extension[@context]]\n" " Dials a given extension (and context if specified)\n";
+static int console_dial(int fd, int argc, char *argv[])
+{
+ char *s = NULL, *mye = NULL, *myc = NULL;
+ struct chan_oss_pvt *o = find_desc(oss_active);
-static char mute_usage[] = "Usage: mute\nMutes the microphone\n";
+ if (argc != 2 && argc != 3)
+ return RESULT_SHOWUSAGE;
+ if (o->owner) { /* already in a call */
+ int i;
+ struct ast_frame f = { AST_FRAME_DTMF, 0 };
-static char unmute_usage[] = "Usage: unmute\nUnmutes the microphone\n";
+ if (argc == 1) { /* argument is mandatory here */
+ ast_cli(fd, "Already in a call. You can only dial digits until you hangup.\n");
+ return RESULT_FAILURE;
+ }
+ s = argv[2];
+ /* send the string one char at a time */
+ for (i = 0; i < strlen(s); i++) {
+ f.subclass = s[i];
+ ast_queue_frame(o->owner, &f);
+ }
+ return RESULT_SUCCESS;
+ }
+ /* if we have an argument split it into extension and context */
+ if (argc == 3)
+ s = ast_ext_ctx(argv[2], &mye, &myc);
+ /* supply default values if needed */
+ if (mye == NULL)
+ mye = o->ext;
+ if (myc == NULL)
+ myc = o->ctx;
+ if (ast_exists_extension(NULL, myc, mye, 1, NULL)) {
+ o->hookstate = 1;
+ oss_new(o, mye, myc, AST_STATE_RINGING);
+ } else
+ ast_cli(fd, "No such extension '%s' in context '%s'\n", mye, myc);
+ if (s)
+ free(s);
+ return RESULT_SUCCESS;
+}
-static int console_mute(int fd, int argc, char *argv[])
+static char dial_usage[] =
+ "Usage: console dial [extension[@context]]\n"
+ " Dials a given extension (and context if specified)\n";
+
+static int __console_mute_unmute(int mute)
{
struct chan_oss_pvt *o = find_desc(oss_active);
+
+ o->mute = mute;
+ return RESULT_SUCCESS;
+}
+static int console_mute_deprecated(int fd, int argc, char *argv[])
+{
if (argc != 1)
return RESULT_SHOWUSAGE;
- o->mute = 1;
- return RESULT_SUCCESS;
+
+ return __console_mute_unmute(1);
+}
+
+static int console_mute(int fd, int argc, char *argv[])
+{
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
+
+ return __console_mute_unmute(1);
+}
+
+static char mute_usage[] =
+ "Usage: console mute\nMutes the microphone\n";
+
+static int console_unmute_deprecated(int fd, int argc, char *argv[])
+{
+ if (argc != 1)
+ return RESULT_SHOWUSAGE;
+
+ return __console_mute_unmute(0);
}
static int console_unmute(int fd, int argc, char *argv[])
{
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
+
+ return __console_mute_unmute(0);
+}
+
+static char unmute_usage[] =
+ "Usage: console unmute\nUnmutes the microphone\n";
+
+static int console_transfer_deprecated(int fd, int argc, char *argv[])
+{
struct chan_oss_pvt *o = find_desc(oss_active);
+ struct ast_channel *b = NULL;
+ char *tmp, *ext, *ctx;
- if (argc != 1)
+ if (argc != 2)
return RESULT_SHOWUSAGE;
- o->mute = 0;
+ if (o == NULL)
+ return RESULT_FAILURE;
+ if (o->owner ==NULL || (b = ast_bridged_channel(o->owner)) == NULL) {
+ ast_cli(fd, "There is no call to transfer\n");
+ return RESULT_SUCCESS;
+ }
+
+ tmp = ast_ext_ctx(argv[1], &ext, &ctx);
+ if (ctx == NULL) /* supply default context if needed */
+ ctx = o->owner->context;
+ if (!ast_exists_extension(b, ctx, ext, 1, b->cid.cid_num))
+ ast_cli(fd, "No such extension exists\n");
+ else {
+ ast_cli(fd, "Whee, transferring %s to %s@%s.\n",
+ b->name, ext, ctx);
+ if (ast_async_goto(b, ctx, ext, 1))
+ ast_cli(fd, "Failed to transfer :(\n");
+ }
+ if (tmp)
+ free(tmp);
return RESULT_SUCCESS;
}
@@ -1280,7 +1497,7 @@ static int console_transfer(int fd, int argc, char *argv[])
struct ast_channel *b = NULL;
char *tmp, *ext, *ctx;
- if (argc != 2)
+ if (argc != 3)
return RESULT_SHOWUSAGE;
if (o == NULL)
return RESULT_FAILURE;
@@ -1289,7 +1506,7 @@ static int console_transfer(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
- tmp = ast_ext_ctx(argv[1], &ext, &ctx);
+ tmp = ast_ext_ctx(argv[2], &ext, &ctx);
if (ctx == NULL) /* supply default context if needed */
ctx = o->owner->context;
if (!ast_exists_extension(b, ctx, ext, 1, b->cid.cid_num))
@@ -1304,13 +1521,12 @@ static int console_transfer(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static char transfer_usage[] = "Usage: transfer <extension>[@context]\n" " Transfers the currently connected call to the given extension (and\n" "context if specified)\n";
-
-static char console_usage[] =
- "Usage: console [device]\n"
- " If used without a parameter, displays which device is the current\n" "console. If a device is specified, the console sound device is changed to\n" "the device specified.\n";
+static char transfer_usage[] =
+ "Usage: console transfer <extension>[@context]\n"
+ " Transfers the currently connected call to the given extension (and\n"
+ "context if specified)\n";
-static int console_active(int fd, int argc, char *argv[])
+static int console_active_deprecated(int fd, int argc, char *argv[])
{
if (argc == 1)
ast_cli(fd, "active console is [%s]\n", oss_active);
@@ -1332,6 +1548,34 @@ static int console_active(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int console_active(int fd, int argc, char *argv[])
+{
+ if (argc == 2)
+ ast_cli(fd, "active console is [%s]\n", oss_active);
+ else if (argc != 3)
+ return RESULT_SHOWUSAGE;
+ else {
+ struct chan_oss_pvt *o;
+ if (strcmp(argv[2], "show") == 0) {
+ for (o = oss_default.next; o; o = o->next)
+ ast_cli(fd, "device [%s] exists\n", o->name);
+ return RESULT_SUCCESS;
+ }
+ o = find_desc(argv[2]);
+ if (o == NULL)
+ ast_cli(fd, "No device [%s] exists\n", argv[2]);
+ else
+ oss_active = o->name;
+ }
+ return RESULT_SUCCESS;
+}
+
+static char active_usage[] =
+ "Usage: console active [device]\n"
+ " If used without a parameter, displays which device is the current\n"
+ "console. If a device is specified, the console sound device is changed to\n"
+ "the device specified.\n";
+
/*
* store the boost factor
*/
@@ -1365,18 +1609,105 @@ static int do_boost(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static struct ast_cli_entry myclis[] = {
- {{"answer", NULL}, console_answer, "Answer an incoming console call", answer_usage},
- {{"hangup", NULL}, console_hangup, "Hangup a call on the console", hangup_usage},
- {{"flash", NULL}, console_flash, "Flash a call on the console", flash_usage},
- {{"dial", NULL}, console_dial, "Dial an extension on the console", dial_usage},
- {{"mute", NULL}, console_mute, "Disable mic input", mute_usage},
- {{"unmute", NULL}, console_unmute, "Enable mic input", unmute_usage},
- {{"transfer", NULL}, console_transfer, "Transfer a call to a different extension", transfer_usage},
- {{"send", "text", NULL}, console_sendtext, "Send text to the remote device", sendtext_usage},
- {{"autoanswer", NULL}, console_autoanswer, "Sets/displays autoanswer", autoanswer_usage, autoanswer_complete},
- {{"oss", "boost", NULL}, do_boost, "Sets/displays mic boost in dB"},
- {{"console", NULL}, console_active, "Sets/displays active console", console_usage},
+static struct ast_cli_entry cli_oss_answer_deprecated = {
+ { "answer", NULL },
+ console_answer_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_oss_hangup_deprecated = {
+ { "hangup", NULL },
+ console_hangup_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_oss_flash_deprecated = {
+ { "flash", NULL },
+ console_flash_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_oss_dial_deprecated = {
+ { "dial", NULL },
+ console_dial_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_oss_mute_deprecated = {
+ { "mute", NULL },
+ console_mute_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_oss_unmute_deprecated = {
+ { "unmute", NULL },
+ console_unmute_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_oss_transfer_deprecated = {
+ { "transfer", NULL },
+ console_transfer_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_oss_send_text_deprecated = {
+ { "send", "text", NULL },
+ console_sendtext_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_oss_autoanswer_deprecated = {
+ { "autoanswer", NULL },
+ console_autoanswer_deprecated, NULL,
+ NULL, autoanswer_complete_deprecated };
+
+static struct ast_cli_entry cli_oss_boost_deprecated = {
+ { "oss", "boost", NULL },
+ do_boost, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_oss_active_deprecated = {
+ { "console", NULL },
+ console_active_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_oss[] = {
+ { { "console", "answer", NULL },
+ console_answer, "Answer an incoming console call",
+ answer_usage, NULL, &cli_oss_answer_deprecated },
+
+ { { "console", "hangup", NULL },
+ console_hangup, "Hangup a call on the console",
+ hangup_usage, NULL, &cli_oss_hangup_deprecated },
+
+ { { "console", "flash", NULL },
+ console_flash, "Flash a call on the console",
+ flash_usage, NULL, &cli_oss_flash_deprecated },
+
+ { { "console", "dial", NULL },
+ console_dial, "Dial an extension on the console",
+ dial_usage, NULL, &cli_oss_dial_deprecated },
+
+ { { "console", "mute", NULL },
+ console_mute, "Disable mic input",
+ mute_usage, NULL, &cli_oss_mute_deprecated },
+
+ { { "console", "unmute", NULL },
+ console_unmute, "Enable mic input",
+ unmute_usage, NULL, &cli_oss_unmute_deprecated },
+
+ { { "console", "transfer", NULL },
+ console_transfer, "Transfer a call to a different extension",
+ transfer_usage, NULL, &cli_oss_transfer_deprecated },
+
+ { { "console", "send", "text", NULL },
+ console_sendtext, "Send text to the remote device",
+ sendtext_usage, NULL, &cli_oss_send_text_deprecated },
+
+ { { "console", "autoanswer", NULL },
+ console_autoanswer, "Sets/displays autoanswer",
+ autoanswer_usage, autoanswer_complete, &cli_oss_autoanswer_deprecated },
+
+ { { "console", "boost", NULL },
+ do_boost, "Sets/displays mic boost in dB",
+ NULL, NULL, &cli_oss_boost_deprecated },
+
+ { { "console", "active", NULL },
+ console_active, "Sets/displays active console",
+ active_usage, NULL, &cli_oss_active_deprecated },
};
/*
@@ -1536,7 +1867,7 @@ static int load_module(void)
/* XXX should cleanup allocated memory etc. */
return -1;
}
- ast_cli_register_multiple(myclis, sizeof(myclis) / sizeof(struct ast_cli_entry));
+ ast_cli_register_multiple(cli_oss, sizeof(cli_oss) / sizeof(struct ast_cli_entry));
return 0;
}
@@ -1546,7 +1877,7 @@ static int unload_module(void)
struct chan_oss_pvt *o;
ast_channel_unregister(&oss_tech);
- ast_cli_unregister_multiple(myclis, sizeof(myclis) / sizeof(struct ast_cli_entry));
+ ast_cli_unregister_multiple(cli_oss, sizeof(cli_oss) / sizeof(struct ast_cli_entry));
for (o = oss_default.next; o; o = o->next) {
close(o->sounddev);
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index a9de2e3f0..5314f498d 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -10570,7 +10570,7 @@ static int sip_notify(int fd, int argc, char *argv[])
}
/*! \brief Disable SIP Debugging in CLI */
-static int sip_no_debug(int fd, int argc, char *argv[])
+static int sip_no_debug_deprecated(int fd, int argc, char *argv[])
{
if (argc != 3)
return RESULT_SHOWUSAGE;
@@ -10579,6 +10579,15 @@ static int sip_no_debug(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int sip_no_debug(int fd, int argc, char *argv[])
+{
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
+ ast_clear_flag(&global_flags[1], SIP_PAGE2_DEBUG_CONSOLE);
+ ast_cli(fd, "SIP Debugging Disabled\n");
+ return RESULT_SUCCESS;
+}
+
/*! \brief Enable SIP History logging (CLI) */
static int sip_do_history(int fd, int argc, char *argv[])
{
@@ -10591,7 +10600,7 @@ static int sip_do_history(int fd, int argc, char *argv[])
}
/*! \brief Disable SIP History logging (CLI) */
-static int sip_no_history(int fd, int argc, char *argv[])
+static int sip_no_history_deprecated(int fd, int argc, char *argv[])
{
if (argc != 3) {
return RESULT_SHOWUSAGE;
@@ -10601,6 +10610,15 @@ static int sip_no_history(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int sip_no_history(int fd, int argc, char *argv[])
+{
+ if (argc != 2) {
+ return RESULT_SHOWUSAGE;
+ }
+ recordhistory = FALSE;
+ ast_cli(fd, "SIP History Recording Disabled\n");
+ return RESULT_SUCCESS;
+}
/*! \brief Authenticate for outbound registration */
static int do_register_auth(struct sip_pvt *p, struct sip_request *req, char *header, char *respheader)
@@ -10790,7 +10808,7 @@ static int build_reply_digest(struct sip_pvt *p, int method, char* digest, int d
}
static char show_domains_usage[] =
-"Usage: sip show domains\n"
+"Usage: sip list domains\n"
" Lists all configured SIP local domains.\n"
" Asterisk only responds to SIP messages to local domains.\n";
@@ -10800,22 +10818,22 @@ static char notify_usage[] =
" Message types are defined in sip_notify.conf\n";
static char show_users_usage[] =
-"Usage: sip show users [like <pattern>]\n"
+"Usage: sip list users [like <pattern>]\n"
" Lists all known SIP users.\n"
" Optional regular expression pattern is used to filter the user list.\n";
static char show_user_usage[] =
"Usage: sip show user <name> [load]\n"
-" Lists all details on one SIP user and the current status.\n"
+" Shows all details on one SIP user and the current status.\n"
" Option \"load\" forces lookup of peer in realtime storage.\n";
static char show_inuse_usage[] =
-"Usage: sip show inuse [all]\n"
+"Usage: sip list inuse [all]\n"
" List all SIP users and peers usage counters and limits.\n"
" Add option \"all\" to show all devices, not only those with a limit.\n";
static char show_channels_usage[] =
-"Usage: sip show channels\n"
+"Usage: sip list channels\n"
" Lists all currently active SIP channels.\n";
static char show_channel_usage[] =
@@ -10827,13 +10845,13 @@ static char show_history_usage[] =
" Provides detailed dialog history on a given SIP channel.\n";
static char show_peers_usage[] =
-"Usage: sip show peers [like <pattern>]\n"
+"Usage: sip list peers [like <pattern>]\n"
" Lists all known SIP peers.\n"
" Optional regular expression pattern is used to filter the peer list.\n";
static char show_peer_usage[] =
"Usage: sip show peer <name> [load]\n"
-" Lists all details on one SIP peer and the current status.\n"
+" Shows all details on one SIP peer and the current status.\n"
" Option \"load\" forces lookup of peer in realtime storage.\n";
static char prune_realtime_usage[] =
@@ -10842,7 +10860,7 @@ static char prune_realtime_usage[] =
" Optional regular expression pattern is used to filter the objects.\n";
static char show_reg_usage[] =
-"Usage: sip show registry\n"
+"Usage: sip list registry\n"
" Lists all registration requests and status.\n";
static char debug_usage[] =
@@ -10855,11 +10873,11 @@ static char debug_usage[] =
" Require peer to be registered.\n";
static char no_debug_usage[] =
-"Usage: sip no debug\n"
+"Usage: sip nodebug\n"
" Disables dumping of SIP packets for debugging purposes\n";
static char no_history_usage[] =
-"Usage: sip no history\n"
+"Usage: sip nohistory\n"
" Disables recording of SIP dialog history for debugging purposes\n";
static char history_usage[] =
@@ -10872,19 +10890,17 @@ static char sip_reload_usage[] =
" Reloads SIP configuration from sip.conf\n";
static char show_subscriptions_usage[] =
-"Usage: sip show subscriptions\n"
-" Shows active SIP subscriptions for extension states\n";
+"Usage: sip list subscriptions\n"
+" Lists active SIP subscriptions for extension states\n";
static char show_objects_usage[] =
-"Usage: sip show objects\n"
-" Shows status of known SIP objects\n";
+"Usage: sip list objects\n"
+" Lists status of known SIP objects\n";
static char show_settings_usage[] =
-"Usage: sip show settings\n"
+"Usage: sip list settings\n"
" Provides detailed list of the configuration of the SIP channel.\n";
-
-
/*! \brief Read SIP header (dialplan function) */
static int func_header_read(struct ast_channel *chan, char *function, char *data, char *buf, size_t len)
{
@@ -16569,34 +16585,157 @@ static int reload(void)
return sip_reload(0, 0, NULL);
}
-static struct ast_cli_entry my_clis[] = {
- { { "sip", "notify", NULL }, sip_notify, "Send a notify packet to a SIP peer", notify_usage, complete_sipnotify },
- { { "sip", "show", "objects", NULL }, sip_show_objects, "Show all SIP object allocations", show_objects_usage },
- { { "sip", "show", "users", NULL }, sip_show_users, "Show defined SIP users", show_users_usage },
- { { "sip", "show", "user", NULL }, sip_show_user, "Show details on specific SIP user", show_user_usage, complete_sip_show_user },
- { { "sip", "show", "subscriptions", NULL }, sip_show_subscriptions, "Show active SIP subscriptions", show_subscriptions_usage},
- { { "sip", "show", "channels", NULL }, sip_show_channels, "Show active SIP channels", show_channels_usage},
- { { "sip", "show", "channel", NULL }, sip_show_channel, "Show detailed SIP channel info", show_channel_usage, complete_sipch },
- { { "sip", "show", "history", NULL }, sip_show_history, "Show SIP dialog history", show_history_usage, complete_sipch },
- { { "sip", "show", "domains", NULL }, sip_show_domains, "List our local SIP domains.", show_domains_usage },
- { { "sip", "show", "settings", NULL }, sip_show_settings, "Show SIP global settings", show_settings_usage },
- { { "sip", "debug", NULL }, sip_do_debug, "Enable SIP debugging", debug_usage },
- { { "sip", "debug", "ip", NULL }, sip_do_debug, "Enable SIP debugging on IP", debug_usage },
- { { "sip", "debug", "peer", NULL }, sip_do_debug, "Enable SIP debugging on Peername", debug_usage, complete_sip_debug_peer },
- { { "sip", "show", "peer", NULL }, sip_show_peer, "Show details on specific SIP peer", show_peer_usage, complete_sip_show_peer },
- { { "sip", "show", "peers", NULL }, sip_show_peers, "Show defined SIP peers", show_peers_usage },
- { { "sip", "prune", "realtime", NULL }, sip_prune_realtime,
- "Prune cached Realtime object(s)", prune_realtime_usage },
- { { "sip", "prune", "realtime", "peer", NULL }, sip_prune_realtime,
- "Prune cached Realtime peer(s)", prune_realtime_usage, complete_sip_prune_realtime_peer },
- { { "sip", "prune", "realtime", "user", NULL }, sip_prune_realtime,
- "Prune cached Realtime user(s)", prune_realtime_usage, complete_sip_prune_realtime_user },
- { { "sip", "show", "inuse", NULL }, sip_show_inuse, "List all inuse/limits", show_inuse_usage },
- { { "sip", "show", "registry", NULL }, sip_show_registry, "Show SIP registration status", show_reg_usage },
- { { "sip", "history", NULL }, sip_do_history, "Enable SIP history", history_usage },
- { { "sip", "no", "history", NULL }, sip_no_history, "Disable SIP history", no_history_usage },
- { { "sip", "no", "debug", NULL }, sip_no_debug, "Disable SIP debugging", no_debug_usage },
- { { "sip", "reload", NULL }, sip_reload, "Reload SIP configuration", sip_reload_usage },
+static struct ast_cli_entry cli_sip_no_history_deprecated = {
+ { "sip", "no", "history", NULL },
+ sip_no_history_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_sip_no_debug_deprecated = {
+ { "sip", "no", "debug", NULL },
+ sip_no_debug_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_sip_show_objects_deprecated = {
+ { "sip", "show", "objects", NULL },
+ sip_show_objects, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_sip_show_users_deprecated = {
+ { "sip", "show", "users", NULL },
+ sip_show_users, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_sip_show_subscriptions_deprecated = {
+ { "sip", "show", "subscriptions", NULL },
+ sip_show_subscriptions, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_sip_show_channels_deprecated = {
+ { "sip", "show", "channels", NULL },
+ sip_show_channels, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_sip_show_domains_deprecated = {
+ { "sip", "show", "domains", NULL },
+ sip_show_domains, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_sip_show_settings_deprecated = {
+ { "sip", "show", "settings", NULL },
+ sip_show_settings, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_sip_show_peers_deprecated = {
+ { "sip", "show", "peers", NULL },
+ sip_show_peers, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_sip_show_inuse_deprecated = {
+ { "sip", "show", "inuse", NULL },
+ sip_show_inuse, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_sip_show_registry_deprecated = {
+ { "sip", "show", "registry", NULL },
+ sip_show_registry, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_sip[] = {
+ { { "sip", "list", "channels", NULL },
+ sip_show_channels, "List active SIP channels",
+ show_channels_usage, NULL, &cli_sip_show_channels_deprecated },
+
+ { { "sip", "list", "domains", NULL },
+ sip_show_domains, "List our local SIP domains.",
+ show_domains_usage, NULL, &cli_sip_show_domains_deprecated },
+
+ { { "sip", "list", "inuse", NULL },
+ sip_show_inuse, "List all inuse/limits",
+ show_inuse_usage, NULL, &cli_sip_show_inuse_deprecated },
+
+ { { "sip", "list", "objects", NULL },
+ sip_show_objects, "List all SIP object allocations",
+ show_objects_usage, NULL, &cli_sip_show_objects_deprecated },
+
+ { { "sip", "list", "peers", NULL },
+ sip_show_peers, "List defined SIP peers",
+ show_peers_usage, NULL, &cli_sip_show_peers_deprecated },
+
+ { { "sip", "list", "registry", NULL },
+ sip_show_registry, "List SIP registration status",
+ show_reg_usage, NULL, &cli_sip_show_registry_deprecated },
+
+ { { "sip", "list", "settings", NULL },
+ sip_show_settings, "List SIP global settings",
+ show_settings_usage, NULL, &cli_sip_show_settings_deprecated },
+
+ { { "sip", "list", "subscriptions", NULL },
+ sip_show_subscriptions, "List active SIP subscriptions",
+ show_subscriptions_usage, NULL, &cli_sip_show_subscriptions_deprecated },
+
+ { { "sip", "list", "users", NULL },
+ sip_show_users, "List defined SIP users",
+ show_users_usage, NULL, &cli_sip_show_users_deprecated },
+
+ { { "sip", "notify", NULL },
+ sip_notify, "Send a notify packet to a SIP peer",
+ notify_usage, complete_sipnotify },
+
+ { { "sip", "show", "channel", NULL },
+ sip_show_channel, "Show detailed SIP channel info",
+ show_channel_usage, complete_sipch },
+
+ { { "sip", "show", "history", NULL },
+ sip_show_history, "Show SIP dialog history",
+ show_history_usage, complete_sipch },
+
+ { { "sip", "show", "peer", NULL },
+ sip_show_peer, "Show details on specific SIP peer",
+ show_peer_usage, complete_sip_show_peer },
+
+ { { "sip", "show", "user", NULL },
+ sip_show_user, "Show details on specific SIP user",
+ show_user_usage, complete_sip_show_user },
+
+ { { "sip", "prune", "realtime", NULL },
+ sip_prune_realtime, "Prune cached Realtime object(s)",
+ prune_realtime_usage },
+
+ { { "sip", "prune", "realtime", "peer", NULL },
+ sip_prune_realtime, "Prune cached Realtime peer(s)",
+ prune_realtime_usage, complete_sip_prune_realtime_peer },
+
+ { { "sip", "prune", "realtime", "user", NULL },
+ sip_prune_realtime, "Prune cached Realtime user(s)",
+ prune_realtime_usage, complete_sip_prune_realtime_user },
+
+ { { "sip", "debug", NULL },
+ sip_do_debug, "Enable SIP debugging",
+ debug_usage },
+
+ { { "sip", "debug", "ip", NULL },
+ sip_do_debug, "Enable SIP debugging on IP",
+ debug_usage },
+
+ { { "sip", "debug", "peer", NULL },
+ sip_do_debug, "Enable SIP debugging on Peername",
+ debug_usage, complete_sip_debug_peer },
+
+ { { "sip", "nodebug", NULL },
+ sip_no_debug, "Disable SIP debugging",
+ no_debug_usage, NULL, &cli_sip_no_debug_deprecated },
+
+ { { "sip", "history", NULL },
+ sip_do_history, "Enable SIP history",
+ history_usage },
+
+ { { "sip", "nohistory", NULL },
+ sip_no_history, "Disable SIP history",
+ no_history_usage, NULL, &cli_sip_no_history_deprecated },
+
+ { { "sip", "reload", NULL },
+ sip_reload, "Reload SIP configuration",
+ sip_reload_usage },
};
/*! \brief load_module: PBX load module - initialization */
@@ -16625,7 +16764,7 @@ static int load_module(void)
}
/* Register all CLI functions for SIP */
- ast_cli_register_multiple(my_clis, sizeof(my_clis)/ sizeof(my_clis[0]));
+ ast_cli_register_multiple(cli_sip, sizeof(cli_sip)/ sizeof(struct ast_cli_entry));
/* Tell the RTP subdriver that we're here */
ast_rtp_proto_register(&sip_rtp);
@@ -16673,7 +16812,7 @@ static int unload_module(void)
ast_unregister_application(app_dtmfmode);
ast_unregister_application(app_sipaddheader);
- ast_cli_unregister_multiple(my_clis, sizeof(my_clis) / sizeof(my_clis[0]));
+ ast_cli_unregister_multiple(cli_sip, sizeof(cli_sip) / sizeof(struct ast_cli_entry));
ast_rtp_proto_unregister(&sip_rtp);
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index c6c906cda..3d16ab92f 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -1648,7 +1648,7 @@ static int skinny_do_debug(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static int skinny_no_debug(int fd, int argc, char *argv[])
+static int skinny_no_debug_deprecated(int fd, int argc, char *argv[])
{
if (argc != 3) {
return RESULT_SHOWUSAGE;
@@ -1658,6 +1658,16 @@ static int skinny_no_debug(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int skinny_no_debug(int fd, int argc, char *argv[])
+{
+ if (argc != 2) {
+ return RESULT_SHOWUSAGE;
+ }
+ skinnydebug = 0;
+ ast_cli(fd, "Skinny Debugging Disabled\n");
+ return RESULT_SUCCESS;
+}
+
static char *complete_skinny_reset(const char *line, const char *word, int pos, int state)
{
struct skinny_device *d;
@@ -1839,11 +1849,11 @@ static int skinny_show_lines(int fd, int argc, char *argv[])
}
static char show_devices_usage[] =
-"Usage: skinny show devices\n"
+"Usage: skinny list devices\n"
" Lists all devices known to the Skinny subsystem.\n";
static char show_lines_usage[] =
-"Usage: skinny show lines\n"
+"Usage: skinny list lines\n"
" Lists all lines known to the Skinny subsystem.\n";
static char debug_usage[] =
@@ -1851,27 +1861,49 @@ static char debug_usage[] =
" Enables dumping of Skinny packets for debugging purposes\n";
static char no_debug_usage[] =
-"Usage: skinny no debug\n"
+"Usage: skinny nodebug\n"
" Disables dumping of Skinny packets for debugging purposes\n";
static char reset_usage[] =
"Usage: skinny reset <DeviceId|all> [restart]\n"
" Causes a Skinny device to reset itself, optionally with a full restart\n";
-static struct ast_cli_entry cli_show_devices =
- { { "skinny", "show", "devices", NULL }, skinny_show_devices, "Show defined Skinny devices", show_devices_usage };
-
-static struct ast_cli_entry cli_show_lines =
- { { "skinny", "show", "lines", NULL }, skinny_show_lines, "Show defined Skinny lines per device", show_lines_usage };
-
-static struct ast_cli_entry cli_debug =
- { { "skinny", "debug", NULL }, skinny_do_debug, "Enable Skinny debugging", debug_usage };
-
-static struct ast_cli_entry cli_no_debug =
- { { "skinny", "no", "debug", NULL }, skinny_no_debug, "Disable Skinny debugging", no_debug_usage };
-
-static struct ast_cli_entry cli_reset_device =
- { { "skinny", "reset", NULL }, skinny_reset_device, "Reset Skinny device(s)", reset_usage, complete_skinny_reset };
+static struct ast_cli_entry cli_skinny_show_devices_deprecated = {
+ { "skinny", "show", "devices", NULL },
+ skinny_show_devices, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_skinny_show_lines_deprecated = {
+ { "skinny", "show", "lines", NULL },
+ skinny_show_lines, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_skinny_no_debug_deprecated = {
+ { "skinny", "no", "debug", NULL },
+ skinny_no_debug_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_skinny[] = {
+ { { "skinny", "list", "devices", NULL },
+ skinny_show_devices, "List defined Skinny devices",
+ show_devices_usage, NULL, &cli_skinny_show_devices_deprecated },
+
+ { { "skinny", "list", "lines", NULL },
+ skinny_show_lines, "List defined Skinny lines per device",
+ show_lines_usage, NULL, &cli_skinny_show_lines_deprecated },
+
+ { { "skinny", "debug", NULL },
+ skinny_do_debug, "Enable Skinny debugging",
+ debug_usage },
+
+ { { "skinny", "nodebug", NULL },
+ skinny_no_debug, "Disable Skinny debugging",
+ no_debug_usage, NULL, &cli_skinny_no_debug_deprecated },
+
+ { { "skinny", "reset", NULL },
+ skinny_reset_device, "Reset Skinny device(s)",
+ reset_usage, complete_skinny_reset },
+};
#if 0
static struct skinny_paging_device *build_paging_device(const char *cat, struct ast_variable *v)
@@ -4496,11 +4528,7 @@ static int load_module(void)
}
ast_rtp_proto_register(&skinny_rtp);
- ast_cli_register(&cli_show_devices);
- ast_cli_register(&cli_show_lines);
- ast_cli_register(&cli_debug);
- ast_cli_register(&cli_no_debug);
- ast_cli_register(&cli_reset_device);
+ ast_cli_register_multiple(cli_skinny, sizeof(cli_skinny) / sizeof(struct ast_cli_entry));
sched = sched_context_create();
if (!sched) {
ast_log(LOG_WARNING, "Unable to create schedule context\n");
@@ -4558,11 +4586,7 @@ static int unload_module(void)
ast_rtp_proto_unregister(&skinny_rtp);
ast_channel_unregister(&skinny_tech);
- ast_cli_unregister(&cli_show_devices);
- ast_cli_unregister(&cli_show_lines);
- ast_cli_unregister(&cli_debug);
- ast_cli_unregister(&cli_no_debug);
- ast_cli_unregister(&cli_reset_device);
+ ast_cli_unregister_multiple(cli_skinny, sizeof(cli_skinny) / sizeof(struct ast_cli_entry));
return 0;
#endif
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index 4d8f010cc..b10cd6bcc 100644
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -9621,22 +9621,34 @@ static const char pri_show_spans_help[] =
" Displays PRI Information\n";
static struct ast_cli_entry zap_pri_cli[] = {
- { { "pri", "debug", "span", NULL }, handle_pri_debug,
- "Enables PRI debugging on a span", pri_debug_help, complete_span_4 },
- { { "pri", "no", "debug", "span", NULL }, handle_pri_no_debug,
- "Disables PRI debugging on a span", pri_no_debug_help, complete_span_5 },
- { { "pri", "intense", "debug", "span", NULL }, handle_pri_really_debug,
- "Enables REALLY INTENSE PRI debugging", pri_really_debug_help, complete_span_5 },
- { { "pri", "show", "spans", NULL }, handle_pri_show_spans,
- "Displays PRI Information", pri_show_spans_help },
- { { "pri", "show", "span", NULL }, handle_pri_show_span,
- "Displays PRI Information", pri_show_span_help, complete_span_4 },
- { { "pri", "show", "debug", NULL }, handle_pri_show_debug,
- "Displays current PRI debug settings" },
- { { "pri", "set", "debug", "file", NULL }, handle_pri_set_debug_file,
- "Sends PRI debug output to the specified file" },
- { { "pri", "unset", "debug", "file", NULL }, handle_pri_set_debug_file,
- "Ends PRI debug output to file" },
+ { { "pri", "debug", "span", NULL },
+ handle_pri_debug, "Enables PRI debugging on a span",
+ pri_debug_help, complete_span_4 },
+
+ { { "pri", "no", "debug", "span", NULL },
+ handle_pri_no_debug, "Disables PRI debugging on a span",
+ pri_no_debug_help, complete_span_5 },
+
+ { { "pri", "intense", "debug", "span", NULL },
+ handle_pri_really_debug, "Enables REALLY INTENSE PRI debugging",
+ pri_really_debug_help, complete_span_5 },
+
+ { { "pri", "show", "spans", NULL },
+ handle_pri_show_spans, "Displays PRI Information",
+ pri_show_spans_help },
+
+ { { "pri", "show", "span", NULL },
+ handle_pri_show_span, "Displays PRI Information",
+ pri_show_span_help, complete_span_4 },
+
+ { { "pri", "show", "debug", NULL },
+ handle_pri_show_debug, "Displays current PRI debug settings" },
+
+ { { "pri", "set", "debug", "file", NULL },
+ handle_pri_set_debug_file, "Sends PRI debug output to the specified file" },
+
+ { { "pri", "unset", "debug", "file", NULL },
+ handle_pri_set_debug_file, "Ends PRI debug output to file" },
};
#endif /* HAVE_PRI */
@@ -10012,18 +10024,29 @@ static char zap_restart_usage[] =
"";
static struct ast_cli_entry zap_cli[] = {
- { { "zap", "show", "cadences", NULL }, handle_zap_show_cadences,
- "List cadences", zap_show_cadences_help },
- { {"zap", "show", "channels", NULL}, zap_show_channels,
- "Show active zapata channels", show_channels_usage },
- { {"zap", "show", "channel", NULL}, zap_show_channel,
- "Show information on a channel", show_channel_usage },
- { {"zap", "destroy", "channel", NULL}, zap_destroy_channel,
- "Destroy a channel", destroy_channel_usage },
- { {"zap", "restart", NULL}, zap_restart_cmd,
- "Fully restart zaptel channels", zap_restart_usage },
- { {"zap", "show", "status", NULL}, zap_show_status,
- "Show all Zaptel cards status", zap_show_status_usage },
+ { { "zap", "show", "cadences", NULL },
+ handle_zap_show_cadences, "List cadences",
+ zap_show_cadences_help },
+
+ { { "zap", "show", "channels", NULL},
+ zap_show_channels, "Show active zapata channels",
+ show_channels_usage },
+
+ { { "zap", "show", "channel", NULL},
+ zap_show_channel, "Show information on a channel",
+ show_channel_usage },
+
+ { { "zap", "destroy", "channel", NULL},
+ zap_destroy_channel, "Destroy a channel",
+ destroy_channel_usage },
+
+ { { "zap", "restart", NULL},
+ zap_restart_cmd, "Fully restart zaptel channels",
+ zap_restart_usage },
+
+ { { "zap", "show", "status", NULL},
+ zap_show_status, "Show all Zaptel cards status",
+ zap_show_status_usage },
};
#define TRANSFER 0
@@ -10213,10 +10236,10 @@ static int __unload_module(void)
if (pris[i].master != AST_PTHREADT_NULL)
pthread_cancel(pris[i].master);
}
- ast_cli_unregister_multiple(zap_pri_cli, sizeof(zap_pri_cli) / sizeof(zap_pri_cli[0]));
+ ast_cli_unregister_multiple(zap_pri_cli, sizeof(zap_pri_cli) / sizeof(struct ast_cli_entry));
ast_unregister_application(zap_send_keypad_facility_app);
#endif
- ast_cli_unregister_multiple(zap_cli, sizeof(zap_cli) / sizeof(zap_cli[0]));
+ ast_cli_unregister_multiple(zap_cli, sizeof(zap_cli) / sizeof(struct ast_cli_entry));
ast_manager_unregister( "ZapDialOffhook" );
ast_manager_unregister( "ZapHangup" );
ast_manager_unregister( "ZapTransfer" );
@@ -11186,9 +11209,9 @@ static int load_module(void)
#ifdef HAVE_PRI
ast_string_field_init(&inuse, 16);
ast_string_field_set(&inuse, name, "GR-303InUse");
- ast_cli_register_multiple(zap_pri_cli, sizeof(zap_pri_cli) / sizeof(zap_pri_cli[0]));
+ ast_cli_register_multiple(zap_pri_cli, sizeof(zap_pri_cli) / sizeof(struct ast_cli_entry));
#endif
- ast_cli_register_multiple(zap_cli, sizeof(zap_cli) / sizeof(zap_cli[0]));
+ ast_cli_register_multiple(zap_cli, sizeof(zap_cli) / sizeof(struct ast_cli_entry));
memset(round_robin, 0, sizeof(round_robin));
ast_manager_register( "ZapTransfer", 0, action_transfer, "Transfer Zap Channel" );
diff --git a/channels/iax2-provision.c b/channels/iax2-provision.c
index 0b1fc3e33..229c64043 100644
--- a/channels/iax2-provision.c
+++ b/channels/iax2-provision.c
@@ -400,7 +400,7 @@ static int iax_process_template(struct ast_config *cfg, char *s, char *def)
}
static char show_provisioning_usage[] =
-"Usage: iax show provisioning [template]\n"
+"Usage: iax list provisioning [template]\n"
" Lists all known IAX provisioning templates or a\n"
" specific one if specified.\n";
@@ -466,12 +466,20 @@ static int iax_show_provisioning(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static struct ast_cli_entry cli_show_provisioning =
- { { "iax2", "show", "provisioning", NULL }, iax_show_provisioning, "Show iax provisioning", show_provisioning_usage, iax_prov_complete_template };
+static struct ast_cli_entry cli_iax2_show_provisioning = {
+ { "iax2", "show", "provisioning", NULL },
+ iax_show_provisioning, NULL,
+ NULL, iax_prov_complete_template };
+
+static struct ast_cli_entry cli_iax2_provision[] = {
+ { { "iax2", "show", "provisioning", NULL },
+ iax_show_provisioning, "Display iax provisioning",
+ show_provisioning_usage, iax_prov_complete_template, &cli_iax2_show_provisioning },
+};
static int iax_provision_init(void)
{
- ast_cli_register(&cli_show_provisioning);
+ ast_cli_register_multiple(cli_iax2_provision, sizeof(cli_iax2_provision) / sizeof(struct ast_cli_entry));
provinit = 1;
return 0;
}
@@ -479,7 +487,7 @@ static int iax_provision_init(void)
int iax_provision_unload(void)
{
provinit = 0;
- ast_cli_unregister(&cli_show_provisioning);
+ ast_cli_unregister_multiple(cli_iax2_provision, sizeof(cli_iax2_provision) / sizeof(struct ast_cli_entry));
return 0;
}
diff --git a/include/asterisk/cli.h b/include/asterisk/cli.h
index 02cdb290f..e2a6f818b 100644
--- a/include/asterisk/cli.h
+++ b/include/asterisk/cli.h
@@ -69,10 +69,17 @@ struct ast_cli_entry {
until a NULL is returned.
*/
char *(*generator)(const char *line, const char *word, int pos, int n);
+ struct ast_cli_entry *deprecate_cmd;
/*! For keeping track of usage */
int inuse;
struct module *module; /*! module this belongs to */
char *_full_cmd; /* built at load time from cmda[] */
+ /* This gets set in ast_cli_register()
+ It then gets set to something different when the deprecated command
+ is run for the first time (ie; after we warn the user that it's deprecated)
+ */
+ int deprecated;
+ char *_deprecated_by; /* copied from the "parent" _full_cmd, on deprecated commands */
/*! For linking */
AST_LIST_ENTRY(ast_cli_entry) list;
};
diff --git a/main/asterisk.c b/main/asterisk.c
index e5b117baf..e8bf9575b 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -438,7 +438,7 @@ int64_t ast_mark(int i, int startstop)
return prof_data->e[i].mark;
}
-static int handle_show_profile(int fd, int argc, char *argv[])
+static int handle_show_profile_deprecated(int fd, int argc, char *argv[])
{
int i, min, max;
char *search = NULL;
@@ -484,9 +484,55 @@ static int handle_show_profile(int fd, int argc, char *argv[])
return 0;
}
+static int handle_show_profile(int fd, int argc, char *argv[])
+{
+ int i, min, max;
+ char *search = NULL;
+
+ if (prof_data == NULL)
+ return 0;
+
+ min = 0;
+ max = prof_data->entries;
+ if (argc >= 3) { /* specific entries */
+ if (isdigit(argv[2][0])) {
+ min = atoi(argv[2]);
+ if (argc == 4 && strcmp(argv[3], "-"))
+ max = atoi(argv[3]);
+ } else
+ search = argv[2];
+ }
+ if (max > prof_data->entries)
+ max = prof_data->entries;
+ if (!strcmp(argv[1], "clear")) {
+ for (i= min; i < max; i++) {
+ if (!search || strstr(prof_data->e[i].name, search)) {
+ prof_data->e[i].value = 0;
+ prof_data->e[i].events = 0;
+ }
+ }
+ return 0;
+ }
+ ast_cli(fd, "profile values (%d, allocated %d)\n-------------------\n",
+ prof_data->entries, prof_data->max_size);
+ ast_cli(fd, "%6s %8s %10s %12s %12s %s\n", "ID", "Scale", "Events",
+ "Value", "Average", "Name");
+ for (i = min; i < max; i++) {
+ struct profile_entry *e = &prof_data->e[i];
+ if (!search || strstr(prof_data->e[i].name, search))
+ ast_cli(fd, "%6d: [%8ld] %10ld %12lld %12lld %s\n",
+ i,
+ (long)e->scale,
+ (long)e->events, (long long)e->value,
+ (long long)(e->events ? e->value / e->events : e->value),
+ e->name);
+ }
+ return 0;
+}
+
static char show_version_files_help[] =
-"Usage: show version files [like <pattern>]\n"
-" Shows the revision numbers of the files used to build this copy of Asterisk.\n"
+"Usage: file list version [like <pattern>]\n"
+" Lists the revision numbers of the files used to build this copy of Asterisk.\n"
" Optional regular expression pattern is used to filter the file list.\n";
/*! \brief CLI command to list module versions */
@@ -1471,38 +1517,83 @@ static int show_license(int fd, int argc, char *argv[])
#define ASTERISK_PROMPT2 "%s*CLI> "
-static struct ast_cli_entry core_cli[] = {
- { { "abort", "halt", NULL }, handle_abort_halt,
- "Cancel a running halt", abort_halt_help },
- { { "stop", "now", NULL }, handle_shutdown_now,
- "Shut down Asterisk immediately", shutdown_now_help },
- { { "stop", "gracefully", NULL }, handle_shutdown_gracefully,
- "Gracefully shut down Asterisk", shutdown_gracefully_help },
- { { "stop", "when","convenient", NULL }, handle_shutdown_when_convenient,
- "Shut down Asterisk at empty call volume", shutdown_when_convenient_help },
- { { "restart", "now", NULL }, handle_restart_now,
- "Restart Asterisk immediately", restart_now_help },
- { { "restart", "gracefully", NULL }, handle_restart_gracefully,
- "Restart Asterisk gracefully", restart_gracefully_help },
- { { "restart", "when", "convenient", NULL }, handle_restart_when_convenient,
- "Restart Asterisk at empty call volume", restart_when_convenient_help },
- { { "show", "warranty", NULL }, show_warranty,
- "Show the warranty (if any) for this copy of Asterisk", show_warranty_help },
- { { "show", "license", NULL }, show_license,
- "Show the license(s) for this copy of Asterisk", show_license_help },
- { { "show", "version", NULL }, handle_version,
- "Display version info", version_help },
- { { "!", NULL }, handle_bang,
- "Execute a shell command", bang_help },
#if !defined(LOW_MEMORY)
- { { "show", "version", "files", NULL }, handle_show_version_files,
- "Show versions of files used to build Asterisk", show_version_files_help, complete_show_version_files },
- { { "show", "threads", NULL }, handle_show_threads,
- "Show running threads", show_threads_help, NULL },
- { { "show", "profile", NULL }, handle_show_profile,
- "Show profiling info"},
- { { "clear", "profile", NULL }, handle_show_profile,
- "Clear profiling info"},
+static struct ast_cli_entry cli_show_version_files_deprecated = {
+ { "show", "version", "files", NULL },
+ handle_show_version_files, NULL,
+ NULL, complete_show_version_files };
+
+static struct ast_cli_entry cli_show_profile_deprecated = {
+ { "show", "profile", NULL },
+ handle_show_profile_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_clear_profile_deprecated = {
+ { "clear", "profile", NULL },
+ handle_show_profile_deprecated, NULL,
+ NULL };
+#endif /* ! LOW_MEMORY */
+
+static struct ast_cli_entry cli_asterisk[] = {
+ { { "abort", "halt", NULL },
+ handle_abort_halt, "Cancel a running halt",
+ abort_halt_help },
+
+ { { "stop", "now", NULL },
+ handle_shutdown_now, "Shut down Asterisk immediately",
+ shutdown_now_help },
+
+ { { "stop", "gracefully", NULL },
+ handle_shutdown_gracefully, "Gracefully shut down Asterisk",
+ shutdown_gracefully_help },
+
+ { { "stop", "when", "convenient", NULL },
+ handle_shutdown_when_convenient, "Shut down Asterisk at empty call volume",
+ shutdown_when_convenient_help },
+
+ { { "restart", "now", NULL },
+ handle_restart_now, "Restart Asterisk immediately", restart_now_help },
+
+ { { "restart", "gracefully", NULL },
+ handle_restart_gracefully, "Restart Asterisk gracefully",
+ restart_gracefully_help },
+
+ { { "restart", "when", "convenient", NULL },
+ handle_restart_when_convenient, "Restart Asterisk at empty call volume",
+ restart_when_convenient_help },
+
+ { { "show", "warranty", NULL },
+ show_warranty, "Show the warranty (if any) for this copy of Asterisk",
+ show_warranty_help },
+
+ { { "show", "license", NULL },
+ show_license, "Show the license(s) for this copy of Asterisk",
+ show_license_help },
+
+ { { "show", "version", NULL },
+ handle_version, "Display version info",
+ version_help },
+
+ { { "!", NULL },
+ handle_bang, "Execute a shell command",
+ bang_help },
+
+#if !defined(LOW_MEMORY)
+ { { "file", "list", "version", NULL },
+ handle_show_version_files, "List versions of files used to build Asterisk",
+ show_version_files_help, complete_show_version_files, &cli_show_version_files_deprecated },
+
+ { { "show", "threads", NULL },
+ handle_show_threads, "Show running threads",
+ show_threads_help },
+
+ { { "profile", "list", NULL },
+ handle_show_profile, "Display profiling info",
+ NULL, NULL, &cli_show_profile_deprecated },
+
+ { { "profile", "clear", NULL },
+ handle_show_profile, "Clear profiling info",
+ NULL, NULL, &cli_clear_profile_deprecated },
#endif /* ! LOW_MEMORY */
};
@@ -2047,9 +2138,9 @@ static void ast_remotecontrol(char * data)
pid = atoi(cpid);
else
pid = -1;
- snprintf(tmp, sizeof(tmp), "set verbose atleast %d", option_verbose);
+ snprintf(tmp, sizeof(tmp), "core verbose %d", option_verbose);
fdprint(ast_consock, tmp);
- snprintf(tmp, sizeof(tmp), "set debug atleast %d", option_debug);
+ snprintf(tmp, sizeof(tmp), "core debug %d", option_debug);
fdprint(ast_consock, tmp);
if (ast_opt_mute) {
snprintf(tmp, sizeof(tmp), "log and verbose output currently muted ('logger unmute' to unmute)");
@@ -2708,7 +2799,7 @@ int main(int argc, char *argv[])
#endif
time(&ast_startuptime);
- ast_cli_register_multiple(core_cli, sizeof(core_cli) / sizeof(core_cli[0]));
+ ast_cli_register_multiple(cli_asterisk, sizeof(cli_asterisk) / sizeof(struct ast_cli_entry));
if (ast_opt_console) {
/* Console stuff now... */
diff --git a/main/astmm.c b/main/astmm.c
index b3b68dc06..990fe26f0 100644
--- a/main/astmm.c
+++ b/main/astmm.c
@@ -302,7 +302,7 @@ static int handle_show_memory(int fd, int argc, char *argv[])
unsigned int count = 0;
unsigned int *fence;
- if (argc > 3)
+ if (argc > 3)
fn = argv[3];
ast_mutex_lock(&showmemorylock);
@@ -395,31 +395,40 @@ static int handle_show_memory_summary(int fd, int argc, char *argv[])
}
static char show_memory_help[] =
-"Usage: show memory allocations [<file>]\n"
+"Usage: memory show allocations [<file>]\n"
" Dumps a list of all segments of allocated memory, optionally\n"
"limited to those from a specific file\n";
static char show_memory_summary_help[] =
-"Usage: show memory summary [<file>]\n"
+"Usage: memory show summary [<file>]\n"
" Summarizes heap memory allocations by file, or optionally\n"
"by function, if a file is specified\n";
-static struct ast_cli_entry show_memory_allocations_cli =
- { { "show", "memory", "allocations", NULL },
+static struct ast_cli_entry cli_show_memory_allocations_deprecated = {
+ { "show", "memory", "allocations", NULL },
+ handle_show_memory, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_show_memory_summary_deprecated = {
+ { "show", "memory", "summary", NULL },
+ handle_show_memory_summary, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_memory[] = {
+ { { "memory", "show", "allocations", NULL },
handle_show_memory, "Display outstanding memory allocations",
- show_memory_help };
+ show_memory_help, NULL, &cli_show_memory_allocations },
-static struct ast_cli_entry show_memory_summary_cli =
- { { "show", "memory", "summary", NULL },
+ { { "memory", "show", "summary", NULL },
handle_show_memory_summary, "Summarize outstanding memory allocations",
- show_memory_summary_help };
+ show_memory_summary_help, NULL, &cli_show_memory_summary },
+};
void __ast_mm_init(void)
{
char filename[PATH_MAX];
- ast_cli_register(&show_memory_allocations_cli);
- ast_cli_register(&show_memory_summary_cli);
+ ast_cli_register_multiple(cli_memory, sizeof(cli_memory) / sizeof(struct ast_cli_entry));
snprintf(filename, sizeof(filename), "%s/mmlog", (char *)ast_config_AST_LOG_DIR);
diff --git a/main/cdr.c b/main/cdr.c
index 19163cff6..4d3ca86bf 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -1011,19 +1011,15 @@ static int handle_cli_submit(int fd, int argc, char *argv[])
}
static struct ast_cli_entry cli_submit = {
- .cmda = { "cdr", "submit", NULL },
- .handler = handle_cli_submit,
- .summary = "Posts all pending batched CDR data",
- .usage =
+ { "cdr", "submit", NULL },
+ handle_cli_submit, "Posts all pending batched CDR data",
"Usage: cdr submit\n"
" Posts all pending batched CDR data to the configured CDR backend engine modules.\n"
};
static struct ast_cli_entry cli_status = {
- .cmda = { "cdr", "status", NULL },
- .handler = handle_cli_status,
- .summary = "Display the CDR status",
- .usage =
+ { "cdr", "status", NULL },
+ handle_cli_status, "Display the CDR status",
"Usage: cdr status\n"
" Displays the Call Detail Record engine system status.\n"
};
diff --git a/main/channel.c b/main/channel.c
index 24fe88a25..9c9f1daa3 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -288,18 +288,32 @@ static char *complete_channeltypes(const char *line, const char *word, int pos,
}
static char show_channeltypes_usage[] =
-"Usage: show channeltypes\n"
-" Shows available channel types registered in your Asterisk server.\n";
+"Usage: channeltype list\n"
+" Lists available channel types registered in your Asterisk server.\n";
static char show_channeltype_usage[] =
-"Usage: show channeltype <name>\n"
+"Usage: channeltype show <name>\n"
" Show details about the specified channel type, <name>.\n";
-static struct ast_cli_entry cli_show_channeltypes =
- { { "show", "channeltypes", NULL }, show_channeltypes, "Show available channel types", show_channeltypes_usage };
+static struct ast_cli_entry cli_show_channeltypes_deprecated = {
+ { "show", "channeltypes", NULL },
+ show_channeltypes, NULL,
+ NULL };
-static struct ast_cli_entry cli_show_channeltype =
- { { "show", "channeltype", NULL }, show_channeltype, "Give more details on that channel type", show_channeltype_usage, complete_channeltypes };
+static struct ast_cli_entry cli_show_channeltype_deprecated = {
+ { "show", "channeltype", NULL },
+ show_channeltype, NULL,
+ NULL, complete_channeltypes };
+
+static struct ast_cli_entry cli_channel[] = {
+ { { "channeltype", "list", NULL },
+ show_channeltypes, "List available channel types",
+ show_channeltypes_usage, NULL, &cli_show_channeltypes_deprecated },
+
+ { { "channeltype", "show", NULL },
+ show_channeltype, "Give more details on that channel type",
+ show_channeltype_usage, complete_channeltypes, &cli_show_channeltype_deprecated },
+};
/*! \brief Checks to see if a channel is needing hang up */
int ast_check_hangup(struct ast_channel *chan)
@@ -4149,8 +4163,7 @@ void ast_moh_cleanup(struct ast_channel *chan)
void ast_channels_init(void)
{
- ast_cli_register(&cli_show_channeltypes);
- ast_cli_register(&cli_show_channeltype);
+ ast_cli_register_multiple(cli_channel, sizeof(cli_channel) / sizeof(struct ast_cli_entry));
}
/*! \brief Print call group and pickup group ---*/
diff --git a/main/cli.c b/main/cli.c
index 896ef2848..0eb1ef30d 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -76,11 +76,11 @@ void ast_cli(int fd, char *fmt, ...)
static AST_LIST_HEAD_STATIC(helpers, ast_cli_entry);
static char load_help[] =
-"Usage: load <module name>\n"
+"Usage: module load <module name>\n"
" Loads the specified module into Asterisk.\n";
static char unload_help[] =
-"Usage: unload [-f|-h] <module name>\n"
+"Usage: module unload [-f|-h] <module name>\n"
" Unloads the specified module from Asterisk. The -f\n"
" option causes the module to be unloaded even if it is\n"
" in use (may cause a crash) and the -h module causes the\n"
@@ -94,28 +94,33 @@ static char help_help[] =
" topic, it provides a list of commands.\n";
static char chanlist_help[] =
-"Usage: show channels [concise|verbose]\n"
+"Usage: channel list [concise|verbose]\n"
" Lists currently defined channels and some information about them. If\n"
" 'concise' is specified, the format is abridged and in a more easily\n"
" machine parsable format. If 'verbose' is specified, the output includes\n"
" more and longer fields.\n";
static char reload_help[] =
-"Usage: reload [module ...]\n"
+"Usage: module reload [module ...]\n"
" Reloads configuration files for all listed modules which support\n"
" reloading, or for all supported modules if none are listed.\n";
-static char set_verbose_help[] =
-"Usage: set verbose <level>\n"
+static char verbose_help[] =
+"Usage: core verbose <level>\n"
" Sets level of verbose messages to be displayed. 0 means\n"
" no messages should be displayed. Equivalent to -v[v[v...]]\n"
" on startup\n";
-static char set_debug_help[] =
-"Usage: set debug <level>\n"
+static char debug_help[] =
+"Usage: core debug <level> [filename]\n"
" Sets level of core debug messages to be displayed. 0 means\n"
-" no messages should be displayed. Equivalent to -d[d[d...]]\n"
-" on startup.\n";
+" no messages should be displayed. Equivalent to -d[d[d...]]\n"
+" on startup. If filename is specified, debugging will be\n"
+" limited to just that file.\n";
+
+static char nodebug_help[] =
+"Usage: core nodebug\n"
+" Turns off core debug messages.\n";
static char logger_mute_help[] =
"Usage: logger mute\n"
@@ -128,12 +133,12 @@ static char softhangup_help[] =
" the next time the driver reads or writes from the channel\n";
static char group_show_channels_help[] =
-"Usage: group show channels [pattern]\n"
+"Usage: group list channels [pattern]\n"
" Lists all currently active channels with channel group(s) specified.\n"
" Optional regular expression pattern is matched to group names for each\n"
" channel.\n";
-static int handle_load(int fd, int argc, char *argv[])
+static int handle_load_deprecated(int fd, int argc, char *argv[])
{
if (argc != 2)
return RESULT_SHOWUSAGE;
@@ -144,7 +149,18 @@ static int handle_load(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static int handle_reload(int fd, int argc, char *argv[])
+static int handle_load(int fd, int argc, char *argv[])
+{
+ if (argc != 3)
+ return RESULT_SHOWUSAGE;
+ if (ast_load_resource(argv[2])) {
+ ast_cli(fd, "Unable to load module %s\n", argv[2]);
+ return RESULT_FAILURE;
+ }
+ return RESULT_SUCCESS;
+}
+
+static int handle_reload_deprecated(int fd, int argc, char *argv[])
{
int x;
int res;
@@ -167,7 +183,30 @@ static int handle_reload(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static int handle_set_verbose(int fd, int argc, char *argv[])
+static int handle_reload(int fd, int argc, char *argv[])
+{
+ int x;
+ int res;
+ if (argc < 2)
+ return RESULT_SHOWUSAGE;
+ if (argc > 2) {
+ for (x=2;x<argc;x++) {
+ res = ast_module_reload(argv[x]);
+ switch(res) {
+ case 0:
+ ast_cli(fd, "No such module '%s'\n", argv[x]);
+ break;
+ case 1:
+ ast_cli(fd, "Module '%s' does not support reload\n", argv[x]);
+ break;
+ }
+ }
+ } else
+ ast_module_reload(NULL);
+ return RESULT_SUCCESS;
+}
+
+static int handle_set_verbose_deprecated(int fd, int argc, char *argv[])
{
int val = 0;
int oldval = option_verbose;
@@ -183,16 +222,39 @@ static int handle_set_verbose(int fd, int argc, char *argv[])
option_verbose = val;
} else
return RESULT_SHOWUSAGE;
+
if (oldval != option_verbose && option_verbose > 0)
ast_cli(fd, "Verbosity was %d and is now %d\n", oldval, option_verbose);
else if (oldval > 0 && option_verbose > 0)
ast_cli(fd, "Verbosity is at least %d\n", option_verbose);
else if (oldval > 0 && option_verbose == 0)
ast_cli(fd, "Verbosity is now OFF\n");
+
+ return RESULT_SUCCESS;
+}
+
+static int handle_verbose(int fd, int argc, char *argv[])
+{
+ int oldval = option_verbose;
+
+ if (argc == 3)
+ option_verbose = atoi(argv[2]);
+ else
+ return RESULT_SHOWUSAGE;
+
+ if (oldval > 0 && option_verbose == 0)
+ ast_cli(fd, "Verbosity is now OFF\n");
+ else if (option_verbose > 0) {
+ if (oldval == option_verbose)
+ ast_cli(fd, "Verbosity is at least %d\n", option_verbose);
+ else
+ ast_cli(fd, "Verbosity was %d and is now %d\n", oldval, option_verbose);
+ }
+
return RESULT_SUCCESS;
}
-static int handle_set_debug(int fd, int argc, char *argv[])
+static int handle_set_debug_deprecated(int fd, int argc, char *argv[])
{
int val = 0;
int oldval = option_debug;
@@ -208,12 +270,87 @@ static int handle_set_debug(int fd, int argc, char *argv[])
option_debug = val;
} else
return RESULT_SHOWUSAGE;
+
if (oldval != option_debug && option_debug > 0)
ast_cli(fd, "Core debug was %d and is now %d\n", oldval, option_debug);
else if (oldval > 0 && option_debug > 0)
ast_cli(fd, "Core debug is at least %d\n", option_debug);
else if (oldval > 0 && option_debug == 0)
ast_cli(fd, "Core debug is now OFF\n");
+
+ return RESULT_SUCCESS;
+}
+
+static int handle_debug(int fd, int argc, char *argv[])
+{
+ int oldval = option_debug;
+ int newlevel;
+ char *filename = '\0';
+
+ if ((argc < 3) || (argc > 4))
+ return RESULT_SHOWUSAGE;
+
+ if (sscanf(argv[2], "%d", &newlevel) != 1)
+ return RESULT_SHOWUSAGE;
+
+ option_debug = newlevel;
+
+ if (argc == 4) {
+ filename = argv[3];
+ ast_copy_string(debug_filename, filename, sizeof(debug_filename));
+ } else {
+ debug_filename[0] = '\0';
+ }
+
+ if (oldval > 0 && option_debug == 0)
+ ast_cli(fd, "Core debug is now OFF\n");
+ else if (option_debug > 0) {
+ if (filename) {
+ if (oldval == option_debug)
+ ast_cli(fd, "Core debug is at least %d, file '%s'\n", option_debug, filename);
+ else
+ ast_cli(fd, "Core debug was %d and is now %d, file '%s'\n", oldval, option_debug, filename);
+ } else {
+ if (oldval == option_debug)
+ ast_cli(fd, "Core debug is at least %d\n", option_debug);
+ else
+ ast_cli(fd, "Core debug was %d and is now %d\n", oldval, option_debug);
+ }
+ }
+
+ return RESULT_SUCCESS;
+}
+
+static int handle_nodebug(int fd, int argc, char *argv[])
+{
+ int oldval = option_debug;
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
+
+ option_debug = 0;
+ debug_filename[0] = '\0';
+
+ if (oldval > 0)
+ ast_cli(fd, "Core debug is now OFF\n");
+ return RESULT_SUCCESS;
+}
+
+static int handle_debuglevel_deprecated(int fd, int argc, char *argv[])
+{
+ int newlevel;
+ char *filename = "<any>";
+ if ((argc < 3) || (argc > 4))
+ return RESULT_SHOWUSAGE;
+ if (sscanf(argv[2], "%d", &newlevel) != 1)
+ return RESULT_SHOWUSAGE;
+ option_debug = newlevel;
+ if (argc == 4) {
+ filename = argv[3];
+ ast_copy_string(debug_filename, filename, sizeof(debug_filename));
+ } else {
+ debug_filename[0] = '\0';
+ }
+ ast_cli(fd, "Debugging level set to %d, file '%s'\n", newlevel, filename);
return RESULT_SUCCESS;
}
@@ -225,7 +362,7 @@ static int handle_logger_mute(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static int handle_unload(int fd, int argc, char *argv[])
+static int handle_unload_deprecated(int fd, int argc, char *argv[])
{
int x;
int force=AST_FORCE_SOFT;
@@ -253,6 +390,34 @@ static int handle_unload(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int handle_unload(int fd, int argc, char *argv[])
+{
+ int x;
+ int force=AST_FORCE_SOFT;
+ if (argc < 3)
+ return RESULT_SHOWUSAGE;
+ for (x=2;x<argc;x++) {
+ if (argv[x][0] == '-') {
+ switch(argv[x][1]) {
+ case 'f':
+ force = AST_FORCE_FIRM;
+ break;
+ case 'h':
+ force = AST_FORCE_HARD;
+ break;
+ default:
+ return RESULT_SHOWUSAGE;
+ }
+ } else if (x != argc - 1)
+ return RESULT_SHOWUSAGE;
+ else if (ast_unload_resource(argv[x], force)) {
+ ast_cli(fd, "Unable to unload resource %s\n", argv[x]);
+ return RESULT_FAILURE;
+ }
+ }
+ return RESULT_SUCCESS;
+}
+
#define MODLIST_FORMAT "%-30s %-40.40s %-10d\n"
#define MODLIST_FORMAT2 "%-30s %-40.40s %-10s\n"
@@ -270,7 +435,7 @@ static int modlist_modentry(const char *module, const char *description, int use
}
static char modlist_help[] =
-"Usage: show modules [like keyword]\n"
+"Usage: module list [like keyword]\n"
" Shows Asterisk modules currently in use, and usage statistics.\n";
static char uptime_help[] =
@@ -460,20 +625,15 @@ static int handle_chanlist(int fd, int argc, char *argv[])
}
static char showchan_help[] =
-"Usage: show channel <channel>\n"
+"Usage: channel show <channel>\n"
" Shows lots of information about the specified channel.\n";
static char debugchan_help[] =
-"Usage: debug channel <channel>\n"
+"Usage: channel debug <channel>\n"
" Enables debugging on a specific channel.\n";
-static char debuglevel_help[] =
-"Usage: debug level <level> [filename]\n"
-" Set debug to specified level (0 to disable). If filename\n"
-"is specified, debugging will be limited to just that file.\n";
-
static char nodebugchan_help[] =
-"Usage: no debug channel <channel>\n"
+"Usage: channel nodebug <channel>\n"
" Disables debugging on a specific channel.\n";
static char commandcomplete_help[] =
@@ -580,25 +740,6 @@ static int handle_commandcomplete(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static int handle_debuglevel(int fd, int argc, char *argv[])
-{
- int newlevel;
- char *filename = "<any>";
- if ((argc < 3) || (argc > 4))
- return RESULT_SHOWUSAGE;
- if (sscanf(argv[2], "%d", &newlevel) != 1)
- return RESULT_SHOWUSAGE;
- option_debug = newlevel;
- if (argc == 4) {
- filename = argv[3];
- ast_copy_string(debug_filename, filename, sizeof(debug_filename));
- } else {
- debug_filename[0] = '\0';
- }
- ast_cli(fd, "Debugging level set to %d, file '%s'\n", newlevel, filename);
- return RESULT_SUCCESS;
-}
-
/* XXX todo: merge next two functions!!! */
static int handle_debugchan(int fd, int argc, char *argv[])
{
@@ -634,7 +775,7 @@ static int handle_debugchan(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static int handle_nodebugchan(int fd, int argc, char *argv[])
+static int handle_nodebugchan_deprecated(int fd, int argc, char *argv[])
{
struct ast_channel *c=NULL;
int is_all;
@@ -666,6 +807,38 @@ static int handle_nodebugchan(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int handle_nodebugchan(int fd, int argc, char *argv[])
+{
+ struct ast_channel *c=NULL;
+ int is_all;
+ /* 'no debug channel {all|chan_id}' */
+ if (argc != 3)
+ return RESULT_SHOWUSAGE;
+ is_all = !strcasecmp("all", argv[2]);
+ if (is_all) {
+ global_fin &= ~DEBUGCHAN_FLAG;
+ global_fout &= ~DEBUGCHAN_FLAG;
+ c = ast_channel_walk_locked(NULL);
+ } else {
+ c = ast_get_channel_by_name_locked(argv[2]);
+ if (c == NULL)
+ ast_cli(fd, "No such channel %s\n", argv[2]);
+ }
+ while(c) {
+ if ((c->fin & DEBUGCHAN_FLAG) || (c->fout & DEBUGCHAN_FLAG)) {
+ c->fin &= ~DEBUGCHAN_FLAG;
+ c->fout &= ~DEBUGCHAN_FLAG;
+ ast_cli(fd, "Debugging disabled on channel %s\n", c->name);
+ }
+ ast_channel_unlock(c);
+ if (!is_all)
+ break;
+ c = ast_channel_walk_locked(c);
+ }
+ ast_cli(fd, "Debugging on new channels is disabled\n");
+ return RESULT_SUCCESS;
+}
+
static int handle_showchan(int fd, int argc, char *argv[])
{
struct ast_channel *c=NULL;
@@ -814,12 +987,22 @@ static char *complete_mod_2(const char *line, const char *word, int pos, int sta
return ast_module_helper(line, word, pos, state, 1, 1);
}
+static char *complete_mod_3_nr(const char *line, const char *word, int pos, int state)
+{
+ return ast_module_helper(line, word, pos, state, 2, 0);
+}
+
+static char *complete_mod_3(const char *line, const char *word, int pos, int state)
+{
+ return ast_module_helper(line, word, pos, state, 2, 1);
+}
+
static char *complete_mod_4(const char *line, const char *word, int pos, int state)
{
return ast_module_helper(line, word, pos, state, 3, 0);
}
-static char *complete_fn(const char *line, const char *word, int pos, int state)
+static char *complete_fn_deprecated(const char *line, const char *word, int pos, int state)
{
char *c;
char filename[256];
@@ -840,6 +1023,27 @@ static char *complete_fn(const char *line, const char *word, int pos, int state)
return c ? strdup(c) : c;
}
+static char *complete_fn(const char *line, const char *word, int pos, int state)
+{
+ char *c;
+ char filename[256];
+
+ if (pos != 2)
+ return NULL;
+
+ if (word[0] == '/')
+ ast_copy_string(filename, word, sizeof(filename));
+ else
+ snprintf(filename, sizeof(filename), "%s/%s", ast_config_AST_MODULE_DIR, word);
+
+ c = filename_completion_function(filename, state);
+
+ if (c && word[0] != '/')
+ c += (strlen(ast_config_AST_MODULE_DIR) + 1);
+
+ return c ? strdup(c) : c;
+}
+
static int group_show_channels(int fd, int argc, char *argv[])
{
#define FORMAT_STRING "%-25s %-20s %-20s\n"
@@ -903,31 +1107,162 @@ static char * complete_help(const char *text, const char *word, int pos, int sta
return __ast_cli_generator(text, word, state, 0);
}
+/* XXX Nothing in this array can currently be deprecated...
+ You have to change the way find_cli works in order to remove this array
+ I recommend doing this eventually...
+ */
static struct ast_cli_entry builtins[] = {
/* Keep alphabetized, with longer matches first (example: abcd before abc) */
- { { "_command", "complete", NULL }, handle_commandcomplete, "Command complete", commandcomplete_help },
- { { "_command", "nummatches", NULL }, handle_commandnummatches, "Returns number of command matches", commandnummatches_help },
- { { "_command", "matchesarray", NULL }, handle_commandmatchesarray, "Returns command matches array", commandmatchesarray_help },
- { { "debug", "channel", NULL }, handle_debugchan, "Enable debugging on a channel", debugchan_help, complete_ch_3 },
- { { "debug", "level", NULL }, handle_debuglevel, "Set global debug level", debuglevel_help },
- { { "group", "show", "channels", NULL }, group_show_channels, "Show active channels with group(s)", group_show_channels_help},
- { { "help", NULL }, handle_help, "Display help list, or specific help on a command", help_help, complete_help },
- { { "load", NULL }, handle_load, "Load a module by name", load_help, complete_fn },
- { { "logger", "mute", NULL }, handle_logger_mute, "Toggle logging output to a console", logger_mute_help },
- { { "no", "debug", "channel", NULL }, handle_nodebugchan, "Disable debugging on a channel", nodebugchan_help, complete_ch_4 },
- { { "reload", NULL }, handle_reload, "Reload configuration", reload_help, complete_mod_2 },
- { { "set", "debug", NULL }, handle_set_debug, "Set level of debug chattiness", set_debug_help },
- { { "set", "verbose", NULL }, handle_set_verbose, "Set level of verboseness", set_verbose_help },
- { { "show", "channel", NULL }, handle_showchan, "Display information on a specific channel", showchan_help, complete_ch_3 },
- { { "show", "channels", NULL }, handle_chanlist, "Display information on channels", chanlist_help, complete_show_channels },
- { { "show", "modules", NULL }, handle_modlist, "List modules and info", modlist_help },
- { { "show", "modules", "like", NULL }, handle_modlist, "List modules and info", modlist_help, complete_mod_4 },
- { { "show", "uptime", NULL }, handle_showuptime, "Show uptime information", uptime_help },
- { { "soft", "hangup", NULL }, handle_softhangup, "Request a hangup on a given channel", softhangup_help, complete_ch_3 },
- { { "unload", NULL }, handle_unload, "Unload a module by name", unload_help, complete_mod_2_nr },
+ { { "_command", "complete", NULL },
+ handle_commandcomplete, "Command complete",
+ commandcomplete_help },
+
+ { { "_command", "nummatches", NULL },
+ handle_commandnummatches, "Returns number of command matches",
+ commandnummatches_help },
+
+ { { "_command", "matchesarray", NULL },
+ handle_commandmatchesarray, "Returns command matches array",
+ commandmatchesarray_help },
+
{ { NULL }, NULL, NULL, NULL }
};
+static struct ast_cli_entry cli_debug_channel_deprecated = {
+ { "debug", "channel", NULL },
+ handle_debugchan, NULL,
+ NULL, complete_ch_3 };
+
+static struct ast_cli_entry cli_debug_level_deprecated = {
+ { "debug", "level", NULL },
+ handle_debuglevel_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_group_show_channels_deprecated = {
+ { "group", "show", "channels", NULL },
+ group_show_channels, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_load_deprecated = {
+ { "load", NULL },
+ handle_load_deprecated, NULL,
+ NULL, complete_fn_deprecated };
+
+static struct ast_cli_entry cli_no_debug_channel_deprecated = {
+ { "no", "debug", "channel", NULL },
+ handle_nodebugchan_deprecated, NULL,
+ NULL, complete_ch_4 };
+
+static struct ast_cli_entry cli_reload_deprecated = {
+ { "reload", NULL },
+ handle_reload_deprecated, NULL,
+ NULL, complete_mod_2 };
+
+static struct ast_cli_entry cli_set_debug_deprecated = {
+ { "set", "debug", NULL },
+ handle_set_debug_deprecated, NULL,
+ NULL, NULL, &cli_debug_level_deprecated };
+
+static struct ast_cli_entry cli_set_verbose_deprecated = {
+ { "set", "verbose", NULL },
+ handle_set_verbose_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_show_channel_deprecated = {
+ { "show", "channel", NULL },
+ handle_showchan, NULL,
+ NULL, complete_ch_3 };
+
+static struct ast_cli_entry cli_show_channels_deprecated = {
+ { "show", "channels", NULL },
+ handle_chanlist, NULL,
+ NULL, complete_show_channels };
+
+static struct ast_cli_entry cli_show_modules_deprecated = {
+ { "show", "modules", NULL },
+ handle_modlist, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_show_modules_like_deprecated = {
+ { "show", "modules", "like", NULL },
+ handle_modlist, NULL,
+ NULL, complete_mod_4 };
+
+static struct ast_cli_entry cli_unload_deprecated = {
+ { "unload", NULL },
+ handle_unload_deprecated, NULL,
+ NULL, complete_mod_2_nr };
+
+static struct ast_cli_entry cli_cli[] = {
+ { { "channel", "list", NULL },
+ handle_chanlist, "Display information on channels",
+ chanlist_help, complete_show_channels, &cli_show_channels_deprecated },
+
+ { { "channel", "show", NULL },
+ handle_showchan, "Display information on a specific channel",
+ showchan_help, complete_ch_3, &cli_show_channel_deprecated },
+
+ { { "channel", "debug", NULL },
+ handle_debugchan, "Enable debugging on a channel",
+ debugchan_help, complete_ch_3, &cli_debug_channel_deprecated },
+
+ { { "channel", "nodebug", NULL },
+ handle_nodebugchan, "Disable debugging on a channel",
+ nodebugchan_help, complete_ch_3, &cli_no_debug_channel_deprecated },
+
+ { { "core", "debug", NULL },
+ handle_debug, "Set level of debug chattiness",
+ debug_help, NULL, &cli_set_debug_deprecated },
+
+ { { "core", "nodebug", NULL },
+ handle_nodebug, "Turns off debug chattiness",
+ nodebug_help },
+
+ { { "core", "verbose", NULL },
+ handle_verbose, "Set level of verboseness",
+ verbose_help, NULL, &cli_set_verbose_deprecated },
+
+ { { "group", "list", "channels", NULL },
+ group_show_channels, "Display active channels with group(s)",
+ group_show_channels_help, NULL, &cli_group_show_channels_deprecated },
+
+ { { "help", NULL },
+ handle_help, "Display help list, or specific help on a command",
+ help_help, complete_help },
+
+ { { "logger", "mute", NULL },
+ handle_logger_mute, "Toggle logging output to a console",
+ logger_mute_help },
+
+ { { "module", "list", NULL },
+ handle_modlist, "List modules and info",
+ modlist_help, NULL, &cli_show_modules_deprecated },
+
+ { { "module", "list", "like", NULL },
+ handle_modlist, "List modules and info",
+ modlist_help, complete_mod_4, &cli_show_modules_like_deprecated },
+
+ { { "module", "load", NULL },
+ handle_load, "Load a module by name",
+ load_help, complete_fn, &cli_load_deprecated },
+
+ { { "module", "reload", NULL },
+ handle_reload, "Reload configuration",
+ reload_help, complete_mod_3, &cli_reload_deprecated },
+
+ { { "module", "unload", NULL },
+ handle_unload, "Unload a module by name",
+ unload_help, complete_mod_3_nr, &cli_unload_deprecated },
+
+ { { "show", "uptime", NULL },
+ handle_showuptime, "Show uptime information",
+ uptime_help },
+
+ { { "soft", "hangup", NULL },
+ handle_softhangup, "Request a hangup on a given channel",
+ softhangup_help, complete_ch_3 },
+};
+
/*! \brief initialize the _full_cmd string in * each of the builtins. */
void ast_builtins_init(void)
{
@@ -940,6 +1275,8 @@ void ast_builtins_init(void)
if (!e->_full_cmd)
ast_log(LOG_WARNING, "-- cannot allocate <%s>\n", buf);
}
+
+ ast_cli_register_multiple(cli_cli, sizeof(cli_cli) / sizeof(struct ast_cli_entry));
}
/*
@@ -1041,8 +1378,11 @@ static char *find_best(char *argv[])
return cmdline;
}
-int ast_cli_unregister(struct ast_cli_entry *e)
+static int __ast_cli_unregister(struct ast_cli_entry *e, struct ast_cli_entry *ed)
{
+ if (e->deprecate_cmd) {
+ __ast_cli_unregister(e->deprecate_cmd, e);
+ }
if (e->inuse) {
ast_log(LOG_WARNING, "Can't remove command that is in use\n");
} else {
@@ -1053,7 +1393,7 @@ int ast_cli_unregister(struct ast_cli_entry *e)
return 0;
}
-int ast_cli_register(struct ast_cli_entry *e)
+static int __ast_cli_register(struct ast_cli_entry *e, struct ast_cli_entry *ed)
{
struct ast_cli_entry *cur;
char fulle[80] ="";
@@ -1070,6 +1410,19 @@ int ast_cli_register(struct ast_cli_entry *e)
e->_full_cmd = ast_strdup(fulle);
if (!e->_full_cmd)
goto done;
+
+ if (ed) {
+ e->deprecated = 1;
+ e->summary = ed->summary;
+ e->usage = ed->usage;
+ /* XXX If command A deprecates command B, and command B deprecates command C...
+ Do we want to show command A or command B when telling the user to use new syntax?
+ This currently would show command A.
+ To show command B, you just need to always use ed->_full_cmd.
+ */
+ e->_deprecated_by = S_OR(ed->_deprecated_by, ed->_full_cmd);
+ }
+
lf = strlen(fulle);
AST_LIST_TRAVERSE_SAFE_BEGIN(&helpers, cur, list) {
int len = strlen(cur->_full_cmd);
@@ -1088,10 +1441,27 @@ int ast_cli_register(struct ast_cli_entry *e)
done:
AST_LIST_UNLOCK(&helpers);
+
+ if (e->deprecate_cmd) {
+ /* This command deprecates another command. Register that one also. */
+ __ast_cli_register(e->deprecate_cmd, e);
+ }
return ret;
}
+/* wrapper function, so we can unregister deprecated commands recursively */
+int ast_cli_unregister(struct ast_cli_entry *e)
+{
+ return __ast_cli_unregister(e, NULL);
+}
+
+/* wrapper function, so we can register deprecated commands recursively */
+int ast_cli_register(struct ast_cli_entry *e)
+{
+ return __ast_cli_register(e, NULL);
+}
+
/*
* register/unregister an array of entries.
*/
@@ -1135,6 +1505,9 @@ static int help1(int fd, char *match[], int locked)
/* Hide commands that start with '_' */
if (e->_full_cmd[0] == '_')
continue;
+ /* Hide commands that are marked as deprecated. */
+ if (e->deprecated)
+ continue;
if (match && strncasecmp(matchstr, e->_full_cmd, len))
continue;
ast_cli(fd, "%25.25s %s\n", e->_full_cmd, e->summary);
@@ -1378,6 +1751,14 @@ int ast_cli_command(int fd, const char *s)
else
ast_cli(fd, "Invalid usage, but no usage information available.\n");
break;
+ default:
+ AST_LIST_LOCK(&helpers);
+ if (e->deprecated == 1) {
+ ast_cli(fd, "The '%s' command is deprecated and will be removed in a future release. Please use '%s' instead.\n", e->_full_cmd, e->_deprecated_by);
+ e->deprecated = 2;
+ }
+ AST_LIST_UNLOCK(&helpers);
+ break;
}
} else
ast_cli(fd, "No such command '%s' (type 'help' for help)\n", find_best(argv));
diff --git a/main/config.c b/main/config.c
index 6d88aebec..ffd58b52b 100644
--- a/main/config.c
+++ b/main/config.c
@@ -1232,14 +1232,22 @@ static int config_command(int fd, int argc, char **argv)
}
static char show_config_help[] =
- "Usage: show config mappings\n"
+ "Usage: core list config mappings\n"
" Shows the filenames to config engines.\n";
-static struct ast_cli_entry config_command_struct = {
- { "show", "config", "mappings", NULL }, config_command, "Show Config mappings (file names to config engines)", show_config_help, NULL
+static struct ast_cli_entry cli_show_config_mappings_deprecated = {
+ { "show", "config", "mappings", NULL },
+ config_command, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_config[] = {
+ { { "core", "list", "config", "mappings", NULL },
+ config_command, "Display config mappings (file names to config engines)",
+ show_config_help, NULL, &cli_show_config_mappings_deprecated },
};
int register_config_cli()
{
- return ast_cli_register(&config_command_struct);
+ ast_cli_register_multiple(cli_config, sizeof(cli_config) / sizeof(struct ast_cli_entry));
+ return 0;
}
diff --git a/main/db.c b/main/db.c
index e64e0f521..b9c9115c2 100644
--- a/main/db.c
+++ b/main/db.c
@@ -494,23 +494,31 @@ static char database_deltree_usage[] =
" Deletes a family or specific keytree within a family\n"
"in the Asterisk database.\n";
-struct ast_cli_entry cli_database_show =
-{ { "database", "show", NULL }, database_show, "Shows database contents", database_show_usage };
+struct ast_cli_entry cli_database[] = {
+ { { "database", "show", NULL },
+ database_show, "Shows database contents",
+ database_show_usage },
-struct ast_cli_entry cli_database_showkey =
-{ { "database", "showkey", NULL }, database_showkey, "Shows database contents", database_showkey_usage };
+ { { "database", "showkey", NULL },
+ database_showkey, "Shows database contents",
+ database_showkey_usage },
-struct ast_cli_entry cli_database_get =
-{ { "database", "get", NULL }, database_get, "Gets database value", database_get_usage };
+ { { "database", "get", NULL },
+ database_get, "Gets database value",
+ database_get_usage },
-struct ast_cli_entry cli_database_put =
-{ { "database", "put", NULL }, database_put, "Adds/updates database value", database_put_usage };
+ { { "database", "put", NULL },
+ database_put, "Adds/updates database value",
+ database_put_usage },
-struct ast_cli_entry cli_database_del =
-{ { "database", "del", NULL }, database_del, "Removes database key/value", database_del_usage };
+ { { "database", "del", NULL },
+ database_del, "Removes database key/value",
+ database_del_usage },
-struct ast_cli_entry cli_database_deltree =
-{ { "database", "deltree", NULL }, database_deltree, "Removes database keytree/values", database_deltree_usage };
+ { { "database", "deltree", NULL },
+ database_deltree, "Removes database keytree/values",
+ database_deltree_usage },
+};
static int manager_dbput(struct mansession *s, struct message *m)
{
@@ -581,12 +589,7 @@ static int manager_dbget(struct mansession *s, struct message *m)
int astdb_init(void)
{
dbinit();
- ast_cli_register(&cli_database_show);
- ast_cli_register(&cli_database_showkey);
- ast_cli_register(&cli_database_get);
- ast_cli_register(&cli_database_put);
- ast_cli_register(&cli_database_del);
- ast_cli_register(&cli_database_deltree);
+ ast_cli_register_multiple(cli_database, sizeof(cli_database) / sizeof(struct ast_cli_entry));
ast_manager_register("DBGet", EVENT_FLAG_SYSTEM, manager_dbget, "Get DB Entry");
ast_manager_register("DBPut", EVENT_FLAG_SYSTEM, manager_dbput, "Put DB Entry");
return 0;
diff --git a/main/dnsmgr.c b/main/dnsmgr.c
index 98b7f0905..0cc0d63f8 100644
--- a/main/dnsmgr.c
+++ b/main/dnsmgr.c
@@ -312,29 +312,23 @@ static int handle_cli_status(int fd, int argc, char *argv[])
}
static struct ast_cli_entry cli_reload = {
- .cmda = { "dnsmgr", "reload", NULL },
- .handler = handle_cli_reload,
- .summary = "Reloads the DNS manager configuration",
- .usage =
+ { "dnsmgr", "reload", NULL },
+ handle_cli_reload, "Reloads the DNS manager configuration",
"Usage: dnsmgr reload\n"
" Reloads the DNS manager configuration.\n"
};
static struct ast_cli_entry cli_refresh = {
- .cmda = { "dnsmgr", "refresh", NULL },
- .handler = handle_cli_refresh,
- .summary = "Performs an immediate refresh",
- .usage =
+ { "dnsmgr", "refresh", NULL },
+ handle_cli_refresh, "Performs an immediate refresh",
"Usage: dnsmgr refresh [pattern]\n"
" Peforms an immediate refresh of the managed DNS entries.\n"
" Optional regular expression pattern is used to filter the entries to refresh.\n",
};
static struct ast_cli_entry cli_status = {
- .cmda = { "dnsmgr", "status", NULL },
- .handler = handle_cli_status,
- .summary = "Display the DNS manager status",
- .usage =
+ { "dnsmgr", "status", NULL },
+ handle_cli_status, "Display the DNS manager status",
"Usage: dnsmgr status\n"
" Displays the DNS manager status.\n"
};
diff --git a/main/file.c b/main/file.c
index 101b9ac66..f130b99c8 100644
--- a/main/file.c
+++ b/main/file.c
@@ -1148,17 +1148,23 @@ static int show_file_formats(int fd, int argc, char *argv[])
#undef FORMAT2
}
-struct ast_cli_entry show_file =
-{
+char show_file_formats_usage[] =
+"Usage: core list file formats\n"
+" Displays currently registered file formats (if any)\n";
+
+struct ast_cli_entry cli_show_file_formats_deprecated = {
{ "show", "file", "formats" },
- show_file_formats,
- "Displays file formats",
- "Usage: show file formats\n"
- " displays currently registered file formats (if any)\n"
+ show_file_formats, NULL,
+ NULL };
+
+struct ast_cli_entry cli_file[] = {
+ { { "file", "list", "formats" },
+ show_file_formats, "Displays file formats",
+ show_file_formats_usage, NULL, &cli_show_file_formats_deprecated },
};
int ast_file_init(void)
{
- ast_cli_register(&show_file);
+ ast_cli_register_multiple(cli_file, sizeof(cli_file) / sizeof(struct ast_cli_entry));
return 0;
}
diff --git a/main/frame.c b/main/frame.c
index 5650df475..07714e07f 100644
--- a/main/frame.c
+++ b/main/frame.c
@@ -595,7 +595,7 @@ char *ast_codec2str(int codec)
return ret;
}
-static int show_codecs(int fd, int argc, char *argv[])
+static int show_codecs_deprecated(int fd, int argc, char *argv[])
{
int i, found=0;
char hex[25];
@@ -639,11 +639,55 @@ static int show_codecs(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int show_codecs(int fd, int argc, char *argv[])
+{
+ int i, found=0;
+ char hex[25];
+
+ if ((argc < 3) || (argc > 4))
+ return RESULT_SHOWUSAGE;
+
+ if (!ast_opt_dont_warn)
+ ast_cli(fd, "Disclaimer: this command is for informational purposes only.\n"
+ "\tIt does not indicate anything about your configuration.\n");
+
+ ast_cli(fd, "%11s %9s %10s TYPE %8s %s\n","INT","BINARY","HEX","NAME","DESC");
+ ast_cli(fd, "--------------------------------------------------------------------------------\n");
+ if ((argc == 3) || (!strcasecmp(argv[3],"audio"))) {
+ found = 1;
+ for (i=0;i<12;i++) {
+ snprintf(hex,25,"(0x%x)",1<<i);
+ ast_cli(fd, "%11u (1 << %2d) %10s audio %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
+ }
+ }
+
+ if ((argc == 3) || (!strcasecmp(argv[3],"image"))) {
+ found = 1;
+ for (i=16;i<18;i++) {
+ snprintf(hex,25,"(0x%x)",1<<i);
+ ast_cli(fd, "%11u (1 << %2d) %10s image %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
+ }
+ }
+
+ if ((argc == 3) || (!strcasecmp(argv[3],"video"))) {
+ found = 1;
+ for (i=18;i<22;i++) {
+ snprintf(hex,25,"(0x%x)",1<<i);
+ ast_cli(fd, "%11u (1 << %2d) %10s video %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
+ }
+ }
+
+ if (! found)
+ return RESULT_SHOWUSAGE;
+ else
+ return RESULT_SUCCESS;
+}
+
static char frame_show_codecs_usage[] =
-"Usage: show [audio|video|image] codecs\n"
+"Usage: core list codecs [audio|video|image]\n"
" Displays codec mapping\n";
-static int show_codec_n(int fd, int argc, char *argv[])
+static int show_codec_n_deprecated(int fd, int argc, char *argv[])
{
int codec, i, found=0;
@@ -665,8 +709,30 @@ static int show_codec_n(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int show_codec_n(int fd, int argc, char *argv[])
+{
+ int codec, i, found=0;
+
+ if (argc != 4)
+ return RESULT_SHOWUSAGE;
+
+ if (sscanf(argv[3],"%d",&codec) != 1)
+ return RESULT_SHOWUSAGE;
+
+ for (i = 0; i < 32; i++)
+ if (codec & (1 << i)) {
+ found = 1;
+ ast_cli(fd, "%11u (1 << %2d) %s\n",1 << i,i,ast_codec2str(1<<i));
+ }
+
+ if (!found)
+ ast_cli(fd, "Codec %d not found\n", codec);
+
+ return RESULT_SUCCESS;
+}
+
static char frame_show_codec_n_usage[] =
-"Usage: show codec <number>\n"
+"Usage: core show codec <number>\n"
" Displays codec mapping\n";
/*! Dump a frame for debugging purposes */
@@ -851,7 +917,7 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
#ifdef TRACE_FRAMES
-static int show_frame_stats(int fd, int argc, char *argv[])
+static int show_frame_stats_deprecated(int fd, int argc, char *argv[])
{
struct ast_frame *f;
int x=1;
@@ -868,27 +934,92 @@ static int show_frame_stats(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int show_frame_stats(int fd, int argc, char *argv[])
+{
+ struct ast_frame *f;
+ int x=1;
+ if (argc != 4)
+ return RESULT_SHOWUSAGE;
+ AST_LIST_LOCK(&headerlist);
+ ast_cli(fd, " Framer Statistics \n");
+ ast_cli(fd, "---------------------------\n");
+ ast_cli(fd, "Total allocated headers: %d\n", headers);
+ ast_cli(fd, "Queue Dump:\n");
+ AST_LIST_TRAVERSE(&headerlist, f, frame_list)
+ ast_cli(fd, "%d. Type %d, subclass %d from %s\n", x++, f->frametype, f->subclass, f->src ? f->src : "<Unknown>");
+ AST_LIST_UNLOCK(&headerlist);
+ return RESULT_SUCCESS;
+}
+
static char frame_stats_usage[] =
-"Usage: show frame stats\n"
+"Usage: core show frame stats\n"
" Displays debugging statistics from framer\n";
#endif
/* Builtin Asterisk CLI-commands for debugging */
+static struct ast_cli_entry cli_show_codecs = {
+ { "show", "codecs", NULL },
+ show_codecs_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_show_audio_codecs = {
+ { "show", "audio", "codecs", NULL },
+ show_codecs_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_show_video_codecs = {
+ { "show", "video", "codecs", NULL },
+ show_codecs_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_show_image_codecs = {
+ { "show", "image", "codecs", NULL },
+ show_codecs_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_show_codec = {
+ { "show", "codec", NULL },
+ show_codec_n_deprecated, NULL,
+ NULL };
+
+#ifdef TRACE_FRAMES
+static struct ast_cli_entry cli_show_frame_stats = {
+ { "show", "frame", "stats", NULL },
+ show_frame_stats, NULL,
+ NULL };
+#endif
+
static struct ast_cli_entry my_clis[] = {
-{ { "show", "codecs", NULL }, show_codecs, "Shows codecs", frame_show_codecs_usage },
-{ { "show", "audio", "codecs", NULL }, show_codecs, "Shows audio codecs", frame_show_codecs_usage },
-{ { "show", "video", "codecs", NULL }, show_codecs, "Shows video codecs", frame_show_codecs_usage },
-{ { "show", "image", "codecs", NULL }, show_codecs, "Shows image codecs", frame_show_codecs_usage },
-{ { "show", "codec", NULL }, show_codec_n, "Shows a specific codec", frame_show_codec_n_usage },
+ { { "core", "list", "codecs", NULL },
+ show_codecs, "Displays a list of codecs",
+ frame_show_codecs_usage, NULL, &cli_show_codecs },
+
+ { { "core", "list", "codecs", "audio", NULL },
+ show_codecs, "Displays a list of audio codecs",
+ frame_show_codecs_usage, NULL, &cli_show_audio_codecs },
+
+ { { "core", "list", "codecs", "video", NULL },
+ show_codecs, "Displays a list of video codecs",
+ frame_show_codecs_usage, NULL, &cli_show_video_codecs },
+
+ { { "core", "list", "codecs", "image", NULL },
+ show_codecs, "Displays a list of image codecs",
+ frame_show_codecs_usage, NULL, &cli_show_image_codecs },
+
+ { { "core", "show", "codec", NULL },
+ show_codec_n, "Shows a specific codec",
+ frame_show_codec_n_usage, NULL, &cli_show_codec },
+
#ifdef TRACE_FRAMES
-{ { "show", "frame", "stats", NULL }, show_frame_stats, "Shows frame statistics", frame_stats_usage },
+ { { "core", "show", "frame", "stats", NULL },
+ show_frame_stats, "Shows frame statistics",
+ frame_stats_usage, NULL, &cli_show_frame_stats },
#endif
};
-
int init_framer(void)
{
- ast_cli_register_multiple(my_clis, sizeof(my_clis)/sizeof(my_clis[0]) );
+ ast_cli_register_multiple(my_clis, sizeof(my_clis) / sizeof(struct ast_cli_entry));
return 0;
}
diff --git a/main/http.c b/main/http.c
index 230fec9af..9666539c7 100644
--- a/main/http.c
+++ b/main/http.c
@@ -681,18 +681,24 @@ int ast_http_reload(void)
}
static char show_http_help[] =
-"Usage: http show status\n"
-" Shows status of internal HTTP engine\n";
-
-static struct ast_cli_entry http_cli[] = {
- { { "http", "show", "status", NULL }, handle_show_http,
- "Display HTTP server status", show_http_help },
+"Usage: http list status\n"
+" Lists status of internal HTTP engine\n";
+
+static struct ast_cli_entry cli_http_show_status_deprecated = {
+ { "http", "show", "status", NULL },
+ handle_show_http, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_http[] = {
+ { { "http", "list", "status", NULL },
+ handle_show_http, "Display HTTP server status",
+ show_http_help, NULL, &cli_http_show_status_deprecated },
};
int ast_http_init(void)
{
ast_http_uri_link(&statusuri);
ast_http_uri_link(&staticuri);
- ast_cli_register_multiple(http_cli, sizeof(http_cli) / sizeof(http_cli[0]));
+ ast_cli_register_multiple(cli_http, sizeof(cli_http) / sizeof(struct ast_cli_entry));
return __ast_http_load(0);
}
diff --git a/main/image.c b/main/image.c
index ff67c0340..377ce9208 100644
--- a/main/image.c
+++ b/main/image.c
@@ -46,6 +46,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/cli.h"
#include "asterisk/lock.h"
+/* XXX Why don't we just use the formats struct for this? */
static AST_LIST_HEAD_STATIC(imagers, ast_imager);
int ast_image_register(struct ast_imager *img)
@@ -165,7 +166,6 @@ struct ast_frame *ast_read_image(char *filename, const char *preflang, int forma
return f;
}
-
int ast_send_image(struct ast_channel *chan, char *filename)
{
struct ast_frame *f;
@@ -180,7 +180,7 @@ int ast_send_image(struct ast_channel *chan, char *filename)
return res;
}
-static int show_image_formats(int fd, int argc, char *argv[])
+static int show_image_formats_deprecated(int fd, int argc, char *argv[])
{
#define FORMAT "%10s %10s %50s %10s\n"
#define FORMAT2 "%10s %10s %50s %10s\n"
@@ -193,18 +193,33 @@ static int show_image_formats(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-struct ast_cli_entry show_images =
+static int show_image_formats(int fd, int argc, char *argv[])
{
+#define FORMAT "%10s %10s %50s %10s\n"
+#define FORMAT2 "%10s %10s %50s %10s\n"
+ struct ast_imager *i;
+ if (argc != 4)
+ return RESULT_SHOWUSAGE;
+ ast_cli(fd, FORMAT, "Name", "Extensions", "Description", "Format");
+ AST_LIST_TRAVERSE(&imagers, i, list)
+ ast_cli(fd, FORMAT2, i->name, i->exts, i->desc, ast_getformatname(i->format));
+ return RESULT_SUCCESS;
+}
+
+struct ast_cli_entry cli_show_image_formats_deprecated = {
{ "show", "image", "formats" },
- show_image_formats,
- "Displays image formats",
-"Usage: show image formats\n"
-" displays currently registered image formats (if any)\n"
+ show_image_formats_deprecated, NULL,
+ NULL };
+
+struct ast_cli_entry cli_image[] = {
+ { { "file", "list", "formats", "image" },
+ show_image_formats, "Displays image formats",
+ "Usage: file list formats image\n"
+ " displays currently registered image formats (if any)\n", NULL, &cli_show_image_formats_deprecated },
};
-
int ast_image_init(void)
{
- return ast_cli_register(&show_images);
+ ast_cli_register_multiple(cli_image, sizeof(cli_image) / sizeof(struct ast_cli_entry));
+ return 0;
}
-
diff --git a/main/logger.c b/main/logger.c
index e0f88a10e..c9dbf4dea 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -554,23 +554,27 @@ static char logger_rotate_help[] =
" Rotates and Reopens the log files.\n";
static char logger_show_channels_help[] =
-"Usage: logger show channels\n"
-" Show configured logger channels.\n";
+"Usage: logger list channels\n"
+" List configured logger channels.\n";
-static struct ast_cli_entry logger_show_channels_cli =
- { { "logger", "show", "channels", NULL },
+static struct ast_cli_entry cli_logger_show_channels_deprecated = {
+ { "logger", "show", "channels", NULL },
+ handle_logger_show_channels, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_logger[] = {
+ { { "logger", "list", "channels", NULL },
handle_logger_show_channels, "List configured log channels",
- logger_show_channels_help };
+ logger_show_channels_help, NULL, &cli_logger_show_channels_deprecated },
-static struct ast_cli_entry reload_logger_cli =
{ { "logger", "reload", NULL },
handle_logger_reload, "Reopens the log files",
- logger_reload_help };
+ logger_reload_help },
-static struct ast_cli_entry rotate_logger_cli =
{ { "logger", "rotate", NULL },
handle_logger_rotate, "Rotates and reopens the log files",
- logger_rotate_help };
+ logger_rotate_help },
+};
static int handle_SIGXFSZ(int sig)
{
@@ -587,10 +591,8 @@ int init_logger(void)
/* auto rotate if sig SIGXFSZ comes a-knockin */
(void) signal(SIGXFSZ,(void *) handle_SIGXFSZ);
- /* register the relaod logger cli command */
- ast_cli_register(&reload_logger_cli);
- ast_cli_register(&rotate_logger_cli);
- ast_cli_register(&logger_show_channels_cli);
+ /* register the logger cli commands */
+ ast_cli_register_multiple(cli_logger, sizeof(cli_logger) / sizeof(struct ast_cli_entry));
mkdir((char *)ast_config_AST_LOG_DIR, 0755);
diff --git a/main/manager.c b/main/manager.c
index 90719a0f9..ef72c7c11 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -478,38 +478,60 @@ static int handle_showmaneventq(int fd, int argc, char *argv[])
}
static char showmancmd_help[] =
-"Usage: show manager command <actionname>\n"
+"Usage: manager show command <actionname>\n"
" Shows the detailed description for a specific Asterisk manager interface command.\n";
static char showmancmds_help[] =
-"Usage: show manager commands\n"
+"Usage: manager list commands\n"
" Prints a listing of all the available Asterisk manager interface commands.\n";
static char showmanconn_help[] =
-"Usage: show manager connected\n"
+"Usage: manager list connected\n"
" Prints a listing of the users that are currently connected to the\n"
"Asterisk manager interface.\n";
static char showmaneventq_help[] =
-"Usage: show manager eventq\n"
+"Usage: manager list eventq\n"
" Prints a listing of all events pending in the Asterisk manger\n"
"event queue.\n";
-static struct ast_cli_entry show_mancmd_cli =
- { { "show", "manager", "command", NULL },
- handle_showmancmd, "Show a manager interface command", showmancmd_help, complete_show_mancmd };
-
-static struct ast_cli_entry show_mancmds_cli =
- { { "show", "manager", "commands", NULL },
- handle_showmancmds, "List manager interface commands", showmancmds_help };
-
-static struct ast_cli_entry show_manconn_cli =
- { { "show", "manager", "connected", NULL },
- handle_showmanconn, "Show connected manager interface users", showmanconn_help };
-
-static struct ast_cli_entry show_maneventq_cli =
- { { "show", "manager", "eventq", NULL },
- handle_showmaneventq, "Show manager interface queued events", showmaneventq_help };
+static struct ast_cli_entry cli_show_manager_command_deprecated = {
+ { "show", "manager", "command", NULL },
+ handle_showmancmd, NULL,
+ NULL, complete_show_mancmd };
+
+static struct ast_cli_entry cli_show_manager_commands_deprecated = {
+ { "show", "manager", "commands", NULL },
+ handle_showmancmds, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_show_manager_connected_deprecated = {
+ { "show", "manager", "connected", NULL },
+ handle_showmanconn, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_show_manager_eventq_deprecated = {
+ { "show", "manager", "eventq", NULL },
+ handle_showmaneventq, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_manager[] = {
+ { { "manager", "show", "command", NULL },
+ handle_showmancmd, "Show a manager interface command",
+ showmancmd_help, complete_show_mancmd, &cli_show_manager_command_deprecated },
+
+ { { "manager", "list", "commands", NULL },
+ handle_showmancmds, "List manager interface commands",
+ showmancmds_help, NULL, &cli_show_manager_commands_deprecated },
+
+ { { "manager", "list", "connected", NULL },
+ handle_showmanconn, "List connected manager interface users",
+ showmanconn_help, NULL, &cli_show_manager_connected_deprecated },
+
+ { { "manager", "list", "eventq", NULL },
+ handle_showmaneventq, "List manager interface queued events",
+ showmaneventq_help, NULL, &cli_show_manager_eventq_deprecated },
+};
static void unuse_eventqent(struct eventqent *e)
{
@@ -2479,10 +2501,7 @@ int init_manager(void)
ast_manager_register2("UserEvent", EVENT_FLAG_USER, action_userevent, "Send an arbitrary event", mandescr_userevent);
ast_manager_register2("WaitEvent", 0, action_waitevent, "Wait for an event to occur", mandescr_waitevent);
- ast_cli_register(&show_mancmd_cli);
- ast_cli_register(&show_mancmds_cli);
- ast_cli_register(&show_manconn_cli);
- ast_cli_register(&show_maneventq_cli);
+ ast_cli_register_multiple(cli_manager, sizeof(cli_manager) / sizeof(struct ast_cli_entry));
ast_extension_state_add(NULL, NULL, manager_state_cb, NULL);
registered = 1;
/* Append placeholder event so master_eventq never runs dry */
diff --git a/main/pbx.c b/main/pbx.c
index f07ac5875..977a284f1 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -1211,7 +1211,7 @@ void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, c
/*! \brief CLI function to show installed custom functions
\addtogroup CLI_functions
*/
-static int handle_show_functions(int fd, int argc, char *argv[])
+static int handle_show_functions_deprecated(int fd, int argc, char *argv[])
{
struct ast_custom_function *acf;
int count_acf = 0;
@@ -1238,8 +1238,35 @@ static int handle_show_functions(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int handle_show_functions(int fd, int argc, char *argv[])
+{
+ struct ast_custom_function *acf;
+ int count_acf = 0;
+ int like = 0;
-static int handle_show_function(int fd, int argc, char *argv[])
+ if (argc == 5 && (!strcmp(argv[3], "like")) ) {
+ like = 1;
+ } else if (argc != 3) {
+ return RESULT_SHOWUSAGE;
+ }
+
+ ast_cli(fd, "%s Custom Functions:\n--------------------------------------------------------------------------------\n", like ? "Matching" : "Installed");
+
+ AST_LIST_LOCK(&acf_root);
+ AST_LIST_TRAVERSE(&acf_root, acf, acflist) {
+ if (!like || strstr(acf->name, argv[4])) {
+ count_acf++;
+ ast_cli(fd, "%-20.20s %-35.35s %s\n", acf->name, acf->syntax, acf->synopsis);
+ }
+ }
+ AST_LIST_UNLOCK(&acf_root);
+
+ ast_cli(fd, "%d %scustom functions installed.\n", count_acf, like ? "matching " : "");
+
+ return RESULT_SUCCESS;
+}
+
+static int handle_show_function_deprecated(int fd, int argc, char *argv[])
{
struct ast_custom_function *acf;
/* Maximum number of characters added by terminal coloring is 22 */
@@ -1295,6 +1322,62 @@ static int handle_show_function(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int handle_show_function(int fd, int argc, char *argv[])
+{
+ struct ast_custom_function *acf;
+ /* Maximum number of characters added by terminal coloring is 22 */
+ char infotitle[64 + AST_MAX_APP + 22], syntitle[40], destitle[40];
+ char info[64 + AST_MAX_APP], *synopsis = NULL, *description = NULL;
+ char stxtitle[40], *syntax = NULL;
+ int synopsis_size, description_size, syntax_size;
+
+ if (argc < 4)
+ return RESULT_SHOWUSAGE;
+
+ if (!(acf = ast_custom_function_find(argv[3]))) {
+ ast_cli(fd, "No function by that name registered.\n");
+ return RESULT_FAILURE;
+
+ }
+
+ if (acf->synopsis)
+ synopsis_size = strlen(acf->synopsis) + 23;
+ else
+ synopsis_size = strlen("Not available") + 23;
+ synopsis = alloca(synopsis_size);
+
+ if (acf->desc)
+ description_size = strlen(acf->desc) + 23;
+ else
+ description_size = strlen("Not available") + 23;
+ description = alloca(description_size);
+
+ if (acf->syntax)
+ syntax_size = strlen(acf->syntax) + 23;
+ else
+ syntax_size = strlen("Not available") + 23;
+ syntax = alloca(syntax_size);
+
+ snprintf(info, 64 + AST_MAX_APP, "\n -= Info about function '%s' =- \n\n", acf->name);
+ term_color(infotitle, info, COLOR_MAGENTA, 0, 64 + AST_MAX_APP + 22);
+ term_color(stxtitle, "[Syntax]\n", COLOR_MAGENTA, 0, 40);
+ term_color(syntitle, "[Synopsis]\n", COLOR_MAGENTA, 0, 40);
+ term_color(destitle, "[Description]\n", COLOR_MAGENTA, 0, 40);
+ term_color(syntax,
+ acf->syntax ? acf->syntax : "Not available",
+ COLOR_CYAN, 0, syntax_size);
+ term_color(synopsis,
+ acf->synopsis ? acf->synopsis : "Not available",
+ COLOR_CYAN, 0, synopsis_size);
+ term_color(description,
+ acf->desc ? acf->desc : "Not available",
+ COLOR_CYAN, 0, description_size);
+
+ ast_cli(fd,"%s%s%s\n\n%s%s\n\n%s%s\n", infotitle, stxtitle, syntax, syntitle, synopsis, destitle, description);
+
+ return RESULT_SUCCESS;
+}
+
static char *complete_show_function(const char *line, const char *word, int pos, int state)
{
struct ast_custom_function *acf;
@@ -2882,51 +2965,46 @@ void ast_unregister_switch(struct ast_switch *sw)
/*
* Help for CLI commands ...
*/
-static char show_application_help[] =
-"Usage: show application <application> [<application> [<application> [...]]]\n"
-" Describes a particular application.\n";
-
-static char show_functions_help[] =
-"Usage: show functions [like <text>]\n"
-" List builtin functions, optionally only those matching a given string\n";
-
-static char show_function_help[] =
-"Usage: show function <function>\n"
-" Describe a particular dialplan function.\n";
-
static char show_applications_help[] =
-"Usage: show applications [{like|describing} <text>]\n"
+"Usage: core list applications [{like|describing} <text>]\n"
" List applications which are currently available.\n"
" If 'like', <text> will be a substring of the app name\n"
" If 'describing', <text> will be a substring of the description\n";
-static char show_dialplan_help[] =
-"Usage: show dialplan [exten@][context]\n"
-" Show dialplan\n";
+static char show_functions_help[] =
+"Usage: core list functions [like <text>]\n"
+" List builtin functions, optionally only those matching a given string\n";
static char show_switches_help[] =
-"Usage: show switches\n"
-" Show registered switches\n";
+"Usage: core list switches\n"
+" List registered switches\n";
static char show_hints_help[] =
-"Usage: show hints\n"
-" Show registered hints\n";
+"Usage: core list hints\n"
+" List registered hints\n";
static char show_globals_help[] =
-"Usage: show globals\n"
-" Show current global dialplan variables and their values\n";
+"Usage: core list globals\n"
+" List current global dialplan variables and their values\n";
+
+static char show_application_help[] =
+"Usage: core show application <application> [<application> [<application> [...]]]\n"
+" Describes a particular application.\n";
+
+static char show_function_help[] =
+"Usage: core show function <function>\n"
+" Describe a particular dialplan function.\n";
+
+static char show_dialplan_help[] =
+"Usage: dialplan show [exten@][context]\n"
+" Show dialplan\n";
static char set_global_help[] =
-"Usage: set global <name> <value>\n"
+"Usage: core set global <name> <value>\n"
" Set global dialplan variable <name> to <value>\n";
/*
- * IMPLEMENTATION OF CLI FUNCTIONS IS IN THE SAME ORDER AS COMMANDS HELPS
- *
- */
-
-/*
* \brief 'show application' CLI command implementation functions ...
*/
@@ -2955,7 +3033,7 @@ static char *complete_show_application(const char *line, const char *word, int p
return ret;
}
-static int handle_show_application(int fd, int argc, char *argv[])
+static int handle_show_application_deprecated(int fd, int argc, char *argv[])
{
struct ast_app *a;
int app, no_registered_app = 1;
@@ -3025,6 +3103,76 @@ static int handle_show_application(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int handle_show_application(int fd, int argc, char *argv[])
+{
+ struct ast_app *a;
+ int app, no_registered_app = 1;
+
+ if (argc < 4)
+ return RESULT_SHOWUSAGE;
+
+ /* ... go through all applications ... */
+ AST_LIST_LOCK(&apps);
+ AST_LIST_TRAVERSE(&apps, a, list) {
+ /* ... compare this application name with all arguments given
+ * to 'show application' command ... */
+ for (app = 3; app < argc; app++) {
+ if (!strcasecmp(a->name, argv[app])) {
+ /* Maximum number of characters added by terminal coloring is 22 */
+ char infotitle[64 + AST_MAX_APP + 22], syntitle[40], destitle[40];
+ char info[64 + AST_MAX_APP], *synopsis = NULL, *description = NULL;
+ int synopsis_size, description_size;
+
+ no_registered_app = 0;
+
+ if (a->synopsis)
+ synopsis_size = strlen(a->synopsis) + 23;
+ else
+ synopsis_size = strlen("Not available") + 23;
+ synopsis = alloca(synopsis_size);
+
+ if (a->description)
+ description_size = strlen(a->description) + 23;
+ else
+ description_size = strlen("Not available") + 23;
+ description = alloca(description_size);
+
+ if (synopsis && description) {
+ snprintf(info, 64 + AST_MAX_APP, "\n -= Info about application '%s' =- \n\n", a->name);
+ term_color(infotitle, info, COLOR_MAGENTA, 0, 64 + AST_MAX_APP + 22);
+ term_color(syntitle, "[Synopsis]\n", COLOR_MAGENTA, 0, 40);
+ term_color(destitle, "[Description]\n", COLOR_MAGENTA, 0, 40);
+ term_color(synopsis,
+ a->synopsis ? a->synopsis : "Not available",
+ COLOR_CYAN, 0, synopsis_size);
+ term_color(description,
+ a->description ? a->description : "Not available",
+ COLOR_CYAN, 0, description_size);
+
+ ast_cli(fd,"%s%s%s\n\n%s%s\n", infotitle, syntitle, synopsis, destitle, description);
+ } else {
+ /* ... one of our applications, show info ...*/
+ ast_cli(fd,"\n -= Info about application '%s' =- \n\n"
+ "[Synopsis]\n %s\n\n"
+ "[Description]\n%s\n",
+ a->name,
+ a->synopsis ? a->synopsis : "Not available",
+ a->description ? a->description : "Not available");
+ }
+ }
+ }
+ }
+ AST_LIST_UNLOCK(&apps);
+
+ /* we found at least one app? no? */
+ if (no_registered_app) {
+ ast_cli(fd, "Your application(s) is (are) not registered\n");
+ return RESULT_FAILURE;
+ }
+
+ return RESULT_SUCCESS;
+}
+
/*! \brief handle_show_hints: CLI support for listing registred dial plan hints */
static int handle_show_hints(int fd, int argc, char *argv[])
{
@@ -3082,7 +3230,7 @@ static int handle_show_switches(int fd, int argc, char *argv[])
/*
* 'show applications' CLI command implementation functions ...
*/
-static int handle_show_applications(int fd, int argc, char *argv[])
+static int handle_show_applications_deprecated(int fd, int argc, char *argv[])
{
struct ast_app *a;
int like = 0, describing = 0;
@@ -3150,14 +3298,89 @@ static int handle_show_applications(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int handle_show_applications(int fd, int argc, char *argv[])
+{
+ struct ast_app *a;
+ int like = 0, describing = 0;
+ int total_match = 0; /* Number of matches in like clause */
+ int total_apps = 0; /* Number of apps registered */
-static char *complete_show_applications(const char *line, const char *word, int pos, int state)
+ AST_LIST_LOCK(&apps);
+
+ if (AST_LIST_EMPTY(&apps)) {
+ ast_cli(fd, "There are no registered applications\n");
+ AST_LIST_UNLOCK(&apps);
+ return -1;
+ }
+
+ /* core list applications like <keyword> */
+ if ((argc == 5) && (!strcmp(argv[3], "like"))) {
+ like = 1;
+ } else if ((argc > 4) && (!strcmp(argv[3], "describing"))) {
+ describing = 1;
+ }
+
+ /* core list applications describing <keyword1> [<keyword2>] [...] */
+ if ((!like) && (!describing)) {
+ ast_cli(fd, " -= Registered Asterisk Applications =-\n");
+ } else {
+ ast_cli(fd, " -= Matching Asterisk Applications =-\n");
+ }
+
+ AST_LIST_TRAVERSE(&apps, a, list) {
+ int printapp = 0;
+ total_apps++;
+ if (like) {
+ if (strcasestr(a->name, argv[4])) {
+ printapp = 1;
+ total_match++;
+ }
+ } else if (describing) {
+ if (a->description) {
+ /* Match all words on command line */
+ int i;
+ printapp = 1;
+ for (i = 4; i < argc; i++) {
+ if (!strcasestr(a->description, argv[i])) {
+ printapp = 0;
+ } else {
+ total_match++;
+ }
+ }
+ }
+ } else {
+ printapp = 1;
+ }
+
+ if (printapp) {
+ ast_cli(fd," %20s: %s\n", a->name, a->synopsis ? a->synopsis : "<Synopsis not available>");
+ }
+ }
+ if ((!like) && (!describing)) {
+ ast_cli(fd, " -= %d Applications Registered =-\n",total_apps);
+ } else {
+ ast_cli(fd, " -= %d Applications Matching =-\n",total_match);
+ }
+
+ AST_LIST_UNLOCK(&apps);
+
+ return RESULT_SUCCESS;
+}
+
+static char *complete_show_applications_deprecated(const char *line, const char *word, int pos, int state)
{
static char* choices[] = { "like", "describing", NULL };
return (pos != 2) ? NULL : ast_cli_complete(word, choices, state);
}
+static char *complete_show_applications(const char *line, const char *word, int pos, int state)
+{
+ static char* choices[] = { "like", "describing", NULL };
+
+ return (pos != 3) ? NULL : ast_cli_complete(word, choices, state);
+}
+
/*
* 'show dialplan' CLI command implementation functions ...
*/
@@ -3434,7 +3657,7 @@ static int handle_show_globals(int fd, int argc, char *argv[])
}
/*! \brief CLI support for setting global variables */
-static int handle_set_global(int fd, int argc, char *argv[])
+static int handle_set_global_deprecated(int fd, int argc, char *argv[])
{
if (argc != 4)
return RESULT_SHOWUSAGE;
@@ -3446,29 +3669,103 @@ static int handle_set_global(int fd, int argc, char *argv[])
}
+static int handle_set_global(int fd, int argc, char *argv[])
+{
+ if (argc != 5)
+ return RESULT_SHOWUSAGE;
+
+ pbx_builtin_setvar_helper(NULL, argv[3], argv[4]);
+ ast_cli(fd, "\n -- Global variable %s set to %s\n", argv[3], argv[4]);
+
+ return RESULT_SUCCESS;
+}
+
+
/*
* CLI entries for upper commands ...
*/
+static struct ast_cli_entry cli_show_applications_deprecated = {
+ { "show", "applications", NULL },
+ handle_show_applications_deprecated, NULL,
+ NULL, complete_show_applications_deprecated };
+
+static struct ast_cli_entry cli_show_functions_deprecated = {
+ { "show", "functions", NULL },
+ handle_show_functions_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_show_switches_deprecated = {
+ { "show", "switches", NULL },
+ handle_show_switches, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_show_hints_deprecated = {
+ { "show", "hints", NULL },
+ handle_show_hints, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_show_globals_deprecated = {
+ { "show", "globals", NULL },
+ handle_show_globals, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_show_function_deprecated = {
+ { "show" , "function", NULL },
+ handle_show_function_deprecated, NULL,
+ NULL, complete_show_function };
+
+static struct ast_cli_entry cli_show_application_deprecated = {
+ { "show", "application", NULL },
+ handle_show_application_deprecated, NULL,
+ NULL, complete_show_application };
+
+static struct ast_cli_entry cli_show_dialplan_deprecated = {
+ { "show", "dialplan", NULL },
+ handle_show_dialplan, NULL,
+ NULL, complete_show_dialplan_context };
+
+static struct ast_cli_entry cli_set_global_deprecated = {
+ { "set", "global", NULL },
+ handle_set_global_deprecated, NULL,
+ NULL };
+
static struct ast_cli_entry pbx_cli[] = {
- { { "show", "applications", NULL }, handle_show_applications,
- "Shows registered dialplan applications", show_applications_help, complete_show_applications },
- { { "show", "functions", NULL }, handle_show_functions,
- "Shows registered dialplan functions", show_functions_help },
- { { "show" , "function", NULL }, handle_show_function,
- "Describe a specific dialplan function", show_function_help, complete_show_function },
- { { "show", "application", NULL }, handle_show_application,
- "Describe a specific dialplan application", show_application_help, complete_show_application },
- { { "show", "dialplan", NULL }, handle_show_dialplan,
- "Show dialplan", show_dialplan_help, complete_show_dialplan_context },
- { { "show", "switches", NULL }, handle_show_switches,
- "Show alternative switches", show_switches_help },
- { { "show", "hints", NULL }, handle_show_hints,
- "Show dialplan hints", show_hints_help },
- { { "show", "globals", NULL }, handle_show_globals,
- "Show global dialplan variables", show_globals_help },
- { { "set", "global", NULL }, handle_set_global,
- "Set global dialplan variable", set_global_help },
+ { { "core", "list", "applications", NULL },
+ handle_show_applications, "Shows registered dialplan applications",
+ show_applications_help, complete_show_applications, &cli_show_applications_deprecated },
+
+ { { "core", "list", "functions", NULL },
+ handle_show_functions, "Shows registered dialplan functions",
+ show_functions_help, NULL, &cli_show_functions_deprecated },
+
+ { { "core", "list", "switches", NULL },
+ handle_show_switches, "Show alternative switches",
+ show_switches_help, NULL, &cli_show_switches_deprecated },
+
+ { { "core", "list", "hints", NULL },
+ handle_show_hints, "Show dialplan hints",
+ show_hints_help, NULL, &cli_show_hints_deprecated },
+
+ { { "core", "list", "globals", NULL },
+ handle_show_globals, "Show global dialplan variables",
+ show_globals_help, NULL, &cli_show_globals_deprecated },
+
+ { { "core", "show" , "function", NULL },
+ handle_show_function, "Describe a specific dialplan function",
+ show_function_help, complete_show_function, &cli_show_function_deprecated },
+
+ { { "core", "show", "application", NULL },
+ handle_show_application, "Describe a specific dialplan application",
+ show_application_help, complete_show_application, &cli_show_application_deprecated },
+
+ { { "core", "set", "global", NULL },
+ handle_set_global, "Set global dialplan variable",
+ set_global_help, NULL, &cli_set_global_deprecated },
+
+ { { "dialplan", "show", NULL },
+ handle_show_dialplan, "Show dialplan",
+ show_dialplan_help, complete_show_dialplan_context, &cli_show_dialplan_deprecated },
};
int ast_unregister_application(const char *app)
@@ -5699,7 +5996,7 @@ int load_pbx(void)
ast_verbose( "Asterisk PBX Core Initializing\n");
ast_verbose( "Registering builtin applications:\n");
}
- ast_cli_register_multiple(pbx_cli, sizeof(pbx_cli) / sizeof(pbx_cli[0]));
+ ast_cli_register_multiple(pbx_cli, sizeof(pbx_cli) / sizeof(struct ast_cli_entry));
/* Register builtin applications */
for (x=0; x<sizeof(builtins) / sizeof(struct pbx_builtin); x++) {
diff --git a/main/rtp.c b/main/rtp.c
index 378fc8455..9813ff996 100644
--- a/main/rtp.c
+++ b/main/rtp.c
@@ -3161,7 +3161,7 @@ static int rtp_do_debug_ip(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static int rtcp_do_debug_ip(int fd, int argc, char *argv[])
+static int rtcp_do_debug_ip_deprecated(int fd, int argc, char *argv[])
{
struct hostent *hp;
struct ast_hostent ahp;
@@ -3191,6 +3191,36 @@ static int rtcp_do_debug_ip(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int rtcp_do_debug_ip(int fd, int argc, char *argv[])
+{
+ struct hostent *hp;
+ struct ast_hostent ahp;
+ int port = 0;
+ char *p, *arg;
+ if (argc != 4)
+ return RESULT_SHOWUSAGE;
+
+ arg = argv[3];
+ p = strstr(arg, ":");
+ if (p) {
+ *p = '\0';
+ p++;
+ port = atoi(p);
+ }
+ hp = ast_gethostbyname(arg, &ahp);
+ if (hp == NULL)
+ return RESULT_SHOWUSAGE;
+ rtcpdebugaddr.sin_family = AF_INET;
+ memcpy(&rtcpdebugaddr.sin_addr, hp->h_addr, sizeof(rtcpdebugaddr.sin_addr));
+ rtcpdebugaddr.sin_port = htons(port);
+ if (port == 0)
+ ast_cli(fd, "RTCP Debugging Enabled for IP: %s\n", ast_inet_ntoa(rtcpdebugaddr.sin_addr));
+ else
+ ast_cli(fd, "RTCP Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(rtcpdebugaddr.sin_addr), port);
+ rtcpdebug = 1;
+ return RESULT_SUCCESS;
+}
+
static int rtp_do_debug(int fd, int argc, char *argv[])
{
if (argc != 2) {
@@ -3204,10 +3234,22 @@ static int rtp_do_debug(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static int rtcp_do_debug(int fd, int argc, char *argv[]) {
+static int rtcp_do_debug_deprecated(int fd, int argc, char *argv[]) {
if (argc != 3) {
if (argc != 5)
return RESULT_SHOWUSAGE;
+ return rtcp_do_debug_ip_deprecated(fd, argc, argv);
+ }
+ rtcpdebug = 1;
+ memset(&rtcpdebugaddr,0,sizeof(rtcpdebugaddr));
+ ast_cli(fd, "RTCP Debugging Enabled\n");
+ return RESULT_SUCCESS;
+}
+
+static int rtcp_do_debug(int fd, int argc, char *argv[]) {
+ if (argc != 2) {
+ if (argc != 4)
+ return RESULT_SHOWUSAGE;
return rtcp_do_debug_ip(fd, argc, argv);
}
rtcpdebug = 1;
@@ -3216,7 +3258,7 @@ static int rtcp_do_debug(int fd, int argc, char *argv[]) {
return RESULT_SUCCESS;
}
-static int rtcp_do_stats(int fd, int argc, char *argv[]) {
+static int rtcp_do_stats_deprecated(int fd, int argc, char *argv[]) {
if (argc != 3) {
return RESULT_SHOWUSAGE;
}
@@ -3225,7 +3267,16 @@ static int rtcp_do_stats(int fd, int argc, char *argv[]) {
return RESULT_SUCCESS;
}
-static int rtp_no_debug(int fd, int argc, char *argv[])
+static int rtcp_do_stats(int fd, int argc, char *argv[]) {
+ if (argc != 2) {
+ return RESULT_SHOWUSAGE;
+ }
+ rtcpstats = 1;
+ ast_cli(fd, "RTCP Stats Enabled\n");
+ return RESULT_SUCCESS;
+}
+
+static int rtp_no_debug_deprecated(int fd, int argc, char *argv[])
{
if (argc != 3)
return RESULT_SHOWUSAGE;
@@ -3234,7 +3285,16 @@ static int rtp_no_debug(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static int rtcp_no_debug(int fd, int argc, char *argv[])
+static int rtp_no_debug(int fd, int argc, char *argv[])
+{
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
+ rtpdebug = 0;
+ ast_cli(fd,"RTP Debugging Disabled\n");
+ return RESULT_SUCCESS;
+}
+
+static int rtcp_no_debug_deprecated(int fd, int argc, char *argv[])
{
if (argc != 4)
return RESULT_SHOWUSAGE;
@@ -3243,7 +3303,16 @@ static int rtcp_no_debug(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static int rtcp_no_stats(int fd, int argc, char *argv[])
+static int rtcp_no_debug(int fd, int argc, char *argv[])
+{
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
+ rtcpdebug = 0;
+ ast_cli(fd,"RTCP Debugging Disabled\n");
+ return RESULT_SUCCESS;
+}
+
+static int rtcp_no_stats_deprecated(int fd, int argc, char *argv[])
{
if (argc != 4)
return RESULT_SHOWUSAGE;
@@ -3252,6 +3321,14 @@ static int rtcp_no_stats(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int rtcp_no_stats(int fd, int argc, char *argv[])
+{
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
+ rtcpstats = 0;
+ ast_cli(fd,"RTCP Stats Disabled\n");
+ return RESULT_SUCCESS;
+}
static int stun_do_debug(int fd, int argc, char *argv[])
{
@@ -3263,7 +3340,7 @@ static int stun_do_debug(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static int stun_no_debug(int fd, int argc, char *argv[])
+static int stun_no_debug_deprecated(int fd, int argc, char *argv[])
{
if (argc != 3)
return RESULT_SHOWUSAGE;
@@ -3272,13 +3349,21 @@ static int stun_no_debug(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int stun_no_debug(int fd, int argc, char *argv[])
+{
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
+ stundebug = 0;
+ ast_cli(fd,"STUN Debugging Disabled\n");
+ return RESULT_SUCCESS;
+}
static char debug_usage[] =
"Usage: rtp debug [ip host[:port]]\n"
" Enable dumping of all RTP packets to and from host.\n";
static char no_debug_usage[] =
- "Usage: rtp no debug\n"
+ "Usage: rtp nodebug\n"
" Disable all RTP debugging\n";
static char stun_debug_usage[] =
@@ -3286,55 +3371,101 @@ static char stun_debug_usage[] =
" Enable STUN (Simple Traversal of UDP through NATs) debugging\n";
static char stun_no_debug_usage[] =
- "Usage: stun no debug\n"
+ "Usage: stun nodebug\n"
" Disable STUN debugging\n";
-
-static struct ast_cli_entry cli_debug_ip =
-{{ "rtp", "debug", "ip", NULL } , rtp_do_debug, "Enable RTP debugging on IP", debug_usage };
-
-static struct ast_cli_entry cli_debug =
-{{ "rtp", "debug", NULL } , rtp_do_debug, "Enable RTP debugging", debug_usage };
-
-static struct ast_cli_entry cli_no_debug =
-{{ "rtp", "no", "debug", NULL } , rtp_no_debug, "Disable RTP debugging", no_debug_usage };
-
static char rtcp_debug_usage[] =
- "Usage: rtp rtcp debug [ip host[:port]]\n"
+ "Usage: rtcp debug [ip host[:port]]\n"
" Enable dumping of all RTCP packets to and from host.\n";
static char rtcp_no_debug_usage[] =
- "Usage: rtp rtcp no debug\n"
+ "Usage: rtcp nodebug\n"
" Disable all RTCP debugging\n";
static char rtcp_stats_usage[] =
- "Usage: rtp rtcp stats\n"
+ "Usage: rtcp stats\n"
" Enable dumping of RTCP stats.\n";
static char rtcp_no_stats_usage[] =
- "Usage: rtp rtcp no stats\n"
+ "Usage: rtcp nostats\n"
" Disable all RTCP stats\n";
-static struct ast_cli_entry cli_debug_ip_rtcp =
-{{ "rtp", "rtcp", "debug", "ip", NULL } , rtcp_do_debug, "Enable RTCP debugging on IP", rtcp_debug_usage };
-
-static struct ast_cli_entry cli_debug_rtcp =
-{{ "rtp", "rtcp", "debug", NULL } , rtcp_do_debug, "Enable RTCP debugging", rtcp_debug_usage };
-
-static struct ast_cli_entry cli_no_debug_rtcp =
-{{ "rtp", "rtcp", "no", "debug", NULL } , rtcp_no_debug, "Disable RTCP debugging", rtcp_no_debug_usage };
-
-static struct ast_cli_entry cli_stats_rtcp =
-{{ "rtp", "rtcp", "stats", NULL } , rtcp_do_stats, "Enable RTCP stats", rtcp_stats_usage };
-
-static struct ast_cli_entry cli_no_stats_rtcp =
-{{ "rtp", "rtcp", "no", "stats", NULL } , rtcp_no_stats, "Disable RTCP stats", rtcp_no_stats_usage };
-
-static struct ast_cli_entry cli_stun_debug =
-{{ "stun", "debug", NULL } , stun_do_debug, "Enable STUN debugging", stun_debug_usage };
-
-static struct ast_cli_entry cli_stun_no_debug =
-{{ "stun", "no", "debug", NULL } , stun_no_debug, "Disable STUN debugging", stun_no_debug_usage };
+static struct ast_cli_entry cli_rtp_no_debug_deprecated = {
+ { "rtp", "no", "debug", NULL },
+ rtp_no_debug_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_rtp_rtcp_debug_ip_deprecated = {
+ { "rtp", "rtcp", "debug", "ip", NULL },
+ rtcp_do_debug_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_rtp_rtcp_debug_deprecated = {
+ { "rtp", "rtcp", "debug", NULL },
+ rtcp_do_debug_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_rtp_rtcp_no_debug_deprecated = {
+ { "rtp", "rtcp", "no", "debug", NULL },
+ rtcp_no_debug_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_rtp_rtcp_stats_deprecated = {
+ { "rtp", "rtcp", "stats", NULL },
+ rtcp_do_stats_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_rtp_rtcp_no_stats_deprecated = {
+ { "rtp", "rtcp", "no", "stats", NULL },
+ rtcp_no_stats_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_stun_no_debug_deprecated = {
+ { "stun", "no", "debug", NULL },
+ stun_no_debug_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_rtp[] = {
+ { { "rtp", "debug", "ip", NULL },
+ rtp_do_debug, "Enable RTP debugging on IP",
+ debug_usage },
+
+ { { "rtp", "debug", NULL },
+ rtp_do_debug, "Enable RTP debugging",
+ debug_usage },
+
+ { { "rtp", "nodebug", NULL },
+ rtp_no_debug, "Disable RTP debugging",
+ no_debug_usage, NULL, &cli_rtp_no_debug_deprecated },
+
+ { { "rtcp", "debug", "ip", NULL },
+ rtcp_do_debug, "Enable RTCP debugging on IP",
+ rtcp_debug_usage, NULL, &cli_rtp_rtcp_debug_ip_deprecated },
+
+ { { "rtcp", "debug", NULL },
+ rtcp_do_debug, "Enable RTCP debugging",
+ rtcp_debug_usage, NULL, &cli_rtp_rtcp_debug_deprecated },
+
+ { { "rtcp", "nodebug", NULL },
+ rtcp_no_debug, "Disable RTCP debugging",
+ rtcp_no_debug_usage, NULL, &cli_rtp_rtcp_no_debug_deprecated },
+
+ { { "rtcp", "stats", NULL },
+ rtcp_do_stats, "Enable RTCP stats",
+ rtcp_stats_usage, NULL, &cli_rtp_rtcp_stats_deprecated },
+
+ { { "rtcp", "nostats", NULL },
+ rtcp_no_stats, "Disable RTCP stats",
+ rtcp_no_stats_usage, NULL, &cli_rtp_rtcp_no_stats_deprecated },
+
+ { { "stun", "debug", NULL },
+ stun_do_debug, "Enable STUN debugging",
+ stun_debug_usage },
+
+ { { "stun", "nodebug", NULL },
+ stun_no_debug, "Disable STUN debugging",
+ stun_no_debug_usage, NULL, &cli_stun_no_debug_deprecated },
+};
int ast_rtp_reload(void)
{
@@ -3403,19 +3534,7 @@ int ast_rtp_reload(void)
/*! \brief Initialize the RTP system in Asterisk */
void ast_rtp_init(void)
{
- ast_cli_register(&cli_debug);
- ast_cli_register(&cli_debug_ip);
- ast_cli_register(&cli_no_debug);
-
- ast_cli_register(&cli_debug_rtcp);
- ast_cli_register(&cli_debug_ip_rtcp);
- ast_cli_register(&cli_no_debug_rtcp);
-
- ast_cli_register(&cli_stats_rtcp);
- ast_cli_register(&cli_no_stats_rtcp);
-
- ast_cli_register(&cli_stun_debug);
- ast_cli_register(&cli_stun_no_debug);
+ ast_cli_register_multiple(cli_rtp, sizeof(cli_rtp) / sizeof(struct ast_cli_entry));
ast_rtp_reload();
}
diff --git a/main/translate.c b/main/translate.c
index 45b0292bd..77feabbac 100644
--- a/main/translate.c
+++ b/main/translate.c
@@ -475,7 +475,7 @@ static void rebuild_matrix(int samples)
}
/*! \brief CLI "show translation" command handler */
-static int show_translation(int fd, int argc, char *argv[])
+static int show_translation_deprecated(int fd, int argc, char *argv[])
{
#define SHOW_TRANS 12
int x, y, z;
@@ -544,16 +544,92 @@ static int show_translation(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int show_translation(int fd, int argc, char *argv[])
+{
+#define SHOW_TRANS 12
+ int x, y, z;
+ int curlen = 0, longest = 0;
+
+ if (argc > 5)
+ return RESULT_SHOWUSAGE;
+
+ AST_LIST_LOCK(&translators);
+
+ if (argv[3] && !strcasecmp(argv[3], "recalc")) {
+ z = argv[4] ? atoi(argv[4]) : 1;
+
+ if (z <= 0) {
+ ast_cli(fd, " C'mon let's be serious here... defaulting to 1.\n");
+ z = 1;
+ }
+
+ if (z > MAX_RECALC) {
+ ast_cli(fd, " Maximum limit of recalc exceeded by %d, truncating value to %d\n", z - MAX_RECALC, MAX_RECALC);
+ z = MAX_RECALC;
+ }
+ ast_cli(fd, " Recalculating Codec Translation (number of sample seconds: %d)\n\n", z);
+ rebuild_matrix(z);
+ }
+
+ ast_cli(fd, " Translation times between formats (in milliseconds) for one second of data\n");
+ ast_cli(fd, " Source Format (Rows) Destination Format (Columns)\n\n");
+ /* Get the length of the longest (usable?) codec name, so we know how wide the left side should be */
+ for (x = 0; x < SHOW_TRANS; x++) {
+ curlen = strlen(ast_getformatname(1 << (x + 1)));
+ if (curlen > longest)
+ longest = curlen;
+ }
+ for (x = -1; x < SHOW_TRANS; x++) {
+ char line[80];
+ char *buf = line;
+ size_t left = sizeof(line) - 1; /* one initial space */
+ /* next 2 lines run faster than using ast_build_string() */
+ *buf++ = ' ';
+ *buf = '\0';
+ for (y = -1; y < SHOW_TRANS; y++) {
+ curlen = strlen(ast_getformatname(1 << (y)));
+
+ if (x >= 0 && y >= 0 && tr_matrix[x][y].step) {
+ /* XXX 999 is a little hackish
+ We don't want this number being larger than the shortest (or current) codec
+ For now, that is "gsm" */
+ ast_build_string(&buf, &left, "%*d", curlen + 1, tr_matrix[x][y].cost > 999 ? 0 : tr_matrix[x][y].cost);
+ } else if (x == -1 && y >= 0) {
+ /* Top row - use a dynamic size */
+ ast_build_string(&buf, &left, "%*s", curlen + 1, ast_getformatname(1 << (x + y + 1)) );
+ } else if (y == -1 && x >= 0) {
+ /* Left column - use a static size. */
+ ast_build_string(&buf, &left, "%*s", longest, ast_getformatname(1 << (x + y + 1)) );
+ } else if (x >= 0 && y >= 0) {
+ ast_build_string(&buf, &left, "%*s", curlen + 1, "-");
+ } else {
+ ast_build_string(&buf, &left, "%*s", longest, "");
+ }
+ }
+ ast_build_string(&buf, &left, "\n");
+ ast_cli(fd, line);
+ }
+ AST_LIST_UNLOCK(&translators);
+ return RESULT_SUCCESS;
+}
static char show_trans_usage[] =
-"Usage: show translation [recalc] [<recalc seconds>]\n"
+"Usage: core show translation [recalc] [<recalc seconds>]\n"
" Displays known codec translators and the cost associated\n"
"with each conversion. If the argument 'recalc' is supplied along\n"
"with optional number of seconds to test a new test will be performed\n"
"as the chart is being displayed.\n";
-static struct ast_cli_entry show_trans =
-{ { "show", "translation", NULL }, show_translation, "Display translation matrix", show_trans_usage };
+static struct ast_cli_entry cli_show_translation_deprecated = {
+ { "show", "translation", NULL },
+ show_translation_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_translate[] = {
+ { { "core", "show", "translation", NULL },
+ show_translation, "Display translation matrix",
+ show_trans_usage, NULL, &cli_show_translation_deprecated },
+};
/*! \brief register codec translator */
int __ast_register_translator(struct ast_translator *t, struct ast_module *mod)
@@ -613,7 +689,7 @@ int __ast_register_translator(struct ast_translator *t, struct ast_module *mod)
}
AST_LIST_LOCK(&translators);
if (!added_cli) {
- ast_cli_register(&show_trans);
+ ast_cli_register_multiple(cli_translate, sizeof(cli_translate) / sizeof(struct ast_cli_entry));
added_cli++;
}
AST_LIST_INSERT_HEAD(&translators, t, list);
diff --git a/main/udptl.c b/main/udptl.c
index 1264c23fc..d21cfe981 100644
--- a/main/udptl.c
+++ b/main/udptl.c
@@ -1135,7 +1135,7 @@ static int udptl_do_debug(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static int udptl_no_debug(int fd, int argc, char *argv[])
+static int udptl_nodebug_deprecated(int fd, int argc, char *argv[])
{
if (argc !=3)
return RESULT_SHOWUSAGE;
@@ -1144,22 +1144,41 @@ static int udptl_no_debug(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int udptl_nodebug(int fd, int argc, char *argv[])
+{
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
+ udptldebug = 0;
+ ast_cli(fd,"UDPTL Debugging Disabled\n");
+ return RESULT_SUCCESS;
+}
+
static char debug_usage[] =
"Usage: udptl debug [ip host[:port]]\n"
" Enable dumping of all UDPTL packets to and from host.\n";
-static char no_debug_usage[] =
- "Usage: udptl no debug\n"
+static char nodebug_usage[] =
+ "Usage: udptl nodebug\n"
" Disable all UDPTL debugging\n";
-static struct ast_cli_entry cli_debug_ip =
-{{ "udptl", "debug", "ip", NULL } , udptl_do_debug, "Enable UDPTL debugging on IP", debug_usage };
+static struct ast_cli_entry cli_udptl_no_debug = {
+ { "udptl", "no", "debug", NULL },
+ udptl_nodebug_deprecated, NULL,
+ NULL };
-static struct ast_cli_entry cli_debug =
-{{ "udptl", "debug", NULL } , udptl_do_debug, "Enable UDPTL debugging", debug_usage };
+static struct ast_cli_entry cli_udptl[] = {
+ { { "udptl", "debug", NULL },
+ udptl_do_debug, "Enable UDPTL debugging",
+ debug_usage },
-static struct ast_cli_entry cli_no_debug =
-{{ "udptl", "no", "debug", NULL } , udptl_no_debug, "Disable UDPTL debugging", no_debug_usage };
+ { { "udptl", "debug", "ip", NULL },
+ udptl_do_debug, "Enable UDPTL debugging on IP",
+ debug_usage },
+
+ { { "udptl", "nodebug", NULL },
+ udptl_nodebug, "Disable UDPTL debugging",
+ nodebug_usage, NULL, &cli_udptl_no_debug },
+};
void ast_udptl_reload(void)
{
@@ -1239,8 +1258,6 @@ void ast_udptl_reload(void)
void ast_udptl_init(void)
{
- ast_cli_register(&cli_debug);
- ast_cli_register(&cli_debug_ip);
- ast_cli_register(&cli_no_debug);
+ ast_cli_register_multiple(cli_udptl, sizeof(cli_udptl) / sizeof(struct ast_cli_entry));
ast_udptl_reload();
}
diff --git a/pbx/pbx_ael.c b/pbx/pbx_ael.c
index c45f73601..cbef91f6a 100644
--- a/pbx/pbx_ael.c
+++ b/pbx/pbx_ael.c
@@ -3861,25 +3861,42 @@ static int ael2_reload(int fd, int argc, char *argv[])
return (pbx_load_module());
}
-static struct ast_cli_entry ael_cli[] = {
- { { "ael", "reload", NULL }, ael2_reload, "Reload AEL configuration"},
- { { "ael", "debug", "read", NULL }, ael2_debug_read, "Enable AEL read debug (does nothing)"},
- { { "ael", "debug", "tokens", NULL }, ael2_debug_tokens, "Enable AEL tokens debug (does nothing)"},
- { { "ael", "debug", "macros", NULL }, ael2_debug_macros, "Enable AEL macros debug (does nothing)"},
- { { "ael", "debug", "contexts", NULL }, ael2_debug_contexts, "Enable AEL contexts debug (does nothing)"},
- { { "ael", "no", "debug", NULL }, ael2_no_debug, "Disable AEL debug messages"},
+static struct ast_cli_entry cli_ael_no_debug = {
+ { "ael", "no", "debug", NULL },
+ ael2_no_debug, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_ael[] = {
+ { { "ael", "reload", NULL },
+ ael2_reload, "Reload AEL configuration" },
+
+ { { "ael", "debug", "read", NULL },
+ ael2_debug_read, "Enable AEL read debug (does nothing)" },
+
+ { { "ael", "debug", "tokens", NULL },
+ ael2_debug_tokens, "Enable AEL tokens debug (does nothing)" },
+
+ { { "ael", "debug", "macros", NULL },
+ ael2_debug_macros, "Enable AEL macros debug (does nothing)" },
+
+ { { "ael", "debug", "contexts", NULL },
+ ael2_debug_contexts, "Enable AEL contexts debug (does nothing)" },
+
+ { { "ael", "nodebug", NULL },
+ ael2_no_debug, "Disable AEL debug messages",
+ NULL, NULL, &cli_ael_no_debug },
};
static int unload_module(void)
{
ast_context_destroy(NULL, registrar);
- ast_cli_unregister_multiple(ael_cli, sizeof(ael_cli)/ sizeof(ael_cli[0]));
+ ast_cli_unregister_multiple(cli_ael, sizeof(cli_ael) / sizeof(struct ast_cli_entry));
return 0;
}
static int load_module(void)
{
- ast_cli_register_multiple(ael_cli, sizeof(ael_cli)/ sizeof(ael_cli[0]));
+ ast_cli_register_multiple(cli_ael, sizeof(cli_ael) / sizeof(struct ast_cli_entry));
return (pbx_load_module());
}
diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c
index e63ab74ae..801438ffd 100644
--- a/pbx/pbx_config.c
+++ b/pbx/pbx_config.c
@@ -58,55 +58,54 @@ static struct ast_context *local_contexts = NULL;
/*
* Help for commands provided by this module ...
*/
-static char context_dont_include_help[] =
-"Usage: dont include <context> in <context>\n"
-" Remove an included context from another context.\n";
-
-static char context_remove_extension_help[] =
-"Usage: remove extension exten@context [priority]\n"
-" Remove an extension from a given context. If a priority\n"
-" is given, only that specific priority from the given extension\n"
-" will be removed.\n";
-
-static char context_add_include_help[] =
-"Usage: include <context> in <context>\n"
-" Include a context in another context.\n";
-
-static char save_dialplan_help[] =
-"Usage: save dialplan [/path/to/extension/file]\n"
-" Save dialplan created by pbx_config module.\n"
-"\n"
-"Example: save dialplan (/etc/asterisk/extensions.conf)\n"
-" save dialplan /home/markster (/home/markster/extensions.conf)\n";
-
static char context_add_extension_help[] =
-"Usage: add extension <exten>,<priority>,<app>,<app-data> into <context>\n"
-" [replace]\n\n"
+"Usage: dialplan add extension <exten>,<priority>,<app>,<app-data>\n"
+" into <context> [replace]\n\n"
" This command will add new extension into <context>. If there is an\n"
" existence of extension with the same priority and last 'replace'\n"
" arguments is given here we simply replace this extension.\n"
"\n"
-"Example: add extension 6123,1,Dial,IAX/216.207.245.56/6123 into local\n"
+"Example: dialplan add extension 6123,1,Dial,IAX/216.207.245.56/6123 into local\n"
" Now, you can dial 6123 and talk to Markster :)\n";
+static char context_remove_extension_help[] =
+"Usage: dialplan remove extension exten@context [priority]\n"
+" Remove an extension from a given context. If a priority\n"
+" is given, only that specific priority from the given extension\n"
+" will be removed.\n";
+
static char context_add_ignorepat_help[] =
-"Usage: add ignorepat <pattern> into <context>\n"
+"Usage: dialplan add ignorepat <pattern> into <context>\n"
" This command adds a new ignore pattern into context <context>\n"
"\n"
-"Example: add ignorepat _3XX into local\n";
+"Example: dialplan add ignorepat _3XX into local\n";
static char context_remove_ignorepat_help[] =
-"Usage: remove ignorepat <pattern> from <context>\n"
+"Usage: dialplan remove ignorepat <pattern> from <context>\n"
" This command removes an ignore pattern from context <context>\n"
"\n"
-"Example: remove ignorepat _3XX from local\n";
+"Example: dialplan remove ignorepat _3XX from local\n";
+
+static char context_add_include_help[] =
+"Usage: dialplan add include <context> into <context>\n"
+" Include a context in another context.\n";
+
+static char context_remove_include_help[] =
+"Usage: dialplan remove include <context> from <context>\n"
+" Remove an included context from another context.\n";
+
+static char save_dialplan_help[] =
+"Usage: dialplan save [/path/to/extension/file]\n"
+" Save dialplan created by pbx_config module.\n"
+"\n"
+"Example: dialplan save (/etc/asterisk/extensions.conf)\n"
+" dialplan save /home/markster (/home/markster/extensions.conf)\n";
static char reload_extensions_help[] =
-"Usage: reload extensions.conf without reloading any other modules\n"
+"Usage: dialplan reload\n"
+" reload extensions.conf without reloading any other modules\n"
" This command does not delete global variables unless\n"
-" clearglobalvars is set to yes in extensions.conf\n"
-"\n"
-"Example: extensions reload\n";
+" clearglobalvars is set to yes in extensions.conf\n";
/*
* Implementation of functions provided by this module
@@ -115,16 +114,16 @@ static char reload_extensions_help[] =
/*!
* REMOVE INCLUDE command stuff
*/
-static int handle_context_dont_include(int fd, int argc, char *argv[])
+static int handle_context_dont_include_deprecated(int fd, int argc, char *argv[])
{
if (argc != 5)
return RESULT_SHOWUSAGE;
- if (strcmp(argv[3], "in"))
+ if (strcmp(argv[3], "into"))
return RESULT_SHOWUSAGE;
if (!ast_context_remove_include(argv[4], argv[2], registrar)) {
- ast_cli(fd, "We are not including '%s' in '%s' now\n",
+ ast_cli(fd, "We are not including '%s' into '%s' now\n",
argv[2], argv[4]);
return RESULT_SUCCESS;
}
@@ -134,6 +133,25 @@ static int handle_context_dont_include(int fd, int argc, char *argv[])
return RESULT_FAILURE;
}
+static int handle_context_remove_include(int fd, int argc, char *argv[])
+{
+ if (argc != 6)
+ return RESULT_SHOWUSAGE;
+
+ if (strcmp(argv[4], "into"))
+ return RESULT_SHOWUSAGE;
+
+ if (!ast_context_remove_include(argv[5], argv[3], registrar)) {
+ ast_cli(fd, "We are not including '%s' into '%s' now\n",
+ argv[3], argv[5]);
+ return RESULT_SUCCESS;
+ }
+
+ ast_cli(fd, "Failed to remove '%s' include from '%s' context\n",
+ argv[3], argv[5]);
+ return RESULT_FAILURE;
+}
+
/*! \brief return true if 'name' is included by context c */
static int lookup_ci(struct ast_context *c, const char *name)
{
@@ -209,7 +227,7 @@ static int split_ec(const char *src, char **ext, char ** const ctx)
}
/* _X_ is the string we need to complete */
-static char *complete_context_dont_include(const char *line, const char *word,
+static char *complete_context_dont_include_deprecated(const char *line, const char *word,
int pos, int state)
{
int which = 0;
@@ -330,10 +348,131 @@ static char *complete_context_dont_include(const char *line, const char *word,
return NULL;
}
+static char *complete_context_remove_include(const char *line, const char *word,
+ int pos, int state)
+{
+ int which = 0;
+ char *res = NULL;
+ int len = strlen(word); /* how many bytes to match */
+ struct ast_context *c = NULL;
+
+ if (pos == 3) { /* "dialplan remove include _X_" */
+ if (ast_lock_contexts()) {
+ ast_log(LOG_ERROR, "Failed to lock context list\n");
+ return NULL;
+ }
+ /* walk contexts and their includes, return the n-th match */
+ while (!res && (c = ast_walk_contexts(c))) {
+ struct ast_include *i = NULL;
+
+ if (ast_lock_context(c)) /* error ? skip this one */
+ continue;
+
+ while ( !res && (i = ast_walk_context_includes(c, i)) ) {
+ const char *i_name = ast_get_include_name(i);
+ struct ast_context *nc = NULL;
+ int already_served = 0;
+
+ if (!partial_match(i_name, word, len))
+ continue; /* not matched */
+
+ /* check if this include is already served or not */
+
+ /* go through all contexts again till we reach actual
+ * context or already_served = 1
+ */
+ while ( (nc = ast_walk_contexts(nc)) && nc != c && !already_served)
+ already_served = lookup_ci(nc, i_name);
+
+ if (!already_served && ++which > state)
+ res = strdup(i_name);
+ }
+ ast_unlock_context(c);
+ }
+
+ ast_unlock_contexts();
+ return res;
+ } else if (pos == 4) { /* "dialplan remove include CTX _X_" */
+ /*
+ * complete as 'from', but only if previous context is really
+ * included somewhere
+ */
+ char *context, *dupline;
+ const char *s = skip_words(line, 3); /* skip 'dialplan' 'remove' 'include' */
+
+ if (state > 0)
+ return NULL;
+ context = dupline = strdup(s);
+ if (!dupline) {
+ ast_log(LOG_ERROR, "Out of free memory\n");
+ return NULL;
+ }
+ strsep(&dupline, " ");
+
+ if (ast_lock_contexts()) {
+ ast_log(LOG_ERROR, "Failed to lock contexts list\n");
+ free(context);
+ return NULL;
+ }
+
+ /* go through all contexts and check if is included ... */
+ while (!res && (c = ast_walk_contexts(c)))
+ if (lookup_ci(c, context)) /* context is really included, complete "from" command */
+ res = strdup("from");
+ ast_unlock_contexts();
+ if (!res)
+ ast_log(LOG_WARNING, "%s not included anywhere\n", context);
+ free(context);
+ return res;
+ } else if (pos == 5) { /* "dialplan remove include CTX from _X_" */
+ /*
+ * Context from which we removing include ...
+ */
+ char *context, *dupline, *from;
+ const char *s = skip_words(line, 3); /* skip 'dialplan' 'remove' 'include' */
+ context = dupline = strdup(s);
+ if (!dupline) {
+ ast_log(LOG_ERROR, "Out of free memory\n");
+ return NULL;
+ }
+
+ strsep(&dupline, " "); /* skip context */
+
+ /* fourth word must be 'from' */
+ from = strsep(&dupline, " ");
+ if (!from || strcmp(from, "from")) {
+ free(context);
+ return NULL;
+ }
+
+ if (ast_lock_contexts()) {
+ ast_log(LOG_ERROR, "Failed to lock context list\n");
+ free(context);
+ return NULL;
+ }
+
+ /* walk through all contexts ... */
+ c = NULL;
+ while ( !res && (c = ast_walk_contexts(c))) {
+ const char *c_name = ast_get_context_name(c);
+ if (!partial_match(c_name, word, len)) /* not a good target */
+ continue;
+ /* walk through all includes and check if it is our context */
+ if (lookup_ci(c, context) && ++which > state)
+ res = strdup(c_name);
+ }
+ ast_unlock_contexts();
+ free(context);
+ return res;
+ }
+
+ return NULL;
+}
+
/*!
* REMOVE EXTENSION command stuff
*/
-static int handle_context_remove_extension(int fd, int argc, char *argv[])
+static int handle_context_remove_extension_deprecated(int fd, int argc, char *argv[])
{
int removing_priority = 0;
char *exten, *context;
@@ -400,6 +539,73 @@ static int handle_context_remove_extension(int fd, int argc, char *argv[])
return ret;
}
+static int handle_context_remove_extension(int fd, int argc, char *argv[])
+{
+ int removing_priority = 0;
+ char *exten, *context;
+ int ret = RESULT_FAILURE;
+
+ if (argc != 5 && argc != 4) return RESULT_SHOWUSAGE;
+
+ /*
+ * Priority input checking ...
+ */
+ if (argc == 5) {
+ char *c = argv[4];
+
+ /* check for digits in whole parameter for right priority ...
+ * why? because atoi (strtol) returns 0 if any characters in
+ * string and whole extension will be removed, it's not good
+ */
+ if (!strcmp("hint", c))
+ removing_priority = PRIORITY_HINT;
+ else {
+ while (*c && isdigit(*c))
+ c++;
+ if (*c) { /* non-digit in string */
+ ast_cli(fd, "Invalid priority '%s'\n", argv[4]);
+ return RESULT_FAILURE;
+ }
+ removing_priority = atoi(argv[4]);
+ }
+
+ if (removing_priority == 0) {
+ ast_cli(fd, "If you want to remove whole extension, please " \
+ "omit priority argument\n");
+ return RESULT_FAILURE;
+ }
+ }
+
+ /* XXX original overwrote argv[3] */
+ /*
+ * Format exten@context checking ...
+ */
+ if (split_ec(argv[3], &exten, &context))
+ return RESULT_FAILURE; /* XXX malloc failure */
+ if ((!strlen(exten)) || (!(strlen(context)))) {
+ ast_cli(fd, "Missing extension or context name in third argument '%s'\n",
+ argv[3]);
+ free(exten);
+ return RESULT_FAILURE;
+ }
+
+ if (!ast_context_remove_extension(context, exten, removing_priority, registrar)) {
+ if (!removing_priority)
+ ast_cli(fd, "Whole extension %s@%s removed\n",
+ exten, context);
+ else
+ ast_cli(fd, "Extension %s@%s with priority %d removed\n",
+ exten, context, removing_priority);
+
+ ret = RESULT_SUCCESS;
+ } else {
+ ast_cli(fd, "Failed to remove extension %s@%s\n", exten, context);
+ ret = RESULT_FAILURE;
+ }
+ free(exten);
+ return ret;
+}
+
#define BROKEN_READLINE 1
#ifdef BROKEN_READLINE
@@ -447,7 +653,7 @@ static int fix_complete_args(const char *line, char **word, int *pos)
}
#endif /* BROKEN_READLINE */
-static char *complete_context_remove_extension(const char *line, const char *word, int pos,
+static char *complete_context_remove_extension_deprecated(const char *line, const char *word, int pos,
int state)
{
char *ret = NULL;
@@ -569,10 +775,132 @@ static char *complete_context_remove_extension(const char *line, const char *wor
return ret;
}
+static char *complete_context_remove_extension(const char *line, const char *word, int pos,
+ int state)
+{
+ char *ret = NULL;
+ int which = 0;
+
+#ifdef BROKEN_READLINE
+ char *word2;
+ /*
+ * Fix arguments, *word is a new allocated structure, REMEMBER to
+ * free *word when you want to return from this function ...
+ */
+ if (fix_complete_args(line, &word2, &pos)) {
+ ast_log(LOG_ERROR, "Out of free memory\n");
+ return NULL;
+ }
+ word = word2;
+#endif
+
+ if (pos == 3) { /* 'dialplan remove extension _X_' (exten@context ... */
+ struct ast_context *c = NULL;
+ char *context = NULL, *exten = NULL;
+ int le = 0; /* length of extension */
+ int lc = 0; /* length of context */
+
+ lc = split_ec(word, &exten, &context);
+#ifdef BROKEN_READLINE
+ free(word2);
+#endif
+ if (lc) /* error */
+ return NULL;
+ le = strlen(exten);
+ lc = strlen(context);
+
+ if (ast_lock_contexts()) {
+ ast_log(LOG_ERROR, "Failed to lock context list\n");
+ goto error2;
+ }
+
+ /* find our context ... */
+ while ( (c = ast_walk_contexts(c)) ) { /* match our context if any */
+ struct ast_exten *e = NULL;
+ /* XXX locking ? */
+ if (!partial_match(ast_get_context_name(c), context, lc))
+ continue; /* context not matched */
+ while ( (e = ast_walk_context_extensions(c, e)) ) { /* try to complete extensions ... */
+ if ( partial_match(ast_get_extension_name(e), exten, le) && ++which > state) { /* n-th match */
+ /* If there is an extension then return exten@context. XXX otherwise ? */
+ if (exten)
+ asprintf(&ret, "%s@%s", ast_get_extension_name(e), ast_get_context_name(c));
+ break;
+ }
+ }
+ if (e) /* got a match */
+ break;
+ }
+
+ ast_unlock_contexts();
+ error2:
+ if (exten)
+ free(exten);
+ } else if (pos == 4) { /* 'dialplan remove extension EXT _X_' (priority) */
+ char *exten = NULL, *context, *p;
+ struct ast_context *c;
+ int le, lc, len;
+ const char *s = skip_words(line, 3); /* skip 'dialplan' 'remove' 'extension' */
+ int i = split_ec(s, &exten, &context); /* parse ext@context */
+
+ if (i) /* error */
+ goto error3;
+ if ( (p = strchr(exten, ' ')) ) /* remove space after extension */
+ *p = '\0';
+ if ( (p = strchr(context, ' ')) ) /* remove space after context */
+ *p = '\0';
+ le = strlen(exten);
+ lc = strlen(context);
+ len = strlen(word);
+ if (le == 0 || lc == 0)
+ goto error3;
+
+ if (ast_lock_contexts()) {
+ ast_log(LOG_ERROR, "Failed to lock context list\n");
+ goto error3;
+ }
+
+ /* walk contexts */
+ c = NULL;
+ while ( (c = ast_walk_contexts(c)) ) {
+ /* XXX locking on c ? */
+ struct ast_exten *e;
+ if (strcmp(ast_get_context_name(c), context) != 0)
+ continue;
+ /* got it, we must match here */
+ e = NULL;
+ while ( (e = ast_walk_context_extensions(c, e)) ) {
+ struct ast_exten *priority;
+ char buffer[10];
+
+ if (strcmp(ast_get_extension_name(e), exten) != 0)
+ continue;
+ /* XXX lock e ? */
+ priority = NULL;
+ while ( !ret && (priority = ast_walk_extension_priorities(e, priority)) ) {
+ snprintf(buffer, sizeof(buffer), "%u", ast_get_extension_priority(priority));
+ if (partial_match(buffer, word, len) && ++which > state) /* n-th match */
+ ret = strdup(buffer);
+ }
+ break;
+ }
+ break;
+ }
+ ast_unlock_contexts();
+ error3:
+ if (exten)
+ free(exten);
+#ifdef BROKEN_READLINE
+ free(word2);
+#endif
+ }
+ return ret;
+}
+
/*!
* Include context ...
*/
-static int handle_context_add_include(int fd, int argc, char *argv[])
+static int handle_context_add_include_deprecated(int fd, int argc, char *argv[])
{
if (argc != 5) /* include context CTX in CTX */
return RESULT_SHOWUSAGE;
@@ -617,7 +945,52 @@ static int handle_context_add_include(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static char *complete_context_add_include(const char *line, const char *word, int pos,
+static int handle_context_add_include(int fd, int argc, char *argv[])
+{
+ if (argc != 6) /* dialplan add include CTX in CTX */
+ return RESULT_SHOWUSAGE;
+
+ /* fifth arg must be 'into' ... */
+ if (strcmp(argv[4], "into"))
+ return RESULT_SHOWUSAGE;
+
+ if (ast_context_add_include(argv[5], argv[3], registrar)) {
+ switch (errno) {
+ case ENOMEM:
+ ast_cli(fd, "Out of memory for context addition\n");
+ break;
+
+ case EBUSY:
+ ast_cli(fd, "Failed to lock context(s) list, please try again later\n");
+ break;
+
+ case EEXIST:
+ ast_cli(fd, "Context '%s' already included in '%s' context\n",
+ argv[3], argv[5]);
+ break;
+
+ case ENOENT:
+ case EINVAL:
+ ast_cli(fd, "There is no existence of context '%s'\n",
+ errno == ENOENT ? argv[5] : argv[3]);
+ break;
+
+ default:
+ ast_cli(fd, "Failed to include '%s' in '%s' context\n",
+ argv[3], argv[5]);
+ break;
+ }
+ return RESULT_FAILURE;
+ }
+
+ /* show some info ... */
+ ast_cli(fd, "Context '%s' included in '%s' context\n",
+ argv[3], argv[5]);
+
+ return RESULT_SUCCESS;
+}
+
+static char *complete_context_add_include_deprecated(const char *line, const char *word, int pos,
int state)
{
struct ast_context *c;
@@ -712,6 +1085,101 @@ static char *complete_context_add_include(const char *line, const char *word, in
return NULL;
}
+static char *complete_context_add_include(const char *line, const char *word, int pos,
+ int state)
+{
+ struct ast_context *c;
+ int which = 0;
+ char *ret = NULL;
+ int len = strlen(word);
+
+ if (pos == 3) { /* 'dialplan add include _X_' (context) ... */
+ if (ast_lock_contexts()) {
+ ast_log(LOG_ERROR, "Failed to lock context list\n");
+ return NULL;
+ }
+ for (c = NULL; !ret && (c = ast_walk_contexts(c)); )
+ if (partial_match(ast_get_context_name(c), word, len) && ++which > state)
+ ret = strdup(ast_get_context_name(c));
+ ast_unlock_contexts();
+ return ret;
+ } else if (pos == 4) { /* dialplan add include CTX _X_ */
+ /* complete as 'into' if context exists or we are unable to check */
+ char *context, *dupline;
+ struct ast_context *c;
+ const char *s = skip_words(line, 3); /* should not fail */
+
+ if (state != 0) /* only once */
+ return NULL;
+
+ /* parse context from line ... */
+ context = dupline = strdup(s);
+ if (!context) {
+ ast_log(LOG_ERROR, "Out of free memory\n");
+ return strdup("into");
+ }
+ strsep(&dupline, " ");
+
+ /* check for context existence ... */
+ if (ast_lock_contexts()) {
+ ast_log(LOG_ERROR, "Failed to lock context list\n");
+ /* our fault, we can't check, so complete 'into' ... */
+ ret = strdup("into");
+ } else {
+ for (c = NULL; !ret && (c = ast_walk_contexts(c)); )
+ if (!strcmp(context, ast_get_context_name(c)))
+ ret = strdup("into"); /* found */
+ ast_unlock_contexts();
+ }
+ free(context);
+ return ret;
+ } else if (pos == 5) { /* 'dialplan add include CTX into _X_' (dst context) */
+ char *context, *dupline, *into;
+ const char *s = skip_words(line, 3); /* should not fail */
+ context = dupline = strdup(s);
+ if (!dupline) {
+ ast_log(LOG_ERROR, "Out of free memory\n");
+ return NULL;
+ }
+ strsep(&dupline, " "); /* skip context */
+ into = strsep(&dupline, " ");
+ /* error if missing context or fifth word is not 'into' */
+ if (!strlen(context) || strcmp(into, "into")) {
+ ast_log(LOG_ERROR, "bad context %s or missing into %s\n",
+ context, into);
+ goto error3;
+ }
+
+ if (ast_lock_contexts()) {
+ ast_log(LOG_ERROR, "Failed to lock context list\n");
+ goto error3;
+ }
+
+ for (c = NULL; (c = ast_walk_contexts(c)); )
+ if (!strcmp(context, ast_get_context_name(c)))
+ break;
+ if (c) { /* first context exists, go on... */
+ /* go through all contexts ... */
+ for (c = NULL; !ret && (c = ast_walk_contexts(c)); ) {
+ if (!strcmp(context, ast_get_context_name(c)))
+ continue; /* skip ourselves */
+ if (partial_match(ast_get_context_name(c), word, len) &&
+ !lookup_ci(c, context) /* not included yet */ &&
+ ++which > state)
+ ret = strdup(ast_get_context_name(c));
+ }
+ } else {
+ ast_log(LOG_ERROR, "context %s not found\n", context);
+ }
+ ast_unlock_contexts();
+ error3:
+ free(context);
+ return ret;
+ }
+
+ return NULL;
+}
+
/*!
* \brief 'save dialplan' CLI command implementation functions ...
*/
@@ -936,7 +1404,7 @@ static int handle_save_dialplan(int fd, int argc, char *argv[])
/*!
* \brief ADD EXTENSION command stuff
*/
-static int handle_context_add_extension(int fd, int argc, char *argv[])
+static int handle_context_add_extension_deprecated(int fd, int argc, char *argv[])
{
char *whole_exten;
char *exten, *prior;
@@ -1029,10 +1497,102 @@ static int handle_context_add_extension(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int handle_context_add_extension(int fd, int argc, char *argv[])
+{
+ char *whole_exten;
+ char *exten, *prior;
+ int iprior = -2;
+ char *cidmatch, *app, *app_data;
+ char *start, *end;
-/*! add extension 6123,1,Dial,IAX/212.71.138.13/6123 into local */
-static char *complete_context_add_extension(const char *line, const char *word,
- int pos, int state)
+ /* check for arguments at first */
+ if (argc != 6 && argc != 7)
+ return RESULT_SHOWUSAGE;
+ if (strcmp(argv[3], "into"))
+ return RESULT_SHOWUSAGE;
+ if (argc == 7) if (strcmp(argv[6], "replace")) return RESULT_SHOWUSAGE;
+
+ /* XXX overwrite argv[3] */
+ whole_exten = argv[3];
+ exten = strsep(&whole_exten,",");
+ if (strchr(exten, '/')) {
+ cidmatch = exten;
+ strsep(&cidmatch,"/");
+ } else {
+ cidmatch = NULL;
+ }
+ prior = strsep(&whole_exten,",");
+ if (prior) {
+ if (!strcmp(prior, "hint")) {
+ iprior = PRIORITY_HINT;
+ } else {
+ if (sscanf(prior, "%d", &iprior) != 1) {
+ ast_cli(fd, "'%s' is not a valid priority\n", prior);
+ prior = NULL;
+ }
+ }
+ }
+ app = whole_exten;
+ if (app && (start = strchr(app, '(')) && (end = strrchr(app, ')'))) {
+ *start = *end = '\0';
+ app_data = start + 1;
+ ast_process_quotes_and_slashes(app_data, ',', '|');
+ } else {
+ if (app) {
+ app_data = strchr(app, ',');
+ if (app_data) {
+ *app_data = '\0';
+ app_data++;
+ }
+ } else
+ app_data = NULL;
+ }
+
+ if (!exten || !prior || !app || (!app_data && iprior != PRIORITY_HINT))
+ return RESULT_SHOWUSAGE;
+
+ if (!app_data)
+ app_data="";
+ if (ast_add_extension(argv[5], argc == 6 ? 1 : 0, exten, iprior, NULL, cidmatch, app,
+ (void *)strdup(app_data), free, registrar)) {
+ switch (errno) {
+ case ENOMEM:
+ ast_cli(fd, "Out of free memory\n");
+ break;
+
+ case EBUSY:
+ ast_cli(fd, "Failed to lock context(s) list, please try again later\n");
+ break;
+
+ case ENOENT:
+ ast_cli(fd, "No existence of '%s' context\n", argv[5]);
+ break;
+
+ case EEXIST:
+ ast_cli(fd, "Extension %s@%s with priority %s already exists\n",
+ exten, argv[5], prior);
+ break;
+
+ default:
+ ast_cli(fd, "Failed to add '%s,%s,%s,%s' extension into '%s' context\n",
+ exten, prior, app, app_data, argv[5]);
+ break;
+ }
+ return RESULT_FAILURE;
+ }
+
+ if (argc == 7)
+ ast_cli(fd, "Extension %s@%s (%s) replace by '%s,%s,%s,%s'\n",
+ exten, argv[5], prior, exten, prior, app, app_data);
+ else
+ ast_cli(fd, "Extension '%s,%s,%s,%s' added into '%s' context\n",
+ exten, prior, app, app_data, argv[5]);
+
+ return RESULT_SUCCESS;
+}
+
+/*! dialplan add extension 6123,1,Dial,IAX/212.71.138.13/6123 into local */
+static char *complete_context_add_extension_deprecated(const char *line, const char *word, int pos, int state)
{
int which = 0;
@@ -1061,10 +1621,39 @@ static char *complete_context_add_extension(const char *line, const char *word,
return NULL;
}
+static char *complete_context_add_extension(const char *line, const char *word, int pos, int state)
+{
+ int which = 0;
+
+ if (pos == 4) { /* complete 'into' word ... */
+ return (state == 0) ? strdup("into") : NULL;
+ } else if (pos == 5) { /* complete context */
+ struct ast_context *c = NULL;
+ int len = strlen(word);
+ char *res = NULL;
+
+ /* try to lock contexts list ... */
+ if (ast_lock_contexts()) {
+ ast_log(LOG_WARNING, "Failed to lock contexts list\n");
+ return NULL;
+ }
+
+ /* walk through all contexts */
+ while ( !res && (c = ast_walk_contexts(c)) )
+ if (partial_match(ast_get_context_name(c), word, len) && ++which > state)
+ res = strdup(ast_get_context_name(c));
+ ast_unlock_contexts();
+ return res;
+ } else if (pos == 6) {
+ return state == 0 ? strdup("replace") : NULL;
+ }
+ return NULL;
+}
+
/*!
* IGNOREPAT CLI stuff
*/
-static int handle_context_add_ignorepat(int fd, int argc, char *argv[])
+static int handle_context_add_ignorepat_deprecated(int fd, int argc, char *argv[])
{
if (argc != 5)
return RESULT_SHOWUSAGE;
@@ -1103,7 +1692,46 @@ static int handle_context_add_ignorepat(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static char *complete_context_add_ignorepat(const char *line, const char *word,
+static int handle_context_add_ignorepat(int fd, int argc, char *argv[])
+{
+ if (argc != 6)
+ return RESULT_SHOWUSAGE;
+ if (strcmp(argv[4], "into"))
+ return RESULT_SHOWUSAGE;
+
+ if (ast_context_add_ignorepat(argv[5], argv[3], registrar)) {
+ switch (errno) {
+ case ENOMEM:
+ ast_cli(fd, "Out of free memory\n");
+ break;
+
+ case ENOENT:
+ ast_cli(fd, "There is no existence of '%s' context\n", argv[5]);
+ break;
+
+ case EEXIST:
+ ast_cli(fd, "Ignore pattern '%s' already included in '%s' context\n",
+ argv[3], argv[5]);
+ break;
+
+ case EBUSY:
+ ast_cli(fd, "Failed to lock context(s) list, please, try again later\n");
+ break;
+
+ default:
+ ast_cli(fd, "Failed to add ingore pattern '%s' into '%s' context\n",
+ argv[3], argv[5]);
+ break;
+ }
+ return RESULT_FAILURE;
+ }
+
+ ast_cli(fd, "Ignore pattern '%s' added into '%s' context\n",
+ argv[3], argv[5]);
+ return RESULT_SUCCESS;
+}
+
+static char *complete_context_add_ignorepat_deprecated(const char *line, const char *word,
int pos, int state)
{
if (pos == 3)
@@ -1152,7 +1780,56 @@ static char *complete_context_add_ignorepat(const char *line, const char *word,
return NULL;
}
-static int handle_context_remove_ignorepat(int fd, int argc, char *argv[])
+static char *complete_context_add_ignorepat(const char *line, const char *word,
+ int pos, int state)
+{
+ if (pos == 4)
+ return state == 0 ? strdup("into") : NULL;
+ else if (pos == 5) {
+ struct ast_context *c;
+ int which = 0;
+ char *dupline, *ignorepat = NULL;
+ const char *s;
+ char *ret = NULL;
+ int len = strlen(word);
+
+ /* XXX skip first three words 'dialplan' 'add' 'ignorepat' */
+ s = skip_words(line, 3);
+ if (s == NULL)
+ return NULL;
+ dupline = strdup(s);
+ if (!dupline) {
+ ast_log(LOG_ERROR, "Malloc failure\n");
+ return NULL;
+ }
+ ignorepat = strsep(&dupline, " ");
+
+ if (ast_lock_contexts()) {
+ ast_log(LOG_ERROR, "Failed to lock contexts list\n");
+ return NULL;
+ }
+
+ for (c = NULL; !ret && (c = ast_walk_contexts(c));) {
+ int found = 0;
+
+ if (!partial_match(ast_get_context_name(c), word, len))
+ continue; /* not mine */
+ if (ignorepat) /* there must be one, right ? */
+ found = lookup_c_ip(c, ignorepat);
+ if (!found && ++which > state)
+ ret = strdup(ast_get_context_name(c));
+ }
+
+ if (ignorepat)
+ free(ignorepat);
+ ast_unlock_contexts();
+ return ret;
+ }
+
+ return NULL;
+}
+
+static int handle_context_remove_ignorepat_deprecated(int fd, int argc, char *argv[])
{
if (argc != 5)
return RESULT_SHOWUSAGE;
@@ -1186,17 +1863,41 @@ static int handle_context_remove_ignorepat(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static int pbx_load_module(void);
-
-static int handle_reload_extensions(int fd, int argc, char *argv[])
+static int handle_context_remove_ignorepat(int fd, int argc, char *argv[])
{
- if (argc!=2)
+ if (argc != 6)
return RESULT_SHOWUSAGE;
- pbx_load_module();
+ if (strcmp(argv[4], "from"))
+ return RESULT_SHOWUSAGE;
+
+ if (ast_context_remove_ignorepat(argv[5], argv[3], registrar)) {
+ switch (errno) {
+ case EBUSY:
+ ast_cli(fd, "Failed to lock context(s) list, please try again later\n");
+ break;
+
+ case ENOENT:
+ ast_cli(fd, "There is no existence of '%s' context\n", argv[5]);
+ break;
+
+ case EINVAL:
+ ast_cli(fd, "There is no existence of '%s' ignore pattern in '%s' context\n",
+ argv[3], argv[5]);
+ break;
+
+ default:
+ ast_cli(fd, "Failed to remove ignore pattern '%s' from '%s' context\n", argv[3], argv[5]);
+ break;
+ }
+ return RESULT_FAILURE;
+ }
+
+ ast_cli(fd, "Ignore pattern '%s' removed from '%s' context\n",
+ argv[3], argv[5]);
return RESULT_SUCCESS;
}
-static char *complete_context_remove_ignorepat(const char *line, const char *word,
+static char *complete_context_remove_ignorepat_deprecated(const char *line, const char *word,
int pos, int state)
{
struct ast_context *c;
@@ -1278,61 +1979,185 @@ static char *complete_context_remove_ignorepat(const char *line, const char *wor
return NULL;
}
+static char *complete_context_remove_ignorepat(const char *line, const char *word,
+ int pos, int state)
+{
+ struct ast_context *c;
+ int which = 0;
+ char *ret = NULL;
+
+ if (pos == 3) {
+ int len = strlen(word);
+ if (ast_lock_contexts()) {
+ ast_log(LOG_WARNING, "Failed to lock contexts list\n");
+ return NULL;
+ }
+
+ for (c = NULL; !ret && (c = ast_walk_contexts(c));) {
+ struct ast_ignorepat *ip;
+
+ if (ast_lock_context(c)) /* error, skip it */
+ continue;
+
+ for (ip = NULL; !ret && (ip = ast_walk_context_ignorepats(c, ip));) {
+ if (partial_match(ast_get_ignorepat_name(ip), word, len) && ++which > state) {
+ /* n-th match */
+ struct ast_context *cw = NULL;
+ int found = 0;
+ while ( (cw = ast_walk_contexts(cw)) && cw != c && !found) {
+ /* XXX do i stop on c, or skip it ? */
+ found = lookup_c_ip(cw, ast_get_ignorepat_name(ip));
+ }
+ if (!found)
+ ret = strdup(ast_get_ignorepat_name(ip));
+ }
+ }
+ ast_unlock_context(c);
+ }
+ ast_unlock_contexts();
+ return ret;
+ } else if (pos == 4) {
+ return state == 0 ? strdup("from") : NULL;
+ } else if (pos == 5) { /* XXX check this */
+ char *dupline, *duplinet, *ignorepat;
+ int len = strlen(word);
+
+ dupline = strdup(line);
+ if (!dupline) {
+ ast_log(LOG_WARNING, "Out of free memory\n");
+ return NULL;
+ }
+
+ duplinet = dupline;
+ strsep(&duplinet, " ");
+ strsep(&duplinet, " ");
+ ignorepat = strsep(&duplinet, " ");
+
+ if (!ignorepat) {
+ free(dupline);
+ return NULL;
+ }
+
+ if (ast_lock_contexts()) {
+ ast_log(LOG_WARNING, "Failed to lock contexts list\n");
+ free(dupline);
+ return NULL;
+ }
+
+ for (c = NULL; !ret && (c = ast_walk_contexts(c)); ) {
+ if (ast_lock_context(c)) /* fail, skip it */
+ continue;
+ if (!partial_match(ast_get_context_name(c), word, len))
+ continue;
+ if (lookup_c_ip(c, ignorepat) && ++which > state)
+ ret = strdup(ast_get_context_name(c));
+ ast_unlock_context(c);
+ }
+ ast_unlock_contexts();
+ free(dupline);
+ return NULL;
+ }
+
+ return NULL;
+}
+
+static int pbx_load_module(void);
+
+static int handle_reload_extensions(int fd, int argc, char *argv[])
+{
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
+ pbx_load_module();
+ return RESULT_SUCCESS;
+}
+
/*!
* CLI entries for commands provided by this module
*/
-static struct ast_cli_entry context_dont_include_cli =
- { { "dont", "include", NULL }, handle_context_dont_include,
- "Remove a specified include from context", context_dont_include_help,
- complete_context_dont_include };
-
-static struct ast_cli_entry context_remove_extension_cli =
- { { "remove", "extension", NULL }, handle_context_remove_extension,
- "Remove a specified extension", context_remove_extension_help,
- complete_context_remove_extension };
-
-static struct ast_cli_entry context_add_include_cli =
- { { "include", "context", NULL }, handle_context_add_include,
- "Include context in other context", context_add_include_help,
- complete_context_add_include };
-
-static struct ast_cli_entry save_dialplan_cli =
- { { "save", "dialplan", NULL }, handle_save_dialplan,
- "Save dialplan", save_dialplan_help };
-
-static struct ast_cli_entry context_add_extension_cli =
- { { "add", "extension", NULL }, handle_context_add_extension,
- "Add new extension into context", context_add_extension_help,
- complete_context_add_extension };
-
-static struct ast_cli_entry context_add_ignorepat_cli =
- { { "add", "ignorepat", NULL }, handle_context_add_ignorepat,
- "Add new ignore pattern", context_add_ignorepat_help,
- complete_context_add_ignorepat };
-
-static struct ast_cli_entry context_remove_ignorepat_cli =
- { { "remove", "ignorepat", NULL }, handle_context_remove_ignorepat,
- "Remove ignore pattern from context", context_remove_ignorepat_help,
- complete_context_remove_ignorepat };
-
-static struct ast_cli_entry reload_extensions_cli =
- { { "extensions", "reload", NULL}, handle_reload_extensions,
- "Reload extensions and *only* extensions", reload_extensions_help };
+static struct ast_cli_entry cli_dont_include_deprecated = {
+ { "dont", "include", NULL },
+ handle_context_dont_include_deprecated, NULL,
+ NULL, complete_context_dont_include_deprecated };
+
+static struct ast_cli_entry cli_remove_extension_deprecated = {
+ { "remove", "extension", NULL },
+ handle_context_remove_extension_deprecated, NULL,
+ NULL, complete_context_remove_extension_deprecated };
+
+static struct ast_cli_entry cli_include_context_deprecated = {
+ { "include", "context", NULL },
+ handle_context_add_include_deprecated, NULL,
+ NULL, complete_context_add_include_deprecated };
+
+static struct ast_cli_entry cli_add_extension_deprecated = {
+ { "add", "extension", NULL },
+ handle_context_add_extension_deprecated, NULL,
+ NULL, complete_context_add_extension_deprecated };
+
+static struct ast_cli_entry cli_add_ignorepat_deprecated = {
+ { "add", "ignorepat", NULL },
+ handle_context_add_ignorepat_deprecated, NULL,
+ NULL, complete_context_add_ignorepat_deprecated };
+
+static struct ast_cli_entry cli_remove_ignorepat_deprecated = {
+ { "remove", "ignorepat", NULL },
+ handle_context_remove_ignorepat_deprecated, NULL,
+ NULL, complete_context_remove_ignorepat_deprecated };
+
+static struct ast_cli_entry cli_extensions_reload_deprecated = {
+ { "extensions", "reload", NULL },
+ handle_reload_extensions, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_save_dialplan_deprecated = {
+ { "save", "dialplan", NULL },
+ handle_save_dialplan, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_pbx_config[] = {
+ { { "dialplan", "add", "extension", NULL },
+ handle_context_add_extension, "Add new extension into context",
+ context_add_extension_help, complete_context_add_extension, &cli_add_extension_deprecated },
+
+ { { "dialplan", "remove", "extension", NULL },
+ handle_context_remove_extension, "Remove a specified extension",
+ context_remove_extension_help, complete_context_remove_extension, &cli_remove_extension_deprecated },
+
+ { { "dialplan", "add", "ignorepat", NULL },
+ handle_context_add_ignorepat, "Add new ignore pattern",
+ context_add_ignorepat_help, complete_context_add_ignorepat, &cli_add_ignorepat_deprecated },
+
+ { { "dialplan", "remove", "ignorepat", NULL },
+ handle_context_remove_ignorepat, "Remove ignore pattern from context",
+ context_remove_ignorepat_help, complete_context_remove_ignorepat, &cli_remove_ignorepat_deprecated },
+
+ { { "dialplan", "add", "include", NULL },
+ handle_context_add_include, "Include context in other context",
+ context_add_include_help, complete_context_add_include, &cli_include_context_deprecated },
+
+ { { "dialplan", "remove", "include", NULL },
+ handle_context_remove_include, "Remove a specified include from context",
+ context_remove_include_help, complete_context_remove_include, &cli_dont_include_deprecated },
+
+ { { "dialplan", "reload", NULL },
+ handle_reload_extensions, "Reload extensions and *only* extensions",
+ reload_extensions_help, NULL, &cli_extensions_reload_deprecated },
+};
+
+
+static struct ast_cli_entry cli_dialplan_save = {
+ { "dialplan", "save", NULL },
+ handle_save_dialplan, "Save dialplan",
+ save_dialplan_help, NULL, &cli_save_dialplan_deprecated };
/*!
* Standard module functions ...
*/
static int unload_module(void)
{
- ast_cli_unregister(&context_add_extension_cli);
if (static_config && !write_protect_config)
- ast_cli_unregister(&save_dialplan_cli);
- ast_cli_unregister(&context_add_include_cli);
- ast_cli_unregister(&context_dont_include_cli);
- ast_cli_unregister(&context_remove_extension_cli);
- ast_cli_unregister(&context_remove_ignorepat_cli);
- ast_cli_unregister(&context_add_ignorepat_cli);
- ast_cli_unregister(&reload_extensions_cli);
+ ast_cli_unregister(&cli_dialplan_save);
+ ast_cli_unregister_multiple(cli_pbx_config, sizeof(cli_pbx_config) / sizeof(struct ast_cli_entry));
ast_context_destroy(NULL, registrar);
return 0;
}
@@ -1617,15 +2442,9 @@ static int load_module(void)
if (pbx_load_module())
return AST_MODULE_LOAD_DECLINE;
- ast_cli_register(&context_remove_extension_cli);
- ast_cli_register(&context_dont_include_cli);
- ast_cli_register(&context_add_include_cli);
if (static_config && !write_protect_config)
- ast_cli_register(&save_dialplan_cli);
- ast_cli_register(&context_add_extension_cli);
- ast_cli_register(&context_add_ignorepat_cli);
- ast_cli_register(&context_remove_ignorepat_cli);
- ast_cli_register(&reload_extensions_cli);
+ ast_cli_register(&cli_dialplan_save);
+ ast_cli_register_multiple(cli_pbx_config, sizeof(cli_pbx_config) / sizeof(struct ast_cli_entry));
return 0;
}
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 338e77749..5d62c641d 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -2677,50 +2677,67 @@ static char flush_usage[] =
"'stats' is present, clears timer statistics instead of normal\n"
"operation.\n";
-static struct ast_cli_entry cli_debug =
- { { "dundi", "debug", NULL }, dundi_do_debug, "Enable DUNDi debugging", debug_usage };
-
-static struct ast_cli_entry cli_store_history =
- { { "dundi", "store", "history", NULL }, dundi_do_store_history, "Enable DUNDi historic records", store_history_usage };
-
-static struct ast_cli_entry cli_no_store_history =
- { { "dundi", "no", "store", "history", NULL }, dundi_no_store_history, "Disable DUNDi historic records", no_store_history_usage };
-
-static struct ast_cli_entry cli_flush =
- { { "dundi", "flush", NULL }, dundi_flush, "Flush DUNDi cache", flush_usage };
-
-static struct ast_cli_entry cli_no_debug =
- { { "dundi", "no", "debug", NULL }, dundi_no_debug, "Disable DUNDi debugging", no_debug_usage };
-
-static struct ast_cli_entry cli_show_peers =
- { { "dundi", "show", "peers", NULL }, dundi_show_peers, "Show defined DUNDi peers", show_peers_usage };
-
-static struct ast_cli_entry cli_show_trans =
- { { "dundi", "show", "trans", NULL }, dundi_show_trans, "Show active DUNDi transactions", show_trans_usage };
-
-static struct ast_cli_entry cli_show_entityid =
- { { "dundi", "show", "entityid", NULL }, dundi_show_entityid, "Display Global Entity ID", show_entityid_usage };
-
-static struct ast_cli_entry cli_show_mappings =
- { { "dundi", "show", "mappings", NULL }, dundi_show_mappings, "Show DUNDi mappings", show_mappings_usage };
-
-static struct ast_cli_entry cli_show_precache =
- { { "dundi", "show", "precache", NULL }, dundi_show_precache, "Show DUNDi precache", show_precache_usage };
-
-static struct ast_cli_entry cli_show_requests =
- { { "dundi", "show", "requests", NULL }, dundi_show_requests, "Show DUNDi requests", show_requests_usage };
-
-static struct ast_cli_entry cli_show_peer =
- { { "dundi", "show", "peer", NULL }, dundi_show_peer, "Show info on a specific DUNDi peer", show_peer_usage, complete_peer_4 };
-
-static struct ast_cli_entry cli_lookup =
- { { "dundi", "lookup", NULL }, dundi_do_lookup, "Lookup a number in DUNDi", lookup_usage };
-
-static struct ast_cli_entry cli_precache =
- { { "dundi", "precache", NULL }, dundi_do_precache, "Precache a number in DUNDi", precache_usage };
-
-static struct ast_cli_entry cli_queryeid =
- { { "dundi", "query", NULL }, dundi_do_query, "Query a DUNDi EID", query_usage };
+static struct ast_cli_entry cli_dundi[] = {
+ { { "dundi", "debug", NULL },
+ dundi_do_debug, "Enable DUNDi debugging",
+ debug_usage },
+
+ { { "dundi", "store", "history", NULL },
+ dundi_do_store_history, "Enable DUNDi historic records",
+ store_history_usage },
+
+ { { "dundi", "no", "store", "history", NULL },
+ dundi_no_store_history, "Disable DUNDi historic records",
+ no_store_history_usage },
+
+ { { "dundi", "flush", NULL },
+ dundi_flush, "Flush DUNDi cache",
+ flush_usage },
+
+ { { "dundi", "no", "debug", NULL },
+ dundi_no_debug, "Disable DUNDi debugging",
+ no_debug_usage },
+
+ { { "dundi", "show", "peers", NULL },
+ dundi_show_peers, "Show defined DUNDi peers",
+ show_peers_usage },
+
+ { { "dundi", "show", "trans", NULL },
+ dundi_show_trans, "Show active DUNDi transactions",
+ show_trans_usage },
+
+ { { "dundi", "show", "entityid", NULL },
+ dundi_show_entityid, "Display Global Entity ID",
+ show_entityid_usage },
+
+ { { "dundi", "show", "mappings", NULL },
+ dundi_show_mappings, "Show DUNDi mappings",
+ show_mappings_usage },
+
+ { { "dundi", "show", "precache", NULL },
+ dundi_show_precache, "Show DUNDi precache",
+ show_precache_usage },
+
+ { { "dundi", "show", "requests", NULL },
+ dundi_show_requests, "Show DUNDi requests",
+ show_requests_usage },
+
+ { { "dundi", "show", "peer", NULL },
+ dundi_show_peer, "Show info on a specific DUNDi peer",
+ show_peer_usage, complete_peer_4 },
+
+ { { "dundi", "lookup", NULL },
+ dundi_do_lookup, "Lookup a number in DUNDi",
+ lookup_usage },
+
+ { { "dundi", "precache", NULL },
+ dundi_do_precache, "Precache a number in DUNDi",
+ precache_usage },
+
+ { { "dundi", "query", NULL },
+ dundi_do_query, "Query a DUNDi EID",
+ query_usage },
+};
static struct dundi_transaction *create_transaction(struct dundi_peer *p)
{
@@ -4438,21 +4455,7 @@ static int unload_module(void)
{
ast_module_user_hangup_all();
- ast_cli_unregister(&cli_debug);
- ast_cli_unregister(&cli_store_history);
- ast_cli_unregister(&cli_flush);
- ast_cli_unregister(&cli_no_debug);
- ast_cli_unregister(&cli_no_store_history);
- ast_cli_unregister(&cli_show_peers);
- ast_cli_unregister(&cli_show_entityid);
- ast_cli_unregister(&cli_show_trans);
- ast_cli_unregister(&cli_show_requests);
- ast_cli_unregister(&cli_show_mappings);
- ast_cli_unregister(&cli_show_precache);
- ast_cli_unregister(&cli_show_peer);
- ast_cli_unregister(&cli_lookup);
- ast_cli_unregister(&cli_precache);
- ast_cli_unregister(&cli_queryeid);
+ ast_cli_unregister_multiple(cli_dundi, sizeof(cli_dundi) / sizeof(struct ast_cli_entry));
ast_unregister_switch(&dundi_switch);
ast_custom_function_unregister(&dundi_function);
sched_context_destroy(sched);
@@ -4518,21 +4521,7 @@ static int load_module(void)
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "DUNDi Ready and Listening on %s port %d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
- ast_cli_register(&cli_debug);
- ast_cli_register(&cli_store_history);
- ast_cli_register(&cli_flush);
- ast_cli_register(&cli_no_debug);
- ast_cli_register(&cli_no_store_history);
- ast_cli_register(&cli_show_peers);
- ast_cli_register(&cli_show_entityid);
- ast_cli_register(&cli_show_trans);
- ast_cli_register(&cli_show_requests);
- ast_cli_register(&cli_show_mappings);
- ast_cli_register(&cli_show_precache);
- ast_cli_register(&cli_show_peer);
- ast_cli_register(&cli_lookup);
- ast_cli_register(&cli_precache);
- ast_cli_register(&cli_queryeid);
+ ast_cli_register_multiple(cli_dundi, sizeof(cli_dundi) / sizeof(struct ast_cli_entry));
if (ast_register_switch(&dundi_switch))
ast_log(LOG_ERROR, "Unable to register DUNDi switch\n");
ast_custom_function_register(&dundi_function);
diff --git a/res/res_agi.c b/res/res_agi.c
index edcda4e60..7794449aa 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -1302,7 +1302,7 @@ static char debug_usage[] =
" Enables dumping of AGI transactions for debugging purposes\n";
static char no_debug_usage[] =
-"Usage: agi no debug\n"
+"Usage: agi nodebug\n"
" Disables dumping of AGI transactions for debugging purposes\n";
static int agi_do_debug(int fd, int argc, char *argv[])
@@ -1314,7 +1314,7 @@ static int agi_do_debug(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static int agi_no_debug(int fd, int argc, char *argv[])
+static int agi_no_debug_deprecated(int fd, int argc, char *argv[])
{
if (argc != 3)
return RESULT_SHOWUSAGE;
@@ -1323,11 +1323,14 @@ static int agi_no_debug(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static struct ast_cli_entry cli_debug =
- { { "agi", "debug", NULL }, agi_do_debug, "Enable AGI debugging", debug_usage };
-
-static struct ast_cli_entry cli_no_debug =
- { { "agi", "no", "debug", NULL }, agi_no_debug, "Disable AGI debugging", no_debug_usage };
+static int agi_no_debug(int fd, int argc, char *argv[])
+{
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
+ agidebug = 0;
+ ast_cli(fd, "AGI Debugging Disabled\n");
+ return RESULT_SUCCESS;
+}
static int handle_noop(struct ast_channel *chan, AGI *agi, int arg, char *argv[])
{
@@ -1924,7 +1927,7 @@ static int handle_showagi(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-static int handle_dumpagihtml(int fd, int argc, char *argv[])
+static int handle_agidumphtml(int fd, int argc, char *argv[])
{
struct agi_command *e;
char fullcmd[80];
@@ -2080,29 +2083,53 @@ static int deadagi_exec(struct ast_channel *chan, void *data)
}
static char showagi_help[] =
-"Usage: show agi [topic]\n"
+"Usage: agi list [topic]\n"
" When called with a topic as an argument, displays usage\n"
" information on the given command. If called without a\n"
" topic, it provides a list of AGI commands.\n";
static char dumpagihtml_help[] =
-"Usage: dump agihtml <filename>\n"
+"Usage: agi dumphtml <filename>\n"
" Dumps the agi command list in html format to given filename\n";
-static struct ast_cli_entry showagi =
-{ { "show", "agi", NULL }, handle_showagi, "Show AGI commands or specific help", showagi_help };
-
-static struct ast_cli_entry dumpagihtml =
-{ { "dump", "agihtml", NULL }, handle_dumpagihtml, "Dumps a list of agi command in html format", dumpagihtml_help };
+static struct ast_cli_entry cli_show_agi_deprecated = {
+ { "show", "agi", NULL },
+ handle_showagi, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_dump_agihtml_deprecated = {
+ { "dump", "agihtml", NULL },
+ handle_agidumphtml, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_agi_no_debug_deprecated = {
+ { "agi", "no", "debug", NULL },
+ agi_no_debug_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_agi[] = {
+ { { "agi", "debug", NULL },
+ agi_do_debug, "Enable AGI debugging",
+ debug_usage },
+
+ { { "agi", "nodebug", NULL },
+ agi_no_debug, "Disable AGI debugging",
+ no_debug_usage, NULL, &cli_agi_no_debug_deprecated },
+
+ { { "agi", "list", NULL },
+ handle_showagi, "List AGI commands or specific help",
+ showagi_help, NULL, &cli_show_agi_deprecated },
+
+ { { "agi", "dumphtml", NULL },
+ handle_agidumphtml, "Dumps a list of agi commands in html format",
+ dumpagihtml_help, NULL, &cli_dump_agihtml_deprecated },
+};
static int unload_module(void)
{
ast_module_user_hangup_all();
- ast_cli_unregister(&showagi);
- ast_cli_unregister(&dumpagihtml);
- ast_cli_unregister(&cli_debug);
- ast_cli_unregister(&cli_no_debug);
+ ast_cli_unregister_multiple(cli_agi, sizeof(cli_agi) / sizeof(struct ast_cli_entry));
ast_unregister_application(eapp);
ast_unregister_application(deadapp);
return ast_unregister_application(app);
@@ -2110,10 +2137,7 @@ static int unload_module(void)
static int load_module(void)
{
- ast_cli_register(&showagi);
- ast_cli_register(&dumpagihtml);
- ast_cli_register(&cli_debug);
- ast_cli_register(&cli_no_debug);
+ ast_cli_register_multiple(cli_agi, sizeof(cli_agi) / sizeof(struct ast_cli_entry));
ast_register_application(deadapp, deadagi_exec, deadsynopsis, descrip);
ast_register_application(eapp, eagi_exec, esynopsis, descrip);
return ast_register_application(app, agi_exec, synopsis, descrip);
diff --git a/res/res_clioriginate.c b/res/res_clioriginate.c
index 454dc7815..44afd7b76 100644
--- a/res/res_clioriginate.c
+++ b/res/res_clioriginate.c
@@ -63,7 +63,11 @@ static char orig_help[] =
static int handle_orig(int fd, int argc, char *argv[]);
static char *complete_orig(const char *line, const char *word, int pos, int state);
-struct ast_cli_entry cli_orig = { { "originate", NULL }, handle_orig, "Originate a call", orig_help, complete_orig };
+struct ast_cli_entry cli_cliorig[] = {
+ { { "originate", NULL },
+ handle_orig, "Originate a call",
+ orig_help, complete_orig },
+};
static int orig_app(int fd, const char *chan, const char *app, const char *appdata)
{
@@ -158,12 +162,14 @@ static char *complete_orig(const char *line, const char *word, int pos, int stat
static int unload_module(void)
{
- return ast_cli_unregister(&cli_orig);
+ ast_cli_unregister_multiple(cli_cliorig, sizeof(cli_cliorig) / sizeof(struct ast_cli_entry));
+ return 0;
}
static int load_module(void)
{
- return ast_cli_register(&cli_orig);
+ ast_cli_register_multiple(cli_cliorig, sizeof(cli_cliorig) / sizeof(struct ast_cli_entry));
+ return 0;
}
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Call origination from the CLI");
diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c
index 4665823f3..fae140011 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -70,11 +70,11 @@ static char cli_realtime_pgsql_status_usage[] =
"Usage: realtime pgsql status\n"
" Shows connection information for the Postgresql RealTime driver\n";
-static struct ast_cli_entry cli_realtime_pgsql_status = {
- { "realtime", "pgsql", "status", NULL }, realtime_pgsql_status,
- "Shows connection information for the Postgresql RealTime driver",
- cli_realtime_pgsql_status_usage, NULL
- };
+static struct ast_cli_entry cli_realtime[] = {
+ { { "realtime", "pgsql", "status", NULL },
+ realtime_pgsql_status, "Shows connection information for the Postgresql RealTime driver",
+ cli_realtime_pgsql_status_usage },
+};
static struct ast_variable *realtime_pgsql(const char *database, const char *table, va_list ap)
{
@@ -569,7 +569,7 @@ static int load_module(void)
if (option_verbose) {
ast_verbose("Postgresql RealTime driver loaded.\n");
}
- ast_cli_register(&cli_realtime_pgsql_status);
+ ast_cli_register_multiple(cli_realtime, sizeof(cli_realtime) / sizeof(struct ast_cli_entry));
ast_mutex_unlock(&pgsql_lock);
@@ -585,7 +585,7 @@ static int unload_module(void)
PQfinish(pgsqlConn);
pgsqlConn = NULL;
};
- ast_cli_unregister(&cli_realtime_pgsql_status);
+ ast_cli_unregister_multiple(cli_realtime, sizeof(cli_realtime) / sizeof(struct ast_cli_entry));
ast_config_engine_deregister(&pgsql_engine);
if (option_verbose) {
ast_verbose("Postgresql RealTime unloaded.\n");
diff --git a/res/res_convert.c b/res/res_convert.c
index 0f46cf14d..ed2c6465a 100644
--- a/res/res_convert.c
+++ b/res/res_convert.c
@@ -122,24 +122,33 @@ fail_out:
}
static char usage_audio_convert[] =
-"Usage: convert <file_in> <file_out>\n"
+"Usage: file convert <file_in> <file_out>\n"
" Convert from file_in to file_out. If an absolute path is not given, the\n"
"default Asterisk sounds directory will be used.\n\n"
"Example:\n"
-" convert tt-weasels.gsm tt-weasels.ulaw\n";
+" file convert tt-weasels.gsm tt-weasels.ulaw\n";
-static struct ast_cli_entry audio_convert_cli={
- { "convert" , NULL }, cli_audio_convert, "Convert audio files", usage_audio_convert
+static struct ast_cli_entry cli_convert_deprecated = {
+ { "convert" , NULL },
+ cli_audio_convert, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_convert[] = {
+ { { "file", "convert" , NULL },
+ cli_audio_convert, "Convert audio file",
+ usage_audio_convert, NULL, &cli_convert_deprecated },
};
static int unload_module(void)
{
- return ast_cli_unregister(&audio_convert_cli);
+ ast_cli_unregister_multiple(cli_convert, sizeof(cli_convert) / sizeof(struct ast_cli_entry));
+ return 0;
}
static int load_module(void)
{
- return ast_cli_register(&audio_convert_cli);
+ ast_cli_register_multiple(cli_convert, sizeof(cli_convert) / sizeof(struct ast_cli_entry));
+ return 0;
}
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "File format conversion CLI command");
diff --git a/res/res_crypto.c b/res/res_crypto.c
index 3fab770e6..586dd77cf 100644
--- a/res/res_crypto.c
+++ b/res/res_crypto.c
@@ -554,25 +554,38 @@ static int init_keys(int fd, int argc, char *argv[])
}
static char show_key_usage[] =
-"Usage: show keys\n"
+"Usage: keys list\n"
" Displays information about RSA keys known by Asterisk\n";
static char init_keys_usage[] =
-"Usage: init keys\n"
+"Usage: keys init\n"
" Initializes private keys (by reading in pass code from the user)\n";
-static struct ast_cli_entry cli_show_keys =
-{ { "show", "keys", NULL }, show_keys, "Displays RSA key information", show_key_usage };
+static struct ast_cli_entry cli_show_keys_deprecated = {
+ { "show", "keys", NULL },
+ show_keys, NULL,
+ NULL };
-static struct ast_cli_entry cli_init_keys =
-{ { "init", "keys", NULL }, init_keys, "Initialize RSA key passcodes", init_keys_usage };
+static struct ast_cli_entry cli_init_keys_deprecated = {
+ { "init", "keys", NULL },
+ init_keys, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_crypto[] = {
+ { { "keys", "list", NULL },
+ show_keys, "Displays RSA key information",
+ show_key_usage, NULL, &cli_show_keys_deprecated },
+
+ { { "keys", "init", NULL },
+ init_keys, "Initialize RSA key passcodes",
+ init_keys_usage, NULL, &cli_init_keys_deprecated },
+};
static int crypto_init(void)
{
SSL_library_init();
ERR_load_crypto_strings();
- ast_cli_register(&cli_show_keys);
- ast_cli_register(&cli_init_keys);
+ ast_cli_register_multiple(cli_crypto, sizeof(cli_crypto) / sizeof(struct ast_cli_entry));
/* Install ourselves into stubs */
ast_key_get = __ast_key_get;
diff --git a/res/res_features.c b/res/res_features.c
index 88c728fdd..48f93d873 100644
--- a/res/res_features.c
+++ b/res/res_features.c
@@ -1888,12 +1888,9 @@ static int handle_showfeatures(int fd, int argc, char *argv[])
}
static char showfeatures_help[] =
-"Usage: show features\n"
+"Usage: feature list\n"
" Lists currently configured features.\n";
-static struct ast_cli_entry showfeatures =
-{ { "show", "features", NULL }, handle_showfeatures, "Lists configured features", showfeatures_help };
-
static int handle_parkedcalls(int fd, int argc, char *argv[])
{
struct parkeduser *cur;
@@ -1922,8 +1919,20 @@ static char showparked_help[] =
"Usage: show parkedcalls\n"
" Lists currently parked calls.\n";
-static struct ast_cli_entry showparked =
-{ { "show", "parkedcalls", NULL }, handle_parkedcalls, "Lists parked calls", showparked_help };
+static struct ast_cli_entry cli_show_features_deprecated = {
+ { "show", "features", NULL },
+ handle_showfeatures, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_features[] = {
+ { { "feature", "list", NULL },
+ handle_showfeatures, "Lists configured features",
+ showfeatures_help, NULL, &cli_show_features_deprecated },
+
+ { { "show", "parkedcalls", NULL },
+ handle_parkedcalls, "Lists parked calls",
+ showparked_help },
+};
/*! \brief Dump lot status */
static int manager_parking_status( struct mansession *s, struct message *m )
@@ -2299,8 +2308,7 @@ static int load_module(void)
if ((res = load_config()))
return res;
- ast_cli_register(&showparked);
- ast_cli_register(&showfeatures);
+ ast_cli_register_multiple(cli_features, sizeof(cli_features) / sizeof(struct ast_cli_entry));
ast_pthread_create(&parking_thread, NULL, do_parking_thread, NULL);
res = ast_register_application(parkedcall, park_exec, synopsis, descrip);
if (!res)
@@ -2323,8 +2331,7 @@ static int unload_module(void)
ast_manager_unregister("ParkedCalls");
ast_manager_unregister("Park");
- ast_cli_unregister(&showfeatures);
- ast_cli_unregister(&showparked);
+ ast_cli_unregister_multiple(cli_features, sizeof(cli_features) / sizeof(struct ast_cli_entry));
ast_unregister_application(parkcall);
ast_devstate_prov_del("Park");
return ast_unregister_application(parkedcall);
diff --git a/res/res_indications.c b/res/res_indications.c
index d12868d9c..34ddf1e31 100644
--- a/res/res_indications.c
+++ b/res/res_indications.c
@@ -64,8 +64,8 @@ static char help_remove_indication[] =
" Remove the given indication from the country.\n";
static char help_show_indications[] =
-"Usage: show indications [<country> ...]\n"
-" Show either a condensed for of all country/indications, or the\n"
+"Usage: indication list [<country> ...]\n"
+" Display either a condensed for of all country/indications, or the\n"
" indications for the specified countries.\n";
char *playtones_desc=
@@ -345,20 +345,24 @@ out: v = v->next;
/*
* CLI entries for commands provided by this module
*/
-static struct ast_cli_entry add_indication_cli =
- { { "indication", "add", NULL }, handle_add_indication,
- "Add the given indication to the country", help_add_indication,
- NULL };
+static struct ast_cli_entry cli_show_indications_deprecated = {
+ { "show", "indications", NULL },
+ handle_show_indications, NULL,
+ NULL };
-static struct ast_cli_entry remove_indication_cli =
- { { "indication", "remove", NULL }, handle_remove_indication,
- "Remove the given indication from the country", help_remove_indication,
- NULL };
+static struct ast_cli_entry cli_indications[] = {
+ { { "indication", "add", NULL },
+ handle_add_indication, "Add the given indication to the country",
+ help_add_indication, NULL },
-static struct ast_cli_entry show_indications_cli =
- { { "show", "indications", NULL }, handle_show_indications,
- "Show a list of all country/indications", help_show_indications,
- NULL };
+ { { "indication", "remove", NULL },
+ handle_remove_indication, "Remove the given indication from the country",
+ help_remove_indication, NULL },
+
+ { { "indication", "list", NULL },
+ handle_show_indications, "Display a list of all countries/indications",
+ help_show_indications, NULL, &cli_show_indications_deprecated },
+};
/*
* Standard module functions ...
@@ -369,9 +373,7 @@ static int unload_module(void)
ast_unregister_indication_country(NULL);
/* and the functions */
- ast_cli_unregister(&add_indication_cli);
- ast_cli_unregister(&remove_indication_cli);
- ast_cli_unregister(&show_indications_cli);
+ ast_cli_unregister_multiple(cli_indications, sizeof(cli_indications) / sizeof(struct ast_cli_entry));
ast_unregister_application("PlayTones");
ast_unregister_application("StopPlayTones");
return 0;
@@ -382,9 +384,7 @@ static int load_module(void)
{
if (ind_load_module())
return AST_MODULE_LOAD_DECLINE;
- ast_cli_register(&add_indication_cli);
- ast_cli_register(&remove_indication_cli);
- ast_cli_register(&show_indications_cli);
+ ast_cli_register_multiple(cli_indications, sizeof(cli_indications) / sizeof(struct ast_cli_entry));
ast_register_application("PlayTones", handle_playtones, "Play a tone list", playtones_desc);
ast_register_application("StopPlayTones", handle_stopplaytones, "Stop playing a tone list","Stop playing a tone list");
diff --git a/res/res_jabber.c b/res/res_jabber.c
index a3da8ff5a..bcd9f6135 100644
--- a/res/res_jabber.c
+++ b/res/res_jabber.c
@@ -113,12 +113,26 @@ static char test_usage[] =
" as configured in jabber.conf can be optionally specified.\n";
static struct ast_cli_entry aji_cli[] = {
- {{ "jabber", "debug", NULL}, aji_do_debug, "Enable Jabber debugging", debug_usage },
- {{ "jabber", "reload", NULL}, aji_do_reload, "Enable Jabber debugging", reload_usage },
- {{ "jabber", "show", "connected", NULL}, aji_show_clients, "Show state of clients and components", debug_usage },
- {{ "jabber", "no", "debug", NULL}, aji_no_debug, "Disable Jabber debug", no_debug_usage },
- {{ "jabber", "test", NULL}, aji_test, "Shows roster, but is genearlly used for mog's debugging.", test_usage },
- };
+ { { "jabber", "debug", NULL},
+ aji_do_debug, "Enable Jabber debugging",
+ debug_usage },
+
+ { { "jabber", "reload", NULL},
+ aji_do_reload, "Enable Jabber debugging",
+ reload_usage },
+
+ { { "jabber", "show", "connected", NULL},
+ aji_show_clients, "Show state of clients and components",
+ debug_usage },
+
+ { { "jabber", "no", "debug", NULL},
+ aji_no_debug, "Disable Jabber debug",
+ no_debug_usage },
+
+ { { "jabber", "test", NULL},
+ aji_test, "Shows roster, but is generally used for mog's debugging.",
+ test_usage },
+};
static char *app_ajisend = "JabberSend";
@@ -2286,7 +2300,7 @@ static int aji_reload()
static int unload_module(void)
{
- ast_cli_unregister_multiple(aji_cli, sizeof(aji_cli) / sizeof(aji_cli[0]));
+ ast_cli_unregister_multiple(aji_cli, sizeof(aji_cli) / sizeof(struct ast_cli_entry));
ast_unregister_application(app_ajisend);
ast_manager_unregister("JabberSend");
ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, {
@@ -2315,7 +2329,7 @@ static int load_module(void)
"Sends a message to a Jabber Client", mandescr_jabber_send);
ast_register_application(app_ajisend, aji_send_exec, ajisend_synopsis, ajisend_descrip);
ast_register_application(app_ajistatus, aji_status_exec, ajistatus_synopsis, ajistatus_descrip);
- ast_cli_register_multiple(aji_cli, sizeof(aji_cli) / sizeof(aji_cli[0]));
+ ast_cli_register_multiple(aji_cli, sizeof(aji_cli) / sizeof(struct ast_cli_entry));
ast_log(LOG_NOTICE, "res_jabber.so loaded.\n");
return 0;
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 18436e0bf..e553a994d 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -1183,11 +1183,29 @@ static int moh_classes_show(int fd, int argc, char *argv[])
return 0;
}
-static struct ast_cli_entry cli_moh = { { "moh", "reload"}, moh_cli, "Music On Hold", "Music On Hold", NULL};
-
-static struct ast_cli_entry cli_moh_classes_show = { { "moh", "classes", "show"}, moh_classes_show, "List MOH classes", "Lists all MOH classes", NULL};
-
-static struct ast_cli_entry cli_moh_files_show = { { "moh", "files", "show"}, cli_files_show, "List MOH file-based classes", "Lists all loaded file-based MOH classes and their files", NULL};
+static struct ast_cli_entry cli_moh_classes_show_deprecated = {
+ { "moh", "classes", "show"},
+ moh_classes_show, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_moh_files_show_deprecated = {
+ { "moh", "files", "show"},
+ cli_files_show, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_moh[] = {
+ { { "moh", "reload"},
+ moh_cli, "Music On Hold",
+ "Music On Hold" },
+
+ { { "moh", "list", "classes"},
+ moh_classes_show, "List MOH classes",
+ "Lists all MOH classes", NULL, &cli_moh_classes_show_deprecated },
+
+ { { "moh", "list", "files"},
+ cli_files_show, "List MOH file-based classes",
+ "Lists all loaded file-based MOH classes and their files", NULL, &cli_moh_files_show_deprecated },
+};
static int init_classes(int reload)
{
@@ -1212,9 +1230,7 @@ static int load_module(void)
res = ast_register_application(app0, moh0_exec, synopsis0, descrip0);
ast_register_atexit(ast_moh_destroy);
- ast_cli_register(&cli_moh);
- ast_cli_register(&cli_moh_files_show);
- ast_cli_register(&cli_moh_classes_show);
+ ast_cli_register_multiple(cli_moh, sizeof(cli_moh) / sizeof(struct ast_cli_entry));
if (!res)
res = ast_register_application(app1, moh1_exec, synopsis1, descrip1);
if (!res)
diff --git a/res/res_odbc.c b/res/res_odbc.c
index 1d4f9b5af..4ca7b0036 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -309,41 +309,48 @@ static int odbc_show_command(int fd, int argc, char **argv)
struct odbc_class *class;
struct odbc_obj *current;
- if (!strcmp(argv[1], "show")) {
- AST_LIST_LOCK(&odbc_list);
- AST_LIST_TRAVERSE(&odbc_list, class, list) {
- if ((argc == 2) || (argc == 3 && !strcmp(argv[2], "all")) || (!strcmp(argv[2], class->name))) {
- int count = 0;
- ast_cli(fd, "Name: %s\nDSN: %s\n", class->name, class->dsn);
+ AST_LIST_LOCK(&odbc_list);
+ AST_LIST_TRAVERSE(&odbc_list, class, list) {
+ if ((argc == 2) || (argc == 3 && !strcmp(argv[2], "all")) || (!strcmp(argv[2], class->name))) {
+ int count = 0;
+ ast_cli(fd, "Name: %s\nDSN: %s\n", class->name, class->dsn);
- if (class->haspool) {
- ast_cli(fd, "Pooled: yes\nLimit: %d\nConnections in use: %d\n", class->limit, class->count);
+ if (class->haspool) {
+ ast_cli(fd, "Pooled: yes\nLimit: %d\nConnections in use: %d\n", class->limit, class->count);
- AST_LIST_TRAVERSE(&(class->odbc_obj), current, list) {
- ast_cli(fd, " Connection %d: %s", ++count, current->up && odbc_sanity_check(current) ? "connected" : "disconnected");
- }
- } else {
- /* Should only ever be one of these */
- AST_LIST_TRAVERSE(&(class->odbc_obj), current, list) {
- ast_cli(fd, "Pooled: no\nConnected: %s\n", current->up && odbc_sanity_check(current) ? "yes" : "no");
- }
+ AST_LIST_TRAVERSE(&(class->odbc_obj), current, list) {
+ ast_cli(fd, " Connection %d: %s", ++count, current->up && odbc_sanity_check(current) ? "connected" : "disconnected");
+ }
+ } else {
+ /* Should only ever be one of these */
+ AST_LIST_TRAVERSE(&(class->odbc_obj), current, list) {
+ ast_cli(fd, "Pooled: no\nConnected: %s\n", current->up && odbc_sanity_check(current) ? "yes" : "no");
}
+ }
ast_cli(fd, "\n");
- }
}
- AST_LIST_UNLOCK(&odbc_list);
}
+ AST_LIST_UNLOCK(&odbc_list);
+
return 0;
}
static char show_usage[] =
-"Usage: odbc show [<class>]\n"
+"Usage: odbc list [<class>]\n"
" List settings of a particular ODBC class.\n"
" or, if not specified, all classes.\n";
-static struct ast_cli_entry odbc_show_struct =
- { { "odbc", "show", NULL }, odbc_show_command, "Show ODBC DSN(s)", show_usage };
+static struct ast_cli_entry cli_odbc_show_deprecated = {
+ { "odbc", "show", NULL },
+ odbc_show_command, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_odbc[] = {
+ { { "odbc", "list", NULL },
+ odbc_show_command, "List ODBC DSN(s)",
+ show_usage, NULL, &cli_odbc_show_deprecated },
+};
static int odbc_register_class(struct odbc_class *class, int connect)
{
@@ -668,7 +675,7 @@ static int load_module(void)
{
if(load_odbc_config() == -1)
return AST_MODULE_LOAD_DECLINE;
- ast_cli_register(&odbc_show_struct);
+ ast_cli_register_multiple(cli_odbc, sizeof(cli_odbc) / sizeof(struct ast_cli_entry));
ast_log(LOG_NOTICE, "res_odbc loaded.\n");
return 0;
}