[Asterisk-cvs] asterisk cli.c,1.79,1.80 frame.c,1.53,1.54
kpfleming at lists.digium.com
kpfleming at lists.digium.com
Sat May 14 22:58:19 CDT 2005
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv859
Modified Files:
cli.c frame.c
Log Message:
add functions to register/unregister multiple CLI commands in a single operation (bug #4255, with minor mods)
Index: cli.c
===================================================================
RCS file: /usr/cvsroot/asterisk/cli.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- cli.c 29 Apr 2005 17:00:33 -0000 1.79
+++ cli.c 15 May 2005 03:03:48 -0000 1.80
@@ -992,6 +992,25 @@
return 0;
}
+/*
+ * register/unregister an array of entries.
+ */
+void ast_cli_register_multiple(struct ast_cli_entry *e, int len)
+{
+ int i;
+
+ for (i=0; i < len; i++)
+ ast_cli_register(e + i);
+}
+
+void ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
+{
+ int i;
+
+ for (i=0; i < len; i++)
+ ast_cli_unregister(e + i);
+}
+
static int help_workhorse(int fd, char *match[])
{
char fullcmd1[80] = "";
Index: frame.c
===================================================================
RCS file: /usr/cvsroot/asterisk/frame.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- frame.c 14 May 2005 23:57:44 -0000 1.53
+++ frame.c 15 May 2005 03:03:48 -0000 1.54
@@ -596,15 +596,6 @@
"Usage: show [audio|video|image] codecs\n"
" Displays codec mapping\n";
-struct ast_cli_entry cli_show_codecs =
-{ { "show", "codecs", NULL }, show_codecs, "Shows codecs", frame_show_codecs_usage };
-struct ast_cli_entry cli_show_codecs_audio =
-{ { "show", "audio", "codecs", NULL }, show_codecs, "Shows audio codecs", frame_show_codecs_usage };
-struct ast_cli_entry cli_show_codecs_video =
-{ { "show", "video", "codecs", NULL }, show_codecs, "Shows video codecs", frame_show_codecs_usage };
-struct ast_cli_entry cli_show_codecs_image =
-{ { "show", "image", "codecs", NULL }, show_codecs, "Shows image codecs", frame_show_codecs_usage };
-
static int show_codec_n(int fd, int argc, char *argv[])
{
int codec, i, found=0;
@@ -631,9 +622,6 @@
"Usage: show codec <number>\n"
" Displays codec mapping\n";
-struct ast_cli_entry cli_show_codec_n =
-{ { "show", "codec", NULL }, show_codec_n, "Shows a specific codec", frame_show_codec_n_usage };
-
void ast_frame_dump(char *name, struct ast_frame *f, char *prefix)
{
char *n = "unknown";
@@ -815,21 +803,23 @@
static char frame_stats_usage[] =
"Usage: show frame stats\n"
" Displays debugging statistics from framer\n";
+#endif
-struct ast_cli_entry cli_frame_stats =
-{ { "show", "frame", "stats", NULL }, show_frame_stats, "Shows frame statistics", frame_stats_usage };
+/* XXX no unregister function here ??? */
+static struct ast_cli_entry my_clis[] = {
+{ { "show", "codecs", NULL }, show_codecs, "Shows codecs", frame_show_codecs_usage },
+{ { "show", "audio", "codecs", NULL }, show_codecs, "Shows audio codecs", frame_show_codecs_usage },
+{ { "show", "video", "codecs", NULL }, show_codecs, "Shows video codecs", frame_show_codecs_usage },
+{ { "show", "image", "codecs", NULL }, show_codecs, "Shows image codecs", frame_show_codecs_usage },
+{ { "show", "codec", NULL }, show_codec_n, "Shows a specific codec", frame_show_codec_n_usage },
+#ifdef TRACE_FRAMES
+{ { "show", "frame", "stats", NULL }, show_frame_stats, "Shows frame statistics", frame_stats_usage },
#endif
+};
int init_framer(void)
{
-#ifdef TRACE_FRAMES
- ast_cli_register(&cli_frame_stats);
-#endif
- ast_cli_register(&cli_show_codecs);
- ast_cli_register(&cli_show_codecs_audio);
- ast_cli_register(&cli_show_codecs_video);
- ast_cli_register(&cli_show_codecs_image);
- ast_cli_register(&cli_show_codec_n);
+ ast_cli_register_multiple(my_clis, sizeof(my_clis)/sizeof(my_clis[0]) );
return 0;
}
More information about the svn-commits
mailing list