static char sccsid
[] = " rain.c 4.1 82/10/24 ";
/* rain 11/3/1980 EPS/CITHEP */
/* cc rain.c -o rain -O -ltermlib */
#define cursor(col,row) tputs(tgoto(CM,col,row),1,outc)
char *tgetstr(), *tgoto();
static int xpos
[5], ypos
[5];
register char *CM
, *BC
, *DN
, *ND
;
setbuf(stdout
,malloc(BUFSIZ
));
if (!(term
=getenv("TERM"))) {
fprintf(stderr
,"%s: TERM: parameter not set\n",*argv
);
if (tgetent(malloc(1024),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
))) BC
="\b";
if (!(DN
=tgetstr("dn",&tcp
))) DN
="\n";
if (!(ND
=tgetstr("nd",&tcp
))) ND
=" ";
if (!(LL
=tgetstr("ll",&tcp
))) strcpy(LL
=malloc(10),tgoto(CM
,0,23));
for (j
=SIGHUP
;j
<=SIGTERM
;j
++)
if (signal(j
,SIG_IGN
)!=SIG_IGN
) signal(j
,onsig
);
gtty(1, &old_tty
); /* save tty bits for exit */
sg
.sg_flags
&=~(CRMOD
|ECHO
);
if (TI
) fputs(TI
,stdout
);
tputs(tgetstr("cl",&tcp
),1,fputchar
);
xpos
[j
]=(int)(76.*ranf())+2;
ypos
[j
]=(int)(20.*ranf())+2;
cursor(x
,y
); fputchar('.');
cursor(xpos
[j
],ypos
[j
]); fputchar('o');
cursor(xpos
[j
],ypos
[j
]); fputchar('O');
cursor(xpos
[j
],ypos
[j
]-1);
fputs(DN
,stdout
); fputs(BC
,stdout
); fputs(BC
,stdout
);
fputs(DN
,stdout
); fputs(BC
,stdout
); fputs(BC
,stdout
);
cursor(xpos
[j
],ypos
[j
]-2); fputchar('-');
fputs(DN
,stdout
); fputs(BC
,stdout
); fputs(BC
,stdout
);
cursor(xpos
[j
]-2,ypos
[j
]);
cursor(xpos
[j
]-1,ypos
[j
]+1);
fputs(DN
,stdout
); fputs(BC
,stdout
); fputs(BC
,stdout
);
cursor(xpos
[j
],ypos
[j
]-2); fputchar(' ');
fputs(DN
,stdout
); fputs(BC
,stdout
); fputs(BC
,stdout
);
fputchar(' '); fputs(ND
,stdout
); fputchar(' ');
cursor(xpos
[j
]-2,ypos
[j
]);
fputchar(' '); fputs(ND
,stdout
); fputchar(' ');
fputs(ND
,stdout
); fputchar(' ');
cursor(xpos
[j
]-1,ypos
[j
]+1);
fputchar(' '); fputs(ND
,stdout
); fputchar(' ');
fputs(DN
,stdout
); fputs(BC
,stdout
); fputs(BC
,stdout
);
if (TE
) fputs(TE
, stdout
);
return((float)rand()/2147483647.);