1: /*
   2:  * Copyright (c) 1983 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #if !defined(lint) && defined(DOSCCS)
   8: char copyright[] =
   9: "@(#) Copyright (c) 1980 Regents of the University of California.\n\
  10:  All rights reserved.\n";
  11: 
  12: static char sccsid[] = "@(#)main.c	5.1.2 (2.11BSD) 1997/9/9";
  13: #endif
  14: 
  15: #include "externs.h"
  16: 
  17: /*ARGSUSED*/
  18: main(argc, argv)
  19:     int argc;
  20:     register char **argv;
  21: {
  22:     register char *p;
  23:     int i;
  24:     char stdobuf[BUFSIZ];
  25: 
  26:     setbuf(stdout, stdobuf);
  27:     (void) srand(getpid());
  28:     issetuid = getuid() != geteuid();
  29:     if (p = rindex(*argv, '/'))
  30:         p++;
  31:     else
  32:         p = *argv;
  33:     if (strcmp(p, "driver") == 0 || strcmp(p, "saildriver") == 0)
  34:         mode = MODE_DRIVER;
  35:     else if (strcmp(p, "sail.log") == 0)
  36:         mode = MODE_LOGGER;
  37:     else
  38:         mode = MODE_PLAYER;
  39:     while ((p = *++argv) && *p == '-')
  40:         switch (p[1]) {
  41:         case 'd':
  42:             mode = MODE_DRIVER;
  43:             break;
  44:         case 's':
  45:             mode = MODE_LOGGER;
  46:             break;
  47:         case 'D':
  48:             debug++;
  49:             break;
  50:         case 'x':
  51:             randomize;
  52:             break;
  53:         case 'l':
  54:             longfmt++;
  55:             break;
  56:         case 'b':
  57:             nobells++;
  58:             break;
  59:         default:
  60:             fprintf(stderr, "SAIL: Unknown flag %s.\n", p);
  61:             exit(1);
  62:         }
  63:     if (*argv)
  64:         game = atoi(*argv);
  65:     else
  66:         game = -1;
  67:     if (i = setjmp(restart))
  68:         mode = i;
  69:     switch (mode) {
  70:     case MODE_PLAYER:
  71:         return pl_main();
  72:     case MODE_DRIVER:
  73:         return dr_main();
  74:     case MODE_LOGGER:
  75:         return lo_main();
  76:     default:
  77:         fprintf(stderr, "SAIL: Unknown mode %d.\n", mode);
  78:         abort();
  79:     }
  80:     /*NOTREACHED*/
  81: }
  82: 
  83: /*
  84:  * These used to be macros in machdep.h.  The macros were wrong (didn't use
  85:  * sigmask() and thus only computed 16 bit signal masks).  The signal handling
  86:  * in 2.11BSD is now that of 4.4BSD and the macros were fixed (i.e. rewritten)
  87:  * and made into routines to avoid the plethora of inline 'long' operations.
  88: */
  89: 
  90: void
  91: blockalarm()
  92:     {
  93:     sigset_t set;
  94: 
  95:     sigemptyset(&set);
  96:     sigaddset(&set, SIGALRM);
  97: 
  98:     (void)sigprocmask(SIG_BLOCK, &set, NULL);
  99:     }
 100: 
 101: void
 102: unblockalarm()
 103:     {
 104:     sigset_t set;
 105: 
 106:     sigemptyset(&set);
 107:     sigaddset(&set, SIGALRM);
 108:     (void)sigprocmask(SIG_UNBLOCK, &set, NULL);
 109:     }

Defined functions

main defined in line 18; never used

Defined variables

copyright defined in line 8; never used
sccsid defined in line 12; never used
Last modified: 1997-09-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3381
Valid CSS Valid XHTML 1.0 Strict