aboutsummaryrefslogtreecommitdiffstats
path: root/cli.c
diff options
context:
space:
mode:
authorcitats <citats@f38db490-d61c-443f-a65b-d21fe96a405b>2004-04-06 07:42:01 +0000
committercitats <citats@f38db490-d61c-443f-a65b-d21fe96a405b>2004-04-06 07:42:01 +0000
commitc5b266afba6887c5f0f631dbf29b5d4c3683edcf (patch)
tree79790f5032d8b81ee5ddeca15c9bf201bfebcbfc /cli.c
parent1af364d1d8d2fc86130c4854654aa7e57bff553d (diff)
Remove size restiction on remote console command completion (bug 1360)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2634 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'cli.c')
-rwxr-xr-xcli.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/cli.c b/cli.c
index 0068f1259..b29ddeb9a 100755
--- a/cli.c
+++ b/cli.c
@@ -352,13 +352,17 @@ static char *__ast_cli_generator(char *text, char *word, int state, int lock);
static int handle_commandmatchesarray(int fd, int argc, char *argv[])
{
- char buf[2048];
+ char *buf;
+ int buflen = 2048;
int len = 0;
char **matches;
int x;
if (argc != 4)
return RESULT_SHOWUSAGE;
+ buf = malloc(buflen);
+ if (!buf)
+ return RESULT_FAILURE;
buf[len] = '\0';
matches = ast_cli_completion_matches(argv[2], argv[3]);
if (matches) {
@@ -366,6 +370,10 @@ static int handle_commandmatchesarray(int fd, int argc, char *argv[])
#if 0
printf("command matchesarray for '%s' %s got '%s'\n", argv[2], argv[3], matches[x]);
#endif
+ if (len + strlen(matches[x]) >= buflen) {
+ buflen += strlen(matches[x]) * 3;
+ buf = realloc(buf, buflen);
+ }
len += sprintf( buf + len, "%s ", matches[x]);
free(matches[x]);
matches[x] = NULL;
@@ -377,7 +385,8 @@ static int handle_commandmatchesarray(int fd, int argc, char *argv[])
#endif
if (buf) {
- ast_cli(fd, buf);
+ ast_cli(fd, "%s%s",buf, AST_CLI_COMPLETE_EOF);
+ free(buf);
} else
ast_cli(fd, "NULL\n");