* Copyright (c) 1980 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
static char sccsid
[] = "@(#)rain.c 5.4 (Berkeley) 6/27/88";
* rain 11/3/1980 EPS/CITHEP
* cc rain.c -o rain -O -ltermlib
#define cursor(c, r) tputs(tgoto(CM, c, r), 1, fputchar)
static struct termio sg
, old_tty
;
static struct sgttyb sg
, old_tty
;
register char *CM
, *BC
, *DN
, *ND
, *term
;
char *TI
, *tcp
, *mp
, tcb
[100],
*malloc(), *getenv(), *strcpy(), *tgetstr();
long cols
, lines
, random();
int xpos
[5], ypos
[5], onsig();
if (!(term
= getenv("TERM"))) {
fprintf(stderr
, "%s: TERM: parameter not set\n", *argv
);
if (!(mp
= malloc((u_int
)1024))) {
fprintf(stderr
, "%s: out of space.\n", *argv
);
if (tgetent(mp
, term
) <= 0) {
fprintf(stderr
, "%s: %s: unknown terminal type\n", *argv
, term
);
if (!(CM
= tgetstr("cm", &tcp
))) {
fprintf(stderr
, "%s: terminal not capable of cursor motion\n", *argv
);
if (!(BC
= tgetstr("bc", &tcp
)))
if (!(DN
= tgetstr("dn", &tcp
)))
if (!(ND
= tgetstr("nd", &tcp
)))
if ((cols
= tgetnum("co")) == -1)
if ((lines
= tgetnum("li")) == -1)
TE
= tgetstr("te", &tcp
);
TI
= tgetstr("ti", &tcp
);
UP
= tgetstr("up", &tcp
);
if (!(LL
= tgetstr("ll", &tcp
))) {
if (!(LL
= malloc((u_int
)10))) {
fprintf(stderr
, "%s: out of space.\n", *argv
);
(void)strcpy(LL
, tgoto(CM
, 0, 23));
ospeed
= sg
.c_cflag
&CBAUD
;
(void)signal(SIGHUP
, onsig
);
(void)signal(SIGINT
, onsig
);
(void)signal(SIGQUIT
, onsig
);
(void)signal(SIGSTOP
, onsig
);
(void)signal(SIGTSTP
, onsig
);
(void)signal(SIGTERM
, onsig
);
ioctl(1, TCGETA
, &old_tty
); /* save tty bits for exit */
gtty(1, &old_tty
); /* save tty bits for exit */
sg
.sg_flags
&= ~(CRMOD
|ECHO
);
tputs(tgetstr("cl", &tcp
), 1, fputchar
);
for (j
= 4; j
>= 0; --j
) {
xpos
[j
] = random() % cols
+ 2;
ypos
[j
] = random() % lines
+ 2;
y
= random() % lines
+ 2;
cursor(xpos
[j
], ypos
[j
]);
cursor(xpos
[j
], ypos
[j
]);
cursor(xpos
[j
], ypos
[j
] - 1);
cursor(xpos
[j
], ypos
[j
] - 2);
cursor(xpos
[j
] - 2, ypos
[j
]);
cursor(xpos
[j
] - 1, ypos
[j
] + 1);
cursor(xpos
[j
], ypos
[j
] - 2);
cursor(xpos
[j
] - 2, ypos
[j
]);
cursor(xpos
[j
] - 1, ypos
[j
] + 1);
ioctl(1, TCSETAW
, &old_tty
);