summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2005-02-13 16:56:20 +0000
committerMark Spencer <markster@digium.com>2005-02-13 16:56:20 +0000
commite83c29f281252556de95517502a1d33311b90bfc (patch)
tree7a9f3bd8a3b12c8962189e63ca49541f2c982595 /channels
parentafc33139c429c279acc0a1b1167750b616549122 (diff)
Add sip show user completion (bug #3574)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5019 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rwxr-xr-xchannels/chan_sip.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 115481aec..a4c300153 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -6497,6 +6497,33 @@ static char *complete_sip_debug_peer(char *line, char *word, int pos, int state)
return NULL;
}
+/*--- complete_sip_user: Do completion on user name ---*/
+static char *complete_sip_user(char *word, int state)
+{
+ char *result = NULL;
+ int wordlen = strlen(word);
+ int which = 0;
+
+ ASTOBJ_CONTAINER_TRAVERSE(&userl, !result, do {
+ /* locking of the object is not required because only the name is being compared */
+ if (!strncasecmp(word, iterator->name, wordlen)) {
+ if (++which > state) {
+ result = strdup(iterator->name);
+ }
+ }
+ } while(0) );
+ return result;
+}
+
+/*--- complete_sip_show_user: Support routine for 'sip show user' CLI ---*/
+static char *complete_sip_show_user(char *line, char *word, int pos, int state)
+{
+ if (pos == 3)
+ return complete_sip_user(word, state);
+
+ return NULL;
+}
+
/*--- complete_sipnotify: Support routine for 'sip notify' CLI ---*/
static char *complete_sipnotify(char *line, char *word, int pos, int state)
{
@@ -7152,7 +7179,7 @@ static struct ast_cli_entry cli_show_objects =
static struct ast_cli_entry cli_show_users =
{ { "sip", "show", "users", NULL }, sip_show_users, "Show defined SIP users", show_users_usage };
static struct ast_cli_entry cli_show_user =
- { { "sip", "show", "user", NULL }, sip_show_user, "Show details on specific SIP user", show_user_usage };
+ { { "sip", "show", "user", NULL }, sip_show_user, "Show details on specific SIP user", show_user_usage, complete_sip_show_user };
static struct ast_cli_entry cli_show_subscriptions =
{ { "sip", "show", "subscriptions", NULL }, sip_show_subscriptions, "Show active SIP subscriptions", show_subscriptions_usage};
static struct ast_cli_entry cli_show_channels =