[Asterisk-Dev] show translate with format labels

cisb ariel at cisb.mine.nu
Thu Jun 26 09:31:22 MST 2003


REMOVE
----- Original Message -----
From: "Karl Putland" <karl at putland.linux-site.net>
To: <asterisk-dev at lists.digium.com>
Sent: Wednesday, June 25, 2003 11:30 PM
Subject: [Asterisk-Dev] show translate with format labels


> Still have to look up/remember the numeric values but at least it's
> easier to read.
>
> --Karl
>
>
> Index: translate.c
> ===================================================================
> RCS file: /usr/cvsroot/asterisk/translate.c,v
> retrieving revision 1.1.1.2
> diff -u -r1.1.1.2 translate.c
> --- translate.c 16 Mar 2003 22:37:29 -0000      1.1.1.2
> +++ translate.c 26 Jun 2003 02:50:09 -0000
> @@ -252,7 +252,7 @@
>
>  static int show_translation(int fd, int argc, char *argv[])
>  {
> -#define SHOW_TRANS 14
> +#define SHOW_TRANS 13
>         int x,y;
>         char line[80];
>         if (argc != 2)
> @@ -260,18 +260,26 @@
>         ast_cli(fd, "                        Translation times between
formats (in milliseconds)\n");
>         ast_cli(fd, "                                 Destination
Format\n");
>         ast_pthread_mutex_lock(&list_lock);
> -       for (x=0;x<SHOW_TRANS; x++) {
> +       for (x=-1;x<SHOW_TRANS; x++) {
>                 if (x == 1)
>                         strcpy(line, "  Src  ");
>                 else if (x == 2)
>                         strcpy(line, "  Fmt  ");
>                 else
>                         strcpy(line, "       ");
> -               for (y=0;y<SHOW_TRANS;y++) {
> -                       if (tr_matrix[x][y].step)
> +               for (y=-1;y<SHOW_TRANS;y++) {
> +                       if (x >= 0 && y >= 0 && tr_matrix[x][y].step)
>                                 snprintf(line + strlen(line),
sizeof(line) - strlen(line), " %4d", tr_matrix[x][y].cost);
>                         else
> -                               snprintf(line + strlen(line),
sizeof(line) - strlen(line), "  n/a");
> +                               if (x == -1 && y >= 0) {
> +                                       snprintf(line + strlen(line),
> +                                               sizeof(line) -
strlen(line), "%5d", 1<<y);
> +                               } else if (y == -1 && x >= 0) {
> +                                       snprintf(line + strlen(line),
> +                                               sizeof(line) -
strlen(line), "%5d", 1<<x);
> +                               } else {
> +                                       snprintf(line + strlen(line),
sizeof(line) - strlen(line), "  n/a");
> +                               }
>                 }
>                 snprintf(line + strlen(line), sizeof(line) - strlen(line),
"\n");
>                 ast_cli(fd, line);
>
> --
> Karl Putland <karl at putland.linux-site.net>
>
> _______________________________________________
> Asterisk-Dev mailing list
> Asterisk-Dev at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-dev
>





More information about the asterisk-dev mailing list