[asterisk-commits] nadi: branch nadi/trunk-cm r44564 - /team/nadi/trunk-cm/res/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Oct 6 06:08:48 MST 2006


Author: nadi
Date: Fri Oct  6 08:08:48 2006
New Revision: 44564

URL: http://svn.digium.com/view/asterisk?rev=44564&view=rev
Log:
new cli command for csel, change configman cli command to follow trunk style

Modified:
    team/nadi/trunk-cm/res/res_configman.c
    team/nadi/trunk-cm/res/res_csel.c

Modified: team/nadi/trunk-cm/res/res_configman.c
URL: http://svn.digium.com/view/asterisk/team/nadi/trunk-cm/res/res_configman.c?rev=44564&r1=44563&r2=44564&view=diff
==============================================================================
--- team/nadi/trunk-cm/res/res_configman.c (original)
+++ team/nadi/trunk-cm/res/res_configman.c Fri Oct  6 08:08:48 2006
@@ -33,7 +33,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 44151 $")
 
 #include <errno.h>
 #include <stdarg.h>
@@ -997,7 +997,7 @@
 	cm->clis[2].cmda[1] = SHOW;
 	cm->clis[2].cmda[2] = CONFIG;
 	cm->clis[2].cmda[3] = VALUES;
-	snprintf(buf, sizeof(buf), "Prints the configuration values read from file.");
+	snprintf(buf, sizeof(buf), "Print the configuration values read from file");
 	cm->clis[2].summary = strdup(buf);
 	snprintf(buf, sizeof(buf), "Usage: %s show config values [<section name> [<key>]]\n", cm->modname);
 	cm->clis[2].usage = strdup(buf);
@@ -1125,7 +1125,7 @@
 	cm->clis[0].cmda[1] = SHOW;
 	cm->clis[0].cmda[2] = CONFIG;
 	cm->clis[0].cmda[3] = DESCRIPTION;
-	snprintf(buf, sizeof(buf), "Prints the description for the given configuration directive.");
+	snprintf(buf, sizeof(buf), "Display description for the given configuration directive");
 	cm->clis[0].summary = strdup(buf);
 	snprintf(buf, sizeof(buf), "Usage: %s show config description <directive>\n", cm->modname);
 	cm->clis[0].usage = strdup(buf);
@@ -1137,7 +1137,7 @@
 	cm->clis[1].cmda[1] = SHOW;
 	cm->clis[1].cmda[2] = CONFIG;
 	cm->clis[1].cmda[3] = DESCRIPTIONS;
-	snprintf(buf, sizeof(buf), "Prints a list of descriptions for all configuration directives.");
+	snprintf(buf, sizeof(buf), "List descriptions for all configuration directives");
 	cm->clis[1].summary = strdup(buf);
 	snprintf(buf, sizeof(buf), "Usage: %s show config descriptions [<section name>]\n", cm->modname);
 	cm->clis[1].usage = strdup(buf);
@@ -1166,7 +1166,7 @@
 }
 
 /* configman cli commands */
-static int configman_show_usage (int fd, int argc, char *argv[])
+static int configman_list_modules (int fd, int argc, char *argv[])
 {
 	cm_t * cm;
 	char * key;
@@ -1184,9 +1184,9 @@
 }
 
 static struct ast_cli_entry configman_clis[] = {
-	{ { "configman", "show", "usage", NULL }, configman_show_usage,
-		"Displays a list of modules that are using configman.",
-		"Usage: configman show usage\n" },
+	{ { "configman", "list", "modules", NULL }, configman_list_modules,
+		"List modules using configman",
+		"Usage: configman list modules\n" },
 };
 
 static int load_module (void)

Modified: team/nadi/trunk-cm/res/res_csel.c
URL: http://svn.digium.com/view/asterisk/team/nadi/trunk-cm/res/res_csel.c?rev=44564&r1=44563&r2=44564&view=diff
==============================================================================
--- team/nadi/trunk-cm/res/res_csel.c (original)
+++ team/nadi/trunk-cm/res/res_csel.c Fri Oct  6 08:08:48 2006
@@ -32,6 +32,8 @@
 #include "asterisk/logger.h"
 #include "asterisk/lock.h"
 #include "asterisk/utils.h"
+#include "asterisk/cli.h"
+#include "asterisk/term.h"
 
 #include <stdlib.h>
 #include <string.h>
@@ -48,6 +50,8 @@
 
 struct method {
 	char          * name;
+	char          * desc;
+	char          * desc_params;
 	int          (* init) (struct csel *cs, const char *params);
 	void         (* destroy) (struct csel *cs);
 	int          (* add) (struct csel *cs, void *priv);
@@ -232,9 +236,12 @@
 /* ROUND ROBIN: end */
 
 static struct method methods[] = {
-	{ "standard", standard_init, standard_destroy, standard_add, standard_get_next, 0, 0 },
-	{ "random", rand_init, rand_destroy, rand_add, rand_get_next, 0, 0 },
-	{ "round_robin", rr_init, rr_destroy, rr_add, rr_get_next, 0, 0 },
+	{ "standard", "Select the first free channel. This is the default", 0,
+		standard_init, standard_destroy, standard_add, standard_get_next, 0, 0 },
+	{ "random", "Select a random free channel.", 0,
+		rand_init, rand_destroy, rand_add, rand_get_next, 0, 0 },
+	{ "round_robin", "Use the round robin algorithm to select a free channel.", 0,
+		rr_init, rr_destroy, rr_add, rr_get_next, 0, 0 },
 };
 
 struct csel * csel_create (const char *method,
@@ -325,13 +332,42 @@
 	UNLOCK(cs);
 }
 
+static int csel_list_methods (int fd, int argc, char *argv[])
+{
+	int i = 0;
+	char method[128],
+		 desc[128],
+		 params[128];
+
+	term_color(method, "Method", COLOR_YELLOW, 0, sizeof(method));
+	term_color(desc, "Description", COLOR_BRWHITE, 0, sizeof(desc));
+	term_color(params, "Parameters", COLOR_BRWHITE, 0, sizeof(params));
+
+	for (; i < (sizeof(methods) / sizeof(struct method)); ++i)
+		ast_cli(fd, "%s: %s\n%s: %s\n%s: %s\n%s", method, methods[i].name,
+				desc, methods[i].desc, params, methods[i].desc_params ? methods[i].desc_params : "(none)",
+				(i + 1) < (sizeof(methods) / sizeof(struct method)) ? "\n" : "");
+
+	return 0;
+}
+
+static struct ast_cli_entry csel_clis[] = {
+	{ { "csel", "list", "methods", NULL }, csel_list_methods,
+		"List channel selection methods",
+		"Usage: csel list methods\n" },
+};
+
 static int load_module (void)
 {
+	ast_cli_register_multiple(csel_clis, sizeof(csel_clis) / sizeof(struct ast_cli_entry));
+
 	return 0;
 }
 
 static int unload_module (void)
 {
+	ast_cli_unregister_multiple(csel_clis, sizeof(csel_clis) / sizeof(struct ast_cli_entry));
+	
 	return 0;
 }
 



More information about the asterisk-commits mailing list