mirror of
https://github.com/vattam/BSDGames.git
synced 2025-12-21 03:14:50 +00:00
releasing version 2.17-1
git-svn-id: file:///srv/svn/joey/trunk/src/packages/bsdgames@11092 a4a2c43b-8ac3-0310-8836-e0e880c912e2
This commit is contained in:
46
rain/rain.c
46
rain/rain.c
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rain.c,v 1.16 2004/02/08 22:21:57 jsm Exp $ */
|
||||
/* $NetBSD: rain.c,v 1.17 2004/05/02 21:31:23 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)rain.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: rain.c,v 1.16 2004/02/08 22:21:57 jsm Exp $");
|
||||
__RCSID("$NetBSD: rain.c,v 1.17 2004/05/02 21:31:23 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -56,39 +56,45 @@ __RCSID("$NetBSD: rain.c,v 1.16 2004/02/08 22:21:57 jsm Exp $");
|
||||
#include <stdlib.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
||||
volatile sig_atomic_t sig_caught = 0;
|
||||
static volatile sig_atomic_t sig_caught = 0;
|
||||
|
||||
int main(int, char **);
|
||||
void onsig(int);
|
||||
int main(int, char **);
|
||||
static void onsig(int);
|
||||
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int x, y, j;
|
||||
long cols, lines;
|
||||
unsigned int delay = 0;
|
||||
unsigned long val = 0;
|
||||
int ch;
|
||||
char *ep;
|
||||
int xpos[5], ypos[5];
|
||||
|
||||
/* Revoke setgid privileges */
|
||||
setregid(getgid(), getgid());
|
||||
|
||||
while ((ch = getopt(argc, argv, "d:h")) != -1)
|
||||
while ((ch = getopt(argc, argv, "d:")) != -1)
|
||||
switch (ch) {
|
||||
case 'd':
|
||||
if ((delay = (unsigned int)strtoul(optarg, (char **)NULL, 10)) < 1
|
||||
|| delay > 1000)
|
||||
errx(1, "invalid delay (1-1000)");
|
||||
delay *= 1000; /* ms -> us */
|
||||
val = strtoul(optarg, &ep, 0);
|
||||
if (ep == optarg || *ep)
|
||||
errx(1, "Invalid delay `%s'", optarg);
|
||||
if (errno == ERANGE && val == ULONG_MAX)
|
||||
err(1, "Invalid delay `%s'", optarg);
|
||||
if (val >= 1000)
|
||||
errx(1, "Invalid delay `%s' (1-999)", optarg);
|
||||
delay = (unsigned int)val * 1000; /* ms -> us */
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
(void)fprintf(stderr, "usage: rain [-d delay]\n");
|
||||
exit(1);
|
||||
(void)fprintf(stderr, "Usage: %s [-d delay]\n",
|
||||
getprogname());
|
||||
return 1;
|
||||
}
|
||||
|
||||
initscr();
|
||||
@@ -97,9 +103,6 @@ main(argc, argv)
|
||||
|
||||
(void)signal(SIGHUP, onsig);
|
||||
(void)signal(SIGINT, onsig);
|
||||
(void)signal(SIGQUIT, onsig);
|
||||
(void)signal(SIGSTOP, onsig);
|
||||
(void)signal(SIGTSTP, onsig);
|
||||
(void)signal(SIGTERM, onsig);
|
||||
|
||||
curs_set(0);
|
||||
@@ -148,9 +151,8 @@ main(argc, argv)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
onsig(dummy)
|
||||
int dummy __attribute__((__unused__));
|
||||
static void
|
||||
onsig(int dummy __attribute__((__unused__)))
|
||||
{
|
||||
sig_caught = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user