]> git.draconx.ca Git - liblbx.git/blobdiff - src/lbximg.c
gnulib: Use getopt-gnu module for increased tool portability.
[liblbx.git] / src / lbximg.c
index 61516196174999a7aab25ca0f9428699184845ff..50dff078f7050588c595c60ad179a52785942706 100644 (file)
@@ -1,22 +1,23 @@
-/* 2ooM: The Master of Orion II Reverse Engineering Project
- * Simple command-line tool to convert an LBX image to a set of PNGs.
- * Copyright (C) 2006-2008 Nick Bowler
+/*
+ *  2ooM: The Master of Orion II Reverse Engineering Project
+ *  Simple command-line tool to convert an LBX image to a set of PNGs.
+ *  Copyright (C) 2006-2008 Nick Bowler
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #define _GNU_SOURCE
+#include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -27,6 +28,7 @@
 
 #include <png.h>
 
+#include "tools.h"
 #include "image.h"
 #include "lbx.h"
 
@@ -35,6 +37,19 @@ static int verbose = 0;
 static char *outname = "out";
 static int usepalette = 1;
 
+static void printusage(void)
+{
+       puts("usage: lbximg [-i|-d] [-v] [-p palette_file] [-O override_file]"
+                         " [-f path]");
+       puts("              [frameno ...]");
+}
+
+static void printhelp(void)
+{
+       printusage();
+       puts("For now, see the man page for detailed help.");
+}
+
 static const char *progname;
 #define errmsg(fmt, ...) (\
        fprintf(stderr, "%s: " fmt, progname, __VA_ARGS__)\
@@ -356,7 +371,7 @@ int main(int argc, char **argv)
        LBX_IMG *img;
        int opt;
 
-       static const char *sopts = "idvf:p:O:";
+       static const char *sopts = "idvf:p:O:V";
        static const struct option lopts[] = {
                { "ident",    0, NULL, 'i' },
                { "decode",   0, NULL, 'd' },
@@ -365,6 +380,10 @@ int main(int argc, char **argv)
                { "palette",  1, NULL, 'p' },
                { "override", 1, NULL, 'p' },
 
+               { "version",  0, NULL, 'V' },
+               { "usage",    0, NULL, 'U' },
+               { "help",     0, NULL, 'H' },
+
                { "nopalette", 0, &usepalette, 0 },
 
                { 0 }
@@ -410,6 +429,15 @@ int main(int argc, char **argv)
                                return EXIT_FAILURE;
                        }
                        break;
+               case 'V':
+                       puts(VERSION_BOILERPLATE("lbximg"));
+                       return EXIT_SUCCESS;
+               case 'U':
+                       printusage();
+                       return EXIT_SUCCESS;
+               case 'H':
+                       printhelp();
+                       return EXIT_SUCCESS;
                case '?':
                case ':':
                        return EXIT_FAILURE;