X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;ds=sidebyside;f=sst.c;h=77fbeb826ba2b4f273df612835c408f13be1827b;hb=998ff9c48426dd89c25b56ab59a0c8e2b6986355;hp=d35b2556ae1407f297b0088838a2c5124b1140c0;hpb=25f221b092e0e9d85aa5d3e6863043f2ab4d7c43;p=super-star-trek.git diff --git a/sst.c b/sst.c index d35b255..77fbeb8 100644 --- a/sst.c +++ b/sst.c @@ -1,6 +1,7 @@ #define INCLUDED // Define externs here -#include "sst.h" #include +#include +#include "sst.h" #ifndef SSTDOC #define SSTDOC "sst.doc" @@ -344,20 +345,28 @@ static void makemoves(void) { int main(int argc, char **argv) { - int i; + int i, option, usecurses = TRUE; int hitme; char ch; + while ((option = getopt(argc, argv, "t")) != -1) { + switch (option) { + case 't': + usecurses = FALSE; + break; + default: + fprintf(stderr, "usage: sst [-t] [startcommand...].\n"); + exit(0); + } + } + + iostart(usecurses); prelim(); - iostart(); line[0] = '\0'; - if (argc > 1) { - while (--argc > 0) { - strcat(line, *(++argv)); - strcat(line, " "); - } + for (i = optind; i < argc; i++) { + strcat(line, argv[i]); + strcat(line, " "); } - while (TRUE) { /* Play a game */ setup(line[0] == '\0'); if (alldone) { @@ -380,7 +389,8 @@ int main(int argc, char **argv) { if (!ja()) break; } skip(1); - prout("May the Great Bird of the Galaxy roost upon your home planet."); + ioend(); + puts("May the Great Bird of the Galaxy roost upon your home planet."); } @@ -478,8 +488,7 @@ int scan(void) { chew(); return IHEOL; } - fgets(line, sizeof(line), stdin); - line[strlen(line)-1] = '\0'; + getline(line, sizeof(line)); linep = line; } // Skip leading white space