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 vasprintf(&stuff, fmt, ap);
44 write(fd, stuff, strlen(stuff));
48 ast_mutex_t clilock = AST_MUTEX_INITIALIZER;
51 struct ast_cli_entry *helpers = NULL;
53 static char load_help[] =
54 "Usage: load <module name>\n"
55 " Loads the specified module into Asterisk.\n";
57 static char unload_help[] =
58 "Usage: unload [-f|-h] <module name>\n"
59 " Unloads the specified module from Asterisk. The -f\n"
60 " option causes the module to be unloaded even if it is\n"
61 " in use (may cause a crash) and the -h module causes the\n"
62 " module to be unloaded even if the module says it cannot, \n"
63 " which almost always will cause a crash.\n";
65 static char help_help[] =
66 "Usage: help [topic]\n"
67 " When called with a topic as an argument, displays usage\n"
68 " information on the given command. If called without a\n"
69 " topic, it provides a list of commands.\n";
71 static char chanlist_help[] =
72 "Usage: show channels\n"
73 " Lists currently defined channels and some information about\n"
76 static char reload_help[] =
78 " Reloads configuration files for all modules which support\n"
81 static char set_verbose_help[] =
82 "Usage: set verbose <level>\n"
83 " Sets level of verbose messages to be displayed. 0 means\n"
84 " no messages should be displayed.\n";
86 static char softhangup_help[] =
87 "Usage: soft hangup <channel>\n"
88 " Request that a channel be hung up. The hangup takes effect\n"
89 " the next time the driver reads or writes from the channel\n";
91 static int handle_load(int fd, int argc, char *argv[])
94 return RESULT_SHOWUSAGE;
95 if (ast_load_resource(argv[1])) {
96 ast_cli(fd, "Unable to load module %s\n", argv[1]);
97 return RESULT_FAILURE;
99 return RESULT_SUCCESS;
102 static int handle_reload(int fd, int argc, char *argv[])
105 return RESULT_SHOWUSAGE;
107 return RESULT_SUCCESS;
110 static int handle_set_verbose(int fd, int argc, char *argv[])
113 /* Has a hidden 'at least' argument */
114 if ((argc != 3) && (argc != 4))
115 return RESULT_SHOWUSAGE;
116 if ((argc == 4) && strcasecmp(argv[2], "atleast"))
117 return RESULT_SHOWUSAGE;
119 option_verbose = atoi(argv[2]);
122 if (val > option_verbose)
123 option_verbose = val;
125 return RESULT_SUCCESS;
128 static int handle_unload(int fd, int argc, char *argv[])
131 int force=AST_FORCE_SOFT;
133 return RESULT_SHOWUSAGE;
134 for (x=1;x<argc;x++) {
135 if (argv[x][0] == '-') {
138 force = AST_FORCE_FIRM;
141 force = AST_FORCE_HARD;
144 return RESULT_SHOWUSAGE;
146 } else if (x != argc - 1)
147 return RESULT_SHOWUSAGE;
148 else if (ast_unload_resource(argv[x], force)) {
149 ast_cli(fd, "Unable to unload resource %s\n", argv[x]);
150 return RESULT_FAILURE;
153 return RESULT_SUCCESS;
156 #define MODLIST_FORMAT "%-20s %-40.40s %-10d\n"
157 #define MODLIST_FORMAT2 "%-25s %-40.40s %-10s\n"
159 static ast_mutex_t climodentrylock = AST_MUTEX_INITIALIZER;
160 static int climodentryfd = -1;
162 static int modlist_modentry(char *module, char *description, int usecnt)
164 ast_cli(climodentryfd, MODLIST_FORMAT, module, description, usecnt);
168 static char modlist_help[] =
169 "Usage: show modules\n"
170 " Shows Asterisk modules currently in use, and usage "
173 static char version_help[] =
174 "Usage: show version\n"
175 " Shows Asterisk version information.\n ";
177 static char *format_uptimestr(time_t timeval)
179 int years = 0, weeks = 0, days = 0, hours = 0, mins = 0, secs = 0;
183 #define MIN (SECOND*60)
184 #define HOUR (MIN*60)
185 #define DAY (HOUR*24)
187 #define YEAR (DAY*365)
189 if (timeval > YEAR) {
190 years = (timeval / YEAR);
191 timeval -= (years * YEAR);
193 pos += sprintf(timestr + pos, "%d years, ", years);
195 pos += sprintf(timestr + pos, "1 year, ");
197 if (timeval > WEEK) {
198 weeks = (timeval / WEEK);
199 timeval -= (weeks * WEEK);
201 pos += sprintf(timestr + pos, "%d weeks, ", weeks);
203 pos += sprintf(timestr + pos, "1 week, ");
206 days = (timeval / DAY);
207 timeval -= (days * DAY);
209 pos += sprintf(timestr + pos, "%d days, ", days);
211 pos += sprintf(timestr + pos, "1 day, ");
214 if (timeval > HOUR) {
215 hours = (timeval / HOUR);
216 timeval -= (hours * HOUR);
218 pos += sprintf(timestr + pos, "%d hours, ", hours);
220 pos += sprintf(timestr + pos, "1 hour, ");
223 mins = (timeval / MIN);
224 timeval -= (mins * MIN);
226 pos += sprintf(timestr + pos, "%d minutes, ", mins);
228 pos += sprintf(timestr + pos, "1 minute, ");
233 pos += sprintf(timestr + pos, "%d seconds", secs);
235 return timestr ? strdup(timestr) : NULL;
238 static int handle_showuptime(int fd, int argc, char *argv[])
240 time_t curtime, tmptime;
244 if (ast_startuptime) {
245 tmptime = curtime - ast_startuptime;
246 timestr = format_uptimestr(tmptime);
248 ast_cli(fd, "System uptime: %s\n", timestr);
252 if (ast_lastreloadtime) {
253 tmptime = curtime - ast_lastreloadtime;
254 timestr = format_uptimestr(tmptime);
256 ast_cli(fd, "Last reload: %s\n", timestr);
260 return RESULT_SUCCESS;
263 static int handle_modlist(int fd, int argc, char *argv[])
266 return RESULT_SHOWUSAGE;
267 ast_mutex_lock(&climodentrylock);
269 ast_cli(fd, MODLIST_FORMAT2, "Module", "Description", "Use Count");
270 ast_update_module_list(modlist_modentry);
272 ast_mutex_unlock(&climodentrylock);
273 return RESULT_SUCCESS;
276 static int handle_version(int fd, int argc, char *argv[])
279 return RESULT_SHOWUSAGE;
280 ast_cli(fd, "%s\n", VERSION_INFO);
281 return RESULT_SUCCESS;
283 static int handle_chanlist(int fd, int argc, char *argv[])
285 #define FORMAT_STRING "%15s (%-10s %-12s %-4d) %7s %-12s %-15s\n"
286 #define FORMAT_STRING2 "%15s (%-10s %-12s %-4s) %7s %-12s %-15s\n"
287 struct ast_channel *c=NULL;
290 return RESULT_SHOWUSAGE;
291 c = ast_channel_walk(NULL);
292 ast_cli(fd, FORMAT_STRING2, "Channel", "Context", "Extension", "Pri", "State", "Appl.", "Data");
294 ast_cli(fd, FORMAT_STRING, c->name, c->context, c->exten, c->priority, ast_state2str(c->_state),
295 c->appl ? c->appl : "(None)", c->data ? ( strlen(c->data) ? c->data : "(Empty)" ): "(None)");
297 c = ast_channel_walk(c);
299 ast_cli(fd, "%d active channel(s)\n", numchans);
300 return RESULT_SUCCESS;
303 static char showchan_help[] =
304 "Usage: show channel <channel>\n"
305 " Shows lots of information about the specified channel.\n";
307 static char debugchan_help[] =
308 "Usage: debug channel <channel>\n"
309 " Enables debugging on a specific channel.\n";
311 static char nodebugchan_help[] =
312 "Usage: no debug channel <channel>\n"
313 " Disables debugging on a specific channel.\n";
315 static char commandcomplete_help[] =
316 "Usage: _command complete \"<line>\" text state\n"
317 " This function is used internally to help with command completion and should.\n"
318 " never be called by the user directly.\n";
320 static char commandnummatches_help[] =
321 "Usage: _command nummatches \"<line>\" text \n"
322 " This function is used internally to help with command completion and should.\n"
323 " never be called by the user directly.\n";
325 static char commandmatchesarray_help[] =
326 "Usage: _command matchesarray \"<line>\" text \n"
327 " This function is used internally to help with command completion and should.\n"
328 " never be called by the user directly.\n";
330 static int handle_softhangup(int fd, int argc, char *argv[])
332 struct ast_channel *c=NULL;
334 return RESULT_SHOWUSAGE;
335 c = ast_channel_walk(NULL);
337 if (!strcasecmp(c->name, argv[2])) {
338 ast_cli(fd, "Requested Hangup on channel '%s'\n", c->name);
339 ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT);
342 c = ast_channel_walk(c);
345 ast_cli(fd, "%s is not a known channel\n", argv[2]);
346 return RESULT_SUCCESS;
349 static char *__ast_cli_generator(char *text, char *word, int state, int lock);
351 static int handle_commandmatchesarray(int fd, int argc, char *argv[])
359 return RESULT_SHOWUSAGE;
361 matches = ast_cli_completion_matches(argv[2], argv[3]);
363 for (x=0; matches[x]; x++) {
365 printf("command matchesarray for '%s' %s got '%s'\n", argv[2], argv[3], matches[x]);
367 len += sprintf( buf + len, "%s ", matches[x]);
374 printf("array for '%s' %s got '%s'\n", argv[2], argv[3], buf);
380 ast_cli(fd, "NULL\n");
382 return RESULT_SUCCESS;
387 static int handle_commandnummatches(int fd, int argc, char *argv[])
392 return RESULT_SHOWUSAGE;
394 matches = ast_cli_generatornummatches(argv[2], argv[3]);
397 printf("Search for '%s' %s got '%d'\n", argv[2], argv[3], matches);
399 ast_cli(fd, "%d", matches);
401 return RESULT_SUCCESS;
404 static int handle_commandcomplete(int fd, int argc, char *argv[])
408 printf("Search for %d args: '%s', '%s', '%s', '%s'\n", argc, argv[0], argv[1], argv[2], argv[3]);
411 return RESULT_SHOWUSAGE;
412 buf = __ast_cli_generator(argv[2], argv[3], atoi(argv[4]), 0);
414 printf("Search for '%s' %s %d got '%s'\n", argv[2], argv[3], atoi(argv[4]), buf);
420 ast_cli(fd, "NULL\n");
421 return RESULT_SUCCESS;
424 static int handle_debugchan(int fd, int argc, char *argv[])
426 struct ast_channel *c=NULL;
428 return RESULT_SHOWUSAGE;
429 c = ast_channel_walk(NULL);
431 if (!strcasecmp(c->name, argv[2])) {
432 c->fin |= 0x80000000;
433 c->fout |= 0x80000000;
436 c = ast_channel_walk(c);
439 ast_cli(fd, "Debugging enabled on channel %s\n", c->name);
441 ast_cli(fd, "No such channel %s\n", argv[2]);
442 return RESULT_SUCCESS;
445 static int handle_nodebugchan(int fd, int argc, char *argv[])
447 struct ast_channel *c=NULL;
449 return RESULT_SHOWUSAGE;
450 c = ast_channel_walk(NULL);
452 if (!strcasecmp(c->name, argv[3])) {
453 c->fin &= 0x7fffffff;
454 c->fout &= 0x7fffffff;
457 c = ast_channel_walk(c);
460 ast_cli(fd, "Debugging disabled on channel %s\n", c->name);
462 ast_cli(fd, "No such channel %s\n", argv[2]);
463 return RESULT_SUCCESS;
468 static int handle_showchan(int fd, int argc, char *argv[])
470 struct ast_channel *c=NULL;
472 return RESULT_SHOWUSAGE;
473 c = ast_channel_walk(NULL);
475 if (!strcasecmp(c->name, argv[2])) {
485 " NativeFormat: %d\n"
488 "1st File Descriptor: %d\n"
490 " Frames out: %d%s\n"
491 " Time to Hangup: %ld\n"
497 " Pickup Group: %d\n"
501 " Blocking in: %s\n",
502 c->name, c->type, c->uniqueid,
503 (c->callerid ? c->callerid : "(N/A)"),
504 (c->dnid ? c->dnid : "(N/A)" ), ast_state2str(c->_state), c->_state, c->rings, c->nativeformats, c->writeformat, c->readformat,
505 c->fds[0], c->fin & 0x7fffffff, (c->fin & 0x80000000) ? " (DEBUGGED)" : "",
506 c->fout & 0x7fffffff, (c->fout & 0x80000000) ? " (DEBUGGED)" : "", (long)c->whentohangup,
507 c->context, c->exten, c->priority, c->callgroup, c->pickupgroup, ( c->appl ? c->appl : "(N/A)" ),
508 ( c-> data ? (strlen(c->data) ? c->data : "(Empty)") : "(None)"),
509 c->stack, (c->blocking ? c->blockproc : "(Not Blocking)"));
513 c = ast_channel_walk(c);
516 ast_cli(fd, "%s is not a known channel\n", argv[2]);
517 return RESULT_SUCCESS;
520 static char *complete_ch(char *line, char *word, int pos, int state)
522 struct ast_channel *c;
524 c = ast_channel_walk(NULL);
526 if (!strncasecmp(word, c->name, strlen(word))) {
530 c = ast_channel_walk(c);
532 return c ? strdup(c->name) : NULL;
535 static char *complete_fn(char *line, char *word, int pos, int state)
542 strncpy(filename, word, sizeof(filename)-1);
544 snprintf(filename, sizeof(filename), "%s/%s", (char *)ast_config_AST_MODULE_DIR, word);
545 c = (char*)filename_completion_function(filename, state);
546 if (c && word[0] != '/')
547 c += (strlen((char*)ast_config_AST_MODULE_DIR) + 1);
548 return c ? strdup(c) : c;
551 static int handle_help(int fd, int argc, char *argv[]);
553 static struct ast_cli_entry builtins[] = {
554 /* Keep alphabetized */
555 { { "_command", "complete", NULL }, handle_commandcomplete, "Command complete", commandcomplete_help },
556 { { "_command", "nummatches", NULL }, handle_commandnummatches, "Returns number of command matches", commandnummatches_help },
557 { { "_command", "matchesarray", NULL }, handle_commandmatchesarray, "Returns command matches array", commandmatchesarray_help },
558 { { "debug", "channel", NULL }, handle_debugchan, "Enable debugging on a channel", debugchan_help, complete_ch },
559 { { "help", NULL }, handle_help, "Display help list, or specific help on a command", help_help },
560 { { "load", NULL }, handle_load, "Load a dynamic module by name", load_help, complete_fn },
561 { { "no", "debug", "channel", NULL }, handle_nodebugchan, "Disable debugging on a channel", nodebugchan_help, complete_ch },
562 { { "reload", NULL }, handle_reload, "Reload configuration", reload_help },
563 { { "set", "verbose", NULL }, handle_set_verbose, "Set level of verboseness", set_verbose_help },
564 { { "show", "channel", NULL }, handle_showchan, "Display information on a specific channel", showchan_help, complete_ch },
565 { { "show", "channels", NULL }, handle_chanlist, "Display information on channels", chanlist_help },
566 { { "show", "modules", NULL }, handle_modlist, "List modules and info", modlist_help },
567 { { "show", "uptime", NULL }, handle_showuptime, "Show uptime information", modlist_help },
568 { { "show", "version", NULL }, handle_version, "Display version info", version_help },
569 { { "soft", "hangup", NULL }, handle_softhangup, "Request a hangup on a given channel", softhangup_help, complete_ch },
570 { { "unload", NULL }, handle_unload, "Unload a dynamic module by name", unload_help, complete_fn },
571 { { NULL }, NULL, NULL, NULL }
574 static struct ast_cli_entry *find_cli(char *cmds[], int exact)
579 struct ast_cli_entry *e=NULL;
580 for (x=0;builtins[x].cmda[0];x++) {
581 /* start optimistic */
583 for (y=0;match && cmds[y]; y++) {
584 /* If there are no more words in the candidate command, then we're
586 if (!builtins[x].cmda[y] && !exact)
588 /* If there are no more words in the command (and we're looking for
589 an exact match) or there is a difference between the two words,
590 then this is not a match */
591 if (!builtins[x].cmda[y] || strcasecmp(builtins[x].cmda[y], cmds[y]))
594 /* If more words are needed to complete the command then this is not
595 a candidate (unless we're looking for a really inexact answer */
596 if ((exact > -1) && builtins[x].cmda[y])
601 for (e=helpers;e;e=e->next) {
603 for (y=0;match && cmds[y]; y++) {
604 if (!e->cmda[y] && !exact)
606 if (!e->cmda[y] || strcasecmp(e->cmda[y], cmds[y]))
609 if ((exact > -1) && e->cmda[y])
617 static void join(char *s, int len, char *w[])
620 /* Join words into a string */
624 strncat(s, " ", len - strlen(s));
625 strncat(s, w[x], len - strlen(s));
629 static void join2(char *s, int len, char *w[])
632 /* Join words into a string */
635 strncat(s, w[x], len - strlen(s));
639 static char *find_best(char *argv[])
641 static char cmdline[80];
643 /* See how close we get, then print the */
644 char *myargv[AST_MAX_CMD_LEN];
645 for (x=0;x<AST_MAX_CMD_LEN;x++)
647 for (x=0;argv[x];x++) {
649 if (!find_cli(myargv, -1))
652 join(cmdline, sizeof(cmdline), myargv);
656 int ast_cli_unregister(struct ast_cli_entry *e)
658 struct ast_cli_entry *cur, *l=NULL;
659 ast_mutex_lock(&clilock);
664 ast_log(LOG_WARNING, "Can't remove command that is in use\n");
678 ast_mutex_unlock(&clilock);
682 int ast_cli_register(struct ast_cli_entry *e)
684 struct ast_cli_entry *cur, *l=NULL;
685 char fulle[80] ="", fulltst[80] ="";
687 ast_mutex_lock(&clilock);
688 join2(fulle, sizeof(fulle), e->cmda);
689 if (find_cli(e->cmda, -1)) {
690 ast_mutex_unlock(&clilock);
691 ast_log(LOG_WARNING, "Command '%s' already registered (or something close enough)\n", fulle);
696 join2(fulltst, sizeof(fulltst), cur->cmda);
697 len = strlen(fulltst);
698 if (strlen(fulle) < len)
700 if (strncasecmp(fulle, fulltst, len) < 0) {
720 ast_mutex_unlock(&clilock);
724 static int help_workhorse(int fd, char *match[])
730 struct ast_cli_entry *e, *e1, *e2;
734 join(matchstr, sizeof(matchstr), match);
735 while(e1->cmda[0] || e2) {
737 join(fullcmd2, sizeof(fullcmd2), e2->cmda);
739 join(fullcmd1, sizeof(fullcmd1), e1->cmda);
741 (e2 && (strcmp(fullcmd2, fullcmd1) < 0))) {
745 /* Increment by going to next */
753 /* Hide commands that start with '_' */
754 if (fullcmd[0] == '_')
757 if (strncasecmp(matchstr, fullcmd, strlen(matchstr))) {
761 ast_cli(fd, "%20.20s %s\n", fullcmd, e->summary);
766 static int handle_help(int fd, int argc, char *argv[]) {
767 struct ast_cli_entry *e;
770 return RESULT_SHOWUSAGE;
772 e = find_cli(argv + 1, 1);
774 ast_cli(fd, e->usage);
776 if (find_cli(argv + 1, -1)) {
777 return help_workhorse(fd, argv + 1);
779 join(fullcmd, sizeof(fullcmd), argv+1);
780 ast_cli(fd, "No such command '%s'.\n", fullcmd);
784 return help_workhorse(fd, NULL);
786 return RESULT_SUCCESS;
789 static char *parse_args(char *s, int *max, char *argv[])
803 /* If it's escaped, put a literal quote */
808 if (quoted && whitespace) {
809 /* If we're starting a quote, coming off white space start a new word, too */
817 if (!quoted && !escaped) {
818 /* If we're not quoted, mark this as whitespace, and
819 end the previous argument */
823 /* Otherwise, just treat it as anything else */
827 /* If we're escaped, print a literal, otherwise enable escaping */
837 if (x >= AST_MAX_ARGS -1) {
838 ast_log(LOG_WARNING, "Too many arguments, truncating\n");
841 /* Coming off of whitespace, start the next argument */
858 /* This returns the number of unique matches for the generator */
859 int ast_cli_generatornummatches(char *text, char *word)
861 int matches = 0, i = 0;
862 char *buf, *oldbuf = NULL;
865 while ( (buf = ast_cli_generator(text, word, i)) ) {
866 if (++i > 1 && strcmp(buf,oldbuf) == 0) {
876 char **ast_cli_completion_matches(char *text, char *word)
878 char **match_list = NULL, *retstr, *prevstr;
879 size_t match_list_len, max_equal, which, i;
883 while ((retstr = ast_cli_generator(text, word, matches)) != NULL) {
884 if (matches + 1 >= match_list_len) {
885 match_list_len <<= 1;
886 match_list = realloc(match_list, match_list_len * sizeof(char *));
888 match_list[++matches] = retstr;
892 return (char **) NULL;
895 prevstr = match_list[1];
896 max_equal = strlen(prevstr);
897 for (; which <= matches; which++) {
898 for (i = 0; i < max_equal && prevstr[i] == match_list[which][i]; i++)
903 retstr = malloc(max_equal + 1);
904 (void) strncpy(retstr, match_list[1], max_equal);
905 retstr[max_equal] = '\0';
906 match_list[0] = retstr;
908 if (matches + 1 >= match_list_len)
909 match_list = realloc(match_list, (match_list_len + 1) * sizeof(char *));
910 match_list[matches + 1] = (char *) NULL;
915 static char *__ast_cli_generator(char *text, char *word, int state, int lock)
917 char *argv[AST_MAX_ARGS];
918 struct ast_cli_entry *e, *e1, *e2;
927 if ((dup = parse_args(text, &x, argv))) {
928 join(matchstr, sizeof(matchstr), argv);
930 ast_mutex_lock(&clilock);
933 while(e1->cmda[0] || e2) {
935 join(fullcmd2, sizeof(fullcmd2), e2->cmda);
937 join(fullcmd1, sizeof(fullcmd1), e1->cmda);
939 (e2 && (strcmp(fullcmd2, fullcmd1) < 0))) {
943 /* Increment by going to next */
951 if ((fullcmd[0] != '_') && !strncasecmp(matchstr, fullcmd, strlen(matchstr))) {
952 /* We contain the first part of one or more commands */
954 if (matchnum > state) {
955 /* Now, what we're supposed to return is the next word... */
956 if (strlen(word) && x>0) {
963 ast_mutex_unlock(&clilock);
965 return res ? strdup(res) : NULL;
969 if (e->generator && !strncasecmp(matchstr, fullcmd, strlen(fullcmd))) {
970 /* We have a command in its entirity within us -- theoretically only one
971 command can have this occur */
972 fullcmd = e->generator(text, word, (strlen(word) ? (x - 1) : (x)), state);
974 ast_mutex_unlock(&clilock);
980 ast_mutex_unlock(&clilock);
986 char *ast_cli_generator(char *text, char *word, int state)
988 return __ast_cli_generator(text, word, state, 1);
991 int ast_cli_command(int fd, char *s)
993 char *argv[AST_MAX_ARGS];
994 struct ast_cli_entry *e;
998 if ((dup = parse_args(s, &x, argv))) {
999 /* We need at least one entry, or ignore */
1001 ast_mutex_lock(&clilock);
1002 e = find_cli(argv, 0);
1005 ast_mutex_unlock(&clilock);
1007 switch(e->handler(fd, x, argv)) {
1008 case RESULT_SHOWUSAGE:
1009 ast_cli(fd, e->usage);
1013 ast_cli(fd, "No such command '%s' (type 'help' for help)\n", find_best(argv));
1015 ast_mutex_lock(&clilock);
1017 ast_mutex_unlock(&clilock);
1022 ast_log(LOG_WARNING, "Out of memory\n");