X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire.c;h=665ec8254c75d59067ba6b86b43e3038cc9978e2;hb=35cb4610fd9a7e9f720a07dadfde944339bfeb21;hp=849f1432ad7de8ba2274bf2cbd4c56d2851ceb80;hpb=0db0213c0d07134f3b3ef641bfa8db30c129d890;p=pspp diff --git a/src/ui/gui/psppire.c b/src/ui/gui/psppire.c index 849f1432ad..665ec8254c 100644 --- a/src/ui/gui/psppire.c +++ b/src/ui/gui/psppire.c @@ -23,7 +23,10 @@ * Glade will not overwrite this file. */ - +#include +#include +#include +#include #include #include #include @@ -47,9 +50,14 @@ PsppireCaseArray *the_cases = 0; PsppireDataStore *data_store = 0; +static bool parse_command_line (int *argc, char ***argv); + + int main(int argc, char *argv[]) { + if ( ! parse_command_line(&argc, &argv) ) + return 0; gtk_init(&argc, &argv); @@ -96,3 +104,41 @@ main(int argc, char *argv[]) return 0; } + +/* Parses the command line specified by ARGC and ARGV as received by + main(). Returns true if normal execution should proceed, + false if the command-line indicates that PSPP should exit. */ +static bool +parse_command_line (int *argc, char ***argv) +{ + static struct option long_options[] = + { + {"help", no_argument, NULL, 'h'}, + {"version", no_argument, NULL, 'V'}, + {0, 0, 0, 0}, + }; + + int c; + + for (;;) + { + c = getopt_long (*argc, *argv, "hV", long_options, NULL); + if (c == -1) + break; + + switch (c) + { + case 'h': + puts("Usage: ./psppire\nMust be run from the directory containing psppire.glade"); + return false; + case 'V': + puts (version); + puts (legal); + return false; + default: + assert (0); + } + } + + return true; +}