aboutsummaryrefslogtreecommitdiffstats
path: root/main/translate.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-10-11 19:03:06 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-10-11 19:03:06 +0000
commit13b9c5237c9f5b8b3d72634d575665b1d1147ba3 (patch)
tree44dcb2c14abed6932db4f248b17626a01a38f59b /main/translate.c
parenta8506328befc2a11643cea88772609610ec11c33 (diff)
Merge a ton of NEW_CLI conversions. Thanks to everyone that helped out! :)
(closes issue #10724) Reported by: eliel Patches: chan_skinny.c.patch uploaded by eliel (license 64) chan_oss.c.patch uploaded by eliel (license 64) chan_mgcp.c.patch2 uploaded by eliel (license 64) pbx_config.c.patch uploaded by seanbright (license 71) iax2-provision.c.patch uploaded by eliel (license 64) chan_gtalk.c.patch uploaded by eliel (license 64) pbx_ael.c.patch uploaded by seanbright (license 71) file.c.patch uploaded by seanbright (license 71) image.c.patch uploaded by seanbright (license 71) cli.c.patch uploaded by moy (license 222) astobj2.c.patch uploaded by moy (license 222) asterisk.c.patch uploaded by moy (license 222) res_limit.c.patch uploaded by seanbright (license 71) res_convert.c.patch uploaded by seanbright (license 71) res_crypto.c.patch uploaded by seanbright (license 71) app_osplookup.c.patch uploaded by seanbright (license 71) app_rpt.c.patch uploaded by seanbright (license 71) app_mixmonitor.c.patch uploaded by seanbright (license 71) channel.c.patch uploaded by seanbright (license 71) translate.c.patch uploaded by seanbright (license 71) udptl.c.patch uploaded by seanbright (license 71) threadstorage.c.patch uploaded by seanbright (license 71) db.c.patch uploaded by seanbright (license 71) cdr.c.patch uploaded by moy (license 222) pbd_dundi.c.patch uploaded by moy (license 222) app_osplookup-rev83558.patch uploaded by moy (license 222) res_clioriginate.c.patch uploaded by moy (license 222) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@85460 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/translate.c')
-rw-r--r--main/translate.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/main/translate.c b/main/translate.c
index b22a3386d..88811ddc8 100644
--- a/main/translate.c
+++ b/main/translate.c
@@ -491,28 +491,42 @@ static void rebuild_matrix(int samples)
}
}
-static int show_translation(int fd, int argc, char *argv[])
+static char *handle_cli_core_show_translation(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
#define SHOW_TRANS 13
int x, y, z;
int curlen = 0, longest = 0;
- if (argc > 5)
- return RESULT_SHOWUSAGE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "core show translation [recalc]";
+ e->usage =
+ "Usage: core show translation [recalc] [<recalc seconds>]\n"
+ " Displays known codec translators and the cost associated\n"
+ " with each conversion. If the argument 'recalc' is supplied along\n"
+ " with optional number of seconds to test a new test will be performed\n"
+ " as the chart is being displayed.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc > 5)
+ return CLI_SHOWUSAGE;
- if (argv[3] && !strcasecmp(argv[3], "recalc")) {
- z = argv[4] ? atoi(argv[4]) : 1;
+ if (a->argv[3] && !strcasecmp(a->argv[3], "recalc")) {
+ z = a->argv[4] ? atoi(a->argv[4]) : 1;
if (z <= 0) {
- ast_cli(fd, " C'mon let's be serious here... defaulting to 1.\n");
+ ast_cli(a->fd, " Recalc must be greater than 0. Defaulting to 1.\n");
z = 1;
}
if (z > MAX_RECALC) {
- ast_cli(fd, " Maximum limit of recalc exceeded by %d, truncating value to %d\n", z - MAX_RECALC, MAX_RECALC);
+ ast_cli(a->fd, " Maximum limit of recalc exceeded by %d, truncating value to %d\n", z - MAX_RECALC, MAX_RECALC);
z = MAX_RECALC;
}
- ast_cli(fd, " Recalculating Codec Translation (number of sample seconds: %d)\n\n", z);
+ ast_cli(a->fd, " Recalculating Codec Translation (number of sample seconds: %d)\n\n", z);
AST_RWLIST_WRLOCK(&translators);
rebuild_matrix(z);
AST_RWLIST_UNLOCK(&translators);
@@ -520,8 +534,8 @@ static int show_translation(int fd, int argc, char *argv[])
AST_RWLIST_RDLOCK(&translators);
- ast_cli(fd, " Translation times between formats (in microseconds) for one second of data\n");
- ast_cli(fd, " Source Format (Rows) Destination Format (Columns)\n\n");
+ ast_cli(a->fd, " Translation times between formats (in microseconds) for one second of data\n");
+ ast_cli(a->fd, " Source Format (Rows) Destination Format (Columns)\n\n");
/* Get the length of the longest (usable?) codec name, so we know how wide the left side should be */
for (x = 0; x < SHOW_TRANS; x++) {
curlen = strlen(ast_getformatname(1 << (x + 1)));
@@ -554,23 +568,14 @@ static int show_translation(int fd, int argc, char *argv[])
}
}
ast_str_append(&out, -1, "\n");
- ast_cli(fd, out->str);
+ ast_cli(a->fd, out->str);
}
AST_RWLIST_UNLOCK(&translators);
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
-static const char show_trans_usage[] =
-"Usage: core show translation [recalc] [<recalc seconds>]\n"
-" Displays known codec translators and the cost associated\n"
-"with each conversion. If the argument 'recalc' is supplied along\n"
-"with optional number of seconds to test a new test will be performed\n"
-"as the chart is being displayed.\n";
-
static struct ast_cli_entry cli_translate[] = {
- { { "core", "show", "translation", NULL },
- show_translation, "Display translation matrix",
- show_trans_usage, NULL, NULL },
+ NEW_CLI(handle_cli_core_show_translation, "Display translation matrix")
};
/*! \brief register codec translator */