Difference between revisions of "Source:Hack 1.0/hack.whatis.c"

From NetHackWiki
Jump to navigation Jump to search
m (Automated source code upload)
 
 
(No difference)

Latest revision as of 22:45, 3 March 2008

Below is the full text to hack.whatis.c from the source code of Hack 1.0. To link to a particular line, write [[Hack 1.0/hack.whatis.c#line123]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code

Screenshots and source code from Hack are used under the CWI license.

1.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */
2.    
3.    #include	<stdio.h>
4.    #include "hack.h"
5.    
6.    dowhatis(str)
7.    register char *str;
8.    {
9.    	FILE *fp;
10.   	char bufr[BUFSZ];
11.   	register char *ep, q;
12.   
13.   	pline("Specify what? ");
14.   	getlin(bufr);
15.   	str = bufr;
16.   	while(*str == ' ') str++;
17.   	q = *str;
18.   	if(*(str+1)) pline("One character please.");
19.   	else if(!(fp = fopen("data","r"))) pline("Cannot open data file!");
20.   	else {
21.   		while(fgets(bufr,BUFSZ,fp))
22.   			if(*bufr == q) {
23.   				ep = index(bufr, '\n');
24.   				if(ep) *ep = 0;
25.   				else impossible();
26.   				pline(bufr);
27.   				if(ep[-1] == ';') morewhat(fp);
28.   				goto fnd;
29.   			}
30.   		pline("Unknown symbol.");
31.   	fnd:
32.   		(void) fclose(fp);
33.   	}
34.   }
35.   
36.   morewhat(fp) FILE *fp; {
37.   char bufr[BUFSZ];
38.   register char *ep;
39.   	pline("More info? ");
40.   	if(readchar() != 'y') return;
41.   	cls();
42.   	while(fgets(bufr,BUFSZ,fp) && *bufr == '\t'){
43.   		ep = index(bufr, '\n');
44.   		if(!ep) break;
45.   		*ep = 0;
46.   		puts(bufr+1);
47.   	}
48.   	more();
49.   	docrt();
50.   }