[asterisk-commits] qwell: branch 1.4 r51241 - /branches/1.4/main/channel.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Jan 18 11:28:30 MST 2007


Author: qwell
Date: Thu Jan 18 12:28:29 2007
New Revision: 51241

URL: http://svn.digium.com/view/asterisk?view=rev&rev=51241
Log:
Fix an issue with deprecated commands

Modified:
    branches/1.4/main/channel.c

Modified: branches/1.4/main/channel.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/channel.c?view=diff&rev=51241&r1=51240&r2=51241
==============================================================================
--- branches/1.4/main/channel.c (original)
+++ branches/1.4/main/channel.c Thu Jan 18 12:28:29 2007
@@ -214,7 +214,7 @@
 
 }
 
-static int show_channeltype(int fd, int argc, char *argv[])
+static int show_channeltype_deprecated(int fd, int argc, char *argv[])
 {
 	struct chanlist *cl = NULL;
 
@@ -267,7 +267,60 @@
 	return RESULT_SUCCESS;
 }
 
-static char *complete_channeltypes(const char *line, const char *word, int pos, int state)
+static int show_channeltype(int fd, int argc, char *argv[])
+{
+	struct chanlist *cl = NULL;
+
+	if (argc != 4)
+		return RESULT_SHOWUSAGE;
+	
+	if (AST_LIST_LOCK(&channels)) {
+		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[3], strlen(cl->tech->type))) {
+			break;
+		}
+	}
+
+
+	if (!cl) {
+		ast_cli(fd, "\n%s is not a registered channel driver.\n", argv[3]);
+		AST_LIST_UNLOCK(&channels);
+		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"
+		"   Digit Begin: %s\n"
+		"     Digit End: %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_begin) ? "yes" : "no",
+		(cl->tech->send_digit_end) ? "yes" : "no",
+		(cl->tech->send_html) ? "yes" : "no",
+		(cl->tech->send_image) ? "yes" : "no",
+		(cl->tech->send_text) ? "yes" : "no"
+		
+	);
+
+	AST_LIST_UNLOCK(&channels);
+	return RESULT_SUCCESS;
+}
+
+static char *complete_channeltypes_deprecated(const char *line, const char *word, int pos, int state)
 {
 	struct chanlist *cl;
 	int which = 0;
@@ -289,6 +342,28 @@
 	return ret;
 }
 
+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 != 3)
+		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: core show channeltypes\n"
 "       Lists available channel types registered in your Asterisk server.\n";
@@ -304,8 +379,8 @@
 
 static struct ast_cli_entry cli_show_channeltype_deprecated = {
 	{ "show", "channeltype", NULL },
-	show_channeltype, NULL,
-	NULL, complete_channeltypes };
+	show_channeltype_deprecated, NULL,
+	NULL, complete_channeltypes_deprecated };
 
 static struct ast_cli_entry cli_channel[] = {
 	{ { "core", "show", "channeltypes", NULL },



More information about the asterisk-commits mailing list