|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T m
Length: 2833 (0xb11) Types: TextFile Names: »main.c.orig«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Adv/Program/main.c.orig«
/* * Adventure Driver Program * * Version 1.0, 29 December 1981 * Chris Torek * advent [-name] [adventure file] * * Lots of hacks sometime in '85 */ #include "adv.h" #undef TRUE #undef FALSE #undef LL #include <pwd.h> #include <ctype.h> #include <signal.h> int IntCatch(); char *getlogin(); struct passwd *getpwuid(); /* * Start up. Handle the single option ("-username"), get the * name of the adventure file, and run it. */ main(argc, argv) register argc; register char **argv; { register int c; ++argv; if (argc > 1 && **argv == '-') { --argc; name = (*argv++) + 1; } else { name = getlogin(); if (name == 0) { struct passwd *p = getpwuid(getuid()); if (p) name = p->pw_name; else { fprintf(stderr, "Who are you?\n"); exit(1); } } } if (--argc) strcpy(fname, *argv); else { printf("Enter the adventure filename: "); fgets(fname, sizeof fname, stdin); fname[strlen(fname) - 1] = 0; } #ifdef DEBUG printf ("Starting adventure %s for %s\n", fname, name); #endif srand(getpid() + time((long *)0)); file = fopen(fname, "r"); if (file == NULL) { printf("There's no such adventure!\n"); exit(1); } /* * Fire up windows. */ if (Winit(0, 0)) { printf ("Sorry, this program won't run on your terminal.\n"); exit(1); } printf("Hi %s, just a second while I create the world...\r\n", name); fflush(stdout); /* * Get some windows and set them up our way (no cursor, nice * newline mode); we'll use the real screen cursor for input. * N.B.: it is important that TopWin is initially as large as * the real screen. */ Wscreensize(&ROWS, &COLS); BaseWin = Wopen(1, 0, 0, COLS, ROWS, 0, 0); TopWin = Wopen(0, 0, 0, COLS, ROWS, 0, 0); Woncursor(BaseWin, 0); Woncursor(TopWin, 0); Wnewline(BaseWin, 1); Wnewline(TopWin, 1); WSetRealCursor++; /* * Read in the adventure file. */ readin(); /* * All set. */ #ifdef BSD41 /* 4.1 */ sigset(SIGINT, IntCatch); sigset(SIGQUIT, IntCatch); #else /* 4.2 */ signal(SIGINT, IntCatch); signal(SIGQUIT, IntCatch); #endif do { init(); play(); prt("Do you wish to play again (Y/N)? "); prt(0); refresh(); do { ReadingTerminal++; c = getchar(); ReadingTerminal = 0; if (isupper(c)) c = tolower(c); } while (c != 'y' && c != 'n'); prt(c == 'n' ? "No\n" : "Yes\n"); Wrefresh(0); } while (c != 'n'); prt("Goodbye!\n"); refresh(); Wexit(0); } /* * Handle interrupts - just print a message about how to quit. */ IntCatch() { static char msg[] = " *** Use the QUIT command to quit."; if (ReadingTerminal == 2) { /* print our msg in TopWin */ WAcursor(TopWin, 1, 0); Wputs(msg, TopWin); } else { if (BaseWin->w_cursor.col) Wputc('\n', BaseWin); Wputs(msg, BaseWin); Wputc('\n', BaseWin); } if (ReadingTerminal) refresh(); }