aboutsummaryrefslogtreecommitdiffstats
path: root/manager.c
diff options
context:
space:
mode:
authorcitats <citats@f38db490-d61c-443f-a65b-d21fe96a405b>2004-06-02 22:30:42 +0000
committercitats <citats@f38db490-d61c-443f-a65b-d21fe96a405b>2004-06-02 22:30:42 +0000
commit1a01bf28062f8e8435efce8d07dcb60e50fc0072 (patch)
tree0740c229a36491be4c8bf8b8f68cb3c211117234 /manager.c
parent87641bf1fe486e9d01ed9ddfc64ce9f35c8e5385 (diff)
Add 'ListCommands' manager command
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3134 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'manager.c')
-rwxr-xr-xmanager.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/manager.c b/manager.c
index 54850f47c..900afc2d5 100755
--- a/manager.c
+++ b/manager.c
@@ -402,6 +402,32 @@ static int action_ping(struct mansession *s, struct message *m)
return 0;
}
+static char mandescr_listcommands[] =
+"Description: Returns the action name and synopsis for every\n"
+" action that is available to the user\n"
+"Variables: NONE\n";
+
+static int action_listcommands(struct mansession *s, struct message *m)
+{
+ struct manager_action *cur = first_action;
+ char idText[256] = "";
+ char *id = astman_get_header(m,"ActionID");
+
+ if (id && !ast_strlen_zero(id))
+ snprintf(idText,256,"ActionID: %s\r\n",id);
+ ast_cli(s->fd, "Response: Success\r\n%s", idText);
+ ast_mutex_lock(&actionlock);
+ while (cur) { /* Walk the list of actions */
+ if ((s->writeperm & cur->authority) == cur->authority)
+ ast_cli(s->fd, "%s: %s\r\n", cur->action, cur->synopsis);
+ cur = cur->next;
+ }
+ ast_mutex_unlock(&actionlock);
+ ast_cli(s->fd, "\r\n");
+
+ return 0;
+}
+
static int action_events(struct mansession *s, struct message *m)
{
char *mask = astman_get_header(m, "EventMask");
@@ -1138,6 +1164,7 @@ int init_manager(void)
ast_manager_register( "ExtensionState", EVENT_FLAG_CALL, action_extensionstate, "Check Extension Status" );
ast_manager_register( "AbsoluteTimeout", EVENT_FLAG_CALL, action_timeout, "Set Absolute Timeout" );
ast_manager_register( "MailboxCount", EVENT_FLAG_CALL, action_mailboxcount, "Check Mailbox Message Count" );
+ ast_manager_register2("ListCommands", 0, action_listcommands, "List available manager commands", mandescr_listcommands);
ast_cli_register(&show_mancmd_cli);
ast_cli_register(&show_mancmds_cli);