diff options
Diffstat (limited to 'games/backgammon/teachgammon/teach.c')
-rw-r--r-- | games/backgammon/teachgammon/teach.c | 88 |
1 files changed, 37 insertions, 51 deletions
diff --git a/games/backgammon/teachgammon/teach.c b/games/backgammon/teachgammon/teach.c index c026dd69dee..624683d5491 100644 --- a/games/backgammon/teachgammon/teach.c +++ b/games/backgammon/teachgammon/teach.c @@ -1,4 +1,4 @@ -/* $NetBSD: teach.c,v 1.4 1995/04/29 00:44:18 mycroft Exp $ */ +/* $OpenBSD: teach.c,v 1.4 1998/03/19 11:13:31 pjanzen Exp $ */ /* * Copyright (c) 1980, 1993 @@ -43,28 +43,16 @@ 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.4 1995/04/29 00:44:18 mycroft Exp $"; +static char rcsid[] = "$OpenBSD: teach.c,v 1.4 1998/03/19 11:13:31 pjanzen Exp $"; #endif #endif /* not lint */ #include "back.h" +#include "tutor.h" -char *hello[]; -char *list[]; -char *intro1[]; -char *intro2[]; -char *moves[]; -char *remove[]; -char *hits[]; -char *endgame[]; -char *doubl[]; -char *stragy[]; -char *prog[]; -char *lastch[]; +extern speed_t ospeed; /* tty output speed for termlib */ -extern speed_t ospeed; /* tty output speed for termlib */ - -char *helpm[] = { +char *helpm[] = { "\nEnter a space or newline to roll, or", " b to display the board", " d to double", @@ -72,54 +60,49 @@ char *helpm[] = { 0 }; -char *contin[] = { +char *contin[] = { "", 0 }; -main (argc,argv) -int argc; -char **argv; - +int +main(argc, argv) + int argc; + char *argv[]; { - register int i; + int i; /* revoke privs */ setegid(getgid()); setgid(getgid()); - signal (2,getout); - if (tcgetattr (0, &old) == -1) /* get old tty mode */ - errexit ("teachgammon(gtty)"); + signal(2, getout); + if (tcgetattr(0, &old) == -1) /* get old tty mode */ + errexit("teachgammon(gtty)"); 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) -#else - while (*++argv != -1) -#endif - getarg (&argv); - if (tflag) { - noech.c_oflag &= ~(ONLCR|OXTABS); - raw.c_oflag &= ~(ONLCR|OXTABS); + raw.c_lflag &= ~ICANON; /* set up modes */ + ospeed = cfgetospeed(&old); /* for termlib */ + tflag = getcaps(getenv("TERM")); + getarg(argc, argv); + if (tflag) { + noech.c_oflag &= ~(ONLCR | OXTABS); + raw.c_oflag &= ~(ONLCR | OXTABS); clear(); } - text (hello); - text (list); - i = text (contin); + text(hello); + text(list); + i = text(contin); if (i == 0) i = 2; init(); while (i) - switch (i) { - + switch (i) { case 1: - leave(); - + leave(); /* Does not return */ + break; + case 2: if (i = text(intro1)) break; @@ -132,7 +115,7 @@ char **argv; break; case 4: - if (i = text(remove)) + if (i = text(removepiece)) break; case 5: @@ -160,15 +143,18 @@ char **argv; break; } tutor(); + /* NOT REACHED */ } -leave() { +void +leave() +{ if (tflag) clear(); else - writec ('\n'); + writec('\n'); fixtty(&old); - execl (EXEC,"backgammon",args,"n",0); - writel ("Help! Backgammon program is missing\007!!\n"); - exit (-1); + execl(EXEC, "backgammon", args, "n", 0); + writel("Help! Backgammon program is missing\007!!\n"); + exit(-1); } |