[asterisk-commits] rizzo: branch rizzo/astobj2 r47534 -
/team/rizzo/astobj2/main/astobj2.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Mon Nov 13 03:36:26 MST 2006
Author: rizzo
Date: Mon Nov 13 04:36:26 2006
New Revision: 47534
URL: http://svn.digium.com/view/asterisk?view=rev&rev=47534
Log:
an example of a new-style CLI handler
Modified:
team/rizzo/astobj2/main/astobj2.c
Modified: team/rizzo/astobj2/main/astobj2.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/main/astobj2.c?view=diff&rev=47534&r1=47533&r2=47534
==============================================================================
--- team/rizzo/astobj2/main/astobj2.c (original)
+++ team/rizzo/astobj2/main/astobj2.c Mon Nov 13 04:36:26 2006
@@ -665,6 +665,34 @@
return 0;
}
+static int test_new_cli(int fd, int argc, char *argv[])
+{
+ struct ast_cli_entry *e;
+ struct ast_cli_args *a;
+
+ switch(argc) {
+ case CLI_USAGE:
+ return (int)"this is the usage string for astobj2 foo bar <n>\n";
+
+ case CLI_CMD_STRING:
+ return (int)"astobj2 foo bar";
+
+ case CLI_GENERATE:
+ a = (struct ast_cli_args *)argv;
+ if (a->pos > a->e->args + 1)
+ return RESULT_SHOWUSAGE;
+ if (a->n < 10) {
+ char *buf;
+ asprintf(&buf, "%d", a->n);
+ return (int)buf;
+ }
+ return NULL;
+ default: /* regular handler */
+ e = (struct ast_cli_entry *)argv[-1];
+ ast_cli(fd, "this is test_new_cli %d for [%d] %s\n", argc, e->args, e->_full_cmd);
+ return 0;
+ }
+}
static struct ast_cli_entry cli_astobj2[] = {
{ { "astobj2", "stats", NULL },
handle_astobj2_stats, "Print astobj2 statistics",
@@ -672,6 +700,7 @@
{ { "astobj2", "test", NULL },
handle_astobj2_test, "Test astobj2",
NULL },
+ { { NULL }, test_new_cli },
};
int astobj2_init(void);
More information about the asterisk-commits
mailing list