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