aboutsummaryrefslogtreecommitdiffstats
path: root/channel.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-01-22 02:23:38 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-01-22 02:23:38 +0000
commit00c1a3311e1a0def1ac849f42609846d542bb8f0 (patch)
treed0fe80f7aacf41b5aa2ea560b3bebef4cd919f10 /channel.c
parentdca33b72edbf15ae4378b6bbf0e336ca83a1b2c7 (diff)
add 'show channeltype' CLI command (issue #6149, with small modifications)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@8422 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channel.c')
-rw-r--r--channel.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/channel.c b/channel.c
index f3f4a30fb..51e171af0 100644
--- a/channel.c
+++ b/channel.c
@@ -193,13 +193,93 @@ static int show_channeltypes(int fd, int argc, char *argv[])
}
+static int show_channeltype(int fd, int argc, char *argv[])
+{
+ struct chanlist *cl = NULL;
+
+ if (argc != 3)
+ return RESULT_SHOWUSAGE;
+
+ if (ast_mutex_lock(&chlock)) {
+ ast_log(LOG_WARNING, "Unable to lock channel list\n");
+ return RESULT_FAILURE;
+ }
+
+ AST_LIST_TRAVERSE(&backends, cl, list) {
+ if (!strncasecmp(cl->tech->type, argv[2], strlen(cl->tech->type))) {
+ break;
+ }
+ }
+
+
+ if (!cl) {
+ ast_cli(fd, "\n%s is not a registered channel driver.\n", argv[2]);
+ ast_mutex_unlock(&chlock);
+ return RESULT_FAILURE;
+ }
+
+ ast_cli(fd,
+ "-- Info about channel driver: %s --\n"
+ " Device State: %s\n"
+ " Indication: %s\n"
+ " Transfer : %s\n"
+ " Capabilities: %d\n"
+ " Send Digit: %s\n"
+ " Send HTML : %s\n"
+ " Image Support: %s\n"
+ " Text Support: %s\n",
+ cl->tech->type,
+ (cl->tech->devicestate) ? "yes" : "no",
+ (cl->tech->indicate) ? "yes" : "no",
+ (cl->tech->transfer) ? "yes" : "no",
+ (cl->tech->capabilities) ? cl->tech->capabilities : -1,
+ (cl->tech->send_digit) ? "yes" : "no",
+ (cl->tech->send_html) ? "yes" : "no",
+ (cl->tech->send_image) ? "yes" : "no",
+ (cl->tech->send_text) ? "yes" : "no"
+
+ );
+
+ ast_mutex_unlock(&chlock);
+ return RESULT_SUCCESS;
+}
+
+static char *complete_channeltypes(const char *line, const char *word, int pos, int state)
+{
+ struct chanlist *cl;
+ int which = 0;
+ int wordlen;
+ char *ret = NULL;
+
+ if (pos != 2)
+ return NULL;
+
+ wordlen = strlen(word);
+
+ AST_LIST_TRAVERSE(&backends, cl, list) {
+ if (!strncasecmp(word, cl->tech->type, wordlen) && ++which > state) {
+ ret = strdup(cl->tech->type);
+ break;
+ }
+ }
+
+ return ret;
+}
+
static char show_channeltypes_usage[] =
"Usage: show channeltypes\n"
" Shows available channel types registered in your Asterisk server.\n";
+static char show_channeltype_usage[] =
+"Usage: show channeltype <name>\n"
+" Show details about the specified channel type, <name>.\n";
+
static struct ast_cli_entry cli_show_channeltypes =
{ { "show", "channeltypes", NULL }, show_channeltypes, "Show available channel types", show_channeltypes_usage };
+static struct ast_cli_entry cli_show_channeltype =
+ { { "show", "channeltype", NULL }, show_channeltype, "Give more details on that channel type", show_channeltype_usage, complete_channeltypes };
+
/*! \brief Checks to see if a channel is needing hang up */
int ast_check_hangup(struct ast_channel *chan)
{
@@ -3779,6 +3859,7 @@ void ast_moh_cleanup(struct ast_channel *chan)
void ast_channels_init(void)
{
ast_cli_register(&cli_show_channeltypes);
+ ast_cli_register(&cli_show_channeltype);
}
/*! \brief Print call group and pickup group ---*/