We have the framework of the curses interface working.
[super-star-trek.git] / sst.c
diff --git a/sst.c b/sst.c
index c8ac356eda049da1ea740374e472d98172f8773b..77fbeb826ba2b4f273df612835c408f13be1827b 100644 (file)
--- a/sst.c
+++ b/sst.c
@@ -1,6 +1,7 @@
 #define INCLUDED       // Define externs here\r
-#include "sst.h"\r
 #include <ctype.h>\r
+#include <getopt.h>\r
+#include "sst.h"\r
 \r
 #ifndef SSTDOC\r
 #define SSTDOC "sst.doc"\r
@@ -344,20 +345,28 @@ static void makemoves(void) {
 \r
 \r
 int main(int argc, char **argv) {\r
-       int i;\r
+    int i, option, usecurses = TRUE;\r
        int hitme;\r
        char ch;\r
 \r
-       iostart();\r
+       while ((option = getopt(argc, argv, "t")) != -1) {\r
+           switch (option) {\r
+           case 't':\r
+               usecurses = FALSE;\r
+               break;\r
+           default:\r
+               fprintf(stderr, "usage: sst [-t] [startcommand...].\n");\r
+               exit(0);\r
+           }\r
+       }\r
+\r
+       iostart(usecurses);\r
        prelim(); \r
        line[0] = '\0';\r
-       if (argc > 1) {\r
-               while (--argc > 0) {\r
-                       strcat(line, *(++argv));\r
-                       strcat(line, " ");\r
-               }\r
+       for (i = optind; i < argc;  i++) {\r
+               strcat(line, argv[i]);\r
+               strcat(line, " ");\r
        }\r
-\r
        while (TRUE) { /* Play a game */\r
                setup(line[0] == '\0');\r
                if (alldone) {\r