summaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1998-02-26 07:58:12 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1998-02-26 07:58:12 +0000
commit17f0a43f74b1040f7adec398749710dbf7819c25 (patch)
treee449fd28b00349d51460f9882e611e23cc6431d4 /games
parentc867096a06f8017d0d29dca0ffb4a2a54f33274a (diff)
cleanup efforts care of pjanzen@foatdi.harvard.edu
Diffstat (limited to 'games')
-rw-r--r--games/arithmetic/arithmetic.c57
-rw-r--r--games/caesar/Makefile5
-rw-r--r--games/caesar/rot13.sh38
-rw-r--r--games/worms/Makefile6
4 files changed, 39 insertions, 67 deletions
diff --git a/games/arithmetic/arithmetic.c b/games/arithmetic/arithmetic.c
index 8cd72060abc..d67467e28f8 100644
--- a/games/arithmetic/arithmetic.c
+++ b/games/arithmetic/arithmetic.c
@@ -79,11 +79,22 @@ static char rcsid[] = "$NetBSD: arithmetic.c,v 1.6 1996/03/21 18:30:19 jtc Exp $
*/
#include <sys/types.h>
-#include <signal.h>
+#include <err.h>
#include <ctype.h>
+#include <signal.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <time.h>
+#include <unistd.h>
+
+int getrandom __P((int, int, int));
+void intr __P((int));
+int opnum __P((int));
+void penalise __P((int, int, int));
+int problem __P((void));
+void showstats __P((void));
+void usage __P((void));
char keylist[] = "+-x/";
char defaultkeys[] = "+-";
@@ -109,30 +120,28 @@ main(argc, argv)
extern char *optarg;
extern int optind;
int ch, cnt;
- void intr();
- while ((ch = getopt(argc, argv, "r:o:")) != -1)
+ /* revoke privs */
+ setegid(getgid());
+ setgid(getgid());
+
+ while ((ch = getopt(argc, argv, "hr:o:")) != -1)
switch(ch) {
case 'o': {
register char *p;
for (p = keys = optarg; *p; ++p)
- if (!strchr(keylist, *p)) {
- (void)fprintf(stderr,
- "arithmetic: unknown key.\n");
- exit(1);
- }
+ if (!strchr(keylist, *p))
+ errx(1,"unknown key.");
nkeys = p - optarg;
break;
}
case 'r':
- if ((rangemax = atoi(optarg)) <= 0) {
- (void)fprintf(stderr,
- "arithmetic: invalid range.\n");
- exit(1);
- }
+ if ((rangemax = atoi(optarg)) <= 0)
+ errx(1, "invalid range.");
break;
case '?':
+ case 'h':
default:
usage();
}
@@ -148,7 +157,7 @@ main(argc, argv)
for (;;) {
for (cnt = NQUESTS; cnt--;)
if (problem() == EOF)
- exit(0);
+ intr(0); /* Print score and exit */
showstats();
}
/* NOTREACHED */
@@ -156,13 +165,15 @@ main(argc, argv)
/* Handle interrupt character. Print score and exit. */
void
-intr()
+intr(dummy)
+ int dummy;
{
showstats();
exit(0);
}
/* Print score. Original `arithmetic' had a delay after printing it. */
+void
showstats()
{
if (nright + nwrong > 0) {
@@ -183,6 +194,7 @@ showstats()
* answer causes the numbers in the problem to be penalised, so that they are
* more likely to appear in subsequent problems.
*/
+int
problem()
{
register char *p;
@@ -294,11 +306,11 @@ struct penalty {
* operand number `operand' (0 or 1). If we run out of memory, we just
* forget about the penalty (how likely is this, anyway?).
*/
+void
penalise(value, op, operand)
int value, op, operand;
{
struct penalty *p;
- char *malloc();
op = opnum(op);
if ((p = (struct penalty *)malloc((u_int)sizeof(*p))) == NULL)
@@ -315,6 +327,7 @@ penalise(value, op, operand)
* as a value, or represents a position in the penalty list. If the latter,
* we find the corresponding value and return that, decreasing its penalty.
*/
+int
getrandom(maxval, op, operand)
int maxval, op, operand;
{
@@ -354,26 +367,24 @@ getrandom(maxval, op, operand)
* correspond to the actual sum of penalties in the list. Provide an
* obscure message.
*/
- (void)fprintf(stderr, "arithmetic: bug: inconsistent penalties\n");
- exit(1);
+ errx(1, "bug: inconsistent penalties\n");
/* NOTREACHED */
}
/* Return an index for the character op, which is one of [+-x/]. */
+int
opnum(op)
int op;
{
char *p;
- if (op == 0 || (p = strchr(keylist, op)) == NULL) {
- (void)fprintf(stderr,
- "arithmetic: bug: op %c not in keylist %s\n", op, keylist);
- exit(1);
- }
+ if (op == 0 || (p = strchr(keylist, op)) == NULL)
+ errx(1, "bug: op %c not in keylist %s\n", op, keylist);
return(p - keylist);
}
/* Print usage message and quit. */
+void
usage()
{
(void)fprintf(stderr, "usage: arithmetic [-o +-x/] [-r range]\n");
diff --git a/games/caesar/Makefile b/games/caesar/Makefile
index b6d515f9bdf..bf1a4b3af8b 100644
--- a/games/caesar/Makefile
+++ b/games/caesar/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.4 1997/09/21 11:35:39 deraadt Exp $
+# $OpenBSD: Makefile,v 1.5 1998/02/26 07:58:07 deraadt Exp $
PROG= caesar
MAN= caesar.6
@@ -7,7 +7,6 @@ LDADD= -lm
MLINKS= caesar.6 rot13.6
beforeinstall:
- ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- ${.CURDIR}/rot13.sh ${DESTDIR}/usr/games/rot13
+ (cd ${DESTDIR}/usr/games; rm -f rot13; ln -s caesar rot13)
.include <bsd.prog.mk>
diff --git a/games/caesar/rot13.sh b/games/caesar/rot13.sh
deleted file mode 100644
index 66297fd01de..00000000000
--- a/games/caesar/rot13.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh -
-# $NetBSD: rot13.sh,v 1.2 1995/03/21 15:08:23 cgd Exp $
-#
-# Copyright (c) 1992, 1993
-# The Regents of the University of California. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 3. All advertising materials mentioning features or use of this software
-# must display the following acknowledgement:
-# This product includes software developed by the University of
-# California, Berkeley and its contributors.
-# 4. Neither the name of the University nor the names of its contributors
-# may be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-# @(#)rot13.sh 8.1 (Berkeley) 5/31/93
-#
-
-caesar 13 $*
diff --git a/games/worms/Makefile b/games/worms/Makefile
index 315da48b008..05d1689d9c8 100644
--- a/games/worms/Makefile
+++ b/games/worms/Makefile
@@ -1,8 +1,8 @@
-# $OpenBSD: Makefile,v 1.3 1997/09/21 11:37:17 deraadt Exp $
+# $OpenBSD: Makefile,v 1.4 1998/02/26 07:58:11 deraadt Exp $
PROG= worms
MAN= worms.6
-DPADD= ${LIBCURSES} ${LIBTERMLIB}
-LDADD= -lcurses -ltermlib
+DPADD= ${LIBTERMLIB}
+LDADD= -ltermlib
.include <bsd.prog.mk>