int i;
FILE *savfil;
-#if 0
if (stat(SAVEDIR,&filestat)) {
printf("Cannot access %s\r\n",SAVEDIR);
finalize(1);
}
- if (filestat.st_uid != geteuid()) {
- printf("Warp will not run right without being setuid.\r\n");
+ if (filestat.st_gid != getegid()) {
+ printf("Warp will not run right without being setgid.\r\n");
finalize(1);
}
if ((filestat.st_mode & 0605) != 0605) {
printf("%s is not protected correctly (must be u+rw o+rx).\r\n",SAVEDIR);
finalize(1);
}
-#endif
#ifdef SCOREFULL
interp(longlognam, sizeof longlognam, "%N");
printf("WHO SCORE DF CDF E B WV FLAGS\r\n");
resetty();
snprintf(spbuf, sizeof(spbuf), "/bin/cat %ssave.*",SAVEDIR);
-#ifndef lint
execl("/bin/sh", "sh", "-c", spbuf, NULL);
-#endif
finalize(1);
}
snprintf(spbuf, sizeof(spbuf), "Star save ratio: %1.8f (%d/%d)",
starscore, numstars, inumstars);
mvaddstr( 6,5, spbuf);
-#ifndef lint
bonuses += tmp = (long) (((double)curscore / possiblescore) *
(starscore*starscore) * smarts * 20);
-#endif
snprintf(spbuf, sizeof(spbuf), "%6ld", tmp);
mvaddstr( 6, 68, spbuf);
row = 7;
{
savetty(); /* remember current tty state */
-#ifdef TERMIO
- ospeed = _tty.c_cflag & CBAUD; /* for tputs() */
+#if defined(TERMIO) || defined(TERMIOS)
+ ospeed = cfgetospeed(&_tty);
ERASECH = _tty.c_cc[VERASE]; /* for finish_command() */
KILLCH = _tty.c_cc[VKILL]; /* for finish_command() */
#else
for (p=filler+(sizeof filler)-1;!*p;--p)
*p = PC;
}
- charsperhalfsec = ospeed >= B9600 ? 480 :
- ospeed == B4800 ? 240 :
- ospeed == B2400 ? 120 :
- ospeed == B1200 ? 60 :
- ospeed == B600 ? 30 :
- /* speed is 300 (?) */ 15;
-
- gfillen = ospeed >= B9600 ? (int /*XXX: speed_t*/)(sizeof filler) :
- ospeed == B4800 ? 13 :
- ospeed == B2400 ? 7 :
- ospeed == B1200 ? 4 :
- (1+BCsize);
- if (ospeed < B2400)
+ charsperhalfsec = (speed_t)ospeed >= B9600 ? (speed_t)480 :
+ (speed_t)ospeed == B4800 ? (speed_t)240 :
+ (speed_t)ospeed == B2400 ? (speed_t)120 :
+ (speed_t)ospeed == B1200 ? (speed_t)60 :
+ (speed_t)ospeed == B600 ? (speed_t)30 :
+ /* speed is 300 (?) */ (speed_t)15;
+
+ gfillen = (speed_t)ospeed >= B9600 ? (speed_t)(sizeof filler) :
+ (speed_t)ospeed == B4800 ? (speed_t)13 :
+ (speed_t)ospeed == B2400 ? (speed_t)7 :
+ (speed_t)ospeed == B1200 ? (speed_t)4 :
+ (speed_t)(1+BCsize);
+ if ((speed_t)ospeed < B2400)
lowspeed = true;
strcpy(term,ttyname(2));
}
got_canonical:
-#ifndef TERMIO
+#if !defined(TERMIO) && !defined(TERMIOS)
if (*whatbuf == '\r')
*whatbuf = '\n';
#endif
/* stuff wanted by terminal mode diddling routines */
-#ifdef TERMIO
+#ifdef TERMIOS
+EXT struct termios _tty, _oldtty;
+#elif defined(TERMIO)
+typedef int speed_t;
EXT struct termio _tty, _oldtty;
+#define tcsetattr(fd, how, ti) ioctl(fd, how, ti)
+#define tcgetattr(fd, ti) ioctl(fd, TCGETA, ti)
+#define cfgetospeed(ti) ((ti)->c_cflag & CBAUD)
#else
+typedef int speed_t;
EXT struct sgttyb _tty;
EXT int _res_flg INIT(0);
#endif
/* terminal mode diddling routines */
-#ifdef TERMIO
+#if defined(TERMIO) || defined(TERMIOS)
-#define raw() ((bizarre=1),_tty.c_lflag &=~ISIG,_tty.c_cc[VMIN] = 1,ioctl(_tty_ch,TCSETAF,&_tty))
-#define noraw() ((bizarre=1),_tty.c_lflag |= ISIG,_tty.c_cc[VEOF] = CEOF,ioctl(_tty_ch,TCSETAF,&_tty))
-#define crmode() ((bizarre=1),_tty.c_lflag &=~ICANON,_tty.c_cc[VMIN] = 1,ioctl(_tty_ch,TCSETAF,&_tty))
-#define nocrmode() ((bizarre=1),_tty.c_lflag |= ICANON,_tty.c_cc[VEOF] = CEOF,ioctl(_tty_ch,TCSETAF,&_tty))
-#define echo() ((bizarre=1),_tty.c_lflag |= ECHO, ioctl(_tty_ch, TCSETAW, &_tty))
-#define noecho() ((bizarre=1),_tty.c_lflag &=~ECHO, ioctl(_tty_ch, TCSETAW, &_tty))
-#define nl() ((bizarre=1),_tty.c_iflag |= ICRNL,_tty.c_oflag |= ONLCR,ioctl(_tty_ch, TCSETAW, &_tty))
-#define nonl() ((bizarre=1),_tty.c_iflag &=~ICRNL,_tty.c_oflag &=~ONLCR,ioctl(_tty_ch, TCSETAW, &_tty))
-#define savetty() (ioctl(_tty_ch, TCGETA, &_oldtty),ioctl(_tty_ch, TCGETA, &_tty))
-#define resetty() ((bizarre=0),ioctl(_tty_ch, TCSETAF, &_oldtty))
+#define raw() ((bizarre=1),_tty.c_lflag &=~ISIG,_tty.c_cc[VMIN] = 1,tcsetattr(_tty_ch,TCSAFLUSH,&_tty))
+#define noraw() ((bizarre=1),_tty.c_lflag |= ISIG,_tty.c_cc[VEOF] = CEOF,tcsetattr(_tty_ch,TCSAFLUSH,&_tty))
+#define crmode() ((bizarre=1),_tty.c_lflag &=~ICANON,_tty.c_cc[VMIN] = 1,tcsetattr(_tty_ch,TCSAFLUSH,&_tty))
+#define nocrmode() ((bizarre=1),_tty.c_lflag |= ICANON,_tty.c_cc[VEOF] = CEOF,tcsetattr(_tty_ch,TCSAFLUSH,&_tty))
+#define echo() ((bizarre=1),_tty.c_lflag |= ECHO, tcsetattr(_tty_ch, TCSANOW, &_tty))
+#define noecho() ((bizarre=1),_tty.c_lflag &=~ECHO, tcsetattr(_tty_ch, TCSANOW, &_tty))
+#define nl() ((bizarre=1),_tty.c_iflag |= ICRNL,_tty.c_oflag |= ONLCR,tcsetattr(_tty_ch, TCSANOW, &_tty))
+#define nonl() ((bizarre=1),_tty.c_iflag &=~ICRNL,_tty.c_oflag &=~ONLCR,tcsetattr(_tty_ch, TCSANOW, &_tty))
+#define savetty() (tcgetattr(_tty_ch, &_oldtty),tcgetattr(_tty_ch, &_tty))
+#define resetty() ((bizarre=0),tcsetattr(_tty_ch, TCSAFLUSH, &_oldtty))
#define unflush_output()
#else