1*35973Sbostic #include <stdio.h>
2*35973Sbostic
3*35973Sbostic /* routine to sort out input stream */
4*35973Sbostic /* first character determines destination of the following data
5*35973Sbostic n - get arguments for 'rspeak'
6*35973Sbostic s - put data on dungeon save file until 'e' is received
7*35973Sbostic else - pass text to screen */
8*35973Sbostic
inprd_(pa,pb,pc)9*35973Sbostic inprd_(pa,pb,pc)
10*35973Sbostic
11*35973Sbostic int *pa, *pb, *pc;
12*35973Sbostic {
13*35973Sbostic int chr;
14*35973Sbostic
15*35973Sbostic (*pa)=(*pb)=(*pc)=0;
16*35973Sbostic
17*35973Sbostic while((chr = getchar()) != EOF) {
18*35973Sbostic if (chr == '\n')
19*35973Sbostic continue;
20*35973Sbostic switch (chr) {
21*35973Sbostic
22*35973Sbostic case 'n': /* get args for rspeak */
23*35973Sbostic if (scanf("%d%d%d",pa,pb,pc) > 0)
24*35973Sbostic return;
25*35973Sbostic else
26*35973Sbostic printf("Speak input error\n");
27*35973Sbostic break;
28*35973Sbostic
29*35973Sbostic case 's': /* send save data to file */
30*35973Sbostic wrtsave();
31*35973Sbostic break;
32*35973Sbostic
33*35973Sbostic default:
34*35973Sbostic putchar(chr);
35*35973Sbostic break;
36*35973Sbostic
37*35973Sbostic }
38*35973Sbostic /* send text to screen */
39*35973Sbostic while((chr = getchar()) != EOF){
40*35973Sbostic if (chr == '~')
41*35973Sbostic break;
42*35973Sbostic putchar(chr);
43*35973Sbostic if (chr == '\n')
44*35973Sbostic break;
45*35973Sbostic }
46*35973Sbostic }
47*35973Sbostic
48*35973Sbostic /* terminate process */
49*35973Sbostic printf("Goodbye ... GASP\n");
50*35973Sbostic exit(0);
51*35973Sbostic }
52*35973Sbostic
53*35973Sbostic /* write a save file */
54*35973Sbostic
wrtsave()55*35973Sbostic wrtsave()
56*35973Sbostic {
57*35973Sbostic FILE *savptr, *fopen();
58*35973Sbostic char chr;
59*35973Sbostic
60*35973Sbostic savptr = fopen("dungeon.sav","w");
61*35973Sbostic
62*35973Sbostic while ((chr = getchar()) != EOF) {
63*35973Sbostic if (chr == 'e') { /* check for end char */
64*35973Sbostic fclose(savptr);
65*35973Sbostic return;
66*35973Sbostic }
67*35973Sbostic putc(chr,savptr);
68*35973Sbostic }
69*35973Sbostic printf("EOF during save\n");
70*35973Sbostic exit(0);
71*35973Sbostic }
72