[asterisk-commits] russell: branch russell/chan_refcount r82356 - /team/russell/chan_refcount/main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 13 17:40:22 CDT 2007


Author: russell
Date: Thu Sep 13 17:40:22 2007
New Revision: 82356

URL: http://svn.digium.com/view/asterisk?view=rev&rev=82356
Log:
convert the handler for ast_complete_channels

Modified:
    team/russell/chan_refcount/main/cli.c

Modified: team/russell/chan_refcount/main/cli.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/main/cli.c?view=diff&rev=82356&r1=82355&r2=82356
==============================================================================
--- team/russell/chan_refcount/main/cli.c (original)
+++ team/russell/chan_refcount/main/cli.c Thu Sep 13 17:40:22 2007
@@ -1032,22 +1032,31 @@
 
 char *ast_complete_channels(const char *line, const char *word, int pos, int state, int rpos)
 {
-	struct ast_channel *c = NULL;
 	int which = 0;
 	int wordlen;
 	char notfound = '\0';
 	char *ret = &notfound; /* so NULL can break the loop */
 
+	auto int complete_chan_cb(void *obj, void *arg, int flags);
+	int complete_chan_cb(void *obj, void *arg, int flags)
+	{
+		struct ast_channel *chan = obj;
+
+		ast_channel_lock(chan);
+		if (!strncasecmp(word, chan->name, wordlen) && ++which > state)
+			ret = ast_strdup(chan->name);
+		ast_channel_unlock(chan);
+
+		return (ret == &notfound) ? 0 : CMP_STOP;
+	}
+
 	if (pos != rpos)
 		return NULL;
 
 	wordlen = strlen(word);	
 
-	while (ret == &notfound && (c = ast_channel_walk_locked(c))) {
-		if (!strncasecmp(word, c->name, wordlen) && ++which > state)
-			ret = ast_strdup(c->name);
-		ast_channel_unlock(c);
-	}
+	ast_channel_callback(complete_chan_cb);
+
 	return ret == &notfound ? NULL : ret;
 }
 




More information about the asterisk-commits mailing list