From 0b8b153d3c30f192725dcf3640f716331b24640f Mon Sep 17 00:00:00 2001 From: Corey Farrell Date: Tue, 7 Nov 2017 18:07:35 -0500 Subject: CLI: Create ast_cli_completion_vector. This is a rewrite of ast_cli_completion_matches using a vector to build the list. The original function calls the vector version, NULL terminates the vector and extracts the elements array. One change in behavior the results are now sorted and deduplicated. This will solve bugs where some duplicate checking was done before the list was sorted. Change-Id: Iede20c5b4d965fa5ec71fda136ce9425eeb69519 --- include/asterisk/cli.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'include') diff --git a/include/asterisk/cli.h b/include/asterisk/cli.h index c51d89eb8..7bf473c61 100644 --- a/include/asterisk/cli.h +++ b/include/asterisk/cli.h @@ -300,6 +300,27 @@ int ast_cli_generatornummatches(const char *, const char *); */ char **ast_cli_completion_matches(const char *, const char *); +/*! + * \brief Generates a vector of strings for CLI completion. + * + * \param text Complete input being matched. + * \param word Current word being matched + * + * The results contain strings that both: + * 1) Begin with the string in \a word. + * 2) Are valid in a command after the string in \a text. + * + * The first entry (offset 0) of the result is the longest common substring + * in the results, useful to extend the string that has been completed. + * Subsequent entries are all possible values. + * + * \note All strings and the vector itself are malloc'ed and must be freed + * by the caller. + * + * \note The vector is sorted and does not contain any duplicates. + */ +struct ast_vector_string *ast_cli_completion_vector(const char *text, const char *word); + /*! * \brief Command completion for the list of active channels. * -- cgit v1.2.3