date and time created 90/10/11 11:35:49 by bostic
[unix-history] / usr / src / contrib / dungeon / listen.c
CommitLineData
8b22683c
KB
1#include <stdio.h>
2
3#ifndef CINDEXFILE
4#define CINDEXFILE "/usr/games/lib/dunlib/dindx.dat"
5#endif
6
7main(numargs, argptr)
8
9int numargs;
10char *argptr[];
11{
12int chr;
13FILE *fpin;
14
15
16 fprintf(stderr,"Yawn... \n");
17
18/* open init file */
19 fpin = fopen(CINDEXFILE, "r");
20 if (fpin == NULL) {
21 fclose(fpin);
22 fprintf(stderr,"Init file missing.\n");
23 exit(0);
24 }
25
26/* transfer init file into the pipe */
27
28 while ((chr = getc(fpin)) != EOF)
29 putchar((char)chr);
30
31 fclose(fpin);
32
33/* check for restore file argument */
34
35 if(numargs > 1){
36 fpin = fopen(*++argptr,"r");
37 if( fpin == NULL)
38 fprintf(stderr,"Restore file missing.\n");
39
40 else {
41 putchar('R');
42 while((chr = getc(fpin)) != EOF)
43 putchar((char)chr);
44 fprintf(stderr,"Now, where were we...\n");
45 fclose(fpin);
46 }
47 }
48
49 fprintf(stderr,"Oh hello .. \n");
50
51/* send end of init data flag */
52
53 putchar('?');
54 fflush(stdout);
55
56/* send lines of standard input to pipe */
57
58 while ((chr = getchar()) != EOF){
59 putchar(chr);
60 if (chr == '\n')
61 fflush(stdout);
62 }
63
64/* end the process */
65 fprintf(stderr,"Goodnight .. \n");
66}