]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.rumors.c
2 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
6 static char rcsid
[] = "$Id: hack.rumors.c,v 1.2 1993/08/02 17:19:20 mycroft Exp $";
10 #include "hack.h" /* for RUMORFILE and BSD (index) */
11 #define CHARSZ 8 /* number of bits in a char */
15 int n_used_rumors
= -1;
18 init_rumors(rumf
) register FILE *rumf
; {
21 while(skipline(rumf
)) n_rumors
++;
24 usedbits
= (char *) alloc((unsigned)(i
+1));
25 for( ; i
>=0; i
--) usedbits
[i
] = 0;
28 skipline(rumf
) register FILE *rumf
; {
31 if(!fgets(line
, sizeof(line
), rumf
)) return(0);
32 if(index(line
, '\n')) return(1);
36 outline(rumf
) register FILE *rumf
; {
39 if(!fgets(line
, sizeof(line
), rumf
)) return;
40 if((ep
= index(line
, '\n')) != 0) *ep
= 0;
41 pline("This cookie has a scrap of paper inside! It reads: ");
48 if(n_rumors
<= n_used_rumors
||
49 (rumf
= fopen(RUMORFILE
, "r")) == (FILE *) 0) return;
50 if(n_used_rumors
< 0) init_rumors(rumf
);
51 if(!n_rumors
) goto none
;
52 rn
= rn2(n_rumors
- n_used_rumors
);
54 while(rn
|| used(i
)) {
55 (void) skipline(rumf
);
59 usedbits
[i
/CHARSZ
] |= (1 << (i
% CHARSZ
));
66 used(i
) register int i
; {
67 return(usedbits
[i
/CHARSZ
] & (1 << (i
% CHARSZ
)));