[asterisk-commits] trunk r15852 - /trunk/res/res_clioriginate.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Mar 28 16:06:48 MST 2006


Author: rizzo
Date: Tue Mar 28 17:06:46 2006
New Revision: 15852

URL: http://svn.digium.com/view/asterisk?rev=15852&view=rev
Log:
use ast_cli_complete() to largely simplify the command completion code.


Modified:
    trunk/res/res_clioriginate.c

Modified: trunk/res/res_clioriginate.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_clioriginate.c?rev=15852&r1=15851&r2=15852&view=diff
==============================================================================
--- trunk/res/res_clioriginate.c (original)
+++ trunk/res/res_clioriginate.c Tue Mar 28 17:06:46 2006
@@ -150,29 +150,15 @@
 
 static char *complete_orig(const char *line, const char *word, int pos, int state)
 {
-	int wordlen;
-	char *app = "application";
-	char *exten = "extension";
-	char *ret = NULL;
+	static char *choices[] = { "application", "extension", NULL };
+	char *ret;
 
-	if (pos != 2 || state)
+	if (pos != 2)
 		return NULL;
 
 	STANDARD_INCREMENT_USECOUNT;
 
-	wordlen = strlen(word);
-
-	if (ast_strlen_zero(word)) {
-		/* show the options in alphabetical order */
-		if (!state)
-			ret = strdup(app);
-		else
-			ret = strdup(exten);
-	} else if (!strncasecmp(word, app, wordlen)) {
-		ret = strdup(app);
-	} else if (!strncasecmp(word, exten, wordlen)) {
-		ret = strdup(exten);
-	}
+	ret = ast_cli_complete(word, choices, state);
 
 	STANDARD_DECREMENT_USECOUNT;
 



More information about the asterisk-commits mailing list