Remove the select_curproc vector from the usched structure. It is used
[dragonfly.git] / games / hack / hack.rumors.c
blob98654a9c234b8a79f6b1f996119d0ca0fdf357ef
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.2 2003/06/17 04:25:24 dillon Exp $ */
6 #include <stdio.h>
7 #include "hack.h" /* for RUMORFILE and BSD (index) */
8 #define CHARSZ 8 /* number of bits in a char */
9 extern long *alloc();
10 extern char *index();
11 int n_rumors = 0;
12 int n_used_rumors = -1;
13 char *usedbits;
15 init_rumors(rumf) FILE *rumf; {
16 int i;
17 n_used_rumors = 0;
18 while(skipline(rumf)) n_rumors++;
19 rewind(rumf);
20 i = n_rumors/CHARSZ;
21 usedbits = (char *) alloc((unsigned)(i+1));
22 for( ; i>=0; i--) usedbits[i] = 0;
25 skipline(rumf) FILE *rumf; {
26 char line[COLNO];
27 while(1) {
28 if(!fgets(line, sizeof(line), rumf)) return(0);
29 if(index(line, '\n')) return(1);
33 outline(rumf) FILE *rumf; {
34 char line[COLNO];
35 char *ep;
36 if(!fgets(line, sizeof(line), rumf)) return;
37 if((ep = index(line, '\n')) != 0) *ep = 0;
38 pline("This cookie has a scrap of paper inside! It reads: ");
39 pline(line);
42 outrumor(){
43 int rn,i;
44 FILE *rumf;
45 if(n_rumors <= n_used_rumors ||
46 (rumf = fopen(RUMORFILE, "r")) == (FILE *) 0) return;
47 if(n_used_rumors < 0) init_rumors(rumf);
48 if(!n_rumors) goto none;
49 rn = rn2(n_rumors - n_used_rumors);
50 i = 0;
51 while(rn || used(i)) {
52 (void) skipline(rumf);
53 if(!used(i)) rn--;
54 i++;
56 usedbits[i/CHARSZ] |= (1 << (i % CHARSZ));
57 n_used_rumors++;
58 outline(rumf);
59 none:
60 (void) fclose(rumf);
63 used(i) int i; {
64 return(usedbits[i/CHARSZ] & (1 << (i % CHARSZ)));