]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - backgammon/teachgammon/teach.c
Cast last argument of execl to (char *).
[bsdgames-darwin.git] / backgammon / teachgammon / teach.c
1 /* $NetBSD: teach.c,v 1.16 2005/02/15 12:56:20 jsm Exp $ */
2
3 /*
4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32 #include <sys/cdefs.h>
33 #ifndef lint
34 __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
35 The Regents of the University of California. All rights reserved.\n");
36 #endif /* not lint */
37
38 #ifndef lint
39 #if 0
40 static char sccsid[] = "@(#)teach.c 8.1 (Berkeley) 5/31/93";
41 #else
42 __RCSID("$NetBSD: teach.c,v 1.16 2005/02/15 12:56:20 jsm Exp $");
43 #endif
44 #endif /* not lint */
45
46 #include "back.h"
47 #include "tutor.h"
48
49 const char *const helpm[] = {
50 "\nEnter a space or newline to roll, or",
51 " b to display the board",
52 " d to double",
53 " q to quit\n",
54 0
55 };
56
57 const char *const contin[] = {
58 "",
59 0
60 };
61
62 int
63 main(argc, argv)
64 int argc __attribute__((__unused__));
65 char *argv[];
66 {
67 int i;
68
69 /* revoke setgid privileges */
70 setgid(getgid());
71
72 signal(SIGINT, getout);
73 if (tcgetattr(0, &old) == -1) /* get old tty mode */
74 errexit("teachgammon(gtty)");
75 noech = old;
76 noech.c_lflag &= ~ECHO;
77 raw = noech;
78 raw.c_lflag &= ~ICANON; /* set up modes */
79 ospeed = cfgetospeed(&old); /* for termlib */
80 tflag = getcaps(getenv("TERM"));
81 #ifdef V7
82 while (*++argv != 0)
83 #else
84 while (*++argv != -1)
85 #endif
86 getarg(&argv);
87 if (tflag) {
88 noech.c_oflag &= ~(ONLCR | OXTABS);
89 raw.c_oflag &= ~(ONLCR | OXTABS);
90 clear();
91 }
92 text(hello);
93 text(list);
94 i = text(contin);
95 if (i == 0)
96 i = 2;
97 init();
98 while (i)
99 switch (i) {
100 case 1:
101 leave();
102
103 case 2:
104 if ((i = text(intro1)) != 0)
105 break;
106 wrboard();
107 if ((i = text(intro2)) != 0)
108 break;
109
110 case 3:
111 if ((i = text(moves)) != 0)
112 break;
113
114 case 4:
115 if ((i = text(removepiece)) != 0)
116 break;
117
118 case 5:
119 if ((i = text(hits)) != 0)
120 break;
121
122 case 6:
123 if ((i = text(endgame)) != 0)
124 break;
125
126 case 7:
127 if ((i = text(doubl)) != 0)
128 break;
129
130 case 8:
131 if ((i = text(stragy)) != 0)
132 break;
133
134 case 9:
135 if ((i = text(prog)) != 0)
136 break;
137
138 case 10:
139 if ((i = text(lastch)) != 0)
140 break;
141 }
142 tutor();
143 /* NOTREACHED */
144 return (0);
145 }
146
147 void
148 leave()
149 {
150 if (tflag)
151 clear();
152 else
153 writec('\n');
154 fixtty(&old);
155 execl(EXEC, "backgammon", "-n", args[0]?args:0, (char *) 0);
156 writel("Help! Backgammon program is missing\007!!\n");
157 exit(1);
158 }