[Asterisk-code-review] CLI: Remove compatability code. (asterisk[master])

Corey Farrell asteriskteam at digium.com
Tue Nov 21 08:50:58 CST 2017


Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/7335


Change subject: CLI: Remove compatability code.
......................................................................

CLI: Remove compatability code.

Previous commits maintained compatability with older remote console
clients as well as maintaining all API's.

Remove the following compatability code:
* ast_cli_generatornummatches.
* Remote command "_command nummatches".
* Sorting / duplicate removal by remote console.

Change-Id: I59e6ce94fa57ae564888442049695f7e46746437
---
M include/asterisk/cli.h
M main/asterisk.c
M main/cli.c
3 files changed, 1 insertion(+), 55 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/35/7335/1

diff --git a/include/asterisk/cli.h b/include/asterisk/cli.h
index 3ed88eb..7a72a73 100644
--- a/include/asterisk/cli.h
+++ b/include/asterisk/cli.h
@@ -290,8 +290,6 @@
  */
 char *ast_cli_generator(const char *, const char *, int);
 
-int ast_cli_generatornummatches(const char *, const char *);
-
 /*!
  * \brief Generates a NULL-terminated array of strings that
  * 1) begin with the string in the second parameter, and
diff --git a/main/asterisk.c b/main/asterisk.c
index db80670..dd66867 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -3015,14 +3015,8 @@
 			break;
 		}
 
-		/* Older daemons sent duplicates. */
-		if (AST_VECTOR_GET_CMP(vec, retstr, strcasecmp)) {
-			continue;
-		}
-
 		retstr = ast_strdup(retstr);
-		/* Older daemons sent unsorted. */
-		if (!retstr || AST_VECTOR_ADD_SORTED(vec, retstr, strcasecmp)) {
+		if (!retstr || AST_VECTOR_APPEND(vec, retstr)) {
 			ast_free(retstr);
 			goto vector_cleanup;
 		}
diff --git a/main/cli.c b/main/cli.c
index eae14ad..4284421 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -1336,33 +1336,6 @@
 }
 
 
-
-static char *handle_commandnummatches(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-	int matches = 0;
-
-	switch (cmd) {
-	case CLI_INIT:
-		e->command = "_command nummatches";
-		e->usage =
-			"Usage: _command nummatches \"<line>\" text \n"
-			"       This function is used internally to help with command completion and should.\n"
-			"       never be called by the user directly.\n";
-		return NULL;
-	case CLI_GENERATE:
-		return NULL;
-	}
-
-	if (a->argc != 4)
-		return CLI_SHOWUSAGE;
-
-	matches = ast_cli_generatornummatches(a->argv[2], a->argv[3]);
-
-	ast_cli(a->fd, "%d", matches);
-
-	return CLI_SUCCESS;
-}
-
 struct channel_set_debug_args {
 	int fd;
 	int is_off;
@@ -1794,7 +1767,6 @@
 static char *handle_help(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
 
 static struct ast_cli_entry cli_cli[] = {
-	AST_CLI_DEFINE(handle_commandnummatches, "Returns number of command matches"),
 	AST_CLI_DEFINE(handle_commandmatchesarray, "Returns command matches array"),
 
 	AST_CLI_DEFINE(handle_nodebugchan_deprecated, "Disable debugging on channel(s)"),
@@ -2470,24 +2442,6 @@
 	*argc = x;
 	*trailingwhitespace = whitespace;
 	return duplicate;
-}
-
-/*! \brief Return the number of unique matches for the generator */
-int ast_cli_generatornummatches(const char *text, const char *word)
-{
-	int matches = 0, i = 0;
-	char *buf = NULL, *oldbuf = NULL;
-
-	while ((buf = ast_cli_generator(text, word, i++))) {
-		if (!oldbuf || strcmp(buf,oldbuf))
-			matches++;
-		if (oldbuf)
-			ast_free(oldbuf);
-		oldbuf = buf;
-	}
-	if (oldbuf)
-		ast_free(oldbuf);
-	return matches;
 }
 
 char **ast_cli_completion_matches(const char *text, const char *word)

-- 
To view, visit https://gerrit.asterisk.org/7335
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I59e6ce94fa57ae564888442049695f7e46746437
Gerrit-Change-Number: 7335
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171121/f9778c08/attachment.html>


More information about the asterisk-code-review mailing list