changeset 2242:65a2c2e99c81

Move listing of C64 formats function to argShowC64Formats in lib64util.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 15 Jun 2019 07:55:26 +0300
parents 587eb90459f9
children 79ece1072143
files tools/64vw.c tools/gfxconv.c tools/lib64util.c tools/lib64util.h
diffstat 4 files changed, 40 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/tools/64vw.c	Sat Jun 15 07:54:39 2019 +0300
+++ b/tools/64vw.c	Sat Jun 15 07:55:26 2019 +0300
@@ -57,27 +57,6 @@
 }
 
 
-void argShowFormats()
-{
-    printf(
-    "Available C64 bitmap formats (-f <frmt>):\n"
-    " frmt | Type            | Description\n"
-    "------+-----------------+-------------------------------------\n"
-    );
-    for (int i = 0; i < ndmC64ImageFormats; i++)
-    {
-        const DMC64ImageFormat *fmt = dmC64ImageFormatsSorted[i];
-        char buf[64];
-        printf("%-6s| %-15s | %s%s\n",
-            fmt->fext,
-            dmC64GetImageTypeString(buf, sizeof(buf), fmt->format->type, FALSE),
-            fmt->name,
-            fmt->flags & DM_FMT_BROKEN ? " [BROKEN]" : "");
-    }
-    printf("%d formats supported.\n", ndmC64ImageFormats);
-}
-
-
 void argShowHelp()
 {
     dmPrintBanner(stdout, dmProgName, "[options] <input image file>");
@@ -151,7 +130,7 @@
             break;
 
         case 5:
-            argShowFormats();
+            argShowC64Formats(stdout, FALSE);
             exit(0);
             break;
 
--- a/tools/gfxconv.c	Sat Jun 15 07:54:39 2019 +0300
+++ b/tools/gfxconv.c	Sat Jun 15 07:55:26 2019 +0300
@@ -206,24 +206,9 @@
     "\n"
     "(Not all input->output combinations are actually supported.)\n"
     "\n"
-    "Available C64 bitmap formats (-f <frmt>):\n"
-    " frmt | RW | Type            | Description\n"
-    "------+----+-----------------+-------------------------------------\n"
     );
 
-    for (int i = 0; i < ndmC64ImageFormats; i++)
-    {
-        const DMC64ImageFormat *fmt = dmC64ImageFormatsSorted[i];
-        char buf[64];
-        printf("%-6s| %c%c | %-15s | %s%s\n",
-            fmt->fext,
-            (fmt->flags & DM_FMT_RD) ? 'R' : ' ',
-            (fmt->flags & DM_FMT_WR) ? 'W' : ' ',
-            dmC64GetImageTypeString(buf, sizeof(buf), fmt->format->type, FALSE),
-            fmt->name,
-            fmt->flags & DM_FMT_BROKEN ? " [BROKEN]" : "");
-    }
-    printf("%d formats supported.\n", ndmC64ImageFormats);
+    argShowC64Formats(stdout, TRUE);
 }
 
 
--- a/tools/lib64util.c	Sat Jun 15 07:54:39 2019 +0300
+++ b/tools/lib64util.c	Sat Jun 15 07:55:26 2019 +0300
@@ -114,6 +114,43 @@
 }
 
 
+void argShowC64Formats(FILE *fp, const BOOL rw)
+{
+    fprintf(fp,
+        "Available C64 bitmap formats (-f <frmt>):\n"
+        " frmt %s| Type            | Description\n"
+        "------%s+-----------------+-------------------------------------\n",
+        rw ? "| RW " : "",
+        rw ? "+----" : ""
+        );
+
+    for (int i = 0; i < ndmC64ImageFormats; i++)
+    {
+        const DMC64ImageFormat *fmt = dmC64ImageFormatsSorted[i];
+        char buf[64];
+
+        fprintf(fp, "%-6s",
+            fmt->fext);
+
+        if (rw)
+        {
+            fprintf(fp, "| %c%c ",
+                (fmt->flags & DM_FMT_RD) ? 'R' : ' ',
+                (fmt->flags & DM_FMT_WR) ? 'W' : ' '
+                );
+        }
+
+        fprintf(fp,
+            "| %-15s | %s%s\n",
+            dmC64GetImageTypeString(buf, sizeof(buf), fmt->format->type, FALSE),
+            fmt->name,
+            fmt->flags & DM_FMT_BROKEN ? " [BROKEN]" : "");
+    }
+
+    fprintf(fp, "%d formats supported.\n", ndmC64ImageFormats);
+}
+
+
 BOOL argHandleC64PaletteOption(char *optArg, DMC64Palette **ppal, char **palFile)
 {
     if (strcasecmp(optArg, "help") == 0 ||
--- a/tools/lib64util.h	Sat Jun 15 07:54:39 2019 +0300
+++ b/tools/lib64util.h	Sat Jun 15 07:55:26 2019 +0300
@@ -25,6 +25,7 @@
 void      dmC64ImageDump(FILE *fh, const DMC64Image *img, const DMC64ImageFormat *fmt, const char *indent);
 
 void      argShowC64PaletteHelp(FILE *fp);
+void      argShowC64Formats(FILE *fp, const BOOL rw);
 BOOL      argHandleC64PaletteOption(char *optArg, DMC64Palette **ppal, char **palFile);
 
 int       dmHandleExternalPalette(const char *filename, DMPalette **ppal);