1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.rumors.c - version 1.0.3 */
5 #include "hack.h" /* for RUMORFILE and BSD (index) */
6 #define CHARSZ 8 /* number of bits in a char */
10 int n_used_rumors = -1;
13 init_rumors(rumf) register FILE *rumf; {
16 while(skipline(rumf)) n_rumors++;
19 usedbits = (char *) alloc((unsigned)(i+1));
20 for( ; i>=0; i--) usedbits[i] = 0;
23 skipline(rumf) register FILE *rumf; {
26 if(!fgets(line, sizeof(line), rumf)) return(0);
27 if(index(line, '\n')) return(1);
31 outline(rumf) register FILE *rumf; {
34 if(!fgets(line, sizeof(line), rumf)) return;
35 if((ep = index(line, '\n')) != 0) *ep = 0;
36 pline("This cookie has a scrap of paper inside! It reads: ");
43 if(n_rumors <= n_used_rumors ||
44 (rumf = fopen(RUMORFILE, "r")) == (FILE *) 0) return;
45 if(n_used_rumors < 0) init_rumors(rumf);
46 if(!n_rumors) goto none;
47 rn = rn2(n_rumors - n_used_rumors);
49 while(rn || used(i)) {
50 (void) skipline(rumf);
54 usedbits[i/CHARSZ] |= (1 << (i % CHARSZ));
61 used(i) register int i; {
62 return(usedbits[i/CHARSZ] & (1 << (i % CHARSZ)));