]> git.sur5r.net Git - cc65/commitdiff
New option --list-conversions.
authoruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 10 Mar 2012 18:51:00 +0000 (18:51 +0000)
committeruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 10 Mar 2012 18:51:00 +0000 (18:51 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@5591 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/sp65/convert.c
src/sp65/convert.h
src/sp65/main.c

index f66d4e7dfdb534384054ecaaff1f152dccf01de8..1a6d228e3f87b27dbdde1f35fea9765126d670dc 100644 (file)
@@ -107,3 +107,12 @@ StrBuf* ConvertTo (const Bitmap* B, const Collection* A)
 
 
 
+void ListConversionTargets (FILE* F)
+/* Output a list of conversion targets */
+{
+    unsigned I;
+    for (I = 0; I < sizeof (ConverterMap) / sizeof (ConverterMap[0]); ++I) {
+        fprintf (F, "  %s\n", ConverterMap[I].Format);
+    }
+}
+                
index 35f9dca64d794261bc3984df985283bbf7304267..b0bc51ba8f1b0c29e989fd8b7ce88af25d9ac8bb 100644 (file)
@@ -38,6 +38,8 @@
 
 
 
+#include <stdio.h>
+
 /* common */
 #include "coll.h"
 #include "strbuf.h"
@@ -60,6 +62,9 @@ StrBuf* ConvertTo (const Bitmap* B, const Collection* A);
  * in the attribute collection A.
  */
 
+void ListConversionTargets (FILE* F);
+/* Output a list of conversion targets */
+
 
 
 /* End of convert.h */
index f243ce3fe83f7cb50c4a4acddbe037893b375935..062ace661b7b33b65e4efa1c481b2190c45411ef 100644 (file)
@@ -85,6 +85,7 @@ static void Usage (void)
                    "  -V\t\t\t\tPrint the version number and exit\n"
             "  -c fmt[,attrlist]\t\tConvert into target format\n"
                    "  -h\t\t\t\tHelp (this text)\n"
+            "  -lc\t\t\t\tList all possible conversions\n"
             "  -r file[,attrlist]\t\tRead an input file\n"
             "  -v\t\t\t\tIncrease verbosity\n"
             "  -w file[,attrlist]\t\tWrite the output to a file\n"
@@ -92,6 +93,7 @@ static void Usage (void)
            "Long options:\n"
             "  --convert-to fmt[,attrlist]\tConvert into target format\n"
            "  --help\t\t\tHelp (this text)\n"
+            "  --list-conversions\t\tList all possible conversions\n"
             "  --pop\t\t\t\tRestore the original loaded image\n"
             "  --read file[,attrlist]\tRead an input file\n"
             "  --slice x,y,w,h\t\tGenerate a slice from the loaded bitmap\n"
@@ -169,6 +171,16 @@ static void OptHelp (const char* Opt attribute ((unused)),
 
 
 
+static void OptListConversions (const char* Opt attribute ((unused)),
+                               const char* Arg attribute ((unused)))
+/* Print a list of all conversions */
+{
+    ListConversionTargets (stdout);
+    exit (EXIT_SUCCESS);
+}
+
+
+
 static void OptPop (const char* Opt attribute ((unused)),
                    const char* Arg attribute ((unused)))
 /* Restore the original image */
@@ -299,6 +311,7 @@ int main (int argc, char* argv [])
     static const LongOpt OptTab[] = {
         { "--convert-to",       1,      OptConvertTo            },
        { "--help",             0,      OptHelp                 },
+        { "--list-conversions", 0,      OptListConversions      },
         { "--pop",              0,      OptPop                  },
         { "--read",             1,      OptRead                 },
         { "--slice",            1,      OptSlice                },
@@ -320,24 +333,32 @@ int main (int argc, char* argv [])
                const char* Arg = ArgVec[I];
 
                /* Check for an option */
-               if (Arg [0] == '-') {
-                   switch (Arg [1]) {
+               if (Arg[0] == '-') {
+                   switch (Arg[1]) {
 
-               case '-':
-                   LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
-                   break;
+               case '-':
+                   LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
+                   break;
 
                        case 'V':
-                   OptVersion (Arg, 0);
-                           break;
+                   OptVersion (Arg, 0);
+                           break;
 
                 case 'c':
                     OptConvertTo (Arg, GetArg (&I, 2));
                     break;
 
-               case 'h':
-                   OptHelp (Arg, 0);
-                   break;
+               case 'h':
+                   OptHelp (Arg, 0);
+                   break;
+
+                case 'l':
+                    if (Arg[2] == 'c') {                       
+                        OptListConversions (Arg, 0);
+                    } else {
+                        UnknownOption (Arg);
+                    }
+                    break;
 
                 case 'r':
                     OptRead (Arg, GetArg (&I, 2));