diff --git a/games/backgammon/backgammon/main.c b/games/backgammon/backgammon/main.c index 78bf69e2347a..7554ff650ff1 100644 --- a/games/backgammon/backgammon/main.c +++ b/games/backgammon/backgammon/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.3 1995/04/24 12:21:52 cgd Exp $ */ +/* $NetBSD: main.c,v 1.4 1995/04/29 00:44:03 mycroft Exp $ */ /* * Copyright (c) 1980, 1993 @@ -43,7 +43,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: main.c,v 1.3 1995/04/24 12:21:52 cgd Exp $"; +static char rcsid[] = "$NetBSD: main.c,v 1.4 1995/04/29 00:44:03 mycroft Exp $"; #endif #endif /* not lint */ @@ -55,7 +55,7 @@ static char rcsid[] = "$NetBSD: main.c,v 1.3 1995/04/24 12:21:52 cgd Exp $"; char *instr[]; /* text of instructions */ char *message[]; /* update message */ -char ospeed; /* tty output speed */ +speed_t ospeed; /* tty output speed */ char *helpm[] = { /* help message */ "Enter a space or newline to roll, or", @@ -111,16 +111,14 @@ char **argv; /* initialization */ bflag = 2; /* default no board */ - signal (2,getout); /* trap interrupts */ - if (gtty (0,&tty) == -1) /* get old tty mode */ + signal (2, getout); /* trap interrupts */ + if (tcgetattr (0, &old) == -1) /* get old tty mode */ errexit ("backgammon(gtty)"); - old = tty.sg_flags; -#ifdef V7 - raw = ((noech = old & ~ECHO) | CBREAK); /* set up modes */ -#else - raw = ((noech = old & ~ECHO) | RAW); /* set up modes */ -#endif - ospeed = tty.sg_ospeed; /* for termlib */ + noech = old; + noech.c_lflag &= ~ECHO; + raw = noech; + raw.c_lflag &= ~ICANON; /* set up modes */ + ospeed = cfgetospeed (&old); /* for termlib */ /* check user count */ # ifdef CORY @@ -152,11 +150,11 @@ char **argv; getarg (&argv); args[acnt] = '\0'; if (tflag) { /* clear screen */ - noech &= ~(CRMOD|XTABS); - raw &= ~(CRMOD|XTABS); + noech.c_oflag &= ~(ONLCR|OXTABS); + raw.c_oflag &= ~(ONLCR|OXTABS); clear(); } - fixtty (raw); /* go into raw mode */ + fixtty (&raw); /* go into raw mode */ /* check if restored * game and save flag @@ -179,7 +177,7 @@ char **argv; writel (rules); if (yorn(0)) { - fixtty (old); /* restore tty */ + fixtty (&old); /* restore tty */ execl (TEACH,"teachgammon",args,0); tflag = 0; /* error! */ diff --git a/games/backgammon/backgammon/move.c b/games/backgammon/backgammon/move.c index 1f437feb2474..f96c57a1c05c 100644 --- a/games/backgammon/backgammon/move.c +++ b/games/backgammon/backgammon/move.c @@ -1,4 +1,4 @@ -/* $NetBSD: move.c,v 1.4 1995/03/21 15:05:10 cgd Exp $ */ +/* $NetBSD: move.c,v 1.5 1995/04/29 00:44:05 mycroft Exp $ */ /* * Copyright (c) 1980, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: move.c,v 1.4 1995/03/21 15:05:10 cgd Exp $"; +static char rcsid[] = "$NetBSD: move.c,v 1.5 1995/04/29 00:44:05 mycroft Exp $"; #endif #endif /* not lint */ @@ -131,14 +131,14 @@ int okay; /* zero if first move */ * while thinking */ if (tflag) cline(); - fixtty (noech); + fixtty (&noech); /* find out how many moves */ mvlim = movallow(); if (mvlim == 0) { writel (" but cannot use it.\n"); nexturn(); - fixtty (raw); + fixtty (&raw); return; } @@ -176,7 +176,7 @@ int okay; /* zero if first move */ buflush(); sleep (3); } - fixtty (raw); /* no more tty interrupt */ + fixtty (&raw); /* no more tty interrupt */ } trymove (mvnum,swapped) diff --git a/games/backgammon/backgammon/text.c b/games/backgammon/backgammon/text.c index 8dbe621d3431..6946799471b7 100644 --- a/games/backgammon/backgammon/text.c +++ b/games/backgammon/backgammon/text.c @@ -1,4 +1,4 @@ -/* $NetBSD: text.c,v 1.3 1995/03/21 15:05:13 cgd Exp $ */ +/* $NetBSD: text.c,v 1.4 1995/04/29 00:44:06 mycroft Exp $ */ /* * Copyright (c) 1980, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)text.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: text.c,v 1.3 1995/03/21 15:05:13 cgd Exp $"; +static char rcsid[] = "$NetBSD: text.c,v 1.4 1995/04/29 00:44:06 mycroft Exp $"; #endif #endif /* not lint */ @@ -117,7 +117,7 @@ char **t; register int i; register char *s, *a; - fixtty (noech); + fixtty (&noech); while (*t != 0) { s = a = *t; for (i = 0; *a != '\0'; i--) @@ -127,12 +127,12 @@ char **t; writec ('\n'); } else { writel ("-->"); - fixtty (raw); + fixtty (&raw); while ((i = readc()) != ' ' && i != '\n'); - fixtty (noech); + fixtty (&noech); clear(); } t++; } - fixtty (raw); + fixtty (&raw); } diff --git a/games/backgammon/common_source/back.h b/games/backgammon/common_source/back.h index 567c936b0f8a..b1be758229fd 100644 --- a/games/backgammon/common_source/back.h +++ b/games/backgammon/common_source/back.h @@ -1,4 +1,4 @@ -/* $NetBSD: back.h,v 1.4 1995/04/24 12:22:06 cgd Exp $ */ +/* $NetBSD: back.h,v 1.5 1995/04/29 00:44:10 mycroft Exp $ */ /* * Copyright (c) 1980, 1993 @@ -35,7 +35,7 @@ * @(#)back.h 8.1 (Berkeley) 5/31/93 */ -#include +#include #include #include @@ -118,10 +118,7 @@ char **colorptr; /* color of current player */ char **Colorptr; /* color of current player, capitalized */ int colen; /* length of color of current player */ -struct sgttyb tty; /* tty information buffer */ -int old; /* original tty status */ -int noech; /* original tty status without echo */ -int raw; /* raw tty status, no echo */ +struct termios old, noech, raw;/* original tty status */ int curr; /* row position of cursor */ int curc; /* column position of cursor */ diff --git a/games/backgammon/common_source/board.c b/games/backgammon/common_source/board.c index 4936b18aac25..eab49a438442 100644 --- a/games/backgammon/common_source/board.c +++ b/games/backgammon/common_source/board.c @@ -1,4 +1,4 @@ -/* $NetBSD: board.c,v 1.3 1995/03/21 15:05:34 cgd Exp $ */ +/* $NetBSD: board.c,v 1.4 1995/04/29 00:44:11 mycroft Exp $ */ /* * Copyright (c) 1980, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)board.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: board.c,v 1.3 1995/03/21 15:05:34 cgd Exp $"; +static char rcsid[] = "$NetBSD: board.c,v 1.4 1995/04/29 00:44:11 mycroft Exp $"; #endif #endif /* not lint */ @@ -53,7 +53,7 @@ wrboard () { static char sv[] = "| | | | \n"; - fixtty (noech); + fixtty (&noech); clear(); if (tflag) { @@ -159,7 +159,7 @@ lastline: writec ('\n'); writec ('\n'); } - fixtty(raw); + fixtty(&raw); } wrbsub () { diff --git a/games/backgammon/common_source/init.c b/games/backgammon/common_source/init.c index c11d41a68b0b..0f8077eb8b54 100644 --- a/games/backgammon/common_source/init.c +++ b/games/backgammon/common_source/init.c @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.3 1995/03/21 15:05:44 cgd Exp $ */ +/* $NetBSD: init.c,v 1.4 1995/04/29 00:44:12 mycroft Exp $ */ /* * Copyright (c) 1980, 1993 @@ -37,11 +37,11 @@ #if 0 static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: init.c,v 1.3 1995/03/21 15:05:44 cgd Exp $"; +static char rcsid[] = "$NetBSD: init.c,v 1.4 1995/04/29 00:44:12 mycroft Exp $"; #endif #endif /* not lint */ -#include +#include /* * variable initialization. diff --git a/games/backgammon/common_source/save.c b/games/backgammon/common_source/save.c index bba3dddb9076..aa86cecfa1b1 100644 --- a/games/backgammon/common_source/save.c +++ b/games/backgammon/common_source/save.c @@ -1,4 +1,4 @@ -/* $NetBSD: save.c,v 1.3 1995/03/21 15:05:52 cgd Exp $ */ +/* $NetBSD: save.c,v 1.4 1995/04/29 00:44:13 mycroft Exp $ */ /* * Copyright (c) 1980, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: save.c,v 1.3 1995/03/21 15:05:52 cgd Exp $"; +static char rcsid[] = "$NetBSD: save.c,v 1.4 1995/04/29 00:44:13 mycroft Exp $"; #endif #endif /* not lint */ @@ -79,7 +79,7 @@ register int n; writel (prompt); fs = fname; while ((*fs = readc()) != '\n') { - if (*fs == tty.sg_erase) { + if (*fs == old.c_cc[VERASE]) { if (fs > fname) { fs--; if (tflag) diff --git a/games/backgammon/common_source/subs.c b/games/backgammon/common_source/subs.c index f6ca2b58a7d8..9fb185fe5a39 100644 --- a/games/backgammon/common_source/subs.c +++ b/games/backgammon/common_source/subs.c @@ -1,4 +1,4 @@ -/* $NetBSD: subs.c,v 1.4 1995/04/24 12:22:12 cgd Exp $ */ +/* $NetBSD: subs.c,v 1.5 1995/04/29 00:44:15 mycroft Exp $ */ /* * Copyright (c) 1980, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)subs.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: subs.c,v 1.4 1995/04/24 12:22:12 cgd Exp $"; +static char rcsid[] = "$NetBSD: subs.c,v 1.5 1995/04/29 00:44:15 mycroft Exp $"; #endif #endif /* not lint */ @@ -413,14 +413,13 @@ wrscore () { wrint (wscore); } -fixtty (mode) -int mode; +fixtty (t) +struct termios *t; { if (tflag) newpos(); buflush(); - tty.sg_flags = mode; - if (stty (0,&tty) < 0) + if (tcsetattr (0, TCSADRAIN, t) < 0) errexit("fixtty"); } @@ -433,7 +432,7 @@ getout () { writec ('\n'); /* fix terminal status */ - fixtty (old); + fixtty (&old); exit(0); } roll () { diff --git a/games/backgammon/common_source/table.c b/games/backgammon/common_source/table.c index c330628d9643..8c8329db7f59 100644 --- a/games/backgammon/common_source/table.c +++ b/games/backgammon/common_source/table.c @@ -1,4 +1,4 @@ -/* $NetBSD: table.c,v 1.3 1995/03/21 15:05:58 cgd Exp $ */ +/* $NetBSD: table.c,v 1.4 1995/04/29 00:44:16 mycroft Exp $ */ /* * Copyright (c) 1980, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: table.c,v 1.3 1995/03/21 15:05:58 cgd Exp $"; +static char rcsid[] = "$NetBSD: table.c,v 1.4 1995/04/29 00:44:16 mycroft Exp $"; #endif #endif /* not lint */ @@ -118,11 +118,11 @@ dochar: } } - if (c == tty.sg_erase && ncin > 0) { + if (c == old.c_cc[VERASE] && ncin > 0) { if (tflag) curmove (curr,curc-1); else { - if (tty.sg_erase == '\010') + if (old.c_cc[VERASE] == '\010') writel ("\010 \010"); else writec (cin[ncin-1]); @@ -139,13 +139,13 @@ dochar: goto domove; } - if (c == tty.sg_kill && ncin > 0) { + if (c == old.c_cc[VKILL] && ncin > 0) { if (tflag) { refresh(); curmove (curr,39); ist = -1; goto domove; - } else if (tty.sg_erase == '\010') { + } else if (old.c_cc[VERASE] == '\010') { for (j = 0; j < ncin; j++) writel ("\010 \010"); ist = -1; diff --git a/games/backgammon/teachgammon/teach.c b/games/backgammon/teachgammon/teach.c index a1f493e8e76e..3eaf273970ae 100644 --- a/games/backgammon/teachgammon/teach.c +++ b/games/backgammon/teachgammon/teach.c @@ -1,4 +1,4 @@ -/* $NetBSD: teach.c,v 1.3 1995/03/21 15:06:13 cgd Exp $ */ +/* $NetBSD: teach.c,v 1.4 1995/04/29 00:44:18 mycroft Exp $ */ /* * Copyright (c) 1980, 1993 @@ -43,7 +43,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)teach.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: teach.c,v 1.3 1995/03/21 15:06:13 cgd Exp $"; +static char rcsid[] = "$NetBSD: teach.c,v 1.4 1995/04/29 00:44:18 mycroft Exp $"; #endif #endif /* not lint */ @@ -62,7 +62,7 @@ char *stragy[]; char *prog[]; char *lastch[]; -extern char ospeed; /* tty output speed for termlib */ +extern speed_t ospeed; /* tty output speed for termlib */ char *helpm[] = { "\nEnter a space or newline to roll, or", @@ -85,15 +85,13 @@ char **argv; register int i; signal (2,getout); - if (gtty (0,&tty) == -1) /* get old tty mode */ + if (tcgetattr (0, &old) == -1) /* get old tty mode */ errexit ("teachgammon(gtty)"); - old = tty.sg_flags; -#ifdef V7 - raw = ((noech = old & ~ECHO) | CBREAK); /* set up modes */ -#else - raw = ((noech = old & ~ECHO) | RAW); /* set up modes */ -#endif - ospeed = tty.sg_ospeed; /* for termlib */ + noech = old; + noech.c_lflag &= ~ECHO; + raw = noech; + raw.c_lflag &= ~ICANON; /* set up modes */ + ospeed = cfgetospeed (&old); /* for termlib */ tflag = getcaps (getenv ("TERM")); #ifdef V7 while (*++argv != 0) @@ -102,8 +100,8 @@ char **argv; #endif getarg (&argv); if (tflag) { - noech &= ~(CRMOD|XTABS); - raw &= ~(CRMOD|XTABS); + noech.c_oflag &= ~(ONLCR|OXTABS); + raw.c_oflag &= ~(ONLCR|OXTABS); clear(); } text (hello); @@ -165,7 +163,7 @@ leave() { clear(); else writec ('\n'); - fixtty(old); + fixtty(&old); execl (EXEC,"backgammon",args,"n",0); writel ("Help! Backgammon program is missing\007!!\n"); exit (-1); diff --git a/games/backgammon/teachgammon/ttext2.c b/games/backgammon/teachgammon/ttext2.c index 07a857a859a4..afb431c171f3 100644 --- a/games/backgammon/teachgammon/ttext2.c +++ b/games/backgammon/teachgammon/ttext2.c @@ -1,4 +1,4 @@ -/* $NetBSD: ttext2.c,v 1.3 1995/03/21 15:06:22 cgd Exp $ */ +/* $NetBSD: ttext2.c,v 1.4 1995/04/29 00:44:20 mycroft Exp $ */ /* * Copyright (c) 1980, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)ttext2.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: ttext2.c,v 1.3 1995/03/21 15:06:22 cgd Exp $"; +static char rcsid[] = "$NetBSD: ttext2.c,v 1.4 1995/04/29 00:44:20 mycroft Exp $"; #endif #endif /* not lint */ @@ -139,7 +139,7 @@ char **txt; char *c; int i; - fixtty (noech); + fixtty (&noech); begin = txt; while (*txt) { a = *(txt++); @@ -149,7 +149,7 @@ char **txt; writel (a); writec ('\n'); } else { - fixtty (raw); + fixtty (&raw); writel (prompt); for (;;) { if ((b = readc()) == '?') { @@ -188,12 +188,12 @@ char **txt; writec ('\n'); if (i) return(i); - fixtty (noech); + fixtty (&noech); if (tflag) curmove (curr,0); begin = txt; } } - fixtty (raw); + fixtty (&raw); return (0); } diff --git a/games/rain/rain.c b/games/rain/rain.c index ee8c32adfd18..ef9fbfbfab31 100644 --- a/games/rain/rain.c +++ b/games/rain/rain.c @@ -1,4 +1,4 @@ -/* $NetBSD: rain.c,v 1.6 1995/04/22 10:26:09 cgd Exp $ */ +/* $NetBSD: rain.c,v 1.7 1995/04/29 00:51:04 mycroft Exp $ */ /* * Copyright (c) 1980, 1993 @@ -43,7 +43,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)rain.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: rain.c,v 1.6 1995/04/22 10:26:09 cgd Exp $"; +static char rcsid[] = "$NetBSD: rain.c,v 1.7 1995/04/29 00:51:04 mycroft Exp $"; #endif #endif /* not lint */ @@ -54,20 +54,12 @@ static char rcsid[] = "$NetBSD: rain.c,v 1.6 1995/04/22 10:26:09 cgd Exp $"; #include #include -#ifdef USG -#include -#else -#include -#endif +#include #include #define cursor(c, r) tputs(tgoto(CM, c, r), 1, fputchar) -#ifdef USG -static struct termio sg, old_tty; -#else -static struct sgttyb sg, old_tty; -#endif +static struct termios sg, old_tty; void fputchar __P((int)); char *LL, *TE, *tgoto(); @@ -76,7 +68,7 @@ main(argc, argv) int argc; char **argv; { - extern short ospeed; + extern speed_t ospeed; extern char *UP; register int x, y, j; register char *CM, *BC, *DN, *ND, *term; @@ -137,32 +129,19 @@ main(argc, argv) } (void)strcpy(LL, tgoto(CM, 0, 23)); } -#ifdef USG - ioctl(1, TCGETA, &sg); - ospeed = sg.c_cflag&CBAUD; -#else - gtty(1, &sg); - ospeed = sg.sg_ospeed; -#endif (void)signal(SIGHUP, onsig); (void)signal(SIGINT, onsig); (void)signal(SIGQUIT, onsig); (void)signal(SIGSTOP, onsig); (void)signal(SIGTSTP, onsig); (void)signal(SIGTERM, onsig); -#ifdef USG - ioctl(1, TCGETA, &old_tty); /* save tty bits for exit */ - ioctl(1, TCGETA, &sg); + tcgetattr(1, &sg); + old_tty = sg; + ospeed = cfgetospeed(&sg); sg.c_iflag &= ~ICRNL; sg.c_oflag &= ~ONLCR; sg.c_lflag &= ~ECHO; - ioctl(1, TCSETAW, &sg); -#else - gtty(1, &old_tty); /* save tty bits for exit */ - gtty(1, &sg); - sg.sg_flags &= ~(CRMOD|ECHO); - stty(1, &sg); -#endif + tcsetattr(1, TCSADRAIN, &sg); if (TI) tputs(TI, 1, fputchar); tputs(tgetstr("cl", &tcp), 1, fputchar); @@ -247,11 +226,7 @@ onsig() if (TE) tputs(TE, 1, fputchar); (void)fflush(stdout); -#ifdef USG - ioctl(1, TCSETAW, &old_tty); -#else - stty(1, &old_tty); -#endif + tcsetattr(1, TCSADRAIN, &old_tty); exit(0); }