-/* $NetBSD: monop.c,v 1.6 1999/08/21 10:40:03 simonb Exp $ */
+/* $NetBSD: monop.c,v 1.17 2008/02/19 09:45:02 dholland Exp $ */
/*
* Copyright (c) 1980, 1993
* 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
+ * 3. 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.
*
#if 0
static char sccsid[] = "@(#)monop.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: monop.c,v 1.6 1999/08/21 10:40:03 simonb Exp $");
+__RCSID("$NetBSD: monop.c,v 1.17 2008/02/19 09:45:02 dholland Exp $");
#endif
#endif /* not lint */
#include <unistd.h>
#include "monop.def"
-int main __P((int, char *[]));
-static void getplayers __P((void));
-static void init_players __P((void));
-static void init_monops __P((void));
-static void do_quit __P((int));
+int main(int, char *[]);
+static void getplayers(void);
+static void init_players(void);
+static void init_monops(void);
+static void do_quit(int);
+void *heapstart;
/*
* This program implements a monopoly game
int ac;
char *av[];
{
+ /* Revoke setgid privileges */
+ setgid(getgid());
+
srand(getpid());
+ heapstart = sbrk(0);
if (ac > 1) {
if (!rest_f(av[1]))
restore();
/*ARGSUSED*/
static void
do_quit(n)
- int n;
+ int n __unused;
{
quit();
}
blew_it:
for (;;) {
- if ((num_play=get_int("How many players? ")) <= 0 ||
+ if ((num_play = get_int("How many players? ")) <= 0 ||
num_play > MAX_PL)
printf("Sorry. Number must range from 1 to 9\n");
else
break;
}
cur_p = play = (PLAY *) calloc(num_play, sizeof (PLAY));
+ if (play == NULL)
+ err(1, NULL);
for (i = 0; i < num_play; i++) {
over:
printf("Player %d's name: ", i + 1);
- for (sp = buf; (*sp=getchar()) != '\n'; sp++)
+ for (sp = buf; (*sp = getchar()) != '\n'; sp++)
continue;
if (sp == buf)
goto over;
*sp++ = '\0';
- strcpy(name_list[i]=play[i].name=(char *)calloc(1,sp-buf),buf);
+ name_list[i] = play[i].name = (char *)calloc(1, sp - buf);
+ if (name_list[i] == NULL)
+ err(1, NULL);
+ strcpy(play[i].name, buf);
play[i].money = 1500;
}
name_list[i++] = "done";
}
/*
- * This routine initalizes the monopoly structures.
+ * This routine initializes the monopoly structures.
*/
static void
-init_monops()
+init_monops()
{
MON *mp;
int i;