From 1c7473ee029b8960e51e2415a10a8439072bb5f0 Mon Sep 17 00:00:00 2001 From: gewlitys Date: Fri, 11 Oct 2002 19:39:59 +0000 Subject: [PATCH] linux-Gg's getopt_long commandline parser (last commit missed one file) git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@110 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/starcon2.c | 115 +++++++++++++++++++++++++++------------------ 1 file changed, 68 insertions(+), 47 deletions(-) diff --git a/sc2/src/starcon2.c b/sc2/src/starcon2.c index 46a5893ea..c20f06578 100644 --- a/sc2/src/starcon2.c +++ b/sc2/src/starcon2.c @@ -18,8 +18,10 @@ #ifndef WIN32 #include +#include #else #include +#include "getopt/getopt.h" #endif #include "libs/graphics/gfx_common.h" @@ -27,7 +29,6 @@ #include "libs/input/input_common.h" #include "libs/tasklib.h" - BOOLEAN FileExists (char *filename) { FILE *fp; @@ -56,65 +57,85 @@ CDToContentDir (char *contentdir) int main (int argc, char *argv[]) { - int i; int gfxdriver = TFB_GFXDRIVER_SDL_PURE; int gfxflags = 0; int width = 640, height = 480, bpp = 16; int frequency = 44100; - char contentdir[1000]; + char contentdir[1000]; + + int option_index = 0, c; + static struct option long_options[] = + { + {"res", 1, NULL, 'r'}, + {"bpp", 1, NULL, 'd'}, + {"fullscreen", 0, NULL, 'f'}, + {"opengl", 0, NULL, 'o'}, + {"bilinear", 0, NULL, 'b'}, + {"frequency", 1, NULL, 'q'}, + {"fps", 0, NULL, 'p'}, + {"tv", 0, NULL, 't'}, + {"contentdir", 1, NULL, 'c'}, + {"help", 0, NULL, 'h'}, + {0, 0, 0, 0} + }; #ifndef WIN32 - strcpy (contentdir, "content"); + strcpy (contentdir, "content"); #else strcpy (contentdir, "../../content"); #endif - // TODO: proper commandline parser, this is just a quick hack - for (i=1;i