mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
Replace things like srandom(time(NULL)) with srandomdev(3). random(3)
good enough for games but we should at least use a decent seed. pjanzen@ OK
This commit is contained in:
parent
819c406ac6
commit
ffe3e52230
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: init.c,v 1.6 1998/08/31 02:29:39 pjanzen Exp $ */
|
||||
/* $OpenBSD: init.c,v 1.7 2002/12/06 21:48:50 millert Exp $ */
|
||||
/* $NetBSD: init.c,v 1.4 1996/05/21 21:53:05 mrg Exp $ */
|
||||
|
||||
/*-
|
||||
@ -43,7 +43,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 6/2/93";
|
||||
#else
|
||||
static char rcsid[] = "$OpenBSD: init.c,v 1.6 1998/08/31 02:29:39 pjanzen Exp $";
|
||||
static char rcsid[] = "$OpenBSD: init.c,v 1.7 2002/12/06 21:48:50 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -227,8 +227,7 @@ void
|
||||
startup()
|
||||
{
|
||||
demo = Start();
|
||||
srandom((unsigned int)(time((time_t *)NULL))); /* random seed */
|
||||
/* srand(371); */ /* non-random seed */
|
||||
srandomdev();
|
||||
hinted[3] = yes(65, 1, 0);
|
||||
newloc = 1;
|
||||
delhit = 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: arithmetic.c,v 1.12 2002/06/11 05:22:40 jsyn Exp $ */
|
||||
/* $OpenBSD: arithmetic.c,v 1.13 2002/12/06 21:48:50 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@ -46,7 +46,7 @@ static char copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)arithmetic.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static char rcsid[] = "$OpenBSD: arithmetic.c,v 1.12 2002/06/11 05:22:40 jsyn Exp $";
|
||||
static char rcsid[] = "$OpenBSD: arithmetic.c,v 1.13 2002/12/06 21:48:50 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -145,7 +145,7 @@ main(argc, argv)
|
||||
usage();
|
||||
|
||||
/* Seed the random-number generator. */
|
||||
srandom((int)time((time_t *)NULL));
|
||||
srandomdev();
|
||||
|
||||
(void)signal(SIGINT, intr);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: atc.6,v 1.9 2001/11/17 05:45:03 pjanzen Exp $
|
||||
.\" $OpenBSD: atc.6,v 1.10 2002/12/06 21:48:50 millert Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -93,7 +93,7 @@ Same as
|
||||
.Fl s .
|
||||
.It Fl r Ar seed
|
||||
Set the random seed.
|
||||
The purpose of this flag is questionable.
|
||||
This option can be used to replay a specific game.
|
||||
.It Fl u
|
||||
Print the usage line and exit.
|
||||
.It Fl ?
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: main.c,v 1.8 1999/09/01 00:27:08 pjanzen Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.9 2002/12/06 21:48:50 millert Exp $ */
|
||||
/* $NetBSD: main.c,v 1.4 1995/04/27 21:22:25 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
@ -56,7 +56,7 @@ static char copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static char rcsid[] = "$OpenBSD: main.c,v 1.8 1999/09/01 00:27:08 pjanzen Exp $";
|
||||
static char rcsid[] = "$OpenBSD: main.c,v 1.9 2002/12/06 21:48:50 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -68,11 +68,10 @@ main(ac, av)
|
||||
int ac;
|
||||
char *av[];
|
||||
{
|
||||
int seed;
|
||||
int f_usage = 0, f_list = 0, f_showscore = 0;
|
||||
int f_printpath = 0;
|
||||
const char *file = NULL;
|
||||
char *name, *ptr;
|
||||
char *name, *ptr, *seed;
|
||||
struct sigaction sa;
|
||||
#ifdef BSD
|
||||
struct itimerval itv;
|
||||
@ -84,8 +83,9 @@ main(ac, av)
|
||||
setegid(getgid());
|
||||
setgid(getgid());
|
||||
|
||||
start_time = seed = time(0);
|
||||
start_time = time(0);
|
||||
makenoise = 1;
|
||||
seed = NULL;
|
||||
|
||||
name = *av++;
|
||||
while (*av) {
|
||||
@ -116,7 +116,7 @@ main(ac, av)
|
||||
makenoise = 0;
|
||||
break;
|
||||
case 'r':
|
||||
seed = atoi(*av);
|
||||
seed = *av;
|
||||
av++;
|
||||
break;
|
||||
case 'f':
|
||||
@ -132,7 +132,10 @@ main(ac, av)
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
srandom(seed);
|
||||
if (seed != NULL)
|
||||
srandom(atol(seed));
|
||||
else
|
||||
srandomdev();
|
||||
|
||||
if (f_usage)
|
||||
fprintf(stderr,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: main.c,v 1.11 2002/05/31 03:40:00 pjanzen Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.12 2002/12/06 21:48:50 millert 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[] = "$OpenBSD: main.c,v 1.11 2002/05/31 03:40:00 pjanzen Exp $";
|
||||
static char rcsid[] = "$OpenBSD: main.c,v 1.12 2002/12/06 21:48:50 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -105,7 +105,6 @@ main (argc,argv)
|
||||
{
|
||||
int i,l; /* non-descript indices */
|
||||
char c; /* non-descript character storage */
|
||||
long t; /* time for random num generator */
|
||||
|
||||
signal(SIGINT, getout); /* trap interrupts */
|
||||
initcurses();
|
||||
@ -120,8 +119,7 @@ main (argc,argv)
|
||||
|
||||
/* use whole screen for text */
|
||||
begscr = 0;
|
||||
t = time(NULL);
|
||||
srandom(t); /* 'random' seed */
|
||||
srandomdev(); /* seed random number generator */
|
||||
|
||||
getarg(argc, argv);
|
||||
args[acnt] = '\0';
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: init.c,v 1.8 2002/02/16 21:27:09 millert Exp $ */
|
||||
/* $OpenBSD: init.c,v 1.9 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: init.c,v 1.4 1995/03/21 15:07:35 cgd Exp $ */
|
||||
|
||||
/*
|
||||
@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)init.c 8.4 (Berkeley) 4/30/95";
|
||||
#else
|
||||
static char rcsid[] = "$OpenBSD: init.c,v 1.8 2002/02/16 21:27:09 millert Exp $";
|
||||
static char rcsid[] = "$OpenBSD: init.c,v 1.9 2002/12/06 21:48:51 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -59,7 +59,7 @@ initialize(filename)
|
||||
puts("First Adventure game written by His Lordship, the honorable");
|
||||
puts("Admiral D.W. Riggle\n");
|
||||
location = dayfile;
|
||||
srandom(getpid());
|
||||
srandomdev();
|
||||
username = getutmp();
|
||||
wordinit();
|
||||
if (filename == NULL) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: bog.c,v 1.10 2002/05/31 04:21:29 pjanzen Exp $ */
|
||||
/* $OpenBSD: bog.c,v 1.11 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: bog.c,v 1.5 1995/04/24 12:22:32 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
@ -47,7 +47,7 @@ static char copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)bog.c 8.1 (Berkeley) 6/11/93";
|
||||
#else
|
||||
static char rcsid[] = "$OpenBSD: bog.c,v 1.10 2002/05/31 04:21:29 pjanzen Exp $";
|
||||
static char rcsid[] = "$OpenBSD: bog.c,v 1.11 2002/12/06 21:48:51 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -129,13 +129,11 @@ main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
time_t seed;
|
||||
int ch, done, i, sflag;
|
||||
char *bspec, *p;
|
||||
int ch, done, i;
|
||||
char *bspec, *p, *seed;
|
||||
|
||||
seed = 0;
|
||||
batch = debug = reuse = selfuse = sflag = 0;
|
||||
bspec = NULL;
|
||||
batch = debug = reuse = selfuse;
|
||||
bspec = seed = NULL;
|
||||
minlength = 3;
|
||||
tlimit = 180; /* 3 minutes is standard */
|
||||
|
||||
@ -148,8 +146,7 @@ main(argc, argv)
|
||||
debug = 1;
|
||||
break;
|
||||
case 's':
|
||||
sflag = 1;
|
||||
seed = atol(optarg);
|
||||
seed = optarg;
|
||||
break;
|
||||
case 't':
|
||||
if ((tlimit = atoi(optarg)) < 1)
|
||||
@ -205,7 +202,7 @@ main(argc, argv)
|
||||
(void) printf("%s\n", p);
|
||||
exit (0);
|
||||
}
|
||||
setup(sflag, seed);
|
||||
setup(seed);
|
||||
prompt("Loading the dictionary...");
|
||||
if ((dictfp = opendict(DICT)) == NULL) {
|
||||
warn("%s", DICT);
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: boggle.6,v 1.10 2001/11/17 05:35:00 pjanzen Exp $
|
||||
.\" $OpenBSD: boggle.6,v 1.11 2002/12/06 21:48:51 millert Exp $
|
||||
.\" $NetBSD: boggle.6,v 1.2 1995/03/21 12:14:35 cgd Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1997, Jason Downs. All rights reserved.
|
||||
@ -111,9 +111,10 @@ is printed to stdout.
|
||||
.It Fl d
|
||||
Enable debugging output.
|
||||
.It Fl s Ar seed
|
||||
Specify a
|
||||
Prime the random number generator with
|
||||
.Ar seed
|
||||
other than the time of day.
|
||||
instead of data from
|
||||
.Pa /dev/arandom .
|
||||
.It Fl t Ar time
|
||||
Change the time limit for each game from the default 3 minutes to
|
||||
.Ar time
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: extern.h,v 1.4 2002/02/17 19:42:20 millert Exp $ */
|
||||
/* $OpenBSD: extern.h,v 1.5 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.3 1995/04/24 12:22:37 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
@ -62,7 +62,7 @@ void prtable(char *[],
|
||||
void putstr(char *);
|
||||
void redraw(void);
|
||||
void results(void);
|
||||
int setup(int, time_t);
|
||||
int setup(char *);
|
||||
void showboard(char *);
|
||||
void showstr(char *, int);
|
||||
void showword(int);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: mach.c,v 1.5 2002/05/31 04:21:29 pjanzen Exp $ */
|
||||
/* $OpenBSD: mach.c,v 1.6 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: mach.c,v 1.5 1995/04/28 22:28:48 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
@ -41,7 +41,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)mach.c 8.1 (Berkeley) 6/11/93";
|
||||
#else
|
||||
static char rcsid[] = "$OpenBSD: mach.c,v 1.5 2002/05/31 04:21:29 pjanzen Exp $";
|
||||
static char rcsid[] = "$OpenBSD: mach.c,v 1.6 2002/12/06 21:48:51 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -87,20 +87,16 @@ static void winch_catcher(int);
|
||||
* This is called once, when the program starts
|
||||
*/
|
||||
int
|
||||
setup(sflag, seed)
|
||||
int sflag;
|
||||
time_t seed;
|
||||
setup(seed)
|
||||
char *seed;
|
||||
{
|
||||
extern int debug;
|
||||
|
||||
if (tty_setup() < 0)
|
||||
return(-1);
|
||||
|
||||
if (!sflag)
|
||||
time(&seed);
|
||||
srandom(seed);
|
||||
if (debug)
|
||||
(void) printf("seed = %ld\n", (long) seed);
|
||||
if (seed != NULL)
|
||||
srandom(atol(seed));
|
||||
else
|
||||
srandomdev();
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: bs.c,v 1.17 2002/08/09 09:54:30 pjanzen Exp $ */
|
||||
/* $OpenBSD: bs.c,v 1.18 2002/12/06 21:48:51 millert Exp $ */
|
||||
/*
|
||||
* bs.c - original author: Bruce Holloway
|
||||
* salvo option by: Chuck A DeGaul
|
||||
@ -11,7 +11,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "$OpenBSD: bs.c,v 1.17 2002/08/09 09:54:30 pjanzen Exp $";
|
||||
static const char rcsid[] = "$OpenBSD: bs.c,v 1.18 2002/12/06 21:48:51 millert Exp $";
|
||||
#endif
|
||||
|
||||
/* #define _POSIX_SOURCE */ /* ( random() ) */
|
||||
@ -219,7 +219,7 @@ static void intro(void)
|
||||
{
|
||||
char *tmpname;
|
||||
|
||||
srandom((unsigned)(time(0L)+getpid())); /* Kick the random number generator */
|
||||
srandomdev(); /* Kick the random number generator */
|
||||
|
||||
(void) signal(SIGINT,uninitgame);
|
||||
(void) signal(SIGINT,uninitgame);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: canfield.c,v 1.7 2002/02/18 06:45:27 deraadt Exp $ */
|
||||
/* $OpenBSD: canfield.c,v 1.8 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: canfield.c,v 1.7 1995/05/13 07:28:35 jtc Exp $ */
|
||||
|
||||
/*
|
||||
@ -44,7 +44,7 @@ static char copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)canfield.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static char rcsid[] = "$OpenBSD: canfield.c,v 1.7 2002/02/18 06:45:27 deraadt Exp $";
|
||||
static char rcsid[] = "$OpenBSD: canfield.c,v 1.8 2002/12/06 21:48:51 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -1676,7 +1676,7 @@ initall()
|
||||
{
|
||||
int i;
|
||||
|
||||
srandom(getpid());
|
||||
srandomdev();
|
||||
time(&acctstart);
|
||||
initdeck(deck);
|
||||
uid = getuid();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: fish.c,v 1.11 2002/05/31 03:40:00 pjanzen Exp $ */
|
||||
/* $OpenBSD: fish.c,v 1.12 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: fish.c,v 1.3 1995/03/23 08:28:18 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
@ -47,7 +47,7 @@ static char copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)fish.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static char rcsid[] = "$OpenBSD: fish.c,v 1.11 2002/05/31 03:40:00 pjanzen Exp $";
|
||||
static char rcsid[] = "$OpenBSD: fish.c,v 1.12 2002/12/06 21:48:51 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -118,7 +118,7 @@ main(argc, argv)
|
||||
usage();
|
||||
}
|
||||
|
||||
srandom(time((time_t *)NULL));
|
||||
srandomdev();
|
||||
instructions();
|
||||
init();
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: strfile.c,v 1.10 2002/02/16 21:27:09 millert Exp $ */
|
||||
/* $OpenBSD: strfile.c,v 1.11 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: strfile.c,v 1.4 1995/04/24 12:23:09 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
@ -47,7 +47,7 @@ static char copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)strfile.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static char rcsid[] = "$OpenBSD: strfile.c,v 1.10 2002/02/16 21:27:09 millert Exp $";
|
||||
static char rcsid[] = "$OpenBSD: strfile.c,v 1.11 2002/12/06 21:48:51 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -451,7 +451,7 @@ randomize()
|
||||
int32_t tmp;
|
||||
int32_t *sp;
|
||||
|
||||
srandom((int)(time((time_t *) NULL) + getpid()));
|
||||
srandomdev();
|
||||
|
||||
Tbl.str_flags |= STR_RANDOM;
|
||||
cnt = Tbl.str_numstr;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: main.c,v 1.12 2002/05/31 03:40:00 pjanzen Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.13 2002/12/06 21:48:51 millert Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
@ -45,7 +45,7 @@ static char copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 5/4/95";
|
||||
#else
|
||||
static char rcsid[] = "$OpenBSD: main.c,v 1.12 2002/05/31 03:40:00 pjanzen Exp $";
|
||||
static char rcsid[] = "$OpenBSD: main.c,v 1.13 2002/12/06 21:48:51 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -154,7 +154,7 @@ main(argc, argv)
|
||||
#ifdef SVR4
|
||||
srand(time(0));
|
||||
#else
|
||||
srandom(time(0));
|
||||
srandomdev();
|
||||
#endif
|
||||
if (interactive)
|
||||
cursinit(); /* initialize curses */
|
||||
|
@ -1,11 +1,11 @@
|
||||
/* $OpenBSD: hack.unix.c,v 1.8 2001/08/06 22:59:13 pjanzen Exp $ */
|
||||
/* $OpenBSD: hack.unix.c,v 1.9 2002/12/06 21:48:51 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$OpenBSD: hack.unix.c,v 1.8 2001/08/06 22:59:13 pjanzen Exp $";
|
||||
static char rcsid[] = "$OpenBSD: hack.unix.c,v 1.9 2002/12/06 21:48:51 millert Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/* This file collects some Unix dependencies; hack.pager.c contains some more */
|
||||
@ -36,7 +36,7 @@ extern time_t time();
|
||||
|
||||
setrandom()
|
||||
{
|
||||
(void) srandom((int) time ((time_t *) 0));
|
||||
(void) srandomdev();
|
||||
}
|
||||
|
||||
struct tm *
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: setup.c,v 1.5 2002/05/31 05:11:37 pjanzen Exp $ */
|
||||
/* $OpenBSD: setup.c,v 1.6 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: setup.c,v 1.3 1995/03/23 08:32:59 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)setup.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static char rcsid[] = "$OpenBSD: setup.c,v 1.5 2002/05/31 05:11:37 pjanzen Exp $";
|
||||
static char rcsid[] = "$OpenBSD: setup.c,v 1.6 2002/12/06 21:48:51 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -70,7 +70,7 @@ setup()
|
||||
addstr(*sp);
|
||||
}
|
||||
|
||||
srandom(time(NULL) + getpid());
|
||||
srandomdev();
|
||||
if ((Dict = fopen(Dict_name, "r")) == NULL) {
|
||||
endwin();
|
||||
err(1, "fopen %s", Dict_name);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: driver.c,v 1.12 2002/05/31 03:40:00 pjanzen Exp $ */
|
||||
/* $OpenBSD: driver.c,v 1.13 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: driver.c,v 1.5 1997/10/20 00:37:16 lukem Exp $ */
|
||||
/*
|
||||
* Hunt
|
||||
@ -434,7 +434,7 @@ init()
|
||||
Num_fds = Server_socket + 1;
|
||||
|
||||
/* Initialise the random seed: */
|
||||
srandom(getpid() + time((time_t *) NULL));
|
||||
srandomdev();
|
||||
|
||||
/* Dig the maze: */
|
||||
makemaze();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: io.c,v 1.8 2002/02/19 19:39:36 millert Exp $ */
|
||||
/* $OpenBSD: io.c,v 1.9 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: io.c,v 1.7 1997/10/18 20:03:26 christos Exp $ */
|
||||
|
||||
/*
|
||||
@ -61,7 +61,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$OpenBSD: io.c,v 1.8 2002/02/19 19:39:36 millert Exp $";
|
||||
static char rcsid[] = "$OpenBSD: io.c,v 1.9 2002/12/06 21:48:51 millert Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "header.h"
|
||||
@ -210,7 +210,7 @@ newgame()
|
||||
|
||||
for (p = c, pe = c + 100; p < pe; *p++ = 0);
|
||||
time(&initialtime);
|
||||
srandom(initialtime);
|
||||
srandomdev();
|
||||
lcreat((char *) 0); /* open buffering for output to terminal */
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: mille.c,v 1.12 2002/05/31 05:11:37 pjanzen Exp $ */
|
||||
/* $OpenBSD: mille.c,v 1.13 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: mille.c,v 1.4 1995/03/24 05:01:48 cgd Exp $ */
|
||||
|
||||
/*
|
||||
@ -44,7 +44,7 @@ static char copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)mille.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static char rcsid[] = "$OpenBSD: mille.c,v 1.12 2002/05/31 05:11:37 pjanzen Exp $";
|
||||
static char rcsid[] = "$OpenBSD: mille.c,v 1.13 2002/12/06 21:48:51 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -95,11 +95,7 @@ main(ac, av)
|
||||
leaveok(Score, TRUE);
|
||||
leaveok(Miles, TRUE);
|
||||
clearok(curscr, TRUE);
|
||||
# ifndef PROF
|
||||
srandom(getpid());
|
||||
# else
|
||||
srandom(0);
|
||||
# endif
|
||||
srandomdev();
|
||||
cbreak();
|
||||
noecho();
|
||||
signal(SIGINT, rub);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: monop.c,v 1.5 2002/07/28 08:44:14 pjanzen Exp $ */
|
||||
/* $OpenBSD: monop.c,v 1.6 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: monop.c,v 1.3 1995/03/23 08:34:52 cgd Exp $ */
|
||||
|
||||
/*
|
||||
@ -44,7 +44,7 @@ static const char copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)monop.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] = "$OpenBSD: monop.c,v 1.5 2002/07/28 08:44:14 pjanzen Exp $";
|
||||
static const char rcsid[] = "$OpenBSD: monop.c,v 1.6 2002/12/06 21:48:51 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -65,7 +65,7 @@ main(ac, av)
|
||||
int ac;
|
||||
char *av[];
|
||||
{
|
||||
srandom(getpid());
|
||||
srandomdev();
|
||||
num_luck = sizeof lucky_mes / sizeof (char *);
|
||||
init_decks();
|
||||
init_monops();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: convert.c,v 1.3 2001/01/28 23:41:47 niklas Exp $ */
|
||||
/* $OpenBSD: convert.c,v 1.4 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: convert.c,v 1.2 1995/03/24 03:58:34 cgd Exp $ */
|
||||
|
||||
/*
|
||||
@ -27,7 +27,7 @@ char Newpfile[] = DEST/newcharacs"; /* new format file */
|
||||
/
|
||||
/ RETURN VALUE: none
|
||||
/
|
||||
/ MODULES CALLED: time(), exit(), fread(), fopen(), srandom(), floor(),
|
||||
/ MODULES CALLED: time(), exit(), fread(), fopen(), srandomdev(), floor(),
|
||||
/ random(), strcmp(), fwrite(), strcpy(), fclose(), fprintf()
|
||||
/
|
||||
/ GLOBAL INPUTS: _iob[], Oldplayer, Newplayer
|
||||
@ -59,7 +59,7 @@ FILE *oldcharac, *newcharac; /* to open old and new files */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
srandom((unsigned) time(NULL)); /* prime random numbers */
|
||||
srandomdev(); /* prime random numbers */
|
||||
|
||||
while (fread((char *) &Oldplayer, sizeof(struct oldplayer), 1, oldcharac) == 1)
|
||||
/* read and convert old structures into new */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: main.c,v 1.10 2002/05/31 05:11:37 pjanzen Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.11 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: main.c,v 1.3 1995/04/24 12:24:37 cgd Exp $ */
|
||||
|
||||
/*
|
||||
@ -385,7 +385,7 @@ initialstate()
|
||||
error(_PATH_VOID);
|
||||
/* NOTREACHED */
|
||||
|
||||
srandom((unsigned) time(NULL)); /* prime random numbers */
|
||||
srandomdev(); /* prime random numbers */
|
||||
}
|
||||
/**/
|
||||
/************************************************************************
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: setup.c,v 1.6 2002/05/31 04:21:30 pjanzen Exp $ */
|
||||
/* $OpenBSD: setup.c,v 1.7 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: setup.c,v 1.4 1995/04/24 12:24:41 cgd Exp $ */
|
||||
|
||||
/*
|
||||
@ -26,7 +26,7 @@ void Error(char *, char *);
|
||||
/ RETURN VALUE: none
|
||||
/
|
||||
/ MODULES CALLED: time(), exit(), stat(), Error(), open(), close(), fopen(),
|
||||
/ fgets(), floor(), srandom(), umask(), strcpy(),
|
||||
/ fgets(), floor(), srandomdev(), umask(), strcpy(),
|
||||
/ unlink(), fwrite(), fclose(), sscanf(), printf(), strlen(), fprintf()
|
||||
/
|
||||
/ GLOBAL INPUTS: Curmonster, _iob[], Databuf[], *Monstfp, Enrgyvoid
|
||||
@ -82,7 +82,7 @@ main(argc, argv)
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
srandom((unsigned) time(NULL)); /* prime random numbers */
|
||||
srandomdev(); /* prime random numbers */
|
||||
|
||||
umask(0117); /* only owner can read/write created files */
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: quiz.c,v 1.11 2002/05/31 03:40:01 pjanzen Exp $ */
|
||||
/* $OpenBSD: quiz.c,v 1.12 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: quiz.c,v 1.9 1995/04/22 10:16:58 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
@ -48,7 +48,7 @@ static char copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)quiz.c 8.3 (Berkeley) 5/4/95";
|
||||
#else
|
||||
static char rcsid[] = "$OpenBSD: quiz.c,v 1.11 2002/05/31 03:40:01 pjanzen Exp $";
|
||||
static char rcsid[] = "$OpenBSD: quiz.c,v 1.12 2002/12/06 21:48:51 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -233,7 +233,7 @@ quiz()
|
||||
char *answer, *t, question[LINE_SZ];
|
||||
const char *s;
|
||||
|
||||
srandom(time(NULL));
|
||||
srandomdev();
|
||||
guesses = rights = wrongs = 0;
|
||||
for (;;) {
|
||||
if (qsize == 0)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: rain.c,v 1.11 2002/05/31 03:40:01 pjanzen Exp $ */
|
||||
/* $OpenBSD: rain.c,v 1.12 2002/12/06 21:48:51 millert 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[] = "$OpenBSD: rain.c,v 1.11 2002/05/31 03:40:01 pjanzen Exp $";
|
||||
static char rcsid[] = "$OpenBSD: rain.c,v 1.12 2002/12/06 21:48:51 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -90,7 +90,7 @@ main(argc, argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
srandom(time((time_t *)NULL));
|
||||
srandomdev();
|
||||
initscr();
|
||||
tcols = COLS - 4;
|
||||
tlines = LINES - 4;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: main.c,v 1.11 2002/05/31 05:11:37 pjanzen Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.12 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: main.c,v 1.5 1995/04/22 10:08:54 cgd Exp $ */
|
||||
|
||||
/*
|
||||
@ -44,7 +44,7 @@ static char copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static char rcsid[] = "$OpenBSD: main.c,v 1.11 2002/05/31 05:11:37 pjanzen Exp $";
|
||||
static char rcsid[] = "$OpenBSD: main.c,v 1.12 2002/12/06 21:48:51 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -155,7 +155,7 @@ main(ac, av)
|
||||
stdscr = newwin(Y_SIZE, X_SIZE, 0, 0);
|
||||
}
|
||||
|
||||
srandom(getpid());
|
||||
srandomdev();
|
||||
do {
|
||||
init_field();
|
||||
for (Level = Start_level; !Dead; Level++) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: main.c,v 1.3 1999/01/18 06:20:53 pjanzen Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.4 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: main.c,v 1.3 1995/04/22 10:37:01 cgd Exp $ */
|
||||
|
||||
/*
|
||||
@ -44,7 +44,7 @@ static char copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 4/28/95";
|
||||
#else
|
||||
static char rcsid[] = "$OpenBSD: main.c,v 1.3 1999/01/18 06:20:53 pjanzen Exp $";
|
||||
static char rcsid[] = "$OpenBSD: main.c,v 1.4 2002/12/06 21:48:51 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -74,7 +74,7 @@ main(argc, argv)
|
||||
exit(1);
|
||||
close(fd);
|
||||
|
||||
srandom(getpid());
|
||||
srandomdev();
|
||||
if ((p = strrchr(*argv, '/')))
|
||||
p++;
|
||||
else
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: snake.c,v 1.6 2002/06/23 03:01:13 deraadt Exp $ */
|
||||
/* $OpenBSD: snake.c,v 1.7 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: snake.c,v 1.8 1995/04/29 00:06:41 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
@ -44,7 +44,7 @@ static char copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)snake.c 8.2 (Berkeley) 1/7/94";
|
||||
#else
|
||||
static char rcsid[] = "$OpenBSD: snake.c,v 1.6 2002/06/23 03:01:13 deraadt Exp $";
|
||||
static char rcsid[] = "$OpenBSD: snake.c,v 1.7 2002/12/06 21:48:51 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -155,7 +155,6 @@ main(argc, argv)
|
||||
{
|
||||
int ch, i;
|
||||
char *p, **av;
|
||||
time_t tv;
|
||||
struct sigaction sa;
|
||||
|
||||
/* don't create the score file if it doesn't exist. */
|
||||
@ -168,8 +167,6 @@ main(argc, argv)
|
||||
setegid(getgid());
|
||||
setgid(getgid());
|
||||
|
||||
(void)time(&tv);
|
||||
|
||||
/* check to see if we were called as snscore */
|
||||
av = argv;
|
||||
p = strrchr(*av, '/');
|
||||
@ -182,11 +179,6 @@ main(argc, argv)
|
||||
|
||||
while ((ch = getopt(argc, argv, "hl:stw:")) != -1)
|
||||
switch ((char)ch) {
|
||||
#if 0
|
||||
case 'd':
|
||||
tv = atol(optarg); /* set seed */
|
||||
break;
|
||||
#endif
|
||||
case 'w': /* width */
|
||||
ccnt = atoi(optarg);
|
||||
break;
|
||||
@ -208,7 +200,7 @@ main(argc, argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
srandom((int)tv);
|
||||
srandomdev();
|
||||
penalty = loot = 0;
|
||||
initscr();
|
||||
#ifdef KEY_LEFT
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: tetris.c,v 1.14 2002/07/26 21:33:28 mickey Exp $ */
|
||||
/* $OpenBSD: tetris.c,v 1.15 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: tetris.c,v 1.2 1995/04/22 07:42:47 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
@ -219,7 +219,7 @@ main(argc, argv)
|
||||
scr_init();
|
||||
setup_board();
|
||||
|
||||
srandom(getpid());
|
||||
srandomdev();
|
||||
scr_set();
|
||||
|
||||
pos = A_FIRST*B_COLS + (B_COLS/2)-1;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: main.c,v 1.9 2002/05/31 04:21:30 pjanzen Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.10 2002/12/06 21:48:51 millert Exp $ */
|
||||
/* $NetBSD: main.c,v 1.4 1995/04/22 10:59:10 cgd Exp $ */
|
||||
|
||||
/*
|
||||
@ -44,7 +44,7 @@ static char copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static char rcsid[] = "$OpenBSD: main.c,v 1.9 2002/05/31 04:21:30 pjanzen Exp $";
|
||||
static char rcsid[] = "$OpenBSD: main.c,v 1.10 2002/12/06 21:48:51 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -139,15 +139,13 @@ main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
time_t curtime;
|
||||
int ac;
|
||||
char **av;
|
||||
|
||||
av = argv;
|
||||
ac = argc;
|
||||
av++;
|
||||
time(&curtime);
|
||||
srandom((long)curtime);
|
||||
srandomdev();
|
||||
|
||||
#ifdef xTRACE
|
||||
Trace = 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: worm.c,v 1.17 2002/05/31 04:21:30 pjanzen Exp $ */
|
||||
/* $OpenBSD: worm.c,v 1.18 2002/12/06 21:48:51 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@ -43,7 +43,7 @@ static char copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)worm.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static char rcsid[] = "$OpenBSD: worm.c,v 1.17 2002/05/31 04:21:30 pjanzen Exp $";
|
||||
static char rcsid[] = "$OpenBSD: worm.c,v 1.18 2002/12/06 21:48:51 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -112,7 +112,7 @@ main(argc, argv)
|
||||
|
||||
FD_ZERO(&rset);
|
||||
setbuf(stdout, outbuf);
|
||||
srandom(getpid());
|
||||
srandomdev();
|
||||
signal(SIGINT, leave);
|
||||
signal(SIGQUIT, leave);
|
||||
signal(SIGTSTP, suspend); /* process control signal */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: worms.c,v 1.13 2002/05/31 04:21:30 pjanzen Exp $ */
|
||||
/* $OpenBSD: worms.c,v 1.14 2002/12/06 21:48:52 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@ -43,7 +43,7 @@ static char copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)worms.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static char rcsid[] = "$OpenBSD: worms.c,v 1.13 2002/05/31 04:21:30 pjanzen Exp $";
|
||||
static char rcsid[] = "$OpenBSD: worms.c,v 1.14 2002/12/06 21:48:52 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -233,7 +233,7 @@ main(argc, argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
srandom(time((time_t *)NULL));
|
||||
srandomdev();
|
||||
if (!(worm = malloc((size_t)number * sizeof(struct worm))))
|
||||
nomem();
|
||||
initscr();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: wump.c,v 1.19 2002/07/30 05:35:22 pjanzen Exp $ */
|
||||
/* $OpenBSD: wump.c,v 1.20 2002/12/06 21:48:52 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@ -47,7 +47,7 @@ static const char copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)wump.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] = "$OpenBSD: wump.c,v 1.19 2002/07/30 05:35:22 pjanzen Exp $";
|
||||
static const char rcsid[] = "$OpenBSD: wump.c,v 1.20 2002/12/06 21:48:52 millert Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -219,8 +219,8 @@ main(int argc, char **argv)
|
||||
errx(1,
|
||||
"too many tunnels! The cave collapsed!\n(Fortunately, the wumpus escaped!)");
|
||||
|
||||
srandomdev();
|
||||
if (level == HARD) {
|
||||
srandom((int)time((time_t *)0));
|
||||
if (room_num / 2 - bat_num)
|
||||
bat_num += (random() % (room_num / 2 - bat_num));
|
||||
if (room_num / 2 - pit_num)
|
||||
@ -595,7 +595,6 @@ cave_init()
|
||||
* exits. It's being kept in case cave_init ever gets reworked into
|
||||
* something more traditional.
|
||||
*/
|
||||
srandom((int)time((time_t *)0));
|
||||
|
||||
/* initialize the cave first off. */
|
||||
for (i = 1; i <= room_num; ++i)
|
||||
@ -697,7 +696,6 @@ dodecahedral_cave_init()
|
||||
errx(1, "wrong parameters for dodecahedron");
|
||||
for (i = 0; i < 20; i++)
|
||||
loc[i] = i;
|
||||
srandom((int)time((time_t *)0));
|
||||
for (i = 0; i < 20; i++) {
|
||||
j = random() % (20 - i);
|
||||
if (j) {
|
||||
|
Loading…
Reference in New Issue
Block a user