1: # include   "mille.h"
   2: # include   <signal.h>
   3: # ifdef attron
   4: #	include   <term.h>
   5: # endif	attron
   6: 
   7: /*
   8:  * @(#)mille.c	1.3 (Berkeley) 5/10/83
   9:  */
  10: 
  11: int rub();
  12: 
  13: char    _sobuf[BUFSIZ];
  14: 
  15: main(ac, av)
  16: reg int     ac;
  17: reg char    *av[]; {
  18: 
  19:     reg bool    restore;
  20:     double      avs[3];
  21: 
  22:     if (strcmp(av[0], "a.out") == 0) {
  23:         outf = fopen("q", "w");
  24:         setbuf(outf, NULL);
  25:         Debug = TRUE;
  26:     }
  27:     restore = FALSE;
  28: # ifdef LOADAV
  29:     if (geteuid() != ARNOLD) {
  30:         loadav(avs);
  31:         if (avs[2] > 9.0) {
  32:             printf("Sorry.  The load average is too high.\n");
  33:             printf("Please try again later\n");
  34:             exit(1);
  35:         }
  36:     }
  37: # endif
  38:     switch (ac) {
  39:       case 2:
  40:         rest_f(av[1]);
  41:         restore = TRUE;
  42:       case 1:
  43:         break;
  44:       default:
  45:         printf("usage: milles [ restore_file ]\n");
  46:         exit(-1);
  47:         /* NOTREACHED */
  48:     }
  49:     setbuf(stdout, _sobuf);
  50:     Play = PLAYER;
  51:     initscr();
  52: # ifdef attron
  53: #	define    CA  cursor_address
  54: # endif
  55:     if (!CA) {
  56:         printf("Sorry.  Need cursor addressing to play mille\n");
  57:         exit(-1);
  58:     }
  59:     delwin(stdscr);
  60:     stdscr = Board = newwin(BOARD_Y, BOARD_X, 0, 0);
  61:     Score = newwin(SCORE_Y, SCORE_X, 0, 40);
  62:     Miles = newwin(MILES_Y, MILES_X, 17, 0);
  63: #ifdef attron
  64:     idlok(Board, TRUE);
  65:     idlok(Score, TRUE);
  66:     idlok(Miles, TRUE);
  67: #endif
  68:     leaveok(Score, TRUE);
  69:     leaveok(Miles, TRUE);
  70:     clearok(curscr, TRUE);
  71: # ifndef PROF
  72:     srandom(getpid());
  73: # else
  74:     srandom(0);
  75: # endif
  76:     crmode();
  77:     noecho();
  78:     signal(SIGINT, rub);
  79:     for (;;) {
  80:         if (!restore || (Player[PLAYER].total >= 5000
  81:             || Player[COMP].total >= 5000)) {
  82:             if (Player[COMP].total < Player[PLAYER].total)
  83:                 Player[PLAYER].games++;
  84:             else if (Player[COMP].total > Player[PLAYER].total)
  85:                 Player[COMP].games++;
  86:             Player[COMP].total = 0;
  87:             Player[PLAYER].total = 0;
  88:         }
  89:         do {
  90:             if (!restore)
  91:                 Handstart = Play = other(Handstart);
  92:             if (!restore || On_exit) {
  93:                 shuffle();
  94:                 init();
  95:             }
  96:             newboard();
  97:             if (restore)
  98:                 mvwaddstr(Score, ERR_Y, ERR_X, Initstr);
  99:             prboard();
 100:             do {
 101:                 domove();
 102:                 if (Finished)
 103:                     newscore();
 104:                 prboard();
 105:             } while (!Finished);
 106:             check_more();
 107:             restore = On_exit = FALSE;
 108:         } while (Player[COMP].total < 5000
 109:             && Player[PLAYER].total < 5000);
 110:     }
 111: }
 112: 
 113: /*
 114:  *	Routine to trap rubouts, and make sure they really want to
 115:  * quit.
 116:  */
 117: rub() {
 118: 
 119:     signal(SIGINT, SIG_IGN);
 120:     if (getyn(REALLYPROMPT))
 121:         die();
 122:     signal(SIGINT, rub);
 123: }
 124: 
 125: /*
 126:  *	Time to go beddy-by
 127:  */
 128: die() {
 129: 
 130:     signal(SIGINT, SIG_IGN);
 131:     if (outf)
 132:         fflush(outf);
 133:     mvcur(0, COLS - 1, LINES - 1, 0);
 134:     endwin();
 135:     exit(1);
 136: }

Defined functions

die defined in line 128; used 3 times
main defined in line 15; never used
rub defined in line 117; used 4 times

Defined variables

_sobuf defined in line 13; used 1 times
  • in line 49

Defined macros

CA defined in line 53; used 1 times
  • in line 55
Last modified: 1986-01-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1308
Valid CSS Valid XHTML 1.0 Strict