aboutsummaryrefslogtreecommitdiffstats
path: root/main/frame.c
diff options
context:
space:
mode:
authorqwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-09-18 22:43:45 +0000
committerqwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-09-18 22:43:45 +0000
commitab51c0d7fad1957b36454533cd8e786ed66efa61 (patch)
treed49317ce7050cdca6ecef46706a320e879421c61 /main/frame.c
parentcedd5ba68f094ce4082e42b47674c0f1c01d447d (diff)
(issue #10724)
Reported by: eliel Patches: res_features.c.patch uploaded by eliel (license 64) res_agi.c.patch uploaded by seanbright (license 71) res_musiconhold.c.patch uploaded by seanbright (license 71) pbx.c.patch uploaded by moy (license 222) logger.c.patch uploaded by moy (license 222) frame.c.patch uploaded by moy (license 222) manager.c.patch uploaded by moy (license 222) http.c.patch uploaded by moy (license 222) dnsmgr.c.patch uploaded by moy (license 222) res_realtime.c.patch uploaded by eliel (license 64) res_odbc.c.patch uploaded by seanbright (license 71) res_jabber.c.patch uploaded by eliel (license 64) chan_local.c.patch uploaded by eliel (license 64) chan_agent.c.patch uploaded by eliel (license 64) chan_alsa.c.patch uploaded by eliel (license 64) chan_features.c.patch uploaded by eliel (license 64) chan_sip.c.patch uploaded by eliel (license 64) RollUp.1.patch (includes all of the above patches) uploaded by seanbright (license 71) Convert many CLI commands to the NEW_CLI format. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@82930 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/frame.c')
-rw-r--r--main/frame.c136
1 files changed, 69 insertions, 67 deletions
diff --git a/main/frame.c b/main/frame.c
index a5383e300..2a5ab57d0 100644
--- a/main/frame.c
+++ b/main/frame.c
@@ -611,80 +611,94 @@ char *ast_codec2str(int codec)
return ret;
}
-static int show_codecs(int fd, int argc, char *argv[])
+static char *show_codecs(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
int i, found=0;
char hex[25];
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "core show codecs [audio|video|image]";
+ e->usage =
+ "Usage: core show codecs [audio|video|image]\n"
+ " Displays codec mapping\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
- if ((argc < 3) || (argc > 4))
- return RESULT_SHOWUSAGE;
+ if ((a->argc < 3) || (a->argc > 4))
+ return CLI_SHOWUSAGE;
if (!ast_opt_dont_warn)
- ast_cli(fd, "Disclaimer: this command is for informational purposes only.\n"
+ ast_cli(a->fd, "Disclaimer: this command is for informational purposes only.\n"
"\tIt does not indicate anything about your configuration.\n");
- ast_cli(fd, "%11s %9s %10s TYPE %8s %s\n","INT","BINARY","HEX","NAME","DESC");
- ast_cli(fd, "--------------------------------------------------------------------------------\n");
- if ((argc == 3) || (!strcasecmp(argv[3],"audio"))) {
+ ast_cli(a->fd, "%11s %9s %10s TYPE %8s %s\n","INT","BINARY","HEX","NAME","DESC");
+ ast_cli(a->fd, "--------------------------------------------------------------------------------\n");
+ if ((a->argc == 3) || (!strcasecmp(a->argv[3],"audio"))) {
found = 1;
for (i=0;i<13;i++) {
snprintf(hex,25,"(0x%x)",1<<i);
- ast_cli(fd, "%11u (1 << %2d) %10s audio %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
+ ast_cli(a->fd, "%11u (1 << %2d) %10s audio %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
}
}
- if ((argc == 3) || (!strcasecmp(argv[3],"image"))) {
+ if ((a->argc == 3) || (!strcasecmp(a->argv[3],"image"))) {
found = 1;
for (i=16;i<18;i++) {
snprintf(hex,25,"(0x%x)",1<<i);
- ast_cli(fd, "%11u (1 << %2d) %10s image %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
+ ast_cli(a->fd, "%11u (1 << %2d) %10s image %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
}
}
- if ((argc == 3) || (!strcasecmp(argv[3],"video"))) {
+ if ((a->argc == 3) || (!strcasecmp(a->argv[3],"video"))) {
found = 1;
for (i=18;i<22;i++) {
snprintf(hex,25,"(0x%x)",1<<i);
- ast_cli(fd, "%11u (1 << %2d) %10s video %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
+ ast_cli(a->fd, "%11u (1 << %2d) %10s video %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
}
}
- if (! found)
- return RESULT_SHOWUSAGE;
+ if (!found)
+ return CLI_SHOWUSAGE;
else
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
-static const char frame_show_codecs_usage[] =
-"Usage: core show codecs [audio|video|image]\n"
-" Displays codec mapping\n";
-
-static int show_codec_n(int fd, int argc, char *argv[])
+static char *show_codec_n(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
int codec, i, found=0;
- if (argc != 4)
- return RESULT_SHOWUSAGE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "core show codec";
+ e->usage =
+ "Usage: core show codec <number>\n"
+ " Displays codec mapping\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
- if (sscanf(argv[3],"%d",&codec) != 1)
- return RESULT_SHOWUSAGE;
+ if (a->argc != 4)
+ return CLI_SHOWUSAGE;
+
+ if (sscanf(a->argv[3],"%d",&codec) != 1)
+ return CLI_SHOWUSAGE;
for (i = 0; i < 32; i++)
if (codec & (1 << i)) {
found = 1;
- ast_cli(fd, "%11u (1 << %2d) %s\n",1 << i,i,ast_codec2str(1<<i));
+ ast_cli(a->fd, "%11u (1 << %2d) %s\n",1 << i,i,ast_codec2str(1<<i));
}
if (!found)
- ast_cli(fd, "Codec %d not found\n", codec);
+ ast_cli(a->fd, "Codec %d not found\n", codec);
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
-static char frame_show_codec_n_usage[] =
-"Usage: core show codec <number>\n"
-" Displays codec mapping\n";
-
/*! Dump a frame for debugging purposes */
void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
{
@@ -867,54 +881,42 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
#ifdef TRACE_FRAMES
-static int show_frame_stats(int fd, int argc, char *argv[])
+static char *show_frame_stats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct ast_frame *f;
int x=1;
- if (argc != 4)
- return RESULT_SHOWUSAGE;
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "core show frame stats";
+ e->usage =
+ "Usage: core show frame stats\n"
+ " Displays debugging statistics from framer\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != 4)
+ return CLI_SHOWUSAGE;
AST_LIST_LOCK(&headerlist);
- ast_cli(fd, " Framer Statistics \n");
- ast_cli(fd, "---------------------------\n");
- ast_cli(fd, "Total allocated headers: %d\n", headers);
- ast_cli(fd, "Queue Dump:\n");
+ ast_cli(a->fd, " Framer Statistics \n");
+ ast_cli(a->fd, "---------------------------\n");
+ ast_cli(a->fd, "Total allocated headers: %d\n", headers);
+ ast_cli(a->fd, "Queue Dump:\n");
AST_LIST_TRAVERSE(&headerlist, f, frame_list)
- ast_cli(fd, "%d. Type %d, subclass %d from %s\n", x++, f->frametype, f->subclass, f->src ? f->src : "<Unknown>");
+ ast_cli(a->fd, "%d. Type %d, subclass %d from %s\n", x++, f->frametype, f->subclass, f->src ? f->src : "<Unknown>");
AST_LIST_UNLOCK(&headerlist);
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
-
-static const char frame_stats_usage[] =
-"Usage: core show frame stats\n"
-" Displays debugging statistics from framer\n";
#endif
/* Builtin Asterisk CLI-commands for debugging */
static struct ast_cli_entry my_clis[] = {
- { { "core", "show", "codecs", NULL },
- show_codecs, "Displays a list of codecs",
- frame_show_codecs_usage },
-
- { { "core", "show", "codecs", "audio", NULL },
- show_codecs, "Displays a list of audio codecs",
- frame_show_codecs_usage },
-
- { { "core", "show", "codecs", "video", NULL },
- show_codecs, "Displays a list of video codecs",
- frame_show_codecs_usage },
-
- { { "core", "show", "codecs", "image", NULL },
- show_codecs, "Displays a list of image codecs",
- frame_show_codecs_usage },
-
- { { "core", "show", "codec", NULL },
- show_codec_n, "Shows a specific codec",
- frame_show_codec_n_usage },
-
+ NEW_CLI(show_codecs, "Displays a list of codecs"),
+ NEW_CLI(show_codec_n, "Shows a specific codec"),
#ifdef TRACE_FRAMES
- { { "core", "show", "frame", "stats", NULL },
- show_frame_stats, "Shows frame statistics",
- frame_stats_usage },
+ NEW_CLI(show_frame_stats, "Shows frame statistics"),
#endif
};