[Asterisk-cvs] asterisk/channels chan_sip.c,1.632,1.633

markster at lists.digium.com markster at lists.digium.com
Sat Jan 15 23:58:22 CST 2005


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv6846/channels

Modified Files:
	chan_sip.c 
Log Message:
config restructure, sip peer completion (bug #3352, #3327)


Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.632
retrieving revision 1.633
diff -u -d -r1.632 -r1.633
--- chan_sip.c	15 Jan 2005 21:51:37 -0000	1.632
+++ chan_sip.c	16 Jan 2005 06:01:50 -0000	1.633
@@ -6208,6 +6208,42 @@
 	return c;
 }
 
+/*--- complete_sip_peer: Do completion on peer name ---*/
+static char *complete_sip_peer(char *word, int state)
+{
+	char *result = NULL;
+	int wordlen = strlen(word);
+	int which = 0;
+
+	ASTOBJ_CONTAINER_TRAVERSE(&peerl, !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_peer: Support routine for 'sip show peer' CLI ---*/
+static char *complete_sip_show_peer(char *line, char *word, int pos, int state)
+{
+	if (pos == 3)
+		return complete_sip_peer(word, state);
+
+	return NULL;
+}
+
+/*--- complete_sip_debug_peer: Support routine for 'sip debug peer' CLI ---*/
+static char *complete_sip_debug_peer(char *line, char *word, int pos, int state)
+{
+	if (pos == 3)
+		return complete_sip_peer(word, state);
+
+	return NULL;
+}
+
 /*--- complete_sipnotify: Support routine for 'sip notify' CLI ---*/
 static char *complete_sipnotify(char *line, char *word, int pos, int state)
 {
@@ -6235,21 +6271,8 @@
 		return c;
 	}
 
-	if (pos > 2) {
-		int which = 0;
-
-		/* do completion for peer name */
-
-		ASTOBJ_CONTAINER_TRAVERSE(&peerl, !c, do {
-			/* locking of the ASTOBJ is not required because I only compare the name */
-			if (!strncasecmp(word, iterator->name, strlen(word))) {
-				if (++which > state) {
-					c = strdup(iterator->name);
-				}
-			}
-		} while(0) );
-		return c;
-	}
+	if (pos > 2)
+		return complete_sip_peer(word, state);
 
 	return NULL;
 }
@@ -6869,9 +6892,9 @@
 static struct ast_cli_entry  cli_debug_ip =
 	{ { "sip", "debug", "ip", NULL }, sip_do_debug, "Enable SIP debugging on IP", debug_usage };
 static struct ast_cli_entry  cli_debug_peer =
-	{ { "sip", "debug", "peer", NULL }, sip_do_debug, "Enable SIP debugging on Peername", debug_usage };
+	{ { "sip", "debug", "peer", NULL }, sip_do_debug, "Enable SIP debugging on Peername", debug_usage, complete_sip_debug_peer };
 static struct ast_cli_entry  cli_show_peer =
-	{ { "sip", "show", "peer", NULL }, sip_show_peer, "Show details on specific SIP peer", show_peer_usage };
+	{ { "sip", "show", "peer", NULL }, sip_show_peer, "Show details on specific SIP peer", show_peer_usage, complete_sip_show_peer };
 static struct ast_cli_entry  cli_show_peers =
 	{ { "sip", "show", "peers", NULL }, sip_show_peers, "Show defined SIP peers", show_peers_usage };
 static struct ast_cli_entry  cli_inuse_show =




More information about the svn-commits mailing list