]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix core show file formats CLI command.
authorJoshua Colp <jcolp@digium.com>
Fri, 26 Jan 2007 23:46:47 +0000 (23:46 +0000)
committerJoshua Colp <jcolp@digium.com>
Fri, 26 Jan 2007 23:46:47 +0000 (23:46 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@52335 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/file.c

index 5192984d318f173af12540dca647a548916123ac..bb9f05964e1b52ac59d07651806cb142edf697f9 100644 (file)
@@ -1133,7 +1133,7 @@ static int show_file_formats(int fd, int argc, char *argv[])
        struct ast_format *f;
        int count_fmt = 0;
 
-       if (argc != 3)
+       if (argc != 4)
                return RESULT_SHOWUSAGE;
        ast_cli(fd, FORMAT, "Format", "Name", "Extensions");
                
@@ -1153,13 +1153,40 @@ static int show_file_formats(int fd, int argc, char *argv[])
 #undef FORMAT2
 }
 
+static int show_file_formats_deprecated(int fd, int argc, char *argv[])
+{
+#define FORMAT "%-10s %-10s %-20s\n"
+#define FORMAT2 "%-10s %-10s %-20s\n"
+       struct ast_format *f;
+       int count_fmt = 0;
+       
+       if (argc != 3)
+               return RESULT_SHOWUSAGE;
+       ast_cli(fd, FORMAT, "Format", "Name", "Extensions");
+       
+       if (AST_LIST_LOCK(&formats)) {
+               ast_log(LOG_WARNING, "Unable to lock format list\n");
+               return -1;
+       }
+       
+       AST_LIST_TRAVERSE(&formats, f, list) {
+               ast_cli(fd, FORMAT2, ast_getformatname(f->format), f->name, f->exts);
+               count_fmt++;
+       }
+       AST_LIST_UNLOCK(&formats);
+       ast_cli(fd, "%d file formats registered.\n", count_fmt);
+       return RESULT_SUCCESS;
+#undef FORMAT
+#undef FORMAT2
+}
+
 char show_file_formats_usage[] = 
 "Usage: core show file formats\n"
 "       Displays currently registered file formats (if any)\n";
 
 struct ast_cli_entry cli_show_file_formats_deprecated = {
        { "show", "file", "formats" },
-       show_file_formats, NULL,
+       show_file_formats_deprecated, NULL,
        NULL };
 
 struct ast_cli_entry cli_file[] = {