2 * Asterisk -- A telephony toolkit for Linux.
4 * Standard Command Line Interface
6 * Copyright (C) 1999, Mark Spencer
8 * Mark Spencer <markster@linux-support.net>
10 * This program is free software, distributed under the terms of
11 * the GNU General Public License
16 #include <asterisk/logger.h>
17 #include <asterisk/options.h>
18 #include <asterisk/cli.h>
19 #include <asterisk/module.h>
20 #include <asterisk/channel.h>
21 #include <asterisk/channel_pvt.h>
22 #include <sys/signal.h>
27 /* For rl_filename_completion */
28 #include "editline/readline/readline.h"
29 /* For module directory */
34 #define VERSION_INFO "Asterisk " ASTERISK_VERSION " built by " BUILD_USER "@" BUILD_HOSTNAME \
35 " on a " BUILD_MACHINE " running " BUILD_OS
37 void ast_cli(int fd, char *fmt, ...)
42 vsnprintf(stuff, sizeof(stuff), fmt, ap);
44 write(fd, stuff, strlen(stuff));
47 ast_mutex_t clilock = AST_MUTEX_INITIALIZER;
50 struct ast_cli_entry *helpers = NULL;
52 static char load_help[] =
53 "Usage: load <module name>\n"
54 " Loads the specified module into Asterisk.\n";
56 static char unload_help[] =
57 "Usage: unload [-f|-h] <module name>\n"
58 " Unloads the specified module from Asterisk. The -f\n"
59 " option causes the module to be unloaded even if it is\n"
60 " in use (may cause a crash) and the -h module causes the\n"
61 " module to be unloaded even if the module says it cannot, \n"
62 " which almost always will cause a crash.\n";
64 static char help_help[] =
65 "Usage: help [topic]\n"
66 " When called with a topic as an argument, displays usage\n"
67 " information on the given command. If called without a\n"
68 " topic, it provides a list of commands.\n";
70 static char chanlist_help[] =
71 "Usage: show channels\n"
72 " Lists currently defined channels and some information about\n"
75 static char reload_help[] =
77 " Reloads configuration files for all modules which support\n"
80 static char set_verbose_help[] =
81 "Usage: set verbose <level>\n"
82 " Sets level of verbose messages to be displayed. 0 means\n"
83 " no messages should be displayed.\n";
85 static char softhangup_help[] =
86 "Usage: soft hangup <channel>\n"
87 " Request that a channel be hung up. The hangup takes effect\n"
88 " the next time the driver reads or writes from the channel\n";
90 static int handle_load(int fd, int argc, char *argv[])
93 return RESULT_SHOWUSAGE;
94 if (ast_load_resource(argv[1])) {
95 ast_cli(fd, "Unable to load module %s\n", argv[1]);
96 return RESULT_FAILURE;
98 return RESULT_SUCCESS;
101 static int handle_reload(int fd, int argc, char *argv[])
104 return RESULT_SHOWUSAGE;
106 return RESULT_SUCCESS;
109 static int handle_set_verbose(int fd, int argc, char *argv[])
112 /* Has a hidden 'at least' argument */
113 if ((argc != 3) && (argc != 4))
114 return RESULT_SHOWUSAGE;
115 if ((argc == 4) && strcasecmp(argv[2], "atleast"))
116 return RESULT_SHOWUSAGE;
118 option_verbose = atoi(argv[2]);
121 if (val > option_verbose)
122 option_verbose = val;
124 return RESULT_SUCCESS;
127 static int handle_unload(int fd, int argc, char *argv[])
130 int force=AST_FORCE_SOFT;
132 return RESULT_SHOWUSAGE;
133 for (x=1;x<argc;x++) {
134 if (argv[x][0] == '-') {
137 force = AST_FORCE_FIRM;
140 force = AST_FORCE_HARD;
143 return RESULT_SHOWUSAGE;
145 } else if (x != argc - 1)
146 return RESULT_SHOWUSAGE;
147 else if (ast_unload_resource(argv[x], force)) {
148 ast_cli(fd, "Unable to unload resource %s\n", argv[x]);
149 return RESULT_FAILURE;
152 return RESULT_SUCCESS;
155 #define MODLIST_FORMAT "%-20s %-40.40s %-10d\n"
156 #define MODLIST_FORMAT2 "%-20s %-40.40s %-10s\n"
158 static ast_mutex_t climodentrylock = AST_MUTEX_INITIALIZER;
159 static int climodentryfd = -1;
161 static int modlist_modentry(char *module, char *description, int usecnt)
163 ast_cli(climodentryfd, MODLIST_FORMAT, module, description, usecnt);
167 static char modlist_help[] =
168 "Usage: show modules\n"
169 " Shows Asterisk modules currently in use, and usage "
172 static char version_help[] =
173 "Usage: show version\n"
174 " Shows Asterisk version information.\n ";
176 static char *format_uptimestr(time_t timeval)
178 int years = 0, weeks = 0, days = 0, hours = 0, mins = 0, secs = 0;
182 #define MIN (SECOND*60)
183 #define HOUR (MIN*60)
184 #define DAY (HOUR*24)
186 #define YEAR (DAY*365)
188 if (timeval > YEAR) {
189 years = (timeval / YEAR);
190 timeval -= (years * YEAR);
192 pos += sprintf(timestr + pos, "%d years, ", years);
194 pos += sprintf(timestr + pos, "1 year, ");
196 if (timeval > WEEK) {
197 weeks = (timeval / WEEK);
198 timeval -= (weeks * WEEK);
200 pos += sprintf(timestr + pos, "%d weeks, ", weeks);
202 pos += sprintf(timestr + pos, "1 week, ");
205 days = (timeval / DAY);
206 timeval -= (days * DAY);
208 pos += sprintf(timestr + pos, "%d days, ", days);
210 pos += sprintf(timestr + pos, "1 day, ");
213 if (timeval > HOUR) {
214 hours = (timeval / HOUR);
215 timeval -= (hours * HOUR);
217 pos += sprintf(timestr + pos, "%d hours, ", hours);
219 pos += sprintf(timestr + pos, "1 hour, ");
222 mins = (timeval / MIN);
223 timeval -= (mins * MIN);
225 pos += sprintf(timestr + pos, "%d minutes, ", mins);
227 pos += sprintf(timestr + pos, "1 minute, ");
232 pos += sprintf(timestr + pos, "%d seconds", secs);
234 return timestr ? strdup(timestr) : NULL;
237 static int handle_showuptime(int fd, int argc, char *argv[])
239 time_t curtime, tmptime;
243 if (ast_startuptime) {
244 tmptime = curtime - ast_startuptime;
245 timestr = format_uptimestr(tmptime);
247 ast_cli(fd, "System uptime: %s\n", timestr);
251 if (ast_lastreloadtime) {
252 tmptime = curtime - ast_lastreloadtime;
253 timestr = format_uptimestr(tmptime);
255 ast_cli(fd, "Last reload: %s\n", timestr);
259 return RESULT_SUCCESS;
262 static int handle_modlist(int fd, int argc, char *argv[])
265 return RESULT_SHOWUSAGE;
266 ast_mutex_lock(&climodentrylock);
268 ast_cli(fd, MODLIST_FORMAT2, "Module", "Description", "Use Count");
269 ast_update_module_list(modlist_modentry);
271 ast_mutex_unlock(&climodentrylock);
272 return RESULT_SUCCESS;
275 static int handle_version(int fd, int argc, char *argv[])
278 return RESULT_SHOWUSAGE;
279 ast_cli(fd, "%s\n", VERSION_INFO);
280 return RESULT_SUCCESS;
282 static int handle_chanlist(int fd, int argc, char *argv[])
284 #define FORMAT_STRING "%15s (%-10s %-12s %-4d) %7s %-12s %-15s\n"
285 #define FORMAT_STRING2 "%15s (%-10s %-12s %-4s) %7s %-12s %-15s\n"
286 struct ast_channel *c=NULL;
289 return RESULT_SHOWUSAGE;
290 c = ast_channel_walk(NULL);
291 ast_cli(fd, FORMAT_STRING2, "Channel", "Context", "Extension", "Pri", "State", "Appl.", "Data");
293 ast_cli(fd, FORMAT_STRING, c->name, c->context, c->exten, c->priority, ast_state2str(c->_state),
294 c->appl ? c->appl : "(None)", c->data ? ( strlen(c->data) ? c->data : "(Empty)" ): "(None)");
296 c = ast_channel_walk(c);
298 ast_cli(fd, "%d active channel(s)\n", numchans);
299 return RESULT_SUCCESS;
302 static char showchan_help[] =
303 "Usage: show channel <channel>\n"
304 " Shows lots of information about the specified channel.\n";
306 static char debugchan_help[] =
307 "Usage: debug channel <channel>\n"
308 " Enables debugging on a specific channel.\n";
310 static char nodebugchan_help[] =
311 "Usage: no debug channel <channel>\n"
312 " Disables debugging on a specific channel.\n";
314 static char commandcomplete_help[] =
315 "Usage: _command complete \"<line>\" text state\n"
316 " This function is used internally to help with command completion and should.\n"
317 " never be called by the user directly.\n";
319 static char commandnummatches_help[] =
320 "Usage: _command nummatches \"<line>\" text \n"
321 " This function is used internally to help with command completion and should.\n"
322 " never be called by the user directly.\n";
324 static char commandmatchesarray_help[] =
325 "Usage: _command matchesarray \"<line>\" text \n"
326 " This function is used internally to help with command completion and should.\n"
327 " never be called by the user directly.\n";
329 static int handle_softhangup(int fd, int argc, char *argv[])
331 struct ast_channel *c=NULL;
333 return RESULT_SHOWUSAGE;
334 c = ast_channel_walk(NULL);
336 if (!strcasecmp(c->name, argv[2])) {
337 ast_cli(fd, "Requested Hangup on channel '%s'\n", c->name);
338 ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT);
341 c = ast_channel_walk(c);
344 ast_cli(fd, "%s is not a known channel\n", argv[2]);
345 return RESULT_SUCCESS;
348 static char *__ast_cli_generator(char *text, char *word, int state, int lock);
350 static int handle_commandmatchesarray(int fd, int argc, char *argv[])
358 return RESULT_SHOWUSAGE;
360 matches = ast_cli_completion_matches(argv[2], argv[3]);
362 for (x=0; matches[x]; x++) {
364 printf("command matchesarray for '%s' %s got '%s'\n", argv[2], argv[3], matches[x]);
366 len += sprintf( buf + len, "%s ", matches[x]);
373 printf("array for '%s' %s got '%s'\n", argv[2], argv[3], buf);
379 ast_cli(fd, "NULL\n");
381 return RESULT_SUCCESS;
386 static int handle_commandnummatches(int fd, int argc, char *argv[])
391 return RESULT_SHOWUSAGE;
393 matches = ast_cli_generatornummatches(argv[2], argv[3]);
396 printf("Search for '%s' %s got '%d'\n", argv[2], argv[3], matches);
398 ast_cli(fd, "%d", matches);
400 return RESULT_SUCCESS;
403 static int handle_commandcomplete(int fd, int argc, char *argv[])
407 printf("Search for %d args: '%s', '%s', '%s', '%s'\n", argc, argv[0], argv[1], argv[2], argv[3]);
410 return RESULT_SHOWUSAGE;
411 buf = __ast_cli_generator(argv[2], argv[3], atoi(argv[4]), 0);
413 printf("Search for '%s' %s %d got '%s'\n", argv[2], argv[3], atoi(argv[4]), buf);
419 ast_cli(fd, "NULL\n");
420 return RESULT_SUCCESS;
423 static int handle_debugchan(int fd, int argc, char *argv[])
425 struct ast_channel *c=NULL;
427 return RESULT_SHOWUSAGE;
428 c = ast_channel_walk(NULL);
430 if (!strcasecmp(c->name, argv[2])) {
431 c->fin |= 0x80000000;
432 c->fout |= 0x80000000;
435 c = ast_channel_walk(c);
438 ast_cli(fd, "Debugging enabled on channel %s\n", c->name);
440 ast_cli(fd, "No such channel %s\n", argv[2]);
441 return RESULT_SUCCESS;
444 static int handle_nodebugchan(int fd, int argc, char *argv[])
446 struct ast_channel *c=NULL;
448 return RESULT_SHOWUSAGE;
449 c = ast_channel_walk(NULL);
451 if (!strcasecmp(c->name, argv[3])) {
452 c->fin &= 0x7fffffff;
453 c->fout &= 0x7fffffff;
456 c = ast_channel_walk(c);
459 ast_cli(fd, "Debugging disabled on channel %s\n", c->name);
461 ast_cli(fd, "No such channel %s\n", argv[2]);
462 return RESULT_SUCCESS;
467 static int handle_showchan(int fd, int argc, char *argv[])
469 struct ast_channel *c=NULL;
471 return RESULT_SHOWUSAGE;
472 c = ast_channel_walk(NULL);
474 if (!strcasecmp(c->name, argv[2])) {
484 " NativeFormat: %d\n"
487 "1st File Descriptor: %d\n"
489 " Frames out: %d%s\n"
490 " Time to Hangup: %ld\n"
496 " Pickup Group: %d\n"
500 " Blocking in: %s\n",
501 c->name, c->type, c->uniqueid,
502 (c->callerid ? c->callerid : "(N/A)"),
503 (c->dnid ? c->dnid : "(N/A)" ), ast_state2str(c->_state), c->_state, c->rings, c->nativeformats, c->writeformat, c->readformat,
504 c->fds[0], c->fin & 0x7fffffff, (c->fin & 0x80000000) ? " (DEBUGGED)" : "",
505 c->fout & 0x7fffffff, (c->fout & 0x80000000) ? " (DEBUGGED)" : "", (long)c->whentohangup,
506 c->context, c->exten, c->priority, c->callgroup, c->pickupgroup, ( c->appl ? c->appl : "(N/A)" ),
507 ( c-> data ? (strlen(c->data) ? c->data : "(Empty)") : "(None)"),
508 c->stack, (c->blocking ? c->blockproc : "(Not Blocking)"));
512 c = ast_channel_walk(c);
515 ast_cli(fd, "%s is not a known channel\n", argv[2]);
516 return RESULT_SUCCESS;
519 static char *complete_ch(char *line, char *word, int pos, int state)
521 struct ast_channel *c;
523 c = ast_channel_walk(NULL);
525 if (!strncasecmp(word, c->name, strlen(word))) {
529 c = ast_channel_walk(c);
531 return c ? strdup(c->name) : NULL;
534 static char *complete_fn(char *line, char *word, int pos, int state)
541 strncpy(filename, word, sizeof(filename)-1);
543 snprintf(filename, sizeof(filename), "%s/%s", (char *)ast_config_AST_MODULE_DIR, word);
544 c = (char*)filename_completion_function(filename, state);
545 if (c && word[0] != '/')
546 c += (strlen((char*)ast_config_AST_MODULE_DIR) + 1);
547 return c ? strdup(c) : c;
550 static int handle_help(int fd, int argc, char *argv[]);
552 static struct ast_cli_entry builtins[] = {
553 /* Keep alphabetized */
554 { { "_command", "complete", NULL }, handle_commandcomplete, "Command complete", commandcomplete_help },
555 { { "_command", "nummatches", NULL }, handle_commandnummatches, "Returns number of command matches", commandnummatches_help },
556 { { "_command", "matchesarray", NULL }, handle_commandmatchesarray, "Returns command matches array", commandmatchesarray_help },
557 { { "debug", "channel", NULL }, handle_debugchan, "Enable debugging on a channel", debugchan_help, complete_ch },
558 { { "help", NULL }, handle_help, "Display help list, or specific help on a command", help_help },
559 { { "load", NULL }, handle_load, "Load a dynamic module by name", load_help, complete_fn },
560 { { "no", "debug", "channel", NULL }, handle_nodebugchan, "Disable debugging on a channel", nodebugchan_help, complete_ch },
561 { { "reload", NULL }, handle_reload, "Reload configuration", reload_help },
562 { { "set", "verbose", NULL }, handle_set_verbose, "Set level of verboseness", set_verbose_help },
563 { { "show", "channel", NULL }, handle_showchan, "Display information on a specific channel", showchan_help, complete_ch },
564 { { "show", "channels", NULL }, handle_chanlist, "Display information on channels", chanlist_help },
565 { { "show", "modules", NULL }, handle_modlist, "List modules and info", modlist_help },
566 { { "show", "uptime", NULL }, handle_showuptime, "Show uptime information", modlist_help },
567 { { "show", "version", NULL }, handle_version, "Display version info", version_help },
568 { { "soft", "hangup", NULL }, handle_softhangup, "Request a hangup on a given channel", softhangup_help, complete_ch },
569 { { "unload", NULL }, handle_unload, "Unload a dynamic module by name", unload_help, complete_fn },
570 { { NULL }, NULL, NULL, NULL }
573 static struct ast_cli_entry *find_cli(char *cmds[], int exact)
578 struct ast_cli_entry *e=NULL;
579 for (x=0;builtins[x].cmda[0];x++) {
580 /* start optimistic */
582 for (y=0;match && cmds[y]; y++) {
583 /* If there are no more words in the candidate command, then we're
585 if (!builtins[x].cmda[y] && !exact)
587 /* If there are no more words in the command (and we're looking for
588 an exact match) or there is a difference between the two words,
589 then this is not a match */
590 if (!builtins[x].cmda[y] || strcasecmp(builtins[x].cmda[y], cmds[y]))
593 /* If more words are needed to complete the command then this is not
594 a candidate (unless we're looking for a really inexact answer */
595 if ((exact > -1) && builtins[x].cmda[y])
600 for (e=helpers;e;e=e->next) {
602 for (y=0;match && cmds[y]; y++) {
603 if (!e->cmda[y] && !exact)
605 if (!e->cmda[y] || strcasecmp(e->cmda[y], cmds[y]))
608 if ((exact > -1) && e->cmda[y])
616 static void join(char *s, int len, char *w[])
619 /* Join words into a string */
623 strncat(s, " ", len - strlen(s));
624 strncat(s, w[x], len - strlen(s));
628 static void join2(char *s, int len, char *w[])
631 /* Join words into a string */
634 strncat(s, w[x], len - strlen(s));
638 static char *find_best(char *argv[])
640 static char cmdline[80];
642 /* See how close we get, then print the */
643 char *myargv[AST_MAX_CMD_LEN];
644 for (x=0;x<AST_MAX_CMD_LEN;x++)
646 for (x=0;argv[x];x++) {
648 if (!find_cli(myargv, -1))
651 join(cmdline, sizeof(cmdline), myargv);
655 int ast_cli_unregister(struct ast_cli_entry *e)
657 struct ast_cli_entry *cur, *l=NULL;
658 ast_mutex_lock(&clilock);
663 ast_log(LOG_WARNING, "Can't remove command that is in use\n");
677 ast_mutex_unlock(&clilock);
681 int ast_cli_register(struct ast_cli_entry *e)
683 struct ast_cli_entry *cur, *l=NULL;
684 char fulle[80] ="", fulltst[80] ="";
686 ast_mutex_lock(&clilock);
687 join2(fulle, sizeof(fulle), e->cmda);
688 if (find_cli(e->cmda, -1)) {
689 ast_mutex_unlock(&clilock);
690 ast_log(LOG_WARNING, "Command '%s' already registered (or something close enough)\n", fulle);
695 join2(fulltst, sizeof(fulltst), cur->cmda);
696 len = strlen(fulltst);
697 if (strlen(fulle) < len)
699 if (strncasecmp(fulle, fulltst, len) < 0) {
719 ast_mutex_unlock(&clilock);
723 static int help_workhorse(int fd, char *match[])
729 struct ast_cli_entry *e, *e1, *e2;
733 join(matchstr, sizeof(matchstr), match);
734 while(e1->cmda[0] || e2) {
736 join(fullcmd2, sizeof(fullcmd2), e2->cmda);
738 join(fullcmd1, sizeof(fullcmd1), e1->cmda);
740 (e2 && (strcmp(fullcmd2, fullcmd1) < 0))) {
744 /* Increment by going to next */
752 /* Hide commands that start with '_' */
753 if (fullcmd[0] == '_')
756 if (strncasecmp(matchstr, fullcmd, strlen(matchstr))) {
760 ast_cli(fd, "%20.20s %s\n", fullcmd, e->summary);
765 static int handle_help(int fd, int argc, char *argv[]) {
766 struct ast_cli_entry *e;
769 return RESULT_SHOWUSAGE;
771 e = find_cli(argv + 1, 1);
773 ast_cli(fd, e->usage);
775 if (find_cli(argv + 1, -1)) {
776 return help_workhorse(fd, argv + 1);
778 join(fullcmd, sizeof(fullcmd), argv+1);
779 ast_cli(fd, "No such command '%s'.\n", fullcmd);
783 return help_workhorse(fd, NULL);
785 return RESULT_SUCCESS;
788 static char *parse_args(char *s, int *max, char *argv[])
802 /* If it's escaped, put a literal quote */
807 if (quoted && whitespace) {
808 /* If we're starting a quote, coming off white space start a new word, too */
816 if (!quoted && !escaped) {
817 /* If we're not quoted, mark this as whitespace, and
818 end the previous argument */
822 /* Otherwise, just treat it as anything else */
826 /* If we're escaped, print a literal, otherwise enable escaping */
836 if (x >= AST_MAX_ARGS -1) {
837 ast_log(LOG_WARNING, "Too many arguments, truncating\n");
840 /* Coming off of whitespace, start the next argument */
857 /* This returns the number of unique matches for the generator */
858 int ast_cli_generatornummatches(char *text, char *word)
860 int matches = 0, i = 0;
861 char *buf, *oldbuf = NULL;
864 while ( (buf = ast_cli_generator(text, word, i)) ) {
865 if (++i > 1 && strcmp(buf,oldbuf) == 0) {
875 char **ast_cli_completion_matches(char *text, char *word)
877 char **match_list = NULL, *retstr, *prevstr;
878 size_t match_list_len, max_equal, which, i;
882 while ((retstr = ast_cli_generator(text, word, matches)) != NULL) {
883 if (matches + 1 >= match_list_len) {
884 match_list_len <<= 1;
885 match_list = realloc(match_list, match_list_len * sizeof(char *));
887 match_list[++matches] = retstr;
891 return (char **) NULL;
894 prevstr = match_list[1];
895 max_equal = strlen(prevstr);
896 for (; which <= matches; which++) {
897 for (i = 0; i < max_equal && prevstr[i] == match_list[which][i]; i++)
902 retstr = malloc(max_equal + 1);
903 (void) strncpy(retstr, match_list[1], max_equal);
904 retstr[max_equal] = '\0';
905 match_list[0] = retstr;
907 if (matches + 1 >= match_list_len)
908 match_list = realloc(match_list, (match_list_len + 1) * sizeof(char *));
909 match_list[matches + 1] = (char *) NULL;
914 static char *__ast_cli_generator(char *text, char *word, int state, int lock)
916 char *argv[AST_MAX_ARGS];
917 struct ast_cli_entry *e, *e1, *e2;
926 if ((dup = parse_args(text, &x, argv))) {
927 join(matchstr, sizeof(matchstr), argv);
929 ast_mutex_lock(&clilock);
932 while(e1->cmda[0] || e2) {
934 join(fullcmd2, sizeof(fullcmd2), e2->cmda);
936 join(fullcmd1, sizeof(fullcmd1), e1->cmda);
938 (e2 && (strcmp(fullcmd2, fullcmd1) < 0))) {
942 /* Increment by going to next */
950 if ((fullcmd[0] != '_') && !strncasecmp(matchstr, fullcmd, strlen(matchstr))) {
951 /* We contain the first part of one or more commands */
953 if (matchnum > state) {
954 /* Now, what we're supposed to return is the next word... */
955 if (strlen(word) && x>0) {
962 ast_mutex_unlock(&clilock);
964 return res ? strdup(res) : NULL;
968 if (e->generator && !strncasecmp(matchstr, fullcmd, strlen(fullcmd))) {
969 /* We have a command in its entirity within us -- theoretically only one
970 command can have this occur */
971 fullcmd = e->generator(text, word, (strlen(word) ? (x - 1) : (x)), state);
973 ast_mutex_unlock(&clilock);
979 ast_mutex_unlock(&clilock);
985 char *ast_cli_generator(char *text, char *word, int state)
987 return __ast_cli_generator(text, word, state, 1);
990 int ast_cli_command(int fd, char *s)
992 char *argv[AST_MAX_ARGS];
993 struct ast_cli_entry *e;
997 if ((dup = parse_args(s, &x, argv))) {
998 /* We need at least one entry, or ignore */
1000 ast_mutex_lock(&clilock);
1001 e = find_cli(argv, 0);
1004 ast_mutex_unlock(&clilock);
1006 switch(e->handler(fd, x, argv)) {
1007 case RESULT_SHOWUSAGE:
1008 ast_cli(fd, e->usage);
1012 ast_cli(fd, "No such command '%s' (type 'help' for help)\n", find_best(argv));
1014 ast_mutex_lock(&clilock);
1016 ast_mutex_unlock(&clilock);
1021 ast_log(LOG_WARNING, "Out of memory\n");