+/* $NetBSD: random.c,v 1.5 1997/10/12 01:14:22 lukem Exp $ */
+
/*
* Copyright (c) 1994
* The Regents of the University of California. All rights reserved.
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1994\n\
- The Regents of the University of California. All rights reserved.\n";
+__COPYRIGHT("@(#) Copyright (c) 1994\n\
+ The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)random.c 8.5 (Berkeley) 4/5/94";
+#if 0
+static char sccsid[] = "@(#)random.c 8.6 (Berkeley) 6/1/94";
+#else
+__RCSID("$NetBSD: random.c,v 1.5 1997/10/12 01:14:22 lukem Exp $");
+#endif
#endif /* not lint */
#include <sys/types.h>
+#include <sys/time.h>
#include <err.h>
#include <errno.h>
#include <unistd.h>
#include <limits.h>
+int main __P((int, char **));
void usage __P((void));
int
int argc;
char *argv[];
{
- extern int optind;
- time_t now;
+ struct timeval tp;
double denom;
int ch, random_exit, selected, unbuffer_output;
char *ep;
+ denom = 0;
random_exit = unbuffer_output = 0;
- while ((ch = getopt(argc, argv, "er")) != EOF)
+ while ((ch = getopt(argc, argv, "er")) != -1)
switch (ch) {
case 'e':
random_exit = 1;
/* NOTREACHED */
}
- (void)time(&now);
- srandom((u_int)(now + getpid()));
+ (void)gettimeofday(&tp, NULL);
+ srandom((u_int)(tp.tv_usec + tp.tv_sec + getpid()));
/* Compute a random exit status between 0 and denom - 1. */
if (random_exit)