[Asterisk-code-review] manager: Show commands by alphabetically (asterisk[master])
Rodrigo Ramirez Norambuena
asteriskteam at digium.com
Mon May 11 21:33:31 CDT 2015
Rodrigo Ramirez Norambuena has uploaded a new change for review.
https://gerrit.asterisk.org/435
Change subject: manager: Show commands by alphabetically
......................................................................
manager: Show commands by alphabetically
The handle_showmancmds - which is used by the CLI to display the command
actions now does the sorting alphabetically itself.
Change-Id: I149da0cd06c3c4445d7516cc303358e9f26f8b4b
---
M include/asterisk/manager.h
M main/manager.c
2 files changed, 4 insertions(+), 1 deletion(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/35/435/1
diff --git a/include/asterisk/manager.h b/include/asterisk/manager.h
index 1ec1cba..0e870f1 100644
--- a/include/asterisk/manager.h
+++ b/include/asterisk/manager.h
@@ -169,6 +169,7 @@
enum ast_doc_src docsrc;
/*! For easy linking */
AST_RWLIST_ENTRY(manager_action) list;
+ AST_LIST_ENTRY(manager_action) entry;
/*!
* \brief TRUE if the AMI action is registered and the callback can be called.
*
diff --git a/main/manager.c b/main/manager.c
index 17a2738..045137b 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -2405,6 +2405,7 @@
struct manager_action *cur;
int name_len = 1;
int space_remaining;
+ AST_LIST_HEAD_NOLOCK(, manager_action) alpha_manager_actions = AST_LIST_HEAD_NOLOCK_INIT_VALUE;
#define HSMC_FORMAT " %-*.*s %-.*s\n"
switch (cmd) {
case CLI_INIT:
@@ -2423,6 +2424,7 @@
if (incoming_len > name_len) {
name_len = incoming_len;
}
+ AST_LIST_INSERT_SORTALPHA(&alpha_manager_actions, cur, entry, action);
}
space_remaining = MGR_SHOW_TERMINAL_WIDTH - name_len - 4;
@@ -2433,7 +2435,7 @@
ast_cli(a->fd, HSMC_FORMAT, name_len, name_len, "Action", space_remaining, "Synopsis");
ast_cli(a->fd, HSMC_FORMAT, name_len, name_len, "------", space_remaining, "--------");
- AST_RWLIST_TRAVERSE(&actions, cur, list) {
+ while ((cur = AST_LIST_REMOVE_HEAD(&alpha_manager_actions, entry))) {
ast_cli(a->fd, HSMC_FORMAT, name_len, name_len, cur->action, space_remaining, cur->synopsis);
}
AST_RWLIST_UNLOCK(&actions);
--
To view, visit https://gerrit.asterisk.org/435
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I149da0cd06c3c4445d7516cc303358e9f26f8b4b
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Rodrigo Ramirez Norambuena <decipher.hk at gmail.com>
More information about the asterisk-code-review
mailing list