add functions to register/unregister multiple CLI commands in a single operation (bug #4255, with minor mods)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5662 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kevin P. Fleming
2005-05-15 03:03:48 +00:00
parent b5272684ee
commit 0356b70224
4 changed files with 81 additions and 120 deletions

36
frame.c
View File

@@ -596,15 +596,6 @@ static char frame_show_codecs_usage[] =
"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 @@ static char frame_show_codec_n_usage[] =
"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 int show_frame_stats(int fd, int argc, char *argv[])
static char frame_stats_usage[] =
"Usage: show frame stats\n"
" Displays debugging statistics from framer\n";
struct ast_cli_entry cli_frame_stats =
{ { "show", "frame", "stats", NULL }, show_frame_stats, "Shows frame statistics", frame_stats_usage };
#endif
/* 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;
}