From d12a2ab400a39540950deb4308ad2fd9a24b5074 Mon Sep 17 00:00:00 2001
From: Corey Farrell <git@cfware.com>
Date: Mon, 20 Nov 2017 17:58:37 -0500
Subject: [PATCH] CLI: Remove compatibility code.

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

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

Change-Id: I59e6ce94fa57ae564888442049695f7e46746437
---
 include/asterisk/cli.h |  2 --
 main/asterisk.c        |  8 +-------
 main/cli.c             | 45 ------------------------------------------
 3 files changed, 1 insertion(+), 54 deletions(-)

diff --git a/include/asterisk/cli.h b/include/asterisk/cli.h
index c75fc295d0..30c5dc7987 100644
--- a/include/asterisk/cli.h
+++ b/include/asterisk/cli.h
@@ -293,8 +293,6 @@ int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len);
  */
 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 db80670b86..dd66867b84 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -3015,14 +3015,8 @@ static struct ast_vector_string *ast_el_strtoarr(char *buf)
 			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 0f023b29f1..75846b8c9a 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -1336,33 +1336,6 @@ static char *handle_commandmatchesarray(struct ast_cli_entry *e, int cmd, struct
 }
 
 
-
-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_cli_wait_fullybooted(struct ast_cli_entry *e, int cmd, struc
 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)"),
@@ -2472,23 +2444,6 @@ static char *parse_args(const char *s, int *argc, const char *argv[], int max, i
 	return duplicate;
 }
 
-/*! \brief Return the number of unique matches for the generator */
-int ast_cli_generatornummatches(const char *text, const char *word)
-{
-	int matches;
-	struct ast_vector_string *vec = ast_cli_completion_vector(text, word);
-
-	if (!vec) {
-		return 0;
-	}
-
-	matches = AST_VECTOR_SIZE(vec) - 1;
-	AST_VECTOR_CALLBACK_VOID(vec, ast_free);
-	AST_VECTOR_PTR_FREE(vec);
-
-	return matches;
-}
-
 char **ast_cli_completion_matches(const char *text, const char *word)
 {
 	struct ast_vector_string *vec = ast_cli_completion_vector(text, word);
-- 
GitLab