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)
23 while (skipline(rumf))
26 i = n_rumors / CHARSZ;
27 usedbits = alloc((unsigned)(i + 1));
38 if (!fgets(line, sizeof(line), rumf))
40 if (strchr(line, '\n'))
51 if (!fgets(line, sizeof(line), rumf))
53 if ((ep = strchr(line, '\n')) != 0)
55 pline("This cookie has a scrap of paper inside! It reads: ");
65 if (n_rumors <= n_used_rumors ||
66 (rumf = fopen(RUMORFILE, "r")) == NULL)
68 if (n_used_rumors < 0)
72 rn = rn2(n_rumors - n_used_rumors);
74 while (rn || used(i)) {
80 usedbits[i / CHARSZ] |= (1 << (i % CHARSZ));
90 return (usedbits[i / CHARSZ] & (1 << (i % CHARSZ)));