[asterisk-commits] trunk - r8422 /trunk/channel.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Jan 21 19:23:39 MST 2006


Author: russell
Date: Sat Jan 21 20:23:38 2006
New Revision: 8422

URL: http://svn.digium.com/view/asterisk?rev=8422&view=rev
Log:
add 'show channeltype' CLI command (issue #6149, with small modifications)

Modified:
    trunk/channel.c

Modified: trunk/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/channel.c?rev=8422&r1=8421&r2=8422&view=diff
==============================================================================
--- trunk/channel.c (original)
+++ trunk/channel.c Sat Jan 21 20:23:38 2006
@@ -193,12 +193,92 @@
 
 }
 
+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_channels_init(void)
 {
 	ast_cli_register(&cli_show_channeltypes);
+	ast_cli_register(&cli_show_channeltype);
 }
 
 /*! \brief Print call group and pickup group ---*/



More information about the asterisk-commits mailing list