1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.rumors.c - version 1.0.3 */
3 /* $FreeBSD: src/games/hack/hack.rumors.c,v 1.3 1999/11/16 02:57:10 billf Exp $ */
4 /* $DragonFly: src/games/hack/hack.rumors.c,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */
6 #include "hack.h" /* for RUMORFILE and BSD (index) */
7 #define CHARSZ 8 /* number of bits in a char */
9 int n_used_rumors
= -1;
12 static void init_rumors(FILE *);
13 static bool skipline(FILE *);
14 static void outline(FILE *);
15 static bool used(int);
18 init_rumors(FILE *rumf
)
22 while(skipline(rumf
)) n_rumors
++;
25 usedbits
= (char *) alloc((unsigned)(i
+1));
26 for( ; i
>=0; i
--) usedbits
[i
] = 0;
34 if(!fgets(line
, sizeof(line
), rumf
)) return(0);
35 if(index(line
, '\n')) return(1);
44 if(!fgets(line
, sizeof(line
), rumf
)) return;
45 if((ep
= index(line
, '\n')) != 0) *ep
= 0;
46 pline("This cookie has a scrap of paper inside! It reads: ");
55 if(n_rumors
<= n_used_rumors
||
56 (rumf
= fopen(RUMORFILE
, "r")) == (FILE *) 0) return;
57 if(n_used_rumors
< 0) init_rumors(rumf
);
58 if(!n_rumors
) goto none
;
59 rn
= rn2(n_rumors
- n_used_rumors
);
61 while(rn
|| used(i
)) {
66 usedbits
[i
/CHARSZ
] |= (1 << (i
% CHARSZ
));
76 return(usedbits
[i
/CHARSZ
] & (1 << (i
% CHARSZ
)));