Index: channel.c =================================================================== RCS file: /usr/cvsroot/asterisk/channel.c,v retrieving revision 1.154 diff -u -r1.154 channel.c --- channel.c 24 Dec 2004 01:40:07 -0000 1.154 +++ channel.c 29 Dec 2004 15:28:15 -0000 @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -58,6 +59,7 @@ static int shutting_down = 0; static int uniqueint = 0; +static int cliappregistred = 0; /* Is the CLI app registred yet? */ unsigned long global_fin = 0, global_fout = 0; @@ -78,6 +80,32 @@ AST_MUTEX_DEFINE_STATIC(chlock); +static int show_channeltypes(int fd, int argc, char *argv[]) +{ +#define FORMAT "%-7.7s %-50.50s\n" + struct chanlist *cl = backends; + ast_cli(fd, FORMAT, "Type", "Description"); + ast_cli(fd, FORMAT, "------", "-----------"); + if (ast_mutex_lock(&chlock)) { + ast_log(LOG_WARNING, "Unable to lock channel list\n"); + return -1; + } + while (cl) { + ast_cli(fd, FORMAT, cl->type, cl->description); + cl = cl->next; + } + ast_mutex_unlock(&chlock); + return RESULT_SUCCESS; + +} + +static char show_channeltypes_usage[] = +"Usage: show channeltypes\n" +" Shows available channel types registred in your Asterisk server."; + +static struct ast_cli_entry cli_show_channeltypes = + { { "show", "channeltypes", NULL }, show_channeltypes, "Show available channel types", show_channeltypes_usage }; + int ast_check_hangup(struct ast_channel *chan) { time_t myt; @@ -201,6 +229,10 @@ else if (option_verbose > 1) ast_verbose( VERBOSE_PREFIX_2 "Registered channel type '%s' (%s)\n", chan->type, chan->description); ast_mutex_unlock(&chlock); + if (!cliappregistred) { + ast_cli_register(&cli_show_channeltypes); + cliappregistred = 1; + } return 0; }