From 86f900b20105bf5e918d8347cab8557f33d5fdae Mon Sep 17 00:00:00 2001 From: Michiel van Baak <michiel@vanbaak.info> Date: Wed, 12 Nov 2008 06:46:04 +0000 Subject: [PATCH] This commit does two things: - Add CLI aliases module to asterisk. - Remove all deprecated CLI commands from the code Initial work done by file. Junk-Y and lmadsen did a lot of work and testing to get the list of deprecated commands into the configuration file. Deprecated CLI commands are now handled by this new module, see cli_aliases.conf for more info about that. ok russellb@ via reviewboard (closes issue #13735) Reported by: mvanbaak git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@156120 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- CHANGES | 2 + channels/chan_mgcp.c | 28 +--- channels/chan_sip.c | 34 +--- channels/chan_skinny.c | 32 +--- configs/cli_aliases.conf.sample | 185 +++++++++++++++++++++ funcs/func_devstate.c | 47 +----- include/asterisk/cli.h | 6 - main/asterisk.c | 80 +--------- main/cdr.c | 11 +- main/cli.c | 118 +++----------- main/pbx.c | 39 +---- main/rtp.c | 130 +-------------- main/udptl.c | 63 +------- pbx/pbx_ael.c | 37 +---- pbx/pbx_dundi.c | 56 +------ res/res_agi.c | 28 +--- res/res_clialiases.c | 274 ++++++++++++++++++++++++++++++++ res/res_jabber.c | 44 +---- 18 files changed, 510 insertions(+), 704 deletions(-) create mode 100644 configs/cli_aliases.conf.sample create mode 100644 res/res_clialiases.c diff --git a/CHANGES b/CHANGES index 9da20e49cc..25bdfd520e 100644 --- a/CHANGES +++ b/CHANGES @@ -58,6 +58,8 @@ Miscellaneous same => n,SomethingElse() * musiconhold.conf classes of type 'files' can now use relative directory paths, which are interpreted as relative to the astvarlibdir setting in asterisk.conf. + * All deprecated CLI commands are removed from the sourcecode. They are now handled + by the new clialiases module. See cli_aliases.conf.sample file. ------------------------------------------------------------------------------ --- Functionality changes from Asterisk 1.6.0 to Asterisk 1.6.1 ------------- diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index 083c0e3e25..de502dac80 100644 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -1139,31 +1139,6 @@ static char *handle_mgcp_audit_endpoint(struct ast_cli_entry *e, int cmd, struct return CLI_SUCCESS; } -static char *handle_mgcp_set_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - switch (cmd) { - case CLI_INIT: - e->command = "mgcp set debug [off]"; - e->usage = - "Usage: mgcp set debug [off]\n" - " Enables/Disables dumping of MGCP packets for debugging purposes\n"; - return NULL; - case CLI_GENERATE: - return NULL; - } - - if (a->argc < 3 || a->argc > 4) - return CLI_SHOWUSAGE; - if (a->argc == 3) { - mgcpdebug = 1; - ast_cli(a->fd, "MGCP Debugging Enabled\n"); - } else if (!strncasecmp(a->argv[3], "off", 3)) { - mgcpdebug = 0; - ast_cli(a->fd, "MGCP Debugging Disabled\n"); - } - return CLI_SUCCESS; -} - static char *handle_mgcp_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { @@ -1192,11 +1167,10 @@ static char *handle_mgcp_set_debug(struct ast_cli_entry *e, int cmd, struct ast_ return CLI_SUCCESS; } -static struct ast_cli_entry cli_mgcp_set_debug_deprecated = AST_CLI_DEFINE(handle_mgcp_set_debug_deprecated, "Enable/Disable MGCP debugging"); static struct ast_cli_entry cli_mgcp[] = { AST_CLI_DEFINE(handle_mgcp_audit_endpoint, "Audit specified MGCP endpoint"), AST_CLI_DEFINE(handle_mgcp_show_endpoints, "List defined MGCP endpoints"), - AST_CLI_DEFINE(handle_mgcp_set_debug, "Enable/Disable MGCP debugging", .deprecate_cmd = &cli_mgcp_set_debug_deprecated), + AST_CLI_DEFINE(handle_mgcp_set_debug, "Enable/Disable MGCP debugging"), AST_CLI_DEFINE(mgcp_reload, "Reload MGCP configuration"), }; diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 3a0908fb09..d1c77c4063 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2341,7 +2341,6 @@ static char *sip_do_debug_ip(int fd, char *arg); static char *sip_do_debug_peer(int fd, char *arg); static char *sip_do_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static char *sip_cli_notify(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); -static char *sip_do_history_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static char *sip_set_history(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static int sip_dtmfmode(struct ast_channel *chan, void *data); static int sip_addheader(struct ast_channel *chan, void *data); @@ -15368,36 +15367,6 @@ static char *sip_cli_notify(struct ast_cli_entry *e, int cmd, struct ast_cli_arg return CLI_SUCCESS; } -/*! \brief Enable/Disable SIP History logging (CLI) - deprecated. use sip_set_history instead */ -static char *sip_do_history_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - switch (cmd) { - case CLI_INIT: - e->command = "sip history [off]"; - e->usage = - "Usage: sip history [off]\n" - " Enables/Disables recording of SIP dialog history for debugging purposes.\n" - " Use 'sip show history' to view the history of a call number.\n"; - return NULL; - case CLI_GENERATE: - return NULL; - } - - if (a->argc < 2 || a->argc > 3) { - return CLI_SHOWUSAGE; - } - if (a->argc == 2) { - recordhistory = TRUE; - ast_cli(a->fd, "SIP History Recording Enabled (use 'sip show history')\n"); - } else { - if (strncasecmp(a->argv[2], "off", 3)) - return CLI_SHOWUSAGE; - recordhistory = FALSE; - ast_cli(a->fd, "SIP History Recording Disabled\n"); - } - return CLI_SUCCESS; -} - /*! \brief Enable/Disable SIP History logging (CLI) */ static char *sip_set_history(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { @@ -23728,7 +23697,6 @@ static int reload(void) return 1; } -static struct ast_cli_entry cli_sip_do_history_deprecated = AST_CLI_DEFINE(sip_do_history_deprecated, "Enable/Disable SIP history"); /*! \brief SIP Cli commands definition */ static struct ast_cli_entry cli_sip[] = { AST_CLI_DEFINE(sip_show_channels, "List active SIP channels or subscriptions"), @@ -23749,7 +23717,7 @@ static struct ast_cli_entry cli_sip[] = { AST_CLI_DEFINE(sip_show_sched, "Present a report on the status of the sched queue"), AST_CLI_DEFINE(sip_prune_realtime, "Prune cached Realtime users/peers"), AST_CLI_DEFINE(sip_do_debug, "Enable/Disable SIP debugging"), - AST_CLI_DEFINE(sip_set_history, "Enable/Disable SIP history", .deprecate_cmd = &cli_sip_do_history_deprecated), + AST_CLI_DEFINE(sip_set_history, "Enable/Disable SIP history"), AST_CLI_DEFINE(sip_reload, "Reload SIP configuration"), AST_CLI_DEFINE(sip_show_tcp, "List TCP Connections") }; diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 8b06980c14..a72345cfe4 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -2540,35 +2540,6 @@ static struct ast_rtp_protocol skinny_rtp = { .set_rtp_peer = skinny_set_rtp_peer, }; -static char *handle_skinny_set_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - switch (cmd) { - case CLI_INIT: - e->command = "skinny set debug [off]"; - e->usage = - "Usage: skinny set debug [off]\n" - " Enables/Disables dumping of Skinny packets for debugging purposes\n"; - return NULL; - case CLI_GENERATE: - return NULL; - } - - if (a->argc < 3 || a->argc > 4) - return CLI_SHOWUSAGE; - - if (a->argc == 3) { - skinnydebug = 1; - ast_cli(a->fd, "Skinny Debugging Enabled\n"); - return CLI_SUCCESS; - } else if (!strncasecmp(a->argv[3], "off", 3)) { - skinnydebug = 0; - ast_cli(a->fd, "Skinny Debugging Disabled\n"); - return CLI_SUCCESS; - } else { - return CLI_SHOWUSAGE; - } -} - static char *handle_skinny_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { @@ -3067,14 +3038,13 @@ static char *handle_skinny_show_settings(struct ast_cli_entry *e, int cmd, struc return CLI_SUCCESS; } -static struct ast_cli_entry cli_skinny_set_debug_deprecated = AST_CLI_DEFINE(handle_skinny_set_debug_deprecated, "Enable/Disable Skinny debugging"); static struct ast_cli_entry cli_skinny[] = { AST_CLI_DEFINE(handle_skinny_show_devices, "List defined Skinny devices"), AST_CLI_DEFINE(handle_skinny_show_device, "List Skinny device information"), AST_CLI_DEFINE(handle_skinny_show_lines, "List defined Skinny lines per device"), AST_CLI_DEFINE(handle_skinny_show_line, "List Skinny line information"), AST_CLI_DEFINE(handle_skinny_show_settings, "List global Skinny settings"), - AST_CLI_DEFINE(handle_skinny_set_debug, "Enable/Disable Skinny debugging", .deprecate_cmd = &cli_skinny_set_debug_deprecated), + AST_CLI_DEFINE(handle_skinny_set_debug, "Enable/Disable Skinny debugging"), AST_CLI_DEFINE(handle_skinny_reset, "Reset Skinny device(s)"), }; diff --git a/configs/cli_aliases.conf.sample b/configs/cli_aliases.conf.sample new file mode 100644 index 0000000000..7743a47d68 --- /dev/null +++ b/configs/cli_aliases.conf.sample @@ -0,0 +1,185 @@ +; +; CLI Aliases configuration +; +; This module also registers a "cli show aliases" CLI command to list +; configured CLI aliases. + +[general] +; Here you define what alias templates you want to use. You can also define +; multiple templates to use as well. If you do, and there is a conflict, then +; the first alias defined will win. +; +template = friendly ; By default, include friendly aliases +;template = asterisk12 ; Asterisk 1.2 style syntax +;template = asterisk14 ; Asterisk 1.4 style syntax +;template = individual_custom ; see [individual_custom] example below which + ; includes a list of aliases from an external + ; file + + +; Because the Asterisk CLI syntax follows a "module verb argument" syntax, +; sometimes we run into an issue between being consistant with this format +; in the core system, and maintaining system friendliness. In order to get +; around this we're providing some useful aliases by default. +; +[friendly] +hangup request=channel request hangup +originate=channel originate +help=core show help +pri intense debug span=pri set debug 2 span + +; CLI Alias Templates +; ------------------- +; +; You can define several alias templates. +; It works with context templates like all other configuration files +; +;[asterisk](!) +; To create an alias you simply set the variable name as the alias and variable +; value as the real CLI command you want executed +; +;die die die=stop now + +;[asterisk16](asterisk) +; Alias for making voicemail reload actually do module reload app_voicemail.so +;voicemail reload=module reload app_voicemail.so +; This will make the CLI command "mr" behave as though it is "module reload". +;mr=module reload +; +; +; In addition, you could also include a flat file of aliases which is loaded by +; the [individual_custom] template in the [general] section. +; +;[individual_custom] +;#include "/etc/asterisk/aliases" + +; Implemented CLI Alias Templates +; ------------------------------- +; +; Below here we have provided you with some templates, easily allowing you to +; utilize previous Asterisk CLI commands with any version of Asterisk. In this +; way you will be able to use Asterisk 1.2 and 1.4 style CLI syntax with any +; version Asterisk going forward into the future. +; +; We have also separated out the vanilla syntax into a context template which +; allows you to keep your custom changes separate of the standard templates +; we have provided you. In this way you can clearly see your custom changes, +; and also allowing you to combine various templates as you see fit. +; +; The naming scheme we have used is recommended, but certainly is not enforced +; by Asterisk. If you wish to use the provided templates, simply define the +; context name which does not utilize the '_tpl' at the end. For example, +; if you would like to use the Asterisk 1.2 style syntax, define in the +; [general] section + +[asterisk12_tpl](!) +show channeltypes=core show channeltypes +show channeltype=core show channeltype +show manager command=manager show command +show manager commands=manager show commands +show manager connected=manager show connected +show manager eventq=manager show eventq +rtp no debug=rtp set debug off +rtp rtcp debug ip=rtcp debug ip +rtp rtcp debug=rtcp debug +rtp rtcp no debug=rtcp debug off +rtp rtcp stats=rtcp stats +rtp rtcp no stats=rtcp stats off +stun no debug=stun debug off +udptl no debug=udptl debug off +show image formats=core show image formats +show file formats=core show file formats +show applications=core show applications +show functions=core show functions +show switches=core show switches +show hints=core show hints +show globals=core show globals +show function=core show function +show application=core show application +set global=core set global +show dialplan=dialplan show +show codecs=core show codecs +show audio codecs=core show audio codecs +show video codecs=core show video codecs +show image codecs=core show image codecs +show codec=core show codec +moh classes show=moh show classes +moh files show=moh show files +agi no debug=agi debug off +show agi=agi show +dump agihtml=agi dumphtml +show features=feature show +show indications=indication show +answer=console answer +hangup=console hangup +flash=console flash +dial=console dial +mute=console mute +unmute=console unmute +transfer=console transfer +send text=console send text +autoanswer=console autoanswer +oss boost=console boost +console=console active +save dialplan=dialplan save +add extension=dialplan add extension +remove extension=dialplan remove extension +add ignorepat=dialplan add ignorepat +remove ignorepat=dialplan remove ignorepat +include context=dialplan add include +dont include=dialplan remove include +extensions reload=dialplan reload +show translation=core show translation +convert=file convert +show queue=queue show +add queue member=queue add member +remove queue member=queue remove member +ael no debug=ael nodebug +sip debug=sip set debug +sip no debug=sip set debug off +show voicemail users=voicemail show users +show voicemail zones=voicemail show zones +iax2 trunk debug=iax2 set debug trunk +iax2 jb debug=iax2 set debug jb +iax2 no debug=iax2 set debug off +iax2 no trunk debug=iax2 set debug trunk off +iax2 no jb debug=iax2 set debug jb off +show agents=agent show +show agents online=agent show online +show memory allocations=memory show allocations +show memory summary=memory show summary +show version=core show version +show version files=core show file version +show profile=core show profile +clear profile=core clear profile + +[asterisk12](asterisk12_tpl) +; add any additional custom commands you want below here, for example: +;die quickly=stop now + +[asterisk14_tpl](!) +cdr status=cdr show status +rtp debug=rtp set debug on +rtcp debug=rtcp set debug on +rtcp stats=rtcp set stats on +stun debug=stun set debug on +udptl debug=udptl set debug on +core show globals=dialplan show globals +core set global=dialplan set global +core set chanvar=dialplan set chanvar +agi dumphtml=agi dump html +ael debug=ael set debug +funcdevstate list=devstate list +sip history=sip set history on +skinny debug=skinny set debug on +mgcp set debug=mgcp set debug on +abort shutdown=core abort shutdown +stop now=core stop now +stop gracefully=core stop gracefully +stop when convenient=core stop when convenient +restart now=core restart now +restart gracefully=core restart gracefully +restart when convenient=core restart when convenient + +[asterisk14](asterisk14_tpl) +; add any additional custom commands you want below here. diff --git a/funcs/func_devstate.c b/funcs/func_devstate.c index f164cb7c14..6c02ca0373 100644 --- a/funcs/func_devstate.c +++ b/funcs/func_devstate.c @@ -188,50 +188,6 @@ static enum ast_device_state custom_devstate_callback(const char *data) return ast_devstate_val(buf); } -static char *handle_cli_funcdevstate_list(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - struct ast_db_entry *db_entry, *db_tree; - - switch (cmd) { - case CLI_INIT: - e->command = "funcdevstate list"; - e->usage = - "Usage: funcdevstate list\n" - " List all custom device states that have been set by using\n" - " the DEVICE_STATE dialplan function.\n"; - return NULL; - case CLI_GENERATE: - return NULL; - } - - if (a->argc != e->args) - return CLI_SHOWUSAGE; - - ast_cli(a->fd, "\n" - "---------------------------------------------------------------------\n" - "--- Custom Device States --------------------------------------------\n" - "---------------------------------------------------------------------\n" - "---\n"); - - db_entry = db_tree = ast_db_gettree(astdb_family, NULL); - for (; db_entry; db_entry = db_entry->next) { - const char *dev_name = strrchr(db_entry->key, '/') + 1; - if (dev_name <= (const char *) 1) - continue; - ast_cli(a->fd, "--- Name: 'Custom:%s' State: '%s'\n" - "---\n", dev_name, db_entry->data); - } - ast_db_freetree(db_tree); - db_tree = NULL; - - ast_cli(a->fd, - "---------------------------------------------------------------------\n" - "---------------------------------------------------------------------\n" - "\n"); - - return CLI_SUCCESS; -} - static char *handle_cli_devstate_list(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct ast_db_entry *db_entry, *db_tree; @@ -339,9 +295,8 @@ static char *handle_cli_devstate_change(struct ast_cli_entry *e, int cmd, struct return CLI_SUCCESS; } -static struct ast_cli_entry cli_funcdevstate_list_deprecated = AST_CLI_DEFINE(handle_cli_funcdevstate_list, "List currently known custom device states"); static struct ast_cli_entry cli_funcdevstate[] = { - AST_CLI_DEFINE(handle_cli_devstate_list, "List currently known custom device states", .deprecate_cmd = &cli_funcdevstate_list_deprecated), + AST_CLI_DEFINE(handle_cli_devstate_list, "List currently known custom device states"), AST_CLI_DEFINE(handle_cli_devstate_change, "Change a custom device state"), }; diff --git a/include/asterisk/cli.h b/include/asterisk/cli.h index 854c189ffa..8b337aea15 100644 --- a/include/asterisk/cli.h +++ b/include/asterisk/cli.h @@ -154,21 +154,15 @@ struct ast_cli_entry { const char *summary; /*!< Summary of the command (< 60 characters) */ const char *usage; /*!< Detailed usage information */ - struct ast_cli_entry *deprecate_cmd; - int inuse; /*!< For keeping track of usage */ struct module *module; /*!< module this belongs to */ char *_full_cmd; /*!< built at load time from cmda[] */ int cmdlen; /*!< len up to the first invalid char [<{% */ /*! \brief 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 args; /*!< number of non-null entries in cmda */ char *command; /*!< command, non-null for new-style entries */ - int deprecated; cli_fn handler; - 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 27c221353c..79e5e7be04 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -1590,14 +1590,6 @@ static char *handle_stop_now(struct ast_cli_entry *e, int cmd, struct ast_cli_ar return CLI_SUCCESS; } -static char *handle_stop_now_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - char *res = handle_stop_now(e, cmd, a); - if (cmd == CLI_INIT) - e->command = "stop now"; - return res; -} - static char *handle_stop_gracefully(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { @@ -1618,14 +1610,6 @@ static char *handle_stop_gracefully(struct ast_cli_entry *e, int cmd, struct ast return CLI_SUCCESS; } -static char *handle_stop_gracefully_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - char *res = handle_stop_gracefully(e, cmd, a); - if (cmd == CLI_INIT) - e->command = "stop gracefully"; - return res; -} - static char *handle_stop_when_convenient(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { @@ -1646,14 +1630,6 @@ static char *handle_stop_when_convenient(struct ast_cli_entry *e, int cmd, struc return CLI_SUCCESS; } -static char *handle_stop_when_convenient_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - char *res = handle_stop_when_convenient(e, cmd, a); - if (cmd == CLI_INIT) - e->command = "stop when convenient"; - return res; -} - static char *handle_restart_now(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { @@ -1674,14 +1650,6 @@ static char *handle_restart_now(struct ast_cli_entry *e, int cmd, struct ast_cli return CLI_SUCCESS; } -static char *handle_restart_now_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - char *res = handle_restart_now(e, cmd, a); - if (cmd == CLI_INIT) - e->command = "restart now"; - return res; -} - static char *handle_restart_gracefully(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { @@ -1702,14 +1670,6 @@ static char *handle_restart_gracefully(struct ast_cli_entry *e, int cmd, struct return CLI_SUCCESS; } -static char *handle_restart_gracefully_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - char *res = handle_restart_gracefully(e, cmd, a); - if (cmd == CLI_INIT) - e->command = "restart gracefully"; - return res; -} - static char *handle_restart_when_convenient(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { @@ -1730,14 +1690,6 @@ static char *handle_restart_when_convenient(struct ast_cli_entry *e, int cmd, st return CLI_SUCCESS; } -static char *handle_restart_when_convenient_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - char *res = handle_restart_when_convenient(e, cmd, a); - if (cmd == CLI_INIT) - e->command = "restart when convenient"; - return res; -} - static char *handle_abort_shutdown(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { @@ -1759,14 +1711,6 @@ static char *handle_abort_shutdown(struct ast_cli_entry *e, int cmd, struct ast_ return CLI_SUCCESS; } -static char *handle_abort_shutdown_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - char *res = handle_abort_shutdown(e, cmd, a); - if (cmd == CLI_INIT) - e->command = "abort shutdown"; - return res; -} - static char *handle_bang(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { @@ -1866,24 +1810,14 @@ static char *show_license(struct ast_cli_entry *e, int cmd, struct ast_cli_args #define ASTERISK_PROMPT2 "%s*CLI> " -/* deprecated cli entries */ -static struct ast_cli_entry cli_abort_shutdown_deprecated = AST_CLI_DEFINE(handle_abort_shutdown_deprecated, "Cancel a running shutdown."); -static struct ast_cli_entry cli_stop_now_deprecated = AST_CLI_DEFINE(handle_stop_now_deprecated, "Shut down Asterisk immediately."); -static struct ast_cli_entry cli_stop_gracefully_deprecated = AST_CLI_DEFINE(handle_stop_gracefully_deprecated, "Gracefully shut down Asterisk."); -static struct ast_cli_entry cli_stop_when_convenient_deprecated = AST_CLI_DEFINE(handle_stop_when_convenient_deprecated, "Shut down Asterisk at empty call volume."); -static struct ast_cli_entry cli_restart_now_deprecated = AST_CLI_DEFINE(handle_restart_now_deprecated, "Restart Asterisk immediately."); -static struct ast_cli_entry cli_restart_gracefully_deprecated = AST_CLI_DEFINE(handle_restart_gracefully_deprecated, "Restart Asterisk gracefully."); -static struct ast_cli_entry cli_restart_when_convenient_deprecated = AST_CLI_DEFINE(handle_restart_when_convenient_deprecated, "Restart Asterisk at empty call volume."); -/* end deprecated cli entries */ - static struct ast_cli_entry cli_asterisk[] = { - AST_CLI_DEFINE(handle_abort_shutdown, "Cancel a running shutdown", .deprecate_cmd = &cli_abort_shutdown_deprecated), - AST_CLI_DEFINE(handle_stop_now, "Shut down Asterisk immediately", .deprecate_cmd = &cli_stop_now_deprecated), - AST_CLI_DEFINE(handle_stop_gracefully, "Gracefully shut down Asterisk", .deprecate_cmd = &cli_stop_gracefully_deprecated), - AST_CLI_DEFINE(handle_stop_when_convenient, "Shut down Asterisk at empty call volume", .deprecate_cmd = &cli_stop_when_convenient_deprecated), - AST_CLI_DEFINE(handle_restart_now, "Restart Asterisk immediately", .deprecate_cmd = &cli_restart_now_deprecated), - AST_CLI_DEFINE(handle_restart_gracefully, "Restart Asterisk gracefully", .deprecate_cmd = &cli_restart_gracefully_deprecated), - AST_CLI_DEFINE(handle_restart_when_convenient, "Restart Asterisk at empty call volume", .deprecate_cmd = &cli_restart_when_convenient_deprecated), + AST_CLI_DEFINE(handle_abort_shutdown, "Cancel a running shutdown"), + AST_CLI_DEFINE(handle_stop_now, "Shut down Asterisk immediately"), + AST_CLI_DEFINE(handle_stop_gracefully, "Gracefully shut down Asterisk"), + AST_CLI_DEFINE(handle_stop_when_convenient, "Shut down Asterisk at empty call volume"), + AST_CLI_DEFINE(handle_restart_now, "Restart Asterisk immediately"), + AST_CLI_DEFINE(handle_restart_gracefully, "Restart Asterisk gracefully"), + AST_CLI_DEFINE(handle_restart_when_convenient, "Restart Asterisk at empty call volume"), AST_CLI_DEFINE(show_warranty, "Show the warranty (if any) for this copy of Asterisk"), AST_CLI_DEFINE(show_license, "Show the license(s) for this copy of Asterisk"), AST_CLI_DEFINE(handle_version, "Display version info"), diff --git a/main/cdr.c b/main/cdr.c index e731483999..e4d5f759dc 100644 --- a/main/cdr.c +++ b/main/cdr.c @@ -1334,14 +1334,6 @@ static char *handle_cli_status(struct ast_cli_entry *e, int cmd, struct ast_cli_ return CLI_SUCCESS; } -static char *handle_cli_status_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - char *res = handle_cli_status(e, cmd, a); - if (cmd == CLI_INIT) - e->command = "cdr status"; - return res; -} - static char *handle_cli_submit(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { @@ -1364,8 +1356,7 @@ static char *handle_cli_submit(struct ast_cli_entry *e, int cmd, struct ast_cli_ } static struct ast_cli_entry cli_submit = AST_CLI_DEFINE(handle_cli_submit, "Posts all pending batched CDR data"); -static struct ast_cli_entry cli_status_deprecated = AST_CLI_DEFINE(handle_cli_status_deprecated, "Display the CDR status"); -static struct ast_cli_entry cli_status = AST_CLI_DEFINE(handle_cli_status, "Display the CDR status", .deprecate_cmd = &cli_status_deprecated); +static struct ast_cli_entry cli_status = AST_CLI_DEFINE(handle_cli_status, "Display the CDR status"); static int do_reload(int reload) { diff --git a/main/cli.c b/main/cli.c index f9535c40df..979254d04f 100644 --- a/main/cli.c +++ b/main/cli.c @@ -166,14 +166,6 @@ static char *handle_load(struct ast_cli_entry *e, int cmd, struct ast_cli_args * return CLI_SUCCESS; } -static char *handle_load_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - char *res = handle_load(e, cmd, a); - if (cmd == CLI_INIT) - e->command = "load"; - return res; -} - static char *handle_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { int x; @@ -209,14 +201,6 @@ static char *handle_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args return CLI_SUCCESS; } -static char *handle_reload_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - char *s = handle_reload(e, cmd, a); - if (cmd == CLI_INIT) /* override command name */ - e->command = "reload"; - return s; -} - /*! * \brief Find the debug or verbose file setting * \arg debug 1 for debug, 0 for verbose @@ -428,14 +412,6 @@ static char *handle_unload(struct ast_cli_entry *e, int cmd, struct ast_cli_args return CLI_SUCCESS; } -static char *handle_unload_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - char *res = handle_unload(e, cmd, a); - if (cmd == CLI_INIT) - e->command = "unload"; /* XXX override */ - return res; -} - #define MODLIST_FORMAT "%-30s %-40.40s %-10d\n" #define MODLIST_FORMAT2 "%-30s %-40.40s %-10s\n" @@ -948,18 +924,6 @@ static char *handle_core_set_debug_channel(struct ast_cli_entry *e, int cmd, str return CLI_SUCCESS; } -static char *handle_debugchan_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - char *res; - - if (cmd == CLI_HANDLER && a->argc != e->args + 1) - return CLI_SHOWUSAGE; - res = handle_core_set_debug_channel(e, cmd, a); - if (cmd == CLI_INIT) - e->command = "debug channel"; - return res; -} - static char *handle_nodebugchan_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { char *res; @@ -1175,11 +1139,6 @@ static char *group_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cl #undef FORMAT_STRING } -static struct ast_cli_entry cli_debug_channel_deprecated = AST_CLI_DEFINE(handle_debugchan_deprecated, "Enable debugging on channel"); -static struct ast_cli_entry cli_module_load_deprecated = AST_CLI_DEFINE(handle_load_deprecated, "Load a module"); -static struct ast_cli_entry cli_module_reload_deprecated = AST_CLI_DEFINE(handle_reload_deprecated, "reload modules by name"); -static struct ast_cli_entry cli_module_unload_deprecated = AST_CLI_DEFINE(handle_unload_deprecated, "unload modules by name"); - static char *handle_help(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static struct ast_cli_entry cli_cli[] = { @@ -1196,8 +1155,7 @@ static struct ast_cli_entry cli_cli[] = { AST_CLI_DEFINE(handle_showchan, "Display information on a specific channel"), - AST_CLI_DEFINE(handle_core_set_debug_channel, "Enable/disable debugging on a channel", - .deprecate_cmd = &cli_debug_channel_deprecated), + AST_CLI_DEFINE(handle_core_set_debug_channel, "Enable/disable debugging on a channel"), AST_CLI_DEFINE(handle_verbose, "Set level of debug/verbose chattiness"), @@ -1209,11 +1167,11 @@ static struct ast_cli_entry cli_cli[] = { AST_CLI_DEFINE(handle_modlist, "List modules and info"), - AST_CLI_DEFINE(handle_load, "Load a module by name", .deprecate_cmd = &cli_module_load_deprecated), + AST_CLI_DEFINE(handle_load, "Load a module by name"), - AST_CLI_DEFINE(handle_reload, "Reload configuration", .deprecate_cmd = &cli_module_reload_deprecated), + AST_CLI_DEFINE(handle_reload, "Reload configuration"), - AST_CLI_DEFINE(handle_unload, "Unload a module by name", .deprecate_cmd = &cli_module_unload_deprecated ), + AST_CLI_DEFINE(handle_unload, "Unload a module by name"), AST_CLI_DEFINE(handle_showuptime, "Show uptime information"), @@ -1340,14 +1298,17 @@ static char *is_prefix(const char *word, const char *token, } /*! + * \internal * \brief locate a cli command in the 'helpers' list (which must be locked). - * exact has 3 values: + * The search compares word by word taking care of regexps in e->cmda + * This function will return NULL when nothing is matched, or the ast_cli_entry that matched. + * \param cmds + * \param match_type has 3 possible values: * 0 returns if the search key is equal or longer than the entry. - * note that trailing optional arguments are skipped. + * note that trailing optional arguments are skipped. * -1 true if the mismatch is on the last word XXX not true! * 1 true only on complete, exact match. * - * The search compares word by word taking care of regexps in e->cmda */ static struct ast_cli_entry *find_cli(char *const cmds[], int match_type) { @@ -1389,6 +1350,7 @@ static struct ast_cli_entry *find_cli(char *const cmds[], int match_type) cand = e; } } + return e ? e : cand; } @@ -1413,9 +1375,6 @@ static char *find_best(char *argv[]) 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 { @@ -1462,24 +1421,11 @@ static int __ast_cli_register(struct ast_cli_entry *e, struct ast_cli_entry *ed) AST_RWLIST_WRLOCK(&helpers); if (find_cli(e->cmda, 1)) { - ast_log(LOG_WARNING, "Command '%s' already registered (or something close enough)\n", e->_full_cmd); + ast_log(LOG_WARNING, "Command '%s' already registered (or something close enough)\n", S_OR(e->_full_cmd, e->command)); goto done; } if (set_full_cmd(e)) goto done; - if (!ed) { - e->deprecated = 0; - } else { - 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 = e->cmdlen; AST_RWLIST_TRAVERSE_SAFE_BEGIN(&helpers, cur, list) { @@ -1500,11 +1446,6 @@ static int __ast_cli_register(struct ast_cli_entry *e, struct ast_cli_entry *ed) done: AST_RWLIST_UNLOCK(&helpers); - if (e->deprecate_cmd) { - /* This command deprecates another command. Register that one also. */ - __ast_cli_register(e->deprecate_cmd, e); - } - return ret; } @@ -1564,9 +1505,6 @@ static char *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, "%30.30s %s\n", e->_full_cmd, S_OR(e->summary, "<no description available>")); @@ -1586,37 +1524,39 @@ static char *handle_help(struct ast_cli_entry *e, int cmd, struct ast_cli_args * char *res = CLI_SUCCESS; if (cmd == CLI_INIT) { - e->command = "help"; + e->command = "core show help"; e->usage = - "Usage: help [topic]\n" + "Usage: core show help [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 commands.\n"; return NULL; } else if (cmd == CLI_GENERATE) { - /* skip first 4 or 5 chars, "help " */ + /* skip first 14 or 15 chars, "core show help " */ int l = strlen(a->line); - if (l > 5) - l = 5; + if (l > 15) { + l = 15; + } /* XXX watch out, should stop to the non-generator parts */ return __ast_cli_generator(a->line + l, a->word, a->n, 0); } - if (a->argc == 1) + if (a->argc == e->args) { return help1(a->fd, NULL, 0); + } AST_RWLIST_RDLOCK(&helpers); - my_e = find_cli(a->argv + 1, 1); /* try exact match first */ + my_e = find_cli(a->argv + 3, 1); /* try exact match first */ if (!my_e) { - res = help1(a->fd, a->argv + 1, 1 /* locked */); + res = help1(a->fd, a->argv + 3, 1 /* locked */); AST_RWLIST_UNLOCK(&helpers); return res; } if (my_e->usage) ast_cli(a->fd, "%s", my_e->usage); else { - ast_join(fullcmd, sizeof(fullcmd), a->argv+1); + ast_join(fullcmd, sizeof(fullcmd), a->argv + 3); ast_cli(a->fd, "No help text available for '%s'.\n", fullcmd); } AST_RWLIST_UNLOCK(&helpers); @@ -1877,7 +1817,7 @@ int ast_cli_command(int fd, const char *s) ast_atomic_fetchadd_int(&e->inuse, 1); AST_RWLIST_UNLOCK(&helpers); if (e == NULL) { - ast_cli(fd, "No such command '%s' (type 'help %s' for other possible commands)\n", s, find_best(args + 1)); + ast_cli(fd, "No such command '%s' (type 'core show help %s' for other possible commands)\n", s, find_best(args + 1)); goto done; } /* @@ -1890,19 +1830,9 @@ int ast_cli_command(int fd, const char *s) if (retval == CLI_SHOWUSAGE) { ast_cli(fd, "%s", S_OR(e->usage, "Invalid usage, but no usage information available.\n")); - AST_RWLIST_RDLOCK(&helpers); - if (e->deprecated) - 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); - AST_RWLIST_UNLOCK(&helpers); } else { if (retval == CLI_FAILURE) ast_cli(fd, "Command '%s' failed.\n", s); - AST_RWLIST_RDLOCK(&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_RWLIST_UNLOCK(&helpers); } ast_atomic_fetchadd_int(&e->inuse, -1); done: diff --git a/main/pbx.c b/main/pbx.c index 737fe6d538..f38b7a0f12 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -6058,15 +6058,6 @@ static char *handle_show_globals(struct ast_cli_entry *e, int cmd, struct ast_cl return CLI_SUCCESS; } -static char *handle_show_globals_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - - char *res = handle_show_globals(e, cmd, a); - if (cmd == CLI_INIT) - e->command = "core show globals"; - return res; -} - /*! \brief CLI support for listing chanvar's variables in a parseable way */ static char *handle_show_chanvar(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { @@ -6122,14 +6113,6 @@ static char *handle_set_global(struct ast_cli_entry *e, int cmd, struct ast_cli_ return CLI_SUCCESS; } -static char *handle_set_global_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - char *res = handle_set_global(e, cmd, a); - if (cmd == CLI_INIT) - e->command = "core set global"; - return res; -} - static char *handle_set_chanvar(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct ast_channel *chan; @@ -6165,14 +6148,6 @@ static char *handle_set_chanvar(struct ast_cli_entry *e, int cmd, struct ast_cli return CLI_SUCCESS; } -static char *handle_set_chanvar_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - char *res = handle_set_chanvar(e, cmd, a); - if (cmd == CLI_INIT) - e->command = "core set chanvar"; - return res; -} - static char *handle_set_extenpatternmatchnew(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { int oldval = 0; @@ -6229,14 +6204,6 @@ static char *handle_unset_extenpatternmatchnew(struct ast_cli_entry *e, int cmd, return CLI_SUCCESS; } -/* - * Deprecated CLI commands - */ - -static struct ast_cli_entry cli_show_globals_deprecated = AST_CLI_DEFINE(handle_show_globals_deprecated, "Show global dialplan variables."); -static struct ast_cli_entry cli_set_chanvar_deprecated = AST_CLI_DEFINE(handle_set_chanvar_deprecated, "Set a channel variable."); -static struct ast_cli_entry cli_set_global_deprecated = AST_CLI_DEFINE(handle_set_global_deprecated, "Set global dialplan variable."); - /* * CLI entries for upper commands ... */ @@ -6246,12 +6213,12 @@ static struct ast_cli_entry pbx_cli[] = { AST_CLI_DEFINE(handle_show_switches, "Show alternative switches"), AST_CLI_DEFINE(handle_show_hints, "Show dialplan hints"), AST_CLI_DEFINE(handle_show_hint, "Show dialplan hint"), - AST_CLI_DEFINE(handle_show_globals, "Show global dialplan variables", .deprecate_cmd = &cli_show_globals_deprecated), + AST_CLI_DEFINE(handle_show_globals, "Show global dialplan variables"), AST_CLI_DEFINE(handle_show_chanvar, "Show channel variables"), AST_CLI_DEFINE(handle_show_function, "Describe a specific dialplan function"), AST_CLI_DEFINE(handle_show_application, "Describe a specific dialplan application"), - AST_CLI_DEFINE(handle_set_global, "Set global dialplan variable", .deprecate_cmd = &cli_set_global_deprecated), - AST_CLI_DEFINE(handle_set_chanvar, "Set a channel variable", .deprecate_cmd = &cli_set_chanvar_deprecated), + AST_CLI_DEFINE(handle_set_global, "Set global dialplan variable"), + AST_CLI_DEFINE(handle_set_chanvar, "Set a channel variable"), AST_CLI_DEFINE(handle_show_dialplan, "Show dialplan"), AST_CLI_DEFINE(handle_debug_dialplan, "Show fast extension pattern matching data structures"), AST_CLI_DEFINE(handle_unset_extenpatternmatchnew, "Use the Old extension pattern matching algorithm."), diff --git a/main/rtp.c b/main/rtp.c index 33ea83da59..3da025a2be 100644 --- a/main/rtp.c +++ b/main/rtp.c @@ -4439,41 +4439,6 @@ static char *rtcp_do_debug_ip(struct ast_cli_args *a) return CLI_SUCCESS; } -static char *handle_cli_rtp_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - switch (cmd) { - case CLI_INIT: - e->command = "rtp debug [off|ip]"; - e->usage = - "Usage: rtp debug [off]|[ip host[:port]]\n" - " Enable/Disable dumping of all RTP packets. If 'ip' is\n" - " specified, limit the dumped packets to those to and from\n" - " the specified 'host' with optional port.\n"; - return NULL; - case CLI_GENERATE: - return NULL; - } - - if (a->argc < 2 || a->argc > 4) - return CLI_SHOWUSAGE; - if (a->argc == 2) { - rtpdebug = 1; - memset(&rtpdebugaddr, 0, sizeof(rtpdebugaddr)); - ast_cli(a->fd, "RTP Debugging Enabled\n"); - } else if (a->argc == 3) { - if (strncasecmp(a->argv[2], "off", 3)) - return CLI_SHOWUSAGE; - rtpdebug = 0; - ast_cli(a->fd, "RTP Debugging Disabled\n"); - } else { - if (strncasecmp(a->argv[2], "ip", 2)) - return CLI_SHOWUSAGE; - return rtp_do_debug_ip(a); - } - - return CLI_SUCCESS; -} - static char *handle_cli_rtp_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { @@ -4507,41 +4472,6 @@ static char *handle_cli_rtp_set_debug(struct ast_cli_entry *e, int cmd, struct a return CLI_SHOWUSAGE; /* default, failure */ } -static char *handle_cli_rtcp_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - switch (cmd) { - case CLI_INIT: - e->command = "rtcp debug [off|ip]"; - e->usage = - "Usage: rtcp debug [off]|[ip host[:port]]\n" - " Enable/Disable dumping of all RTCP packets. If 'ip' is\n" - " specified, limit the dumped packets to those to and from\n" - " the specified 'host' with optional port.\n"; - return NULL; - case CLI_GENERATE: - return NULL; - } - - if (a->argc < 2 || a->argc > 4) - return CLI_SHOWUSAGE; - if (a->argc == 2) { - rtcpdebug = 1; - memset(&rtcpdebugaddr, 0, sizeof(rtcpdebugaddr)); - ast_cli(a->fd, "RTCP Debugging Enabled\n"); - } else if (a->argc == 3) { - if (strncasecmp(a->argv[2], "off", 3)) - return CLI_SHOWUSAGE; - rtcpdebug = 0; - ast_cli(a->fd, "RTCP Debugging Disabled\n"); - } else { - if (strncasecmp(a->argv[2], "ip", 2)) - return CLI_SHOWUSAGE; - return rtcp_do_debug_ip(a); - } - - return CLI_SUCCESS; -} - static char *handle_cli_rtcp_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { @@ -4575,29 +4505,6 @@ static char *handle_cli_rtcp_set_debug(struct ast_cli_entry *e, int cmd, struct return CLI_SHOWUSAGE; /* default, failure */ } -static char *handle_cli_rtcp_stats_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - switch (cmd) { - case CLI_INIT: - e->command = "rtcp stats [off]"; - e->usage = - "Usage: rtcp stats [off]\n" - " Enable/Disable dumping of RTCP stats.\n"; - return NULL; - case CLI_GENERATE: - return NULL; - } - - if (a->argc < 2 || a->argc > 3) - return CLI_SHOWUSAGE; - if (a->argc == 3 && strncasecmp(a->argv[2], "off", 3)) - return CLI_SHOWUSAGE; - - rtcpstats = (a->argc == 3) ? 0 : 1; - ast_cli(a->fd, "RTCP Stats %s\n", rtcpstats ? "Enabled" : "Disabled"); - return CLI_SUCCESS; -} - static char *handle_cli_rtcp_set_stats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { @@ -4625,30 +4532,6 @@ static char *handle_cli_rtcp_set_stats(struct ast_cli_entry *e, int cmd, struct return CLI_SUCCESS; } -static char *handle_cli_stun_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - switch (cmd) { - case CLI_INIT: - e->command = "stun debug [off]"; - e->usage = - "Usage: stun debug [off]\n" - " Enable/Disable STUN (Simple Traversal of UDP through NATs)\n" - " debugging\n"; - return NULL; - case CLI_GENERATE: - return NULL; - } - - if (a->argc < 2 || a->argc > 3) - return CLI_SHOWUSAGE; - if (a->argc == 3 && strncasecmp(a->argv[2], "off", 3)) - return CLI_SHOWUSAGE; - - stundebug = (a->argc == 3) ? 0 : 1; - ast_cli(a->fd, "STUN Debugging %s\n", stundebug ? "Enabled" : "Disabled"); - return CLI_SUCCESS; -} - static char *handle_cli_stun_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { @@ -4677,16 +4560,11 @@ static char *handle_cli_stun_set_debug(struct ast_cli_entry *e, int cmd, struct return CLI_SUCCESS; } -static struct ast_cli_entry cli_rtp_debug_deprecated = AST_CLI_DEFINE(handle_cli_rtp_debug_deprecated, "Enable/Disable RTP debugging"); -static struct ast_cli_entry cli_rtcp_debug_deprecated = AST_CLI_DEFINE(handle_cli_rtcp_debug_deprecated, "Enable/Disable RTCP debugging"); -static struct ast_cli_entry cli_rtcp_stats_deprecated = AST_CLI_DEFINE(handle_cli_rtcp_stats_deprecated, "Enable/Disable RTCP stats"); -static struct ast_cli_entry cli_stun_debug_deprecated = AST_CLI_DEFINE(handle_cli_stun_debug_deprecated, "Enable/Disable STUN debugging"); - static struct ast_cli_entry cli_rtp[] = { - AST_CLI_DEFINE(handle_cli_rtp_set_debug, "Enable/Disable RTP debugging", .deprecate_cmd = &cli_rtp_debug_deprecated), - AST_CLI_DEFINE(handle_cli_rtcp_set_debug, "Enable/Disable RTCP debugging", .deprecate_cmd = &cli_rtcp_debug_deprecated), - AST_CLI_DEFINE(handle_cli_rtcp_set_stats, "Enable/Disable RTCP stats", .deprecate_cmd = &cli_rtcp_stats_deprecated), - AST_CLI_DEFINE(handle_cli_stun_set_debug, "Enable/Disable STUN debugging", .deprecate_cmd = &cli_stun_debug_deprecated), + AST_CLI_DEFINE(handle_cli_rtp_set_debug, "Enable/Disable RTP debugging"), + AST_CLI_DEFINE(handle_cli_rtcp_set_debug, "Enable/Disable RTCP debugging"), + AST_CLI_DEFINE(handle_cli_rtcp_set_stats, "Enable/Disable RTCP stats"), + AST_CLI_DEFINE(handle_cli_stun_set_debug, "Enable/Disable STUN debugging"), }; static int __ast_rtp_reload(int reload) diff --git a/main/udptl.c b/main/udptl.c index ad1c96d632..620734b60a 100644 --- a/main/udptl.c +++ b/main/udptl.c @@ -1089,66 +1089,6 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, return -1; } -static char *handle_cli_udptl_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - struct hostent *hp; - struct ast_hostent ahp; - int port; - char *p; - char *arg; - - switch (cmd) { - case CLI_INIT: - e->command = "udptl debug [off|ip]"; - e->usage = - "Usage: udptl debug [off]|[ip host[:port]]\n" - " Enable or disable dumping of UDPTL packets.\n" - " If ip is specified, limit the dumped packets to those to and from\n" - " the specified 'host' with optional port.\n"; - return NULL; - case CLI_GENERATE: - return NULL; - } - - if (a->argc < 2 || a->argc > 4) - return CLI_SHOWUSAGE; - - if (a->argc == 2) { - udptldebug = 1; - memset(&udptldebugaddr, 0, sizeof(udptldebugaddr)); - ast_cli(a->fd, "UDPTL Debugging Enabled\n"); - } else if (a->argc == 3) { - if (strncasecmp(a->argv[2], "off", 3)) - return CLI_SHOWUSAGE; - udptldebug = 0; - ast_cli(a->fd, "UDPTL Debugging Disabled\n"); - } else { - if (strncasecmp(a->argv[2], "ip", 2)) - return CLI_SHOWUSAGE; - port = 0; - arg = a->argv[3]; - p = strstr(arg, ":"); - if (p) { - *p = '\0'; - p++; - port = atoi(p); - } - hp = ast_gethostbyname(arg, &ahp); - if (hp == NULL) - return CLI_SHOWUSAGE; - udptldebugaddr.sin_family = AF_INET; - memcpy(&udptldebugaddr.sin_addr, hp->h_addr, sizeof(udptldebugaddr.sin_addr)); - udptldebugaddr.sin_port = htons(port); - if (port == 0) - ast_cli(a->fd, "UDPTL Debugging Enabled for IP: %s\n", ast_inet_ntoa(udptldebugaddr.sin_addr)); - else - ast_cli(a->fd, "UDPTL Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(udptldebugaddr.sin_addr), port); - udptldebug = 1; - } - - return CLI_SUCCESS; -} - static char *handle_cli_udptl_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct hostent *hp; @@ -1211,10 +1151,9 @@ static char *handle_cli_udptl_set_debug(struct ast_cli_entry *e, int cmd, struct return CLI_SUCCESS; } -static struct ast_cli_entry cli_handle_udptl_debug_deprecated = AST_CLI_DEFINE(handle_cli_udptl_debug_deprecated, "Enable/Disable UDPTL debugging"); static struct ast_cli_entry cli_udptl[] = { - AST_CLI_DEFINE(handle_cli_udptl_set_debug, "Enable/Disable UDPTL debugging", .deprecate_cmd = &cli_handle_udptl_debug_deprecated) + AST_CLI_DEFINE(handle_cli_udptl_set_debug, "Enable/Disable UDPTL debugging") }; static void __ast_udptl_reload(int reload) diff --git a/pbx/pbx_ael.c b/pbx/pbx_ael.c index 81801f1c9e..65569f5b94 100644 --- a/pbx/pbx_ael.c +++ b/pbx/pbx_ael.c @@ -153,40 +153,6 @@ static int pbx_load_module(void) } /* CLI interface */ -static char *handle_cli_ael_debug_multiple_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - switch (cmd) { - case CLI_INIT: - e->command = "ael debug [read|tokens|macros|contexts|off]"; - e->usage = - "Usage: ael debug [read|tokens|macros|contexts|off]\n" - " Enable AEL read, token, macro, or context debugging,\n" - " or disable all AEL debugging messages. Note: this\n" - " currently does nothing.\n"; - return NULL; - case CLI_GENERATE: - return NULL; - } - - if (a->argc != 3) - return CLI_SHOWUSAGE; - - if (!strcasecmp(a->argv[2], "read")) - aeldebug |= DEBUG_READ; - else if (!strcasecmp(a->argv[2], "tokens")) - aeldebug |= DEBUG_TOKENS; - else if (!strcasecmp(a->argv[2], "macros")) - aeldebug |= DEBUG_MACROS; - else if (!strcasecmp(a->argv[2], "contexts")) - aeldebug |= DEBUG_CONTEXTS; - else if (!strcasecmp(a->argv[2], "off")) - aeldebug = 0; - else - return CLI_SHOWUSAGE; - - return CLI_SUCCESS; -} - static char *handle_cli_ael_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { @@ -240,10 +206,9 @@ static char *handle_cli_ael_reload(struct ast_cli_entry *e, int cmd, struct ast_ return (pbx_load_module() ? CLI_FAILURE : CLI_SUCCESS); } -static struct ast_cli_entry cli_ael_debug_multiple_deprecated = AST_CLI_DEFINE(handle_cli_ael_debug_multiple_deprecated, "Enable AEL debugging flags"); static struct ast_cli_entry cli_ael[] = { AST_CLI_DEFINE(handle_cli_ael_reload, "Reload AEL configuration"), - AST_CLI_DEFINE(handle_cli_ael_set_debug, "Enable AEL debugging flags", .deprecate_cmd = &cli_ael_debug_multiple_deprecated) + AST_CLI_DEFINE(handle_cli_ael_set_debug, "Enable AEL debugging flags") }; static int unload_module(void) diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c index 12ab1328d0..2b2ff6ef83 100644 --- a/pbx/pbx_dundi.c +++ b/pbx/pbx_dundi.c @@ -2156,30 +2156,6 @@ static int start_network_thread(void) return 0; } -static char *dundi_do_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - switch (cmd) { - case CLI_INIT: - e->command = "dundi [no] debug"; - e->usage = - "Usage: dundi [no] debug\n" - " Enables/Disables dumping of DUNDi packets for debugging purposes\n"; - return NULL; - case CLI_GENERATE: - return NULL; - } - if (a->argc < 2 || a->argc > 3) - return CLI_SHOWUSAGE; - if (a->argc == 2) { - dundidebug = 1; - ast_cli(a->fd, "DUNDi Debugging Enabled\n"); - } else { - dundidebug = 0; - ast_cli(a->fd, "DUNDi Debugging Disabled\n"); - } - return CLI_SUCCESS; -} - static char *dundi_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { @@ -2206,32 +2182,6 @@ static char *dundi_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_ar return CLI_SUCCESS; } -static char *dundi_do_store_history_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - switch (cmd) { - case CLI_INIT: - e->command = "dundi [no] store history"; - e->usage = - "Usage: dundi [no] store history\n" - " Enables/Disables storing of DUNDi requests and times for debugging\n" - "purposes\n"; - return NULL; - case CLI_GENERATE: - return NULL; - } - if (a->argc < 3 || a->argc > 4) - return CLI_SHOWUSAGE; - - if (a->argc == 3) { - global_storehistory = 1; - ast_cli(a->fd, "DUNDi History Storage Enabled\n"); - } else { - global_storehistory = 0; - ast_cli(a->fd, "DUNDi History Storage Disabled\n"); - } - return CLI_SUCCESS; -} - static char *dundi_store_history(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { @@ -2819,11 +2769,9 @@ static char *dundi_show_precache(struct ast_cli_entry *e, int cmd, struct ast_cl #undef FORMAT2 } -static struct ast_cli_entry cli_dundi_do_debug_deprecated = AST_CLI_DEFINE(dundi_do_debug_deprecated, "Enable/Disable DUNDi debugging"); -static struct ast_cli_entry cli_dundi_do_store_history_deprecated = AST_CLI_DEFINE(dundi_do_store_history_deprecated, "Enable/Disable DUNDi historic records"); static struct ast_cli_entry cli_dundi[] = { - AST_CLI_DEFINE(dundi_set_debug, "Enable/Disable DUNDi debugging", .deprecate_cmd = &cli_dundi_do_debug_deprecated), - AST_CLI_DEFINE(dundi_store_history, "Enable/Disable DUNDi historic records", .deprecate_cmd = &cli_dundi_do_store_history_deprecated), + AST_CLI_DEFINE(dundi_set_debug, "Enable/Disable DUNDi debugging"), + AST_CLI_DEFINE(dundi_store_history, "Enable/Disable DUNDi historic records"), AST_CLI_DEFINE(dundi_flush, "Flush DUNDi cache"), AST_CLI_DEFINE(dundi_show_peers, "Show defined DUNDi peers"), AST_CLI_DEFINE(dundi_show_trans, "Show active DUNDi transactions"), diff --git a/res/res_agi.c b/res/res_agi.c index a373649233..4220e423de 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -3013,30 +3013,6 @@ static int write_htmldump(char *filename) return 0; } -static char *handle_cli_agi_dumphtml_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - switch (cmd) { - case CLI_INIT: - e->command = "agi dumphtml"; - e->usage = - "Usage: agi dumphtml <filename>\n" - " Dumps the AGI command list in HTML format to the given\n" - " file.\n"; - return NULL; - case CLI_GENERATE: - return NULL; - } - if (a->argc < e->args + 1) - return CLI_SHOWUSAGE; - - if (write_htmldump(a->argv[2]) < 0) { - ast_cli(a->fd, "Could not create file '%s'\n", a->argv[2]); - return CLI_SHOWUSAGE; - } - ast_cli(a->fd, "AGI HTML commands dumped to: %s\n", a->argv[2]); - return CLI_SUCCESS; -} - static char *handle_cli_agi_dump_html(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { @@ -3164,13 +3140,11 @@ static int deadagi_exec(struct ast_channel *chan, void *data) return agi_exec(chan, data); } -static struct ast_cli_entry cli_agi_dumphtml_deprecated = AST_CLI_DEFINE(handle_cli_agi_dumphtml_deprecated, "Dumps a list of AGI commands in HTML format"); - static struct ast_cli_entry cli_agi[] = { AST_CLI_DEFINE(handle_cli_agi_add_cmd, "Add AGI command to a channel in Async AGI"), AST_CLI_DEFINE(handle_cli_agi_debug, "Enable/Disable AGI debugging"), AST_CLI_DEFINE(handle_cli_agi_show, "List AGI commands or specific help"), - AST_CLI_DEFINE(handle_cli_agi_dump_html, "Dumps a list of AGI commands in HTML format", .deprecate_cmd = &cli_agi_dumphtml_deprecated) + AST_CLI_DEFINE(handle_cli_agi_dump_html, "Dumps a list of AGI commands in HTML format") }; static int unload_module(void) diff --git a/res/res_clialiases.c b/res/res_clialiases.c new file mode 100644 index 0000000000..bc2942b00b --- /dev/null +++ b/res/res_clialiases.c @@ -0,0 +1,274 @@ +/* + * Asterisk -- An open source telephony toolkit. + * + * Copyright (C) 2008, Digium, Inc. + * + * Joshua Colp <jcolp@digium.com> + * + * See http://www.asterisk.org for more information about + * the Asterisk project. Please do not directly contact + * any of the maintainers of this project for assistance; + * the project provides a web site, mailing lists and IRC + * channels for your use. + * + * This program is free software, distributed under the terms of + * the GNU General Public License Version 2. See the LICENSE file + * at the top of the source tree. + */ + +/*! \file + * + * \brief CLI Aliases + * + * \author\verbatim Joshua Colp <jcolp@digium.com> \endverbatim + * + * This module provides the capability to create aliases to other + * CLI commands. + */ + + +#include "asterisk.h" + +ASTERISK_FILE_VERSION(__FILE__, "$Revision$") + +#include "asterisk/module.h" +#include "asterisk/config.h" +#include "asterisk/cli.h" +#include "asterisk/astobj2.h" + +/*! Maximum number of buckets for CLI aliases */ +#define MAX_ALIAS_BUCKETS 53 + +/*! Configuration file used for this application */ +static const char config_file[] = "cli_aliases.conf"; + +struct cli_alias { + struct ast_cli_entry cli_entry; /*!< Actual CLI structure used for this alias */ + char *alias; /*!< CLI Alias */ + char *real_cmd; /*!< Actual CLI command it is aliased to */ + unsigned int marked:1; /*!< Bit to indicate whether this CLI alias is marked for destruction or not */ +}; + +static struct ao2_container *cli_aliases; + +/*! \brief Hashing function used for aliases */ +static int alias_hash_cb(const void *obj, const int flags) +{ + const struct cli_alias *alias = obj; + return ast_str_hash(alias->cli_entry.command); +} + +/*! \brief Comparison function used for aliases */ +static int alias_cmp_cb(void *obj, void *arg, void *data, int flags) +{ + const struct cli_alias *alias0 = obj, *alias1 = arg; + + return (alias0->cli_entry.command == alias1->cli_entry.command ? CMP_MATCH | CMP_STOP : 0); +} + +/*! \brief Destruction function used for aliases */ +static void alias_destroy(void *obj) +{ + struct cli_alias *alias = obj; + + /* Unregister the CLI entry from the core */ + ast_cli_unregister(&alias->cli_entry); + + return; +} + +/*! \brief Function which passes through an aliased CLI command to the real one */ +static char *cli_alias_passthrough(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +{ + struct cli_alias *alias; + struct cli_alias tmp = { + .cli_entry.command = e->command, + }; + char *generator; + const char *line; + + /* Try to find the alias based on the CLI entry */ + if (!(alias = ao2_find(cli_aliases, &tmp, NULL, OBJ_POINTER))) { + return 0; + } + + switch (cmd) { + case CLI_INIT: + ao2_ref(alias, -1); + return NULL; + case CLI_GENERATE: + line = a->line; + line += (strlen(alias->alias)); + if (!ast_strlen_zero(a->word)) { + struct ast_str *real_cmd = ast_str_alloca(strlen(alias->real_cmd) + strlen(line) + 1); + ast_str_append(&real_cmd, 0, "%s%s", alias->real_cmd, line); + generator = ast_cli_generator(real_cmd->str, a->word, a->n); + } else { + generator = ast_cli_generator(alias->real_cmd, a->word, a->n); + } + ao2_ref(alias, -1); + return generator; + } + + /* If they gave us extra arguments we need to construct a string to pass in */ + if (a->argc != e->args) { + struct ast_str *real_cmd = ast_str_alloca(2048); + int i; + + ast_str_append(&real_cmd, 0, "%s", alias->real_cmd); + + /* Add the additional arguments that have been passed in */ + for (i = e->args + 1; i <= a->argc; i++) { + ast_str_append(&real_cmd, 0, " %s", a->argv[i - 1]); + } + + ast_cli_command(a->fd, real_cmd->str); + } else { + ast_cli_command(a->fd, alias->real_cmd); + } + + ao2_ref(alias, -1); + + return CLI_SUCCESS; +} + +/*! \brief CLI Command to display CLI Aliases */ +static char *alias_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +{ +#define FORMAT "%-50.50s %-50.50s\n" + struct cli_alias *alias; + struct ao2_iterator i; + + switch (cmd) { + case CLI_INIT: + e->command = "cli show aliases"; + e->usage = + "Usage: cli show aliases\n" + " Displays a list of aliased CLI commands.\n"; + return NULL; + case CLI_GENERATE: + return NULL; + } + + ast_cli(a->fd, FORMAT, "Alias Command", "Real Command"); + + i = ao2_iterator_init(cli_aliases, 0); + + for (; (alias = ao2_iterator_next(&i)); ao2_ref(alias, -1)) { + ast_cli(a->fd, FORMAT, alias->alias, alias->real_cmd); + } + + return CLI_SUCCESS; +#undef FORMAT +} + +/*! \brief CLI commands to interact with things */ +static struct ast_cli_entry cli_alias[] = { + AST_CLI_DEFINE(alias_show, "Show CLI command aliases"), +}; + +/*! \brief Function called to mark an alias for destruction */ +static int alias_mark(void *obj, void *arg, void *data, int flags) +{ + struct cli_alias *alias = obj; + alias->marked = 1; + return 0; +} + +/*! \brief Function called to see if an alias is marked for destruction */ +static int alias_marked(void *obj, void *arg, void *data, int flags) +{ + struct cli_alias *alias = obj; + return alias->marked ? CMP_MATCH : 0; +} + +/*! \brief Function called to load or reload the configuration file */ +static void load_config(int reload) +{ + struct ast_config *cfg = NULL; + struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; + struct cli_alias *alias; + struct ast_variable *v, *v1; + + if (!(cfg = ast_config_load(config_file, config_flags))) { + ast_log(LOG_ERROR, "res_clialiases configuration file '%s' not found\n", config_file); + return; + } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { + return; + } + + /* Mark CLI aliases for pruning */ + if (reload) { + ao2_callback(cli_aliases, OBJ_NODATA, alias_mark, NULL, NULL); + } + + for (v = ast_variable_browse(cfg, "general"); v; v = v->next) { + if (strcmp(v->name, "template")) { + ast_log(LOG_WARNING, "%s is not a correct option in [%s]\n", v->name, "general"); + continue; + } + /* Read in those there CLI aliases */ + for (v1 = ast_variable_browse(cfg, v->value); v1; v1 = v1->next) { + if (!(alias = ao2_alloc((sizeof(*alias) + strlen(v1->name) + strlen(v1->value) + 2), alias_destroy))) { + continue; + } + alias->alias = ((char *) alias) + sizeof(alias); + alias->real_cmd = ((char *) alias) + strlen(v1->name) + 1; + strcpy(alias->alias, v1->name); + strcpy(alias->real_cmd, v1->value); + alias->cli_entry.handler = cli_alias_passthrough; + alias->cli_entry.command = alias->alias; + alias->cli_entry.usage = "Aliased CLI Command"; + + ao2_link(cli_aliases, alias); + ast_verbose(VERBOSE_PREFIX_2 "Aliased CLI command '%s' to '%s'\n", v1->name, v1->value); + ao2_ref(alias, -1); + } + } + + /* Drop any CLI aliases that should no longer exist */ + if (reload) { + ao2_callback(cli_aliases, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE , alias_marked, NULL, NULL); + } + + ast_config_destroy(cfg); + + return; +} + +/*! \brief Function called to reload the module */ +static int reload_module(void) +{ + load_config(1); + return 0; +} + +/*! \brief Function called to unload the module */ +static int unload_module(void) +{ + ao2_ref(cli_aliases, -1); + + ast_cli_unregister_multiple(cli_alias, ARRAY_LEN(cli_alias)); + + return 0; +} + +/*! \brief Function called to load the module */ +static int load_module(void) +{ + if (!(cli_aliases = ao2_container_alloc(MAX_ALIAS_BUCKETS, alias_hash_cb, alias_cmp_cb))) { + return AST_MODULE_LOAD_DECLINE; + } + + load_config(0); + + ast_cli_register_multiple(cli_alias, sizeof(cli_alias) / sizeof(struct ast_cli_entry)); + + return AST_MODULE_LOAD_SUCCESS; +} + +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "CLI Aliases", + .load = load_module, + .unload = unload_module, + .reload = reload_module, + ); diff --git a/res/res_jabber.c b/res/res_jabber.c index ebb1059f58..4ee7ea9a48 100644 --- a/res/res_jabber.c +++ b/res/res_jabber.c @@ -96,7 +96,6 @@ static void *aji_recv_loop(void *data); static int aji_initialize(struct aji_client *client); static int aji_client_connect(void *data, ikspak *pak); static void aji_set_presence(struct aji_client *client, char *to, char *from, int level, char *desc); -static char *aji_do_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static char *aji_do_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static char *aji_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static char *aji_show_clients(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); @@ -123,9 +122,8 @@ static int aji_register_transport(void *data, ikspak *pak); static int aji_register_transport2(void *data, ikspak *pak); */ -static struct ast_cli_entry cli_aji_do_debug_deprecated = AST_CLI_DEFINE(aji_do_debug_deprecated, "Enable/disable jabber debugging"); static struct ast_cli_entry aji_cli[] = { - AST_CLI_DEFINE(aji_do_set_debug, "Enable/Disable Jabber debug", .deprecate_cmd = &cli_aji_do_debug_deprecated), + AST_CLI_DEFINE(aji_do_set_debug, "Enable/Disable Jabber debug"), AST_CLI_DEFINE(aji_do_reload, "Reload Jabber configuration"), AST_CLI_DEFINE(aji_show_clients, "Show state of clients and components"), AST_CLI_DEFINE(aji_show_buddies, "Show buddy lists of our clients"), @@ -2389,46 +2387,6 @@ static char *aji_do_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_a return CLI_SHOWUSAGE; /* defaults to invalid */ } -/*! - * \brief Turn on/off console debugging (deprecated, use aji_do_set_debug). - * \return CLI_SUCCESS. - */ -static char *aji_do_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - - switch (cmd) { - case CLI_INIT: - e->command = "jabber debug [off]"; - e->usage = - "Usage: jabber debug [off]\n" - " Enables/disables dumping of Jabber packets for debugging purposes.\n"; - return NULL; - case CLI_GENERATE: - return NULL; - } - - if (a->argc == 2) { - ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { - ASTOBJ_RDLOCK(iterator); - iterator->debug = 1; - ASTOBJ_UNLOCK(iterator); - }); - ast_cli(a->fd, "Jabber Debugging Enabled.\n"); - return CLI_SUCCESS; - } else if (a->argc == 3) { - if (!strncasecmp(a->argv[2], "off", 3)) { - ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { - ASTOBJ_RDLOCK(iterator); - iterator->debug = 0; - ASTOBJ_UNLOCK(iterator); - }); - ast_cli(a->fd, "Jabber Debugging Disabled.\n"); - return CLI_SUCCESS; - } - } - return CLI_SHOWUSAGE; /* defaults to invalid */ -} - /*! * \brief Reload jabber module. * \return CLI_SUCCESS. -- GitLab