io.c revision 1.1 1 1.1 jtc /*-
2 1.1 jtc * Copyright (c) 1991, 1993
3 1.1 jtc * The Regents of the University of California. All rights reserved.
4 1.1 jtc *
5 1.1 jtc * The game adventure was originally written in Fortran by Will Crowther
6 1.1 jtc * and Don Woods. It was later translated to C and enhanced by Jim
7 1.1 jtc * Gillogly. This code is derived from software contributed to Berkeley
8 1.1 jtc * by Jim Gillogly at The Rand Corporation.
9 1.1 jtc *
10 1.1 jtc * Redistribution and use in source and binary forms, with or without
11 1.1 jtc * modification, are permitted provided that the following conditions
12 1.1 jtc * are met:
13 1.1 jtc * 1. Redistributions of source code must retain the above copyright
14 1.1 jtc * notice, this list of conditions and the following disclaimer.
15 1.1 jtc * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 jtc * notice, this list of conditions and the following disclaimer in the
17 1.1 jtc * documentation and/or other materials provided with the distribution.
18 1.1 jtc * 3. All advertising materials mentioning features or use of this software
19 1.1 jtc * must display the following acknowledgement:
20 1.1 jtc * This product includes software developed by the University of
21 1.1 jtc * California, Berkeley and its contributors.
22 1.1 jtc * 4. Neither the name of the University nor the names of its contributors
23 1.1 jtc * may be used to endorse or promote products derived from this software
24 1.1 jtc * without specific prior written permission.
25 1.1 jtc *
26 1.1 jtc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 1.1 jtc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 1.1 jtc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 1.1 jtc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 1.1 jtc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 1.1 jtc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 1.1 jtc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 1.1 jtc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 1.1 jtc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 1.1 jtc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 1.1 jtc * SUCH DAMAGE.
37 1.1 jtc */
38 1.1 jtc
39 1.1 jtc #ifndef lint
40 1.1 jtc static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93";
41 1.1 jtc #endif /* not lint */
42 1.1 jtc
43 1.1 jtc /* Re-coding of advent in C: file i/o and user i/o */
44 1.1 jtc
45 1.1 jtc #include "hdr.h"
46 1.1 jtc #include <stdio.h>
47 1.1 jtc
48 1.1 jtc
49 1.1 jtc getin(wrd1,wrd2) /* get command from user */
50 1.1 jtc char **wrd1,**wrd2; /* no prompt, usually */
51 1.1 jtc { register char *s;
52 1.1 jtc static char wd1buf[MAXSTR],wd2buf[MAXSTR];
53 1.1 jtc int first, numch;
54 1.1 jtc
55 1.1 jtc *wrd1=wd1buf; /* return ptr to internal string*/
56 1.1 jtc *wrd2=wd2buf;
57 1.1 jtc wd2buf[0]=0; /* in case it isn't set here */
58 1.1 jtc for (s=wd1buf, first=1, numch=0;;)
59 1.1 jtc { if ((*s=getchar())>='A' && *s <='Z') *s = *s - ('A' -'a');
60 1.1 jtc /* convert to upper case */
61 1.1 jtc switch(*s) /* start reading from user */
62 1.1 jtc { case '\n':
63 1.1 jtc *s=0;
64 1.1 jtc return;
65 1.1 jtc case ' ':
66 1.1 jtc if (s==wd1buf||s==wd2buf) /* initial blank */
67 1.1 jtc continue;
68 1.1 jtc *s=0;
69 1.1 jtc if (first) /* finished 1st wd; start 2nd */
70 1.1 jtc { first=numch=0;
71 1.1 jtc s=wd2buf;
72 1.1 jtc break;
73 1.1 jtc }
74 1.1 jtc else /* finished 2nd word */
75 1.1 jtc { FLUSHLINE;
76 1.1 jtc *s=0;
77 1.1 jtc return;
78 1.1 jtc }
79 1.1 jtc default:
80 1.1 jtc if (++numch>=MAXSTR) /* string too long */
81 1.1 jtc { printf("Give me a break!!\n");
82 1.1 jtc wd1buf[0]=wd2buf[0]=0;
83 1.1 jtc FLUSHLINE;
84 1.1 jtc return;
85 1.1 jtc }
86 1.1 jtc s++;
87 1.1 jtc }
88 1.1 jtc }
89 1.1 jtc }
90 1.1 jtc
91 1.1 jtc
92 1.1 jtc confirm(mesg) /* confirm irreversible action */
93 1.1 jtc char *mesg;
94 1.1 jtc { register int result;
95 1.1 jtc printf("%s",mesg); /* tell him what he did */
96 1.1 jtc if (getchar()=='y') /* was his first letter a 'y'? */
97 1.1 jtc result=1;
98 1.1 jtc else result=0;
99 1.1 jtc FLUSHLINE;
100 1.1 jtc return(result);
101 1.1 jtc }
102 1.1 jtc
103 1.1 jtc yes(x,y,z) /* confirm with rspeak */
104 1.1 jtc int x,y,z;
105 1.1 jtc { register int result;
106 1.1 jtc register char ch;
107 1.1 jtc for (;;)
108 1.1 jtc { rspeak(x); /* tell him what we want*/
109 1.1 jtc if ((ch=getchar())=='y')
110 1.1 jtc result=TRUE;
111 1.1 jtc else if (ch=='n') result=FALSE;
112 1.1 jtc FLUSHLINE;
113 1.1 jtc if (ch=='y'|| ch=='n') break;
114 1.1 jtc printf("Please answer the question.\n");
115 1.1 jtc }
116 1.1 jtc if (result==TRUE) rspeak(y);
117 1.1 jtc if (result==FALSE) rspeak(z);
118 1.1 jtc return(result);
119 1.1 jtc }
120 1.1 jtc
121 1.1 jtc yesm(x,y,z) /* confirm with mspeak */
122 1.1 jtc int x,y,z;
123 1.1 jtc { register int result;
124 1.1 jtc register char ch;
125 1.1 jtc for (;;)
126 1.1 jtc { mspeak(x); /* tell him what we want*/
127 1.1 jtc if ((ch=getchar())=='y')
128 1.1 jtc result=TRUE;
129 1.1 jtc else if (ch=='n') result=FALSE;
130 1.1 jtc FLUSHLINE;
131 1.1 jtc if (ch=='y'|| ch=='n') break;
132 1.1 jtc printf("Please answer the question.\n");
133 1.1 jtc }
134 1.1 jtc if (result==TRUE) mspeak(y);
135 1.1 jtc if (result==FALSE) mspeak(z);
136 1.1 jtc return(result);
137 1.1 jtc }
138 1.1 jtc
139 1.1 jtc /* FILE *inbuf,*outbuf; */
140 1.1 jtc
141 1.1 jtc char *inptr; /* Pointer into virtual disk */
142 1.1 jtc
143 1.1 jtc int outsw = 0; /* putting stuff to data file? */
144 1.1 jtc
145 1.1 jtc char iotape[] = "Ax3F'\003tt$8h\315qer*h\017nGKrX\207:!l";
146 1.1 jtc char *tape = iotape; /* pointer to encryption tape */
147 1.1 jtc
148 1.1 jtc next() /* next virtual char, bump adr */
149 1.1 jtc {
150 1.1 jtc int ch;
151 1.1 jtc
152 1.1 jtc ch=(*inptr ^ random()) & 0xFF; /* Decrypt input data */
153 1.1 jtc if (outsw) /* putting data in tmp file */
154 1.1 jtc { if (*tape==0) tape=iotape; /* rewind encryption tape */
155 1.1 jtc *inptr = ch ^ *tape++; /* re-encrypt and replace value */
156 1.1 jtc }
157 1.1 jtc inptr++;
158 1.1 jtc return(ch);
159 1.1 jtc }
160 1.1 jtc
161 1.1 jtc char breakch; /* tell which char ended rnum */
162 1.1 jtc
163 1.1 jtc rdata() /* "read" data from virtual file*/
164 1.1 jtc { register int sect;
165 1.1 jtc register char ch;
166 1.1 jtc
167 1.1 jtc inptr = data_file; /* Pointer to virtual data file */
168 1.1 jtc srandom(SEED); /* which is lightly encrypted. */
169 1.1 jtc
170 1.1 jtc clsses=1;
171 1.1 jtc for (;;) /* read data sections */
172 1.1 jtc { sect=next()-'0'; /* 1st digit of section number */
173 1.1 jtc #ifdef VERBOSE
174 1.1 jtc printf("Section %c",sect+'0');
175 1.1 jtc #endif
176 1.1 jtc if ((ch=next())!=LF) /* is there a second digit? */
177 1.1 jtc {
178 1.1 jtc FLUSHLF;
179 1.1 jtc #ifdef VERBOSE
180 1.1 jtc putchar(ch);
181 1.1 jtc #endif
182 1.1 jtc sect=10*sect+ch-'0';
183 1.1 jtc }
184 1.1 jtc #ifdef VERBOSE
185 1.1 jtc putchar('\n');
186 1.1 jtc #endif
187 1.1 jtc switch(sect)
188 1.1 jtc { case 0: /* finished reading database */
189 1.1 jtc return;
190 1.1 jtc case 1: /* long form descriptions */
191 1.1 jtc rdesc(1);
192 1.1 jtc break;
193 1.1 jtc case 2: /* short form descriptions */
194 1.1 jtc rdesc(2);
195 1.1 jtc break;
196 1.1 jtc case 3: /* travel table */
197 1.1 jtc rtrav(); break;
198 1.1 jtc case 4: /* vocabulary */
199 1.1 jtc rvoc();
200 1.1 jtc break;
201 1.1 jtc case 5: /* object descriptions */
202 1.1 jtc rdesc(5);
203 1.1 jtc break;
204 1.1 jtc case 6: /* arbitrary messages */
205 1.1 jtc rdesc(6);
206 1.1 jtc break;
207 1.1 jtc case 7: /* object locations */
208 1.1 jtc rlocs(); break;
209 1.1 jtc case 8: /* action defaults */
210 1.1 jtc rdflt(); break;
211 1.1 jtc case 9: /* liquid assets */
212 1.1 jtc rliq(); break;
213 1.1 jtc case 10: /* class messages */
214 1.1 jtc rdesc(10);
215 1.1 jtc break;
216 1.1 jtc case 11: /* hints */
217 1.1 jtc rhints(); break;
218 1.1 jtc case 12: /* magic messages */
219 1.1 jtc rdesc(12);
220 1.1 jtc break;
221 1.1 jtc default:
222 1.1 jtc printf("Invalid data section number: %d\n",sect);
223 1.1 jtc for (;;) putchar(next());
224 1.1 jtc }
225 1.1 jtc if (breakch!=LF) /* routines return after "-1" */
226 1.1 jtc FLUSHLF;
227 1.1 jtc }
228 1.1 jtc }
229 1.1 jtc
230 1.1 jtc char nbf[12];
231 1.1 jtc
232 1.1 jtc
233 1.1 jtc rnum() /* read initial location num */
234 1.1 jtc { register char *s;
235 1.1 jtc tape = iotape; /* restart encryption tape */
236 1.1 jtc for (s=nbf,*s=0;; s++)
237 1.1 jtc if ((*s=next())==TAB || *s=='\n' || *s==LF)
238 1.1 jtc break;
239 1.1 jtc breakch= *s; /* save char for rtrav() */
240 1.1 jtc *s=0; /* got the number as ascii */
241 1.1 jtc if (nbf[0]=='-') return(-1); /* end of data */
242 1.1 jtc return(atoi(nbf)); /* convert it to integer */
243 1.1 jtc }
244 1.1 jtc
245 1.1 jtc char *seekhere;
246 1.1 jtc
247 1.1 jtc rdesc(sect) /* read description-format msgs */
248 1.1 jtc int sect;
249 1.1 jtc { register char *s,*t;
250 1.1 jtc register int locc;
251 1.1 jtc char *seekstart, *maystart, *adrstart;
252 1.1 jtc char *entry;
253 1.1 jtc
254 1.1 jtc seekhere = inptr; /* Where are we in virtual file?*/
255 1.1 jtc outsw=1; /* these msgs go into tmp file */
256 1.1 jtc for (oldloc= -1, seekstart=seekhere;;)
257 1.1 jtc { maystart=inptr; /* maybe starting new entry */
258 1.1 jtc if ((locc=rnum())!=oldloc && oldloc>=0 /* finished msg */
259 1.1 jtc && ! (sect==5 && (locc==0 || locc>=100)))/* unless sect 5*/
260 1.1 jtc { switch(sect) /* now put it into right table */
261 1.1 jtc { case 1: /* long descriptions */
262 1.1 jtc ltext[oldloc].seekadr=seekhere;
263 1.1 jtc ltext[oldloc].txtlen=maystart-seekstart;
264 1.1 jtc break;
265 1.1 jtc case 2: /* short descriptions */
266 1.1 jtc stext[oldloc].seekadr=seekhere;
267 1.1 jtc stext[oldloc].txtlen=maystart-seekstart;
268 1.1 jtc break;
269 1.1 jtc case 5: /* object descriptions */
270 1.1 jtc ptext[oldloc].seekadr=seekhere;
271 1.1 jtc ptext[oldloc].txtlen=maystart-seekstart;
272 1.1 jtc break;
273 1.1 jtc case 6: /* random messages */
274 1.1 jtc if (oldloc>RTXSIZ)
275 1.1 jtc { printf("Too many random msgs\n");
276 1.1 jtc exit(0);
277 1.1 jtc }
278 1.1 jtc rtext[oldloc].seekadr=seekhere;
279 1.1 jtc rtext[oldloc].txtlen=maystart-seekstart;
280 1.1 jtc break;
281 1.1 jtc case 10: /* class messages */
282 1.1 jtc ctext[clsses].seekadr=seekhere;
283 1.1 jtc ctext[clsses].txtlen=maystart-seekstart;
284 1.1 jtc cval[clsses++]=oldloc;
285 1.1 jtc break;
286 1.1 jtc case 12: /* magic messages */
287 1.1 jtc if (oldloc>MAGSIZ)
288 1.1 jtc { printf("Too many magic msgs\n");
289 1.1 jtc exit(0);
290 1.1 jtc }
291 1.1 jtc mtext[oldloc].seekadr=seekhere;
292 1.1 jtc mtext[oldloc].txtlen=maystart-seekstart;
293 1.1 jtc break;
294 1.1 jtc default:
295 1.1 jtc printf("rdesc called with bad section\n");
296 1.1 jtc exit(0);
297 1.1 jtc }
298 1.1 jtc seekhere += maystart-seekstart;
299 1.1 jtc }
300 1.1 jtc if (locc<0)
301 1.1 jtc { outsw=0; /* turn off output */
302 1.1 jtc seekhere += 3; /* -1<delimiter> */
303 1.1 jtc return;
304 1.1 jtc }
305 1.1 jtc if (sect!=5 || (locc>0 && locc<100))
306 1.1 jtc { if (oldloc!=locc)/* starting a new message */
307 1.1 jtc seekstart=maystart;
308 1.1 jtc oldloc=locc;
309 1.1 jtc }
310 1.1 jtc FLUSHLF; /* scan the line */
311 1.1 jtc }
312 1.1 jtc }
313 1.1 jtc
314 1.1 jtc
315 1.1 jtc rtrav() /* read travel table */
316 1.1 jtc { register int locc;
317 1.1 jtc register struct travlist *t;
318 1.1 jtc register char *s;
319 1.1 jtc char buf[12];
320 1.1 jtc int len,m,n,entries;
321 1.1 jtc for (oldloc= -1;;) /* get another line */
322 1.1 jtc { if ((locc=rnum())!=oldloc && oldloc>=0) /* end of entry */
323 1.1 jtc {
324 1.1 jtc t->next = 0; /* terminate the old entry */
325 1.1 jtc /* printf("%d:%d entries\n",oldloc,entries); */
326 1.1 jtc /* twrite(oldloc); */
327 1.1 jtc }
328 1.1 jtc if (locc== -1) return;
329 1.1 jtc if (locc!=oldloc) /* getting a new entry */
330 1.1 jtc { t=travel[locc]=(struct travlist *) malloc(sizeof (struct travlist));
331 1.1 jtc /* printf("New travel list for %d\n",locc); */
332 1.1 jtc entries=0;
333 1.1 jtc oldloc=locc;
334 1.1 jtc }
335 1.1 jtc for (s=buf;; *s++) /* get the newloc number /ASCII */
336 1.1 jtc if ((*s=next())==TAB || *s==LF) break;
337 1.1 jtc *s=0;
338 1.1 jtc len=length(buf)-1; /* quad long number handling */
339 1.1 jtc /* printf("Newloc: %s (%d chars)\n",buf,len); */
340 1.1 jtc if (len<4) /* no "m" conditions */
341 1.1 jtc { m=0;
342 1.1 jtc n=atoi(buf); /* newloc mod 1000 = newloc */
343 1.1 jtc }
344 1.1 jtc else /* a long integer */
345 1.1 jtc { n=atoi(buf+len-3);
346 1.1 jtc buf[len-3]=0; /* terminate newloc/1000 */
347 1.1 jtc m=atoi(buf);
348 1.1 jtc }
349 1.1 jtc while (breakch!=LF) /* only do one line at a time */
350 1.1 jtc { if (entries++) t=t->next=(struct travlist *) malloc(sizeof (struct travlist));
351 1.1 jtc t->tverb=rnum();/* get verb from the file */
352 1.1 jtc t->tloc=n; /* table entry mod 1000 */
353 1.1 jtc t->conditions=m;/* table entry / 1000 */
354 1.1 jtc /* printf("entry %d for %d\n",entries,locc); */
355 1.1 jtc }
356 1.1 jtc }
357 1.1 jtc }
358 1.1 jtc
359 1.1 jtc #ifdef DEBUG
360 1.1 jtc
361 1.1 jtc twrite(loq) /* travel options from this loc */
362 1.1 jtc int loq;
363 1.1 jtc { register struct travlist *t;
364 1.1 jtc printf("If");
365 1.1 jtc speak(<ext[loq]);
366 1.1 jtc printf("then\n");
367 1.1 jtc for (t=travel[loq]; t!=0; t=t->next)
368 1.1 jtc { printf("verb %d takes you to ",t->tverb);
369 1.1 jtc if (t->tloc<=300)
370 1.1 jtc speak(<ext[t->tloc]);
371 1.1 jtc else if (t->tloc<=500)
372 1.1 jtc printf("special code %d\n",t->tloc-300);
373 1.1 jtc else
374 1.1 jtc rspeak(t->tloc-500);
375 1.1 jtc printf("under conditions %d\n",t->conditions);
376 1.1 jtc }
377 1.1 jtc }
378 1.1 jtc
379 1.1 jtc #endif DEBUG
380 1.1 jtc
381 1.1 jtc rvoc()
382 1.1 jtc { register char *s; /* read the vocabulary */
383 1.1 jtc register int index;
384 1.1 jtc char buf[6];
385 1.1 jtc for (;;)
386 1.1 jtc { index=rnum();
387 1.1 jtc if (index<0) break;
388 1.1 jtc for (s=buf,*s=0;; s++) /* get the word */
389 1.1 jtc if ((*s=next())==TAB || *s=='\n' || *s==LF
390 1.1 jtc || *s==' ') break;
391 1.1 jtc /* terminate word with newline, LF, tab, blank */
392 1.1 jtc if (*s!='\n' && *s!=LF) FLUSHLF; /* can be comments */
393 1.1 jtc *s=0;
394 1.1 jtc /* printf("\"%s\"=%d\n",buf,index);*/
395 1.1 jtc vocab(buf,-2,index);
396 1.1 jtc }
397 1.1 jtc /* prht(); */
398 1.1 jtc }
399 1.1 jtc
400 1.1 jtc
401 1.1 jtc rlocs() /* initial object locations */
402 1.1 jtc { for (;;)
403 1.1 jtc { if ((obj=rnum())<0) break;
404 1.1 jtc plac[obj]=rnum(); /* initial loc for this obj */
405 1.1 jtc if (breakch==TAB) /* there's another entry */
406 1.1 jtc fixd[obj]=rnum();
407 1.1 jtc else fixd[obj]=0;
408 1.1 jtc }
409 1.1 jtc }
410 1.1 jtc
411 1.1 jtc rdflt() /* default verb messages */
412 1.1 jtc { for (;;)
413 1.1 jtc { if ((verb=rnum())<0) break;
414 1.1 jtc actspk[verb]=rnum();
415 1.1 jtc }
416 1.1 jtc }
417 1.1 jtc
418 1.1 jtc rliq() /* liquid assets &c: cond bits */
419 1.1 jtc { register int bitnum;
420 1.1 jtc for (;;) /* read new bit list */
421 1.1 jtc { if ((bitnum=rnum())<0) break;
422 1.1 jtc for (;;) /* read locs for bits */
423 1.1 jtc { cond[rnum()] |= setbit[bitnum];
424 1.1 jtc if (breakch==LF) break;
425 1.1 jtc }
426 1.1 jtc }
427 1.1 jtc }
428 1.1 jtc
429 1.1 jtc rhints()
430 1.1 jtc { register int hintnum,i;
431 1.1 jtc hntmax=0;
432 1.1 jtc for (;;)
433 1.1 jtc { if ((hintnum=rnum())<0) break;
434 1.1 jtc for (i=1; i<5; i++)
435 1.1 jtc hints[hintnum][i]=rnum();
436 1.1 jtc if (hintnum>hntmax) hntmax=hintnum;
437 1.1 jtc }
438 1.1 jtc }
439 1.1 jtc
440 1.1 jtc
441 1.1 jtc rspeak(msg)
442 1.1 jtc int msg;
443 1.1 jtc { if (msg!=0) speak(&rtext[msg]);
444 1.1 jtc }
445 1.1 jtc
446 1.1 jtc
447 1.1 jtc mspeak(msg)
448 1.1 jtc int msg;
449 1.1 jtc { if (msg!=0) speak(&mtext[msg]);
450 1.1 jtc }
451 1.1 jtc
452 1.1 jtc
453 1.1 jtc speak(msg) /* read, decrypt, and print a message (not ptext) */
454 1.1 jtc struct text *msg;/* msg is a pointer to seek address and length of mess */
455 1.1 jtc {
456 1.1 jtc register char *s, nonfirst;
457 1.1 jtc
458 1.1 jtc s = msg->seekadr;
459 1.1 jtc nonfirst=0;
460 1.1 jtc while (s - msg->seekadr < msg->txtlen) /* read a line at a time */
461 1.1 jtc { tape=iotape; /* restart decryption tape */
462 1.1 jtc while ((*s++ ^ *tape++) != TAB); /* read past loc num */
463 1.1 jtc /* assume tape is longer than location number */
464 1.1 jtc /* plus the lookahead put together */
465 1.1 jtc if ((*s ^ *tape) == '>' &&
466 1.1 jtc (*(s+1) ^ *(tape+1)) == '$' &&
467 1.1 jtc (*(s+2) ^ *(tape+2)) == '<') break;
468 1.1 jtc if (blklin && !nonfirst++) putchar('\n');
469 1.1 jtc do
470 1.1 jtc { if (*tape == 0) tape = iotape;/* rewind decryp tape */
471 1.1 jtc putchar(*s ^ *tape);
472 1.1 jtc } while ((*s++ ^ *tape++) != LF); /* better end with LF */
473 1.1 jtc }
474 1.1 jtc }
475 1.1 jtc
476 1.1 jtc
477 1.1 jtc pspeak(m,skip) /* read, decrypt an print a ptext message */
478 1.1 jtc int m; /* msg is the number of all the p msgs for this place */
479 1.1 jtc int skip; /* assumes object 1 doesn't have prop 1, obj 2 no prop 2 &c*/
480 1.1 jtc {
481 1.1 jtc register char *s,nonfirst;
482 1.1 jtc char *numst, save;
483 1.1 jtc struct text *msg;
484 1.1 jtc char *tbuf;
485 1.1 jtc
486 1.1 jtc msg = &ptext[m];
487 1.1 jtc if ((tbuf=(char *) malloc(msg->txtlen + 1)) == 0) bug(108);
488 1.1 jtc memcpy(tbuf, msg->seekadr, msg->txtlen + 1); /* Room to null */
489 1.1 jtc s = tbuf;
490 1.1 jtc
491 1.1 jtc nonfirst=0;
492 1.1 jtc while (s - tbuf < msg->txtlen) /* read line at a time */
493 1.1 jtc { tape=iotape; /* restart decryption tape */
494 1.1 jtc for (numst=s; (*s^= *tape++)!=TAB; s++); /* get number */
495 1.1 jtc
496 1.1 jtc save = *s; /* Temporarily trash the string (cringe) */
497 1.1 jtc *s++ = 0; /* decrypting number within the string */
498 1.1 jtc
499 1.1 jtc if (atoi(numst) != 100 * skip && skip >= 0)
500 1.1 jtc { while ((*s++^*tape++)!=LF) /* flush the line */
501 1.1 jtc if (*tape==0) tape=iotape;
502 1.1 jtc continue;
503 1.1 jtc }
504 1.1 jtc if ((*s^*tape)=='>' && (*(s+1)^*(tape+1))=='$' &&
505 1.1 jtc (*(s+2)^*(tape+2))=='<') break;
506 1.1 jtc if (blklin && ! nonfirst++) putchar('\n');
507 1.1 jtc do
508 1.1 jtc { if (*tape==0) tape=iotape;
509 1.1 jtc putchar(*s^*tape);
510 1.1 jtc } while ((*s++^*tape++)!=LF); /* better end with LF */
511 1.1 jtc if (skip<0) break;
512 1.1 jtc }
513 1.1 jtc free(tbuf);
514 1.1 jtc }
515