#Relay-Version: version Notes 2.7.5 (840 Contrib) 87/2/5; site hpesoc1.HP.COM
#From: games-request@tekred.TEK.COM
#Date: Tue, 4 Aug 87 23:49:31 GMT
#Date-Received: Wed, 5 Aug 87 20:51:04 GMT
#Subject: v02i027:  adl - Adventure Definition Language, Part10/11
#Message-ID: <1481@tekred.TEK.COM>
#Path: hpesoc1!hpda!hplabs!ucbvax!ucbcad!ames!ll-xn!mit-eddie!uw-beaver!tektronix!tekgen!tekred!games-request
#Newsgroups: comp.sources.games
#Sender: billr@tekred.TEK.COM
#Approved: billr@tekred.TEK.COM
#Lines: 2330
#
#Submitted by: cunniff%hpda@hplabs.HP.COM (Ross Cunniff)
#Comp.sources.games: Volume 2, Issue 27
#Archive-name: adl/Part10
#
#
#
#
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 10 (of 11)."
# Contents:  Makefile PORTING adlcomp/Makefile adlcomp/adlmsg.c
#   adlcomp/codegen.c adlrun/adldwim.c adlrun/adlerr.c
#   adlrun/adlintrn.c adlrun/adlmacro.c adlrun/adlobjr.c
#   include/adlcomp.h include/adldef.h include/adltypes.h
#   man/adlcomp.6 samples/aard/Makefile samples/aard/locnames.adl
#   samples/aard/routines.adl samples/demos/tiny.adl util/mytime.c
#   util/vstring.c
# Wrapped by billr@tekred on Tue Aug  4 16:27:52 1987
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f Makefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"Makefile\"
else
echo shar: Extracting \"Makefile\" \(1800 characters\)
sed "s/^X//" >Makefile <<'END_OF_Makefile'
X# AR = shar -c -v -d
XDIST = ../adl.dist/SHAR
XAR = post -c -v -p 1 17
X
Xall	:
X		(cd util;	make all);
X		(cd adlcomp;	make all);
X		(cd adlrun;	make all);
X		(cd samples;	make all);
X		(cd misc;	make all);
X
Xinstall :
X		(cd util;	make all);
X		(cd adlcomp;	make install);
X		(cd adlrun;	make install);
X		(cd misc;	make install);
X
Xpost	:	shar
X		mv adl.shar ${DIST}/adl_01.shar
X		mv adlcomp/adlcomp1.shar ${DIST}/adl_02.shar
X		mv adlcomp/adlcomp2.shar ${DIST}/adl_03.shar
X		mv adlrun/adlrun1.shar ${DIST}/adl_04.shar
X		mv adlrun/adlrun2.shar ${DIST}/adl_05.shar
X		mv include/include.shar ${DIST}/adl_06.shar
X		mv misc/misc.shar ${DIST}/adl_07.shar
X		mv samples/samples.shar ${DIST}/adl_08.shar
X		mv util/util.shar ${DIST}/adl_09.shar
X		mv samples/aard/aard1.shar ${DIST}/adl_10.shar
X		mv samples/aard/aard2.shar ${DIST}/adl_11.shar
X		mv samples/demos/demos.shar ${DIST}/adl_12.shar
X		mv samples/mpu/mpu1.shar ${DIST}/adl_13.shar
X		mv samples/mpu/mpu2.shar ${DIST}/adl_14.shar
X
Xshar	:	adl.shar
X		(cd util;	make shar);
X		(cd adlcomp;	make shar);
X		(cd adlrun;	make shar);
X		(cd samples;	make shar);
X		(cd include;	make shar);
X		(cd misc;	make shar);
X
Xadl.shar	: README	COPYRIGHT	PORTING		\
X		  Makefile	man		adlcomp		\
X		  adlrun	misc		util		\
X		  include	samples		samples/aard	\
X		  samples/mpu	samples/demos	man/*.6
X		${AR}	README		COPYRIGHT	PORTING		\
X			Makefile	man		adlcomp		\
X			adlrun		misc		util		\
X			include		samples		samples/aard	\
X			samples/mpu	samples/demos	man/*.6		\
X		> adl.shar
X
Xtouch	:
X		(cd util;	make -t);
X		(cd adlcomp;	make -t);
X		(cd adlrun;	make -t);
X		(cd samples;	make touch);
X		(cd misc;	make -t);
X
Xclean	:
X		(cd util;	make clean);
X		(cd adlcomp;	make clean);
X		(cd adlrun;	make clean);
X		(cd samples;	make clean);
X		(cd include;	make clean);
X		(cd misc;	make clean);
X		rm -f adl.shar
END_OF_Makefile
if test 1800 -ne `wc -c <Makefile`; then
    echo shar: \"Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f PORTING -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"PORTING\"
else
echo shar: Extracting \"PORTING\" \(3168 characters\)
sed "s/^X//" >PORTING <<'END_OF_PORTING'
XPorting ADL to a new system shouldn't be much trouble, as long
Xas the operating system is 'UN*X-like' enough.  MS-DOS is UN*X-like
Xenough, as is AmigaDos.
X
XAfter you have unpacked all of the shar files, look in the file
Xinclude/adltypes.h.  There you will find #defines of the following:
X
X	HPUX		1 if on an HP-UX, SysIII, or SysV computer, 0 otherwise
X	BSD		1 if on a 4.x BSD computer, 0 otherwise
X	MSDOS		1 if on an MS-DOS computer, 0 otherwise
X	AMIGA		1 if on an Amiga, 0 otherwise
X
X	LATTICE		1 if Lattice 'C' was used to compile this, 0 otherwise
X	PCC		1 if a true K&R compiler was used, 0 otherwise
X
X	DEBUG		1 if detailed error checking desired in adlrun,
X			0 otherwise
X
X	HPTERM		1 if screen I/O is going to an HP terminal, 0 otherwise
X	ANSI		1 if screen I/O is going to an ANSI term, 0 otherwise
X	TERMCAP		1 if screen I/O will use termcap, 0 otherwise
X
XChange these to reflect your system.  If your system is not one
Xof those listed, examine the constants, etc. defined in the same file.
XCreate a new name (MYSYS, or whatever) for the system, then create
Xnew constants and macros.
X
XThe files adlcomp/codegen.c, adlrun/adlmach.c, util/virtmem.c, and
Xmisc/adldebug.c include some code to compose integers from bytes -
Xthis may have to be changed on a machine which has other than 8
Xbits per byte.
X
XOnce all changes to the .c files have been made, it will be
Xnecessary to modify the Makefile in each directory to reflect
X
X	1.  Where the programs are to be installed
X	2.  Whether to use termcap, termlib, or nothing in adlrun
X
XAfter all of this has been done, just type "make install" at this level, and
Xthen make all.  Everything should be made.  If you don't have the make
Xutility available, follow these steps in compiling:
X
X	1.  Compile the files in the util directory, like this:
X		cc -c *.c -O -I../include
X	2.  Compile the files in the adlcomp directory, like this:
X		cc -c *.c -O -I../include
X		cc -o adlcomp *.o ../util/*.o
X		mv adlcomp {wherever you want it}
X	3.  Compile the files in the adlrun directory, like this:
X		cc -c *.c -O -I../include
X		cc -o adlrun *.o ../util/*.o	{add -ltermcap or -ltermlib,
X						if appropriate}
X		mv adlrun {wherever you want it}
X	4.  Compile the files in the misc directory, like this:
X		cc -c *.c -O -I../include
X		cc -o adldebug adldebug.o global.o ../util/v*.o
X		cc -o adltouch adltouch.o
X		mv adldebug adltouch {wherever you want them}
X	5.  You should now have adlcomp, adlrun, adldebug, and adltouch.
X	    Go to the samples/demos directory.  For a test, do:
X		adlcomp tiny.adl -o tiny
X	    This should create a file named "tiny" in this directory.  Type
X		adlrun tiny
X	    You should now be running the sample dungeon.  If not, check
X	    all of the above steps, and start over :-(.
X	6.  Finish compiling the dungeons:
X		adlcomp actdemo.adl -o actdemo
X		adlcomp chrdemo.adl -o chrdemo
X		adlcomp alldemo.adl -o alldemo
X		adlcomp newtiny.adl -o newtiny -i..
X		adlcomp baby.adl -o baby -i..
X		cd ../aard
X		adlcomp aard.adl -o aard -i..
X		cd ../mpu
X		adlcomp mpu -o mpu -i..
X	7.  Play the games :-).
X
XPlease send all changes to:
X
X			Ross Cunniff
X			UUCP:	...{ucbvax,hplabs}!hpda!cunniff
X			ARPA:	cunniff%hpda@hplabs.ARPA
END_OF_PORTING
if test 3168 -ne `wc -c <PORTING`; then
    echo shar: \"PORTING\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f adlcomp/Makefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"adlcomp/Makefile\"
else
echo shar: Extracting \"adlcomp/Makefile\" \(2072 characters\)
sed "s/^X//" >adlcomp/Makefile <<'END_OF_adlcomp/Makefile'
X# Source directories - INC is the include directory; UTL is the
X# utilities directory.
XINC = ../include
XUTL = ../util
X
X# shar options.  B is the directory from which to unpack; D is the
X# name of the directory we're unpacking.
XAR1 = post -c -v -p 2 17
XAR2 = post -c -v -p 3 17
XB = ..
XD = adlcomp/
X
X# Where adlcomp will be installed, with make install.
XBIN = /users/cunniff/bin
X
X# Flags for CC
XCFLAGS = -I${INC} -O '-DADL_NAME="${BIN}"'
X
X# Flags for lint
XLFLAGS = -DLINT -I${INC} -C
X
X# Header files used by adlcomp and associated modules
XHDRS =	${INC}/adltypes.h	${INC}/adldef.h		${INC}/adlprog.h \
X	${INC}/adlcomp.h	${INC}/virtmem.h	${INC}/vstring.h
X
X# Utility files used by adlcomp
XUTIL =	${UTL}/virtmem.o	${UTL}/vstring.o	${UTL}/mytime.o
X
X# The object modules from which to buld adlcomp
XOBJS =	adlcomp.o	codegen.o	adllex.o	adlmisc.o	\
X	adlmsg.o	adlobj.o	routcomp.o	predef.o	\
X	compdict.o	adlglob.o
X
X# The rules.
X
Xall		: adlcomp
X
Xshar		: adlcomp1.shar	adlcomp2.shar
X
Xadlcomp1.shar	: README Makefile adlcomp.c adlglob.c adllex.c adlmisc.c
X	( cd ${B} ; ${AR1}					\
X		${D}README	${D}COPYRIGHT	${D}Makefile	\
X		${D}adlcomp.c	${D}adlglob.c	${D}adllex.c	\
X		${D}adlmisc.c					\
X	> ${D}adlcomp1.shar )
X
Xadlcomp2.shar	: adlmsg.c	adlobj.c	codegen.c	\
X		  compdict.c	predef.c	routcomp.c
X	( cd ${B} ; ${AR2}					\
X		${D}adlmsg.c	${D}adlobj.c	${D}codegen.c	\
X		${D}compdict.c	${D}predef.c	${D}routcomp.c	\
X	> ${D}adlcomp2.shar )
X
Xinstall		: adlcomp
X	strip adlcomp
X	cp adlcomp ${BIN}
X	chmod 755 ${BIN}/adlcomp
X
Xclean		:
X	rm -f ${OBJS} core adlcomp1.shar adlcomp2.shar adlcomp
X
Xlint		:
X	lint ${LFLAGS} adlcomp.c codegen.c predef.c \
X		adllex.c adlmisc.c adlmsg.c adlobj.c \
X		routcomp.c compdict.c adlglob.c ${UTL}/*.c
X
Xadlcomp		: ${OBJS} ${UTIL}
X	cc -o adlcomp ${OBJS} ${UTIL}
X
Xcodegen.o	: codegen.c	${HDRS}
X
Xadlcomp.o	: adlcomp.c	${HDRS}
X
Xadllex.o	: adllex.c	${HDRS}
X
Xadlmisc.o	: adlmisc.c	${HDRS}
X
Xadlmsg.o	: adlmsg.c	${HDRS}
X
Xadlobj.o	: adlobj.c	${HDRS}
X
Xpredef.o	: predef.c	${HDRS}
X
Xroutcomp.o	: routcomp.c	${HDRS}
X
Xcompdict.o	: compdict.c	${HDRS}
X
Xadlglob.o	: adlglob.c	${HDRS}
END_OF_adlcomp/Makefile
if test 2072 -ne `wc -c <adlcomp/Makefile`; then
    echo shar: \"adlcomp/Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f adlcomp/adlmsg.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"adlcomp/adlmsg.c\"
else
echo shar: Extracting \"adlcomp/adlmsg.c\" \(3180 characters\)
sed "s/^X//" >adlcomp/adlmsg.c <<'END_OF_adlcomp/adlmsg.c'
X	/***************************************************************\
X	*								*
X	*	adlmsg.c - routines to print error messages during	*
X	*	compilation.						*
X	*	Copyright 1987 by Ross Cunniff.				*
X	*								*
X	\***************************************************************/
X
X#include <stdio.h>
X
X#include "adltypes.h"
X#include "adlprog.h"
X#include "adlcomp.h"
X
X
X/* Predefined error messages */
Xchar
X    *BRACKET_EXPECTED	= "']' expected.\n",
X    *BAD_ARRAY		= "Array size must be greater than 0.\n",
X    *LEFT_EXPECTED	= "'(' expected.\n",
X    *RIGHT_EXPECTED	= "')' expected.\n",
X    *SEMI_EXPECTED	= "';' expected.\n",
X    *COMMA_EXPECTED	= "',' expected.\n",
X    *NOUN_WANTED	= "Noun expected.\n",
X    *CONST_EXPECTED	= "Constant expected.\n",
X    *VAR_EXPECTED	= "Global expected.\n",
X    *EQUAL_EXPECTED	= "'=' expected.\n",
X    *PREP_EXPECTED	= "Preposition expected.\n",
X    *ATTEMPT	= "Attempt to use a modified noun without a modifier.\n",
X    *ILLEGAL_SYMBOL	= "Illegal symbol.\n";
X
Xint16
X    wignore = 0,	/* Ignore warning messages?			*/
X    maxerr  = -1;	/* Maximum number of errors before crash	*/
X
X
X	/***************************************************************\
X	*								*
X	*	eatuntil( c ) - eat tokens until a token with type c	*
X	*	is found, and EOF is found, or a semicolon is found,	*
X	*	whichever comes first.					*
X	*								*
X	\***************************************************************/
X
Xeatuntil( c )
Xint16
X    c;
X{
X    while( (t_type != c) && (t_type != EOF) ) {
X	if( (t_type == '(') && (c == ')') ) {
X	    lexer();
X	    eatuntil( ')' );
X	}
X	else if( t_type == ';' )
X	    return;	/* Don't eat past a ';' */
X	lexer();
X   }
X}
X
X
X
X	/***************************************************************\
X	*								*
X	*	error( msg ) - Print ERROR: msg, increment the error	*
X	*	counter, and exit if too many errors have occurred.	*
X	*								*
X	\***************************************************************/
X
Xerror( s )
Xchar
X    *s;
X{
X    fprintf( stderr, "ERROR: %s", s );
X    if( t_type != EOF ) {
X	fprintf( stderr, "File \"%s\", line %d, token \"%s\"\n",
X		     inname, numline, token );
X	fflush( stderr );
X    }
X    numerr++;
X    if( (maxerr >= 0) && (numerr > maxerr) )
X	fatal( "Maximum number of errors exceeded.\n" );
X}
X
X
X	/***************************************************************\
X	*								*
X	*	warning( msg ) - If warning messages are enabled, print	*
X	*	the string WARNING: msg and increment the warning count.*
X	*								*
X	\***************************************************************/
X
Xwarning( s )
Xchar
X    *s;
X{
X    if( !wignore ) {
X	fprintf( stderr, "WARNING: %s", s );
X	if( t_type != EOF )
X	    fprintf( stderr, "File \"%s\", line %d, token \"%s\"\n",
X		       inname, numline, token );
X	fflush( stderr );
X    }
X    numwarn++;
X}
X
X
X	/***************************************************************\
X	*								*
X	*	fatal( s ) - print the message FATAL ERROR: s and	*
X	*	exit the program.					*
X	*								*
X	\***************************************************************/
X
Xfatal( s )
Xchar
X    *s;
X{
X    fprintf( stderr, "FATAL ERROR: %s", s );
X    fputs( "ADL aborting.\n", stderr );
X    breaker();
X}
X
X/*** EOF adlmsg.c ***/
END_OF_adlcomp/adlmsg.c
if test 3180 -ne `wc -c <adlcomp/adlmsg.c`; then
    echo shar: \"adlcomp/adlmsg.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f adlcomp/codegen.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"adlcomp/codegen.c\"
else
echo shar: Extracting \"adlcomp/codegen.c\" \(2485 characters\)
sed "s/^X//" >adlcomp/codegen.c <<'END_OF_adlcomp/codegen.c'
X	/***************************************************************\
X	*								*
X	*	codegen.c - routines to generate appropriate ADL	*
X	*	stack machine instructions.				*
X	*	Copyright 1987 by Ross Cunniff.				*
X	*								*
X	\***************************************************************/
X
X#include <stdio.h>
X
X#include "adltypes.h"
X#include "virtmem.h"
X#include "adldef.h"
X
Xaddress
X    numcode = 1;		/* Number of bytes of code written	*/
X
Xextern struct pagetab
X    codetab;			/* Code paging table.			*/
X
X	/***************************************************************\
X	*								*
X	*	oldcode( addr, opcode, opnd ) - Emits instruction	*
X	*	opcode opnd at address addr.  Compresses the instr.	*
X	*	if possible.						*
X	*								*
X	\***************************************************************/
X
Xaddress
Xoldcode( addr, opcode, opnd )
Xaddress
X    addr;
Xint16
X    opnd;
Xchar
X    opcode;
X{
X    int16
X	num;
X
X    switch( opcode ) {
X	case PUSH :
X	    if( (opnd >= -127) && (opnd <= 0) ) {
X		opcode = PUSHN | (char)(opnd & 0x07F);
X		num = 1;
X	    }
X	    else if( (opnd >= -1024) && (opnd <= 1023) ) {
X		opcode = PUSHS | (char)((opnd >> 8) & 0x03F);
X		opnd &= 0x0FF;
X		num = 2;
X	    }
X	    else
X		num = 3;
X	   break;
X	case PUSHARG :
X	case PUSHLOCL :
X	case CALL :
X	    opcode |= (char)(opnd & 0x01F);
X	case NOP :
X	case POP :
X	case PUSHME :
X	case RET :
X	    num = 1;
X	    break;
X	case JMP :
X	case JMPZ : 
X	case FILEN :
X	case LINEN :
X	    num = 3;
X	    break;
X    }
X    vm_put8( opcode, (int32)(addr++), &codetab );
X    switch( num ) {
X	case 1 :
X	    break;
X	case 2 :
X	    vm_put8( (char)(opnd & 0x0ff), (int32)addr, &codetab );
X	    break;
X	case 3 :
X	    vm_put16( (int16)(opnd & 0x0ffff), (int32)addr, &codetab );
X	    break;
X    }
X    return (address)num;
X}
X
X
X	/***************************************************************\
X	*								*
X	*	newcode( opcode, opnd ) - emit instruction opcode opnd	*
X	*	at the current address in the code file.		*
X	*								*
X	\***************************************************************/
X
Xaddress
Xnewcode( opcode, opnd )
Xchar
X    opcode;
Xint16
X    opnd;
X{
X    address
X	nc_save;
X
X    nc_save = numcode;
X    numcode += oldcode( numcode, opcode, opnd );
X    return nc_save;
X}
X
X
X	/***************************************************************\
X	*								*
X	*	currcode() - returns the current code address.		*
X	*								*
X	\***************************************************************/
X
Xaddress
Xcurrcode()
X{
X    return numcode;
X}
X
X/*** EOF codegen.c ***/
END_OF_adlcomp/codegen.c
if test 2485 -ne `wc -c <adlcomp/codegen.c`; then
    echo shar: \"adlcomp/codegen.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f adlrun/adldwim.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"adlrun/adldwim.c\"
else
echo shar: Extracting \"adlrun/adldwim.c\" \(3387 characters\)
sed "s/^X//" >adlrun/adldwim.c <<'END_OF_adlrun/adldwim.c'
X#include <stdio.h>
X
X#include "adltypes.h"
X#include "adlprog.h"
X#include "adlrun.h"
X
X
Xint16
Xdwimmer( rp, obj )
Xint16
X    rp,
X    obj;
X{
X    bp = sp = NUMVAR;			/* Trim the stack */
X    push( 2 );				/* Push the stackdepth */
X    push( obj );			/* Push the object */
X    push( NUMVAR );			/* Push the bp */
X    ip = 0;
X    puship();				/* Push the ip */
X    if( !(ip = routspace[ rp ]) ) {
X	/* No dwimmer, so we fail. */
X	bp = sp = NUMVAR;
X	return 0;
X    }
X    runprog();				/* Run the dwimmer */
X    return stack[ NUMVAR ];		/* Return the retval */
X}
X
X
Xdwimerror( n )
Xint16
X    n;
X{
X    switch( n ) {
X	case 1 :
X	    sayer( "You will have to be more specific.\n" );
X	    break;
X	case 2 :
X	    sayer( "You don't see anything like that.\n" );
X	    break;
X    }
X}
X
X
Xint16
Xdwimadj( which, adj )
Xint16
X    which,
X    adj;
X{
X    int16
X	i, tsave;
X
X    tsave = 0;
X    for( i = 0; i < NUMOBJ; i++ ) {
X	if( objspace[ i ].adj == adj ) {
X	    if( dwimmer( which, i ) ) {
X		if( tsave ) {
X		    dwimerror( 1 );
X		    return -1;
X		}
X		else
X		    tsave = i;
X	    }
X	}
X    }
X
X    if( !tsave ) {
X	dwimerror( 2 );
X	return -1;
X    }
X    else
X	return tsave;
X}
X
X
Xint16
Xdwimnoun( which, noun )
Xint16
X    which,
X    noun;
X{
X    int16
X	i, tsave;
X
X    tsave = 0;
X    for( i = nounspace[ noun ]; i != 0; i = objspace[ i ].others ) {
X	if( dwimmer( which, i ) ) {
X	    if( tsave ) {
X		dwimerror( 1 );
X		return -1;
X	    }
X	    else
X		tsave = i;
X	}
X    }
X
X    if( !tsave ) {
X	dwimerror( 2 );
X	return -1;
X    }
X    else
X	return tsave;
X}
X
X
Xdwimi()
X{
X    int16
X	t;
X
X    if( SET_EXIT( 0 ) != 0 )
X	return -1;
X
X    if( Inoun < 0 ) {
X	/* Copy the string index */
X	Iobj = Inoun;
X	return 0;
X    }
X    if( (Inoun == 0) && (Imod == 0) )
X	/* Preserve the old Iobj */
X	return 0;
X    if( Imod != 0 ) {
X	/* The player typed a modifier */
X	if( Inoun ) {
X	    /* The player also typed a noun */
X	    if( (Iobj = noun_exists( Imod, Inoun )) < 0 ) {
X		/* Oops - no such mod-noun pair */
X		dwimerror( 2 );
X		return -1;
X	    }
X	}
X	else {
X	    /* The player typed no noun */
X	    if( (Iobj = dwimadj( _DWIMI, Imod )) < 0 )
X		/* Oops - the modifier wasn't sufficient */
X		return -1;
X	}
X    }
X    else {
X	/* The player typed a noun, but no modifier */
X	if( (t = noun_exists( 0, Inoun )) < 0 ) {
X	    /* There is no unmodified object with noun Inoun */
X	    if( (Iobj = dwimnoun( _DWIMI, Inoun )) < 0 )
X		/* Oops - the noun wasn't sufficient */
X		return -1;
X	}
X	else
X	    /* Everything is fine. */
X	    Iobj = t;
X    }
X    return 0;
X}
X
X
Xdwimd()
X{
X    int16
X	i, t;
X
X    if( SET_EXIT( 0 ) != 0 )
X	return -1;
X
X    for( i = 0; i < NumDobj; i++ ) {
X	if( Dnoun[ i ] < 0 ) {		/* User typed a string */
X	    Dobj[ i ] = Dnoun[ i ];
X	    continue;
X	}
X	if( Dmod[ i ] != 0 ) {
X	    /* The player typed a modifier */
X	    if( Dnoun[ i ] ) {
X		/* The player typed a noun */
X		if( (Dobj[ i ] = noun_exists( Dmod[ i ], Dnoun[ i ] )) < 0 ) {
X		    /* No such mod-noun pair exists */
X		    dwimerror( 2 );
X		    return -1;
X		}
X	    }
X	    else if( (Dobj[ i ] = dwimadj( _DWIMD, Dmod[ i ] )) < 0 ) {
X		return -1;
X	    }
X	}
X	else if( (t = noun_exists( 0, Dnoun[ i ] )) < 0 ) {
X	    /* An object with noun Dnoun[ i ] and mod 0 doesn't exist */
X	    if( (Dobj[ i ] = dwimnoun( _DWIMD, Dnoun[ i ] )) < 0 ) {
X		return -1;
X	    }
X	}
X	else
X	    /* An object with noun Dnoun[ i ] and mod 0 DOES exist */
X	    Dobj[ i ] = t;
X    }
X    return 0;
X}
X
X/*** EOF adldwim.c ***/
END_OF_adlrun/adldwim.c
if test 3387 -ne `wc -c <adlrun/adldwim.c`; then
    echo shar: \"adlrun/adldwim.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f adlrun/adlerr.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"adlrun/adlerr.c\"
else
echo shar: Extracting \"adlrun/adlerr.c\" \(2212 characters\)
sed "s/^X//" >adlrun/adlerr.c <<'END_OF_adlrun/adlerr.c'
X#include <stdio.h>
X
X#include "adltypes.h"
X#include "vstring.h"
X
Xint16
X    foundfile,
X    filenum,
X    linenum;
Xextern int16
X    ip;
X
X
Xerror( num )
Xint
X    num;
X{
X#if DEBUG
X    char
X	*msg;
X    switch( num ) {
X	case 1 : msg = "Divide by zero";			break;
X	case 2 : msg = "Too few arguments";			break;
X	case 3 : msg = "Illegal builtin routine";		break;
X	case 4 : msg = "Illegal routine for $sdem";		break;
X	case 5 : msg = "Illegal routine for $sfus";		break;
X	case 6 : msg = "Illegal routine for $prompt";		break;
X	case 7 : msg = "Illegal object for $actor";		break;
X	case 8 : msg = "Stack overflow";			break;
X	case 9 : msg = "Stack underflow";			break;
X	case 10: msg = "Illegal routine call";			break;
X	case 11: msg = "Illegal instruction";			break;
X	case 12: msg = "Illegal routine call";			break;
X	case 13: msg = "Illegal global for $glob";		break;
X	case 14: msg = "Illegal global for $setg";		break;
X	case 15: msg = "Illegal object for $setp";		break;
X	case 16: msg = "Illegal propnum for $setp";		break;
X	case 17: msg = "Illegal object for $move";		break;
X	case 18: msg = "Illegal object for $prop";		break;
X	case 19: msg = "Illegal promnum for $prop";		break;
X	case 20: msg = "Illegal verb for $vset";		break;
X	case 21: msg = "Illegal propnum for $vset";		break;
X	case 22: msg = "Illegal verb for $vprop";		break;
X	case 23: msg = "Illegal propnum for $vprop";		break;
X	case 24: msg = "Illegal parameter for $spec";		break;
X	case 25: msg = "Illegal object for $name";		break;
X	case 26: msg = "Illegal rout for $miss";		break;
X	case 27: msg = "Out of memory";				break;
X	case 28: msg = "Illegal exitcode";			break;
X	case 29: msg = "Insufficient terminal definition";	break;
X	case 30: msg = "Illegal object for $sfus";		break;
X	case 31: msg = "Illegal actor for $spec 11";		break;
X	case 32: msg = "Unable to open tty";			break;
X	case 33: msg = "Illegal actor for $spec 12";		break;
X	default: msg = "Unknown error number";
X    }
X    fputs( msg, stderr );
X#else
X    fprintf( stderr, "Error #%d", num );
X#endif
X    if( foundfile )
X	fprintf( stderr, ", file \"%s\", line %d",
X		virtstr( filenum ), linenum );
X    fprintf( stderr, ", ip = %ld\n", (long)ip );
X    head_term();
X    exit( num );
X}
X
X/*** EOF adlerr.c ***/
END_OF_adlrun/adlerr.c
if test 2212 -ne `wc -c <adlrun/adlerr.c`; then
    echo shar: \"adlrun/adlerr.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f adlrun/adlintrn.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"adlrun/adlintrn.c\"
else
echo shar: Extracting \"adlrun/adlintrn.c\" \(3037 characters\)
sed "s/^X//" >adlrun/adlintrn.c <<'END_OF_adlrun/adlintrn.c'
X#include <stdio.h>
X
X#include "adltypes.h"
X#include "adlprog.h"
X#include "builtins.h"
X#include "vstring.h"
X#include "adlrun.h"
X
X
Xsetdemon()
X{
X    assertargs( "$sdem", 1 );
X    if( (ARG( 1 ) < 0) || (ARG( 1 ) > NUMROUT) )
X	error( 4 );			/* Illegal routine for $sdem */
X    demons[ numd++ ] = ARG( 1 );
X}
X
X
Xdeldemon()
X{
X    int16
X	i;	/* Loop counter */
X
X    assertargs( "$ddem", 1 );
X    for( i = 0; i < numd; i++ )
X	if( demons[ i ] == ARG( 1 ) )
X	    break;
X    if( i < numd ) {
X	numd--;
X	for( ; i < numd; i++ )
X	    demons[ i ] = demons[ i + 1 ];
X    }
X}
X
X
Xsetfuse()
X{
X    assertargs( "$sfus", 3 );	/* ($sfus actor rout nturns) */
X    if( (ARG( 1 ) < 0) || (ARG( 1 ) > NUMOBJ) )
X	error( 30 );			/* Illegal actor for $sfus */
X    if( (ARG( 2 ) < 0) || (ARG( 2 ) > NUMROUT) )
X	error( 5 );			/* Illegal routine for $sfus */
X    if( !routspace[ ARG( 2 ) ] )
X	return;				/* Don't bother with a null fuse */
X    f_actors[ numf ] = ARG( 1 );
X    fuses[ numf ] = ARG( 2 );
X    ftimes[ numf++ ] = currturn + ARG( 3 );
X}
X
X
Xdelfuse( act, which )
Xint16
X    act,
X    which;
X{
X    int16
X	i;	/* Loop counter */
X
X    for( i = 0; i < numf; i++ )
X	if( (fuses[ i ] == which) && (f_actors[ i ] == act) )
X	    break;
X    if( i < numf ) {
X	numf--;
X	for( ; i < numf; i++ ) {
X	    fuses[ i ] = fuses[ i + 1 ];
X	    ftimes[ i ] = ftimes[ i + 1 ];
X	    f_actors[ i ] = f_actors[ i + 1 ];
X	}
X    }
X}
X
X
Xincturn()
X{
X    if( ARG( 0 ) == 2 )
X	/* The programmer specified an increment */
X	currturn += ARG( 1 );
X    else
X	/* The default increment is 1 */
X	currturn++;
X    execfuses();
X}
X
X
Xretturn()
X{
X    RETVAL = currturn;
X}
X
X
Xdoprompt()
X{
X    assertargs( "$prompt", 1 );
X    if( (ARG( 1 ) < 0) || (ARG( 1 ) > NUMROUT) )
X	error( 6 );		/* Illegal routine for $prompt */
X    prompter = ARG( 1 );
X}
X
X
Xsetactor()
X{
X    assertargs( "$actor", 3 );
X    if( (ARG( 1 ) < 2) || (ARG( 1 ) > NUMOBJ) )
X	error( 7 );		/* Illegal object for $actor */
X    if( numact <  10 ) {
X	actlist[ numact ].actor = ARG( 1 );
X	actlist[ numact ].linebuf = actlist[ numact ].savebuf;
X	actlist[ numact ].interact = ARG( 3 );
X	if( ARG( 2 ) ) {
X	    strncpy( actlist[ numact ].linebuf, virtstr( ARG( 2 ) ), SLEN - 1 );
X	    actlist[ numact ].savebuf[ 79 ] = '\0';
X	}
X	else
X	    *actlist[ numact ].linebuf = '\0';
X	numact++;
X    }
X    else {
X	printf( "Too many actors in actlist, ip = %ld.\n", ip );
X	head_term();
X	exit( -1 );
X    }
X}
X
X
Xdelactor( n )
Xint16
X    n;
X{
X    int16
X	i;	/* Loop counter */
X
X    for( i = 0; i < numact; i++ ) {
X	if( actlist[ i ].actor == n ) {
X	    numact--;
X#if MULTIPLEX
X	    if( actlist[ i ].ttyfile != (FILE *)0 ) {
X		fclose( actlist[ i ].ttyfile );
X		actlist[ i ].ttyfile = (FILE *)0;
X	    }
X#endif
X	    for( ; i < numact; i++ ) {
X		actlist[ i ].actor = actlist[ i + 1 ].actor;
X		strcpy( actlist[ i ].savebuf, actlist[ i + 1 ].linebuf );
X		actlist[ i ].linebuf = actlist[ i ].savebuf;
X#if MULTIPLEX
X		actlist[ i ].ttyfile = actlist[ i + 1 ].ttyfile;
X		strcpy( actlist[ i ].ttyname, actlist[ i + 1 ].ttyname );
X#endif
X	    }
X	    return;
X	}
X    }
X}
X
X/*** EOF adlintrn.c ***/
END_OF_adlrun/adlintrn.c
if test 3037 -ne `wc -c <adlrun/adlintrn.c`; then
    echo shar: \"adlrun/adlintrn.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f adlrun/adlmacro.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"adlrun/adlmacro.c\"
else
echo shar: Extracting \"adlrun/adlmacro.c\" \(1516 characters\)
sed "s/^X//" >adlrun/adlmacro.c <<'END_OF_adlrun/adlmacro.c'
X#include <stdio.h>
X
X#include "adltypes.h"
X#include "adlprog.h"
X#include "adlrun.h"
X
Xstruct	macro
X    *mactab;
X
Xextern char
X    *calloc();
X
Xdefine( str1, str2 )
Xchar
X    *str1,
X    *str2;
X{
X    struct macro
X	*temp;
X
X    temp = (struct macro *)calloc( sizeof( struct macro ), 1 );
X    if( temp == (struct macro *)0 )
X	error( 27 );			/* Out of memory */
X
X    temp->next = mactab;
X    mactab = temp;
X    strcpy( mactab->name, str1 );
X    strcpy( mactab->val, str2 );
X}
X
X
Xint16
Xnummacro()
X{
X    int16
X	count;
X    struct macro
X	*m;
X
X    count = 0;
X    for( m = mactab; m; m = m->next )
X	count++;
X    return count;
X}
X
X
Xundef( str )
Xchar
X    *str;
X{
X    struct macro
X	*which,
X	*last;
X
X    if( !mactab )		/* No macros defined */
X	return;
X    if( !strcmp( mactab->name, str ) ) {	/* First entry is the one we want */
X	which = mactab;
X	mactab = mactab->next;
X	free( mactab );
X	return;
X    }
X    which = mactab->next;
X    last = mactab;
X    while( which ) {
X	if( !strcmp( which->name, str ) ) {
X	    last->next = which->next;
X	    free( which );
X	    return;
X	}
X	last = which;
X	which = which->next;
X    }
X}
X
X
Xchar	*
Xexpand( str )
Xchar
X    *str;
X{
X  struct macro
X	*which;
X
X    which = mactab;
X    while( which ) {
X	if( !strcmp( which->name, str ) )
X	    return which->val;
X	which = which->next;
X    }
X    return str;
X}
X
X
Xclearmacro()
X{
X    struct macro
X	*which, *temp;
X
X    which = mactab;
X    while( which ) {
X	temp = which->next;
X	free( which );
X	which = temp;
X    }
X    mactab = (struct macro *)0;
X}
X
X/*** EOF adlmacro.c ***/
END_OF_adlrun/adlmacro.c
if test 1516 -ne `wc -c <adlrun/adlmacro.c`; then
    echo shar: \"adlrun/adlmacro.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f adlrun/adlobjr.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"adlrun/adlobjr.c\"
else
echo shar: Extracting \"adlrun/adlobjr.c\" \(2864 characters\)
sed "s/^X//" >adlrun/adlobjr.c <<'END_OF_adlrun/adlobjr.c'
X#include <stdio.h>
X
X#include "adltypes.h"
X#include "adlprog.h"
X#include "builtins.h"
X#include "adlrun.h"
X
X
Xsetp()
X{
X    int16
X	a, b;		/* Arg1, arg2 */
X
X    assertargs( "$setp", 3 );
X    a = ARG( 1 );
X    b = ARG( 2 );
X    if( (a < 0) || (a > NUMOBJ) )
X	error( 15 );	/* Illegal object for $setp */
X    if( (b < 1) || (b > _ACT) )
X	error( 16 );	/* Illegal propnum for $setp */
X    if( (b >= 1) && (b <= 16) ) {
X	if( ARG( 3 ) )
X	    objspace[ a ].props1to16 |= bitpat[ b - 1 ];
X	else
X	    objspace[ a ].props1to16 &= ibitpat[ b - 1 ];
X    }
X    else if( (b >= 17) && (b <= _ACT) )
X	objspace[ a ].props[ b - 17 ] = ARG( 3 );
X}
X
X
Xmove_obj()
X{
X    int16
X	a, b, t;	/* Arg1, arg2, temp */
X
X    assertargs( "$move", 2 );
X    a = ARG( 1 );
X    b = ARG( 2 );
X    if( (a < 0) || (b < 0) || (a > NUMOBJ) || (b > NUMOBJ) )
X	error( 17 );	/* Illegal object for $move */
X    t = objspace[ a ].loc;
X    if( objspace[ t ].cont != a ) {
X	t = objspace[ t ].cont;
X	while( objspace[ t ].link != a )
X	    t = objspace[ t ].link;
X	objspace[ t ].link = objspace[ objspace[ t ].link ].link;
X    }
X    else
X	objspace[ t ].cont = objspace[ objspace[ t ].cont ].link;
X    objspace[ a ].loc = b;
X    objspace[ a ].link = 0;
X    t = objspace[ b ].cont;
X    if( t ) {
X	while( objspace[ t ].link )
X	    t = objspace[ t ].link;
X	objspace[ t ].link = a;
X    }
X    else
X	objspace[ b ].cont = a;
X}
X
X
Xobjprop( n )
Xint16
X    n;
X{
X    assertargs( "$prop", 1 );
X    if( (ARG( 1 ) < 0) || (ARG( 1 ) > NUMOBJ) )
X	error( 18 );	/* Illegal object for $prop */
X    if( (n >= 1) && (n <= 16) ) {
X	if( objspace[ ARG( 1 ) ].props1to16 & bitpat[ n - 1 ] )
X	    RETVAL = 1;
X	else
X	    RETVAL = 0;
X    }
X    else if( (n >= 17) && (n <= _ACT) )
X	RETVAL = objspace[ ARG( 1 ) ].props[ n - 17 ];
X    else
X	switch( n ) {
X	    case _LOC :
X		RETVAL = objspace[ ARG( 1 ) ].loc;
X		break;
X	    case _CONT :
X		RETVAL = objspace[ ARG( 1 ) ].cont;
X		break;
X	    case _LINK :
X		RETVAL = objspace[ ARG( 1 ) ].link;
X		break;
X	    case _MODIF :
X		RETVAL = objspace[ ARG( 1 ) ].adj;
X		break;
X	    default :
X		error( 19 );		/* Illegal promnum for $prop */
X	}
X}
X
X
Xvset()
X{
X    assertargs( "$vset", 3 );
X    if( (ARG( 1 ) < 0) || (ARG( 1 ) > NUMVERB) )
X	error( 20 );		/* Illegal verb for $vset */
X    switch( ARG( 2 ) ) {
X	case _PREACT :
X	    verbspace[ ARG( 1 ) ].preact = ARG( 3 );
X	    break;
X	case _ACT :
X	    verbspace[ ARG( 1 ) ].postact = ARG( 3 );
X	    break;
X	default	 :
X	    error( 21 );		/* Illegal propnum for $vset */
X    }
X}
X
X
Xvprop()
X{
X    assertargs( "$vprop", 2 );
X    if( (ARG( 1 ) < 0) || (ARG( 1 ) > NUMVERB) )
X	error( 22 );		/* Illegal verb for $vprop */
X    switch( ARG( 2 ) ) {
X	case _PREACT :
X	    RETVAL = verbspace[ ARG( 1 ) ].preact;
X	    break;
X	case _ACT :
X	    RETVAL = verbspace[ ARG( 1 ) ].postact;
X	    break;
X	default :
X	    error( 23 );		/* Illegal propnum for $vprop */
X    }
X}
X
X/*** EOF adlobjr.c ***/
END_OF_adlrun/adlobjr.c
if test 2864 -ne `wc -c <adlrun/adlobjr.c`; then
    echo shar: \"adlrun/adlobjr.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f include/adlcomp.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"include/adlcomp.h\"
else
echo shar: Extracting \"include/adlcomp.h\" \(2389 characters\)
sed "s/^X//" >include/adlcomp.h <<'END_OF_include/adlcomp.h'
X	/***************************************************************\
X	*								*
X	*	adlcomp.h - variable, function, and macro definitions	*
X	*	for use by adlcomp.					*
X	*								*
X	\***************************************************************/
X
X
Xextern char
X    token[],			/* Current token found by lexer		*/
X    inname[];			/* Name of the current input file	*/
X
Xextern int16
X    t_val,			/* Val of token from dict		*/
X    t_type,			/* Type of token from dict		*/
X    numerr,			/* Number of errors found so far	*/
X    numwarn,			/* Number of warnings found so far	*/
X    numline,			/* Number of lines encountered		*/
X    wignore,			/* Ignore warnings?			*/
X    maxerr;			/* Maximum number of errors allowed	*/
X
Xextern char
X    *BAD_ARRAY,			/* Array size too small			*/
X    *BRACKET_EXPECTED,		/* ']' expected				*/
X    *LEFT_EXPECTED,		/* '(' expected				*/
X    *RIGHT_EXPECTED,		/* ')' expected				*/
X    *SEMI_EXPECTED,		/* ';' expected				*/
X    *COMMA_EXPECTED,		/* ',' expected				*/
X    *NOUN_WANTED,		/* Noun expected in expression		*/
X    *CONST_EXPECTED,		/* Constant expected in expression	*/
X    *VAR_EXPECTED,		/* VAR expected in expression		*/
X    *EQUAL_EXPECTED,		/* '=' expected				*/
X    *PREP_EXPECTED,		/* Prep expected in expression		*/
X    *ATTEMPT,			/* Attempt to redefine a noun		*/
X    *ILLEGAL_SYMBOL;		/* Illegal symbol (syntax error)	*/
X
Xextern int16
X    bitpat[],			/* Bit masks for bit properties		*/
X    ibitpat[];			/* Same as above, but inverted.		*/
X
Xextern int
X    CODE_F;			/* Temporary file for paging code	*/
X
Xextern int
X    breaker();			/* Exit from ADLCOMP after fixing files	*/
X
X/* From codegen.c */
Xextern address
X    newcode(),			/* Add a new instruction to CODE_F	*/
X    oldcode(),			/* Modify an old instruction		*/
X    currcode();			/* Return the current end of CODE_F	*/
X
X/* From adlobj.c */
Xextern int16
X    getnew(),			/* Get an undeclared object from input	*/
X    getold(),			/* Get previously declared obj from input */
X    noun_exists(),		/* Does an object exist with the specified
X				   modifier and noun? */
X/* From dict.c */
X    lookup(),			/* Find the type and value of a token	*/
X    insertkey();		/* Make a new token, given type and val	*/
X
X/* Error macros */
X#define _ERR_FIX( str, ch )	{ error( str ); eatuntil( ch ); return; }
X#define _ERR_FX0( str, ch )	{ error( str ); eatuntil( ch ); return 0; }
X
X/*** EOF adlcomp.h ***/
END_OF_include/adlcomp.h
if test 2389 -ne `wc -c <include/adlcomp.h`; then
    echo shar: \"include/adlcomp.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f include/adldef.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"include/adldef.h\"
else
echo shar: Extracting \"include/adldef.h\" \(1847 characters\)
sed "s/^X//" >include/adldef.h <<'END_OF_include/adldef.h'
X/* Token types */
X
X
X#define MIN_LEGAL	400	/* Lower bound of types that can appear
X				   in an ADL expression */
X#define ROUTINE		400
X#define CONST		401
X#define VAR		402
X#define ARGUMENT	403
X#define LOCAL		404
X
X#define MIN_RT		405	/* Lower bound of types that can appear
X				   in an ADL sentence */
X#define PREP		405
X#define VERB		406
X#define STRING		407
X#define ADJEC		408
X#define NOUN		409
X#define NOUN_SYN	410
X
X#define MAX_LEGAL	410	/* Upper bound of types that can appear
X				   in an ADL expression */
X#define ARTICLE		411
X#define ART		411
X#define	CONJ		412
X#define COMMA		413
X#define	SEP		414
X
X#define MAX_RT		413	/* Upper bound of types that can appear
X				   in an ADL sentence */
X#define MYVAL		414	/* .ME */
X#define UNDECLARED	415
X
X
X/* Control statements */
X
X#define IF		500
X#define THEN		501
X#define ELSEIF		502
X#define ELSE		503
X#define WHILE		504
X#define DO		505
X
X
X/* Declaration statements */
X
X#define	MIN_D		600
X
X#define ROUT_D		600
X#define VERB_D		601
X#define ADJEC_D		602
X#define ART_D		603
X#define PREP_D		604
X
X#define MAX_D		604
X
X#define VAR_D		605
X#define LOCAL_D		606
X#define NOUN_D		607
X#define INCLUDE		608
X#define MESSAGE		609
X
X
X/* stack machine opcodes */
X
X#define NOP	0x00		/* 00000000			*/
X#define PUSHME	0x01		/* 00000001			*/
X#define POP	0x02		/* 00000010			*/
X#define RET	0x03		/* 00000011			*/
X#define FILEN	0x04		/* 00000100 ........ ........	*/
X#define LINEN	0x05		/* 00000101 ........ ........	*/
X#define PUSH	0x06		/* 00000110 ........ ........	*/
X#define ILLEGAL	0x07		/* 00000111			*/
X#define PUSHS	0x08		/* 00001... ........		*/
X#define JMP	0x10		/* 00010... ........ ........	*/
X#define JMPZ	0x18		/* 00011... ........ ........	*/
X#define PUSHARG	0x20		/* 001.....			*/
X#define CALL	0x40		/* 001.....			*/
X#define PUSHLOCL 0x60		/* 001.....			*/
X#define PUSHN	0x80		/* 1.......			*/
X
X/*** EOF adldef.h ***/
END_OF_include/adldef.h
if test 1847 -ne `wc -c <include/adldef.h`; then
    echo shar: \"include/adldef.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f include/adltypes.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"include/adltypes.h\"
else
echo shar: Extracting \"include/adltypes.h\" \(2905 characters\)
sed "s/^X//" >include/adltypes.h <<'END_OF_include/adltypes.h'
X/* Undefine any predefined things */
X#ifdef HPUX
X#	undef HPUX
X#endif
X
X#ifdef MSDOS
X#	undef MSDOS
X#endif
X
X#ifdef BSD
X#	undef BSD
X#endif
X
X#ifdef AMIGA
X#	undef AMIGA
X#endif
X
X#ifdef PCC
X#	undef PCC
X#endif
X
X#ifdef LATTICE
X#	undef LATTICE
X#endif
X
X#ifdef DEBUG
X#	undef DEBUG
X#endif
X
X#ifdef HPTERM
X#	undef HPTERM
X#endif
X
X#ifdef ANSI
X#	undef ANSI
X#endif
X
X#ifdef TERMCAP
X#	undef TERMCAP
X#endif
X
X#ifdef UNIX
X#	undef UNIX
X#endif
X
X#ifdef MULTIPLEX
X#	undef MULTIPLEX
X#endif
X
X
X	/***************************************************************\
X	*								*
X	*	The following #defines configure the ADL system for	*
X	*	local machine architectures and operating systems.	*
X	*	Read them carefully, then appropriately define the	*
X	*	constants.  If your system doesn't exist here, make	*
X	*	up a new name and create a new set of typedefs		*
X	*	and system-dependant #defines for that system.		*
X	*								*
X	\***************************************************************/
X
X#define HPUX	1		/* HP-UX or SysIII or SysV UN*X	*/
X#define MSDOS	0		/* MS-DOS 2.1 or greater	*/
X#define BSD	0		/* BSD 4.2 or greater		*/
X#define AMIGA	0		/* Amiga computer		*/
X
X/* Language defines */
X#define PCC	1		/* UN*X-style C compiler	*/
X#define LATTICE 0		/* Lattice C			*/
X
X/* Utility defines */
X#define DEBUG	1		/* Debugging in ADLRUN		*/
X
X/* Terminal defines */
X#define HPTERM	0		/* HP terminal I/O		*/
X#define ANSI	0		/* ANSI terminal I/O		*/
X#define TERMCAP	1		/* Termcap I/O			*/
X
X/* The following is UNTESTED - do not use it! */
X#define MULTIPLEX 0		/* Allow multiplexing of terminals? */
X
X
X/* The following is for BSD-like systems - it allows for the
X   execution of an ADL binary directly.  Change it to reflect
X   where adlrun lives on your system.
X*/
X
X#ifndef ADL_NAME
X#	define ADL_NAME "/users/cunniff/bin/adlrun"
X#endif
X
X
X/* The following is the character which is used to obfuscate strings */
X#define CODE_CHAR 0xff
X
X#if HPUX
X#  define	UNIX 1
X   typedef	short	int16;
X   typedef	long	int32;
X   typedef	unsigned short address;
X#  define	SRAND	srand
X#  define	RAND	rand()
X#  define	RB	O_RDWR
X#  define	WB	(O_RDWR | O_CREAT | O_TRUNC)
X#endif
X
X#if BSD
X#  define	UNIX	1
X   typedef	short			int16;
X   typedef	long			int32;
X   typedef	unsigned short		address;
X#  define	SRAND	srandom
X#  define	RAND	random()
X#  define	RB	O_RDWR
X#  define	WB	(O_RDWR | O_CREAT | O_TRUNC)
X#endif
X
X#if AMIGA
X#  define	UNIX	0
X   typedef	short			int16;
X   typedef	long			int32;
X   typedef	unsigned short		address;
X#  define	SRAND	srand
X#  define	RAND	rand()
X#  define	time	mytime
X#  define	RB	O_RDWR
X#  define	WB	(O_RDWR | O_CREAT | O_TRUNC)
X#endif
X
X#if MSDOS
X#  define	UNIX			0
X#  define	int16			int
X#  define	int32			long
X#  define	address			unsigned
X#  define	SRAND			srand
X#  define	RAND			rand()
X#  define	time			mytime
X#  define	RB			(O_RDWR | O_RAW)
X#  define	WB			(O_RDWR | O_CREAT | O_TRUNC | O_RAW)
X#  define	void			int
X#endif
X
X/*** EOF adltypes.h ***/
END_OF_include/adltypes.h
if test 2905 -ne `wc -c <include/adltypes.h`; then
    echo shar: \"include/adltypes.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f man/adlcomp.6 -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"man/adlcomp.6\"
else
echo shar: Extracting \"man/adlcomp.6\" \(3409 characters\)
sed "s/^X//" >man/adlcomp.6 <<'END_OF_man/adlcomp.6'
X
X
X
X     ADLCOMP(6)			    (HP)		    ADLCOMP(6)
X
X
X
X
X     NAME
X	  adlcomp  -  compile an ADL program
X
X     SYNOPSIS
X	  adlcomp file [ -o outfile ] [	-idir ]	[ -tdir	] [ -d ] [-w ]
X	  [  -en  ]  [ -gn ] [ -mn ] [ -nn ] [ -pn ] [ -rn ] [ -sn ] [
X	  -vn ]
X
X     DESCRIPTION
X	  Adlcomp reads	an ADL	program	 from  file  and  produces  an
X	  output  file which contains the tables and interpretive code
X	  necessary to play the	game described by the  program	(using
X	  adlrun(6)).	Error  messages	 are  produced on the standard
X	  error	output,	and a data summary is produced on the standard
X	  output.  The following options are available:
X
X	  -o outfile  The  result  of  the  compilation	 is  saved  in
X		      outfile.	 The result is saved in	adlcomp.out in
X		      the current directory  if	 this  option  is  not
X		      specified.
X
X	  -idir	      INCLUDE files are	 searched  for	first  in  the
X		      current directory, then in directories specified
X		      by -i dir	options.  Up to	4 -i  options  may  be
X		      present.
X
X	  -tdir	      Adlcomp  writes  two  temporary  files  in   the
X		      process	of  compilation.   This	 option	 tells
X		      adlcomp  which  directory	 (or  disk,  on	 those
X		      systems	which  allow  it)  to  use  for	 these
X		      temporary	files.	The default is "/tmp" on  UN*X
X		      operating	 systems, "RAM:" on the	Amiga, and the
X		      current directory	on MS-DOS.
X
X	  -d	      Puts adlcomp into	debugging mode.	  All  symbols
X		      are  written out to outfile, and additional code
X		      is produced which	keeps track of the  file  name
X		      and line number.	-d implies -w.
X
X	  -w	      Suppress the printing of warning messages.
X
X	  -en	      Sets the maximum number of  errors  to  n.   The
X		      default  is  -1  (no maximum).  If the number of
X		      errors encountered is greater  than  n,  adlcomp
X		      aborts.
X
X	  -gn	      Sets the maximum number of globals  to  n.   The
X		      default value is 64.
X
X	  -mn	      Sets the maximum	number	of  messages  (strings
X		      enclosed	in  double  quotes) to n.  The default
X
X
X
X     Hewlett-Packard Company	   - 1 -		  Jun 18, 1987
X
X
X
X
X
X
X     ADLCOMP(6)			    (HP)		    ADLCOMP(6)
X
X
X
X
X		      value is 1024.
X
X	  -nn	      Sets the maximum number  of  NOUNs  to  n.   The
X		      default value is 256.
X
X	  -pn	      Sets the maximum number of preposition  synonyms
X		      to n.  The default value is 8.
X
X	  -rn	      Sets the maximum number of routines to  n.   The
X		      default value is 512.
X
X	  -sn	      Sets the maximum number of verb  phrases	to  n.
X		      The default value	is 8.
X
X	  -vn	      Sets the maximum number  of  verbs  to  n.   The
X		      default value is 128.
X
X     CONFORMANCE
X	  This	version	 of  adlcomp  has  a  255-character  limit  on
X	  compile-time	 strings.   It	implements  Pascal-like	 LOCAL
X	  variables.
X
X     EXAMPLE
X	  adlcomp aard.adl -o aard -w
X
X     FILES
X	  adlsval.tmp
X	       String paging file
X
X	  adlcode.tmp
X	       Instruction paging file
X
X	  *.adl
X	       ADL source files
X
X     WARNING
X	  On Amiga computers, the stack	should	be  set	 to  at	 least
X	  10000	before running adlcomp.
X
X     SEE ALSO
X	  adlrun(6)
X	  adldebug(6)
X	  Brengle and Cunniff: The ADL Programmer's Reference Manual
X	  Adler, Kostanick, Stein and Urban: A Brief  Introduction  to
X	  UCLA Dungeon Definition Language
X
X
X
X
X
X
X
X
X
X     Hewlett-Packard Company	   - 2 -		  Jun 18, 1987
X
X
X
END_OF_man/adlcomp.6
if test 3409 -ne `wc -c <man/adlcomp.6`; then
    echo shar: \"man/adlcomp.6\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f samples/aard/Makefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"samples/aard/Makefile\"
else
echo shar: Extracting \"samples/aard/Makefile\" \(725 characters\)
sed "s/^X//" >samples/aard/Makefile <<'END_OF_samples/aard/Makefile'
X# AR = shar -c -v
XAR1 = post -c -v -p 10 17
XAR2 = post -c -v -p 11 17
XB = ../..
XD = samples/aard/
X
Xall		: aard
X
Xaard		: *.adl ../../adlcomp/adlcomp ../standard.adl
X	adlcomp aard.adl -w -o aard -i..
Xshar		: aard1.shar	aard2.shar
X
Xclean		:
X	rm -f aard core aard1.shar aard2.shar
X
Xaard1.shar	: README COPYRIGHT Makefile locales.adl objects.adl verbs.adl
X	( cd ${B} ; ${AR1}	\
X		${D}README	${D}COPYRIGHT	${D}Makefile	\
X		${D}locales.adl	${D}objects.adl	${D}verbs.adl	\
X	> ${D}aard1.shar )
X
Xaard2.shar	: aard.adl	routines.adl	constant.adl \
X		  locnames.adl	objrouts.adl	transit.adl
X	( cd ${B} ; ${AR2}	\
X		${D}aard.adl	${D}routines.adl	${D}constant.adl \
X		${D}locnames.adl ${D}objrouts.adl	${D}transit.adl	\
X	> ${D}aard2.shar )
END_OF_samples/aard/Makefile
if test 725 -ne `wc -c <samples/aard/Makefile`; then
    echo shar: \"samples/aard/Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f samples/aard/locnames.adl -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"samples/aard/locnames.adl\"
else
echo shar: Extracting \"samples/aard/locnames.adl\" \(1555 characters\)
sed "s/^X//" >samples/aard/locnames.adl <<'END_OF_samples/aard/locnames.adl'
X{*** MUSEUM ROOMS ***}
X
XNOUN mrm1,  mrm2,  mrm3,  mrm4,
X     mrm5,  mrm6;
X
Xmrm1(LIGHT) = TRUE;	mrm2(LIGHT) = TRUE;	mrm3(LIGHT) = TRUE;
Xmrm4(LIGHT) = TRUE;	mrm5(LIGHT) = TRUE;	mrm6(LIGHT) = TRUE;
X
X
X{*** INDIAN ROOMS ***}
X
XNOUN irm1,  irm2,  irm3,  irm4,  irm5,  irm6,  irm7,  irm8,
X     irm9,  irm10, irm11, irm12, irm13, irm14, irm15, irm16,
X     irm17, irm18, irm19, irm20, irm21, irm22, irm23;
X
Xirm1(LIGHT) = TRUE;	irm2(LIGHT) = TRUE;	irm3(LIGHT) = TRUE;
Xirm4(LIGHT) = TRUE;	irm5(LIGHT) = TRUE;	irm6(LIGHT) = TRUE;
Xirm7(LIGHT) = TRUE;	irm8(LIGHT) = TRUE;	irm9(LIGHT) = TRUE;
Xirm10(LIGHT) = TRUE;	irm11(LIGHT) = TRUE;	irm12(LIGHT) = TRUE;
Xirm13(LIGHT) = TRUE;	irm14(LIGHT) = TRUE;	irm15(LIGHT) = TRUE;
Xirm16(LIGHT) = TRUE;	irm17(LIGHT) = TRUE;	irm18(LIGHT) = TRUE;
Xirm19(LIGHT) = TRUE;	irm20(LIGHT) = TRUE;	irm21(LIGHT) = TRUE;
Xirm22(LIGHT) = TRUE;	irm23(LIGHT) = TRUE;
X
X{*** PREHISTORIC ROOMS ***}
X
XNOUN prehs;
X
XNOUN prm1(prehs),  prm2(prehs),  prm3(prehs),  prm4(prehs),
X     prm5(prehs),  prm6(prehs),  prm7(prehs),  prm8(prehs),
X     prm9(prehs),  prm10(prehs), prm11(prehs), prm12(prehs),
X     prm13(prehs), prm14(prehs), prm15(prehs), prm16(prehs),
X     prm17(prehs), prm18(prehs), prm19(prehs), prm20(prehs),
X     prm21(prehs), prm22(prehs), prm23(prehs);
X
Xprm2(LIGHT) = TRUE;	prm3(LIGHT) = TRUE;	prm4(LIGHT) = TRUE;
Xprm9(LIGHT) = TRUE;	prm10(LIGHT) = TRUE;	prm11(LIGHT) = TRUE;
Xprm12(LIGHT) = TRUE;	prm13(LIGHT) = TRUE;	prm14(LIGHT) = TRUE;
Xprm15(LIGHT) = TRUE;	prm16(LIGHT) = TRUE;	prm21(LIGHT) = TRUE;
Xprm22(LIGHT) = TRUE;	prm23(LIGHT) = TRUE;
END_OF_samples/aard/locnames.adl
if test 1555 -ne `wc -c <samples/aard/locnames.adl`; then
    echo shar: \"samples/aard/locnames.adl\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f samples/aard/routines.adl -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"samples/aard/routines.adl\"
else
echo shar: Extracting \"samples/aard/routines.adl\" \(2509 characters\)
sed "s/^X//" >samples/aard/routines.adl <<'END_OF_samples/aard/routines.adl'
X{*** ROUTINE DECLARATIONS ***}
X
XROUTINE
X  darkq, ei8, scads, ctake, cdrop, scord, exitg, onlmp;
X
X
X{*** DEAD-END ROUTINES ***}
X
XPROMPT =
X    ($spec 9 (($sdesc ($loc .ME)) 1) ($prop .ME pscore) ($turns))
X    ($say "> ")
X;
X
Xcg = ($say "Can't go that way.\n");
X
Xtosml = ($say "The hole is too small for you to fit through.\n");
X
Xdumdir = ($say "I don't know which direction that is.\n");
X
Xtohigh = ($say "The hole is too high for you to reach.\n");
X
Xnothe = ($say "This section is not implemented yet.\n");
X
Xskore =
X    ($say
X	"You scored "
X	($str ($prop .ME pscore))
X	" out of "
X	($str ($prop .ME pmax))
X	" possible points.\n"
X    )
X;
X
X
XRating0 = "junior beginning";
XRating1 = "senior beginning";
XRating2 = "intermediate";
XRating3 = "expert";
XRating4 = "junior master";
XRating5 = "master";
XRating6 = "senior master";
XRating7 = "life master";
XRating8 = "super-stud";
X
X
Xratng =
X    ($setp .ME ratvl 0)
X    (IF ($prop .ME pscore) THEN
X	($setp .ME ratvl ($div	($times ($prop .ME pscore) 8)
X					($prop .ME pmax)))
X    )
X    ($say
X	"That gives you a ranking of "
X	($plus Rating0 ($prop .ME ratvl))
X	" adventurer.\n"
X    )
X;
X
X
Xratnx =
X    (IF ($eq ($prop .ME ratvl) 8) THEN
X	($say "CONGRATULATIONS.\n")
X	($spec QUIT)
X    )
X    ($setp .ME ratvl ($plus ($prop .ME ratvl) 1))
X    ($setp .ME ratvl ($times ($prop .ME ratvl) ($prop .ME pmax)))
X    ($setp .ME ratvl ($div ($prop .ME ratvl) 8))
X    ($setp .ME ratvl ($plus ($prop .ME ratvl) 1))
X    ($setp .ME ratvl ($minus ($prop .ME ratvl) ($prop .ME pscore)))
X    ($say
X	"To achieve the next higher rating, you need to score "
X	($str ($prop .ME ratvl))
X	" more points.\n"
X    )
X;
X
X
Xendgame =
X    ($incturn)
X    (IF ($eq ($prop .ME pscore) ($prop .ME pmax)) THEN
X	($say
X"     As you drop the last treasure, the lights come up and you hear a voice
Xsay, \"CONGRATULATIONS, ADVENTURER.  You have restored the museum
Xdisplays to their former glory.  Now accept the Director's thanks, and
Xalso his reward!\"\n"
X"     You are miraculously transported to a room you have never seen before,
Xfilled to the top with precious gold and jewels.  The voice appears again,
Xsaying, \"Your reward is as follows:  you are granted the privilege of\n"
X"becoming the new curator of the Museum.  Your first responsibility is
Xto catalog and sort these treasures for placement in the Museum.  Your
Xsalary is $3.25 per hour.  Again, thanks!\"\n"
X"     The voice disappears, and you are left alone in the immense room.
XYou'd better get to work, for you have a LOT to do!\n"
X	)
X	($spec QUIT)
X    )
X;
END_OF_samples/aard/routines.adl
if test 2509 -ne `wc -c <samples/aard/routines.adl`; then
    echo shar: \"samples/aard/routines.adl\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f samples/demos/tiny.adl -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"samples/demos/tiny.adl\"
else
echo shar: Extracting \"samples/demos/tiny.adl\" \(1692 characters\)
sed "s/^X//" >samples/demos/tiny.adl <<'END_OF_samples/demos/tiny.adl'
XINCLUDE "standard.adl";
X
XNOUN startrm, brightroom;		{ Locations in the dungeon }
Xstartrm(LIGHT) = TRUE;		brightroom(LIGHT) = TRUE;
X
Xcg = ($say "You can't go that way.\n");
X
Xstartrm(LDESC) =
X    ($say "You are in a small but comfortable room.  You hardly want ")
X    ($say "to leave, but there is a door leading east, if you insist.\n")
X;
Xstartrm (SDESC) = ($say "Comfortable room.\n");
Xstartrm(ACTION) =
X    ($miss    cg cg 0          cg 0 0 0 0 0 0)
X    ($hit .ME 0  0  brightroom 0  0 0 0 0 0 0)
X;
X
Xbrightroom(LDESC) =
X    ($say "You are in a brightly lit room.  The walls sparkle with ")
X    ($say "scintillating lights.  There is a darker room to the west.\n")
X;
Xbrightroom(SDESC) = ($say "Bright room.\n");
Xbrightroom(ACTION) =
X    ($miss    cg cg cg 0       0 0 0 0 0 0)
X    ($hit .ME 0  0  0  startrm 0 0 0 0 0 0)
X;
X
XADJEC red, blue;
X
XNOUN red pillow(startrm), blue pillow(startrm);
X
Xred pillow(LDESC) = ($say "There is a red pillow here.\n");
Xred pillow(SDESC) = ($say "A red pillow");
X
Xblue pillow(LDESC) = ($say "There is a blue pillow here.\n");
Xblue pillow(SDESC) = ($say "A blue pillow");
X
XNOUN platinum(brightroom);		bar = platinum;
Xplatinum(LDESC) = ($say "There is a bar of platinum here!\n");
Xplatinum(SDESC) = ($say "A platinum bar");
Xplatinum(ACTION) = 
X    (IF ($and ($eq ($verb) drop) ($eq ($loc .ME) ($loc [red pillow]))) THEN
X	($say "The bar falls onto the red pillow, breaking it!  The symbolism ")
X	($say "impresses itself upon you, and you go back to work instead of ")
X	($say "playing these silly games!\n")
X	($spec 3)
X    )
X;
X
XNOUN SELF(startrm);		SELF(NOTAKE) = TRUE;
X
XSTART =
X    (StdInit SELF)
X;
X
XDWIMD = ($return (Dwimmer %1));
XDWIMI = ($return (Dwimmer %1));
END_OF_samples/demos/tiny.adl
if test 1692 -ne `wc -c <samples/demos/tiny.adl`; then
    echo shar: \"samples/demos/tiny.adl\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f util/mytime.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"util/mytime.c\"
else
echo shar: Extracting \"util/mytime.c\" \(1629 characters\)
sed "s/^X//" >util/mytime.c <<'END_OF_util/mytime.c'
X#include "adltypes.h"
X
X#if AMIGA
X#include <libraries/dos.h>
X
X#define MINUTES_PER_DAY	(60 * 24)
X#define TICKS_PER_MINUTE (60 * TICKS_PER_SECOND)
X
Xint32
Xmytime()
X{
X    struct DateStamp
X	ds;
X    long
X	retval;
X
X    DateStamp( &ds );
X    retval = MINUTES_PER_DAY * ds.ds_Days + ds.ds_Minute;
X    retval = TICKS_PER_MINUTE * retval + ds.ds_Tick;
X    return retval;
X}
X
Xcheckbreak( rout )
Xint
X    (*rout)();
X{
X    if( SetSignal( 0L, 0L ) & SIGBREAKF_CTRL_C ) {
X	/* We were signalled - call the routine */
X	(*rout)();
X	/* Reset the signal */
X	(void)SetSignal( 0L, SIGBREAKF_CTRL_C );
X    }
X}
X
X#endif
X
X
X#if MSDOS
X#include <dos.h>
X#undef time
X
Xint32
Xmytime( )
X{
X    int32 temp[ 3 ];		/* Buffer */
X
X    time( (char *)temp, 0 );	/* Get a bcd version of time of day */
X    return temp[ 0 ];		/* And pretend that it fits in one long */
X}
X
Xcheckbreak( rout )
Xint
X    (*rout)();
X{
X    /* No convenient way of doing this from C under MS-DOS.  Sigh. */
X    union REGS
X	reglist;
X
X    reglist.h.ah = 0x0b;		/* Check keyboard status */
X    int86( 0x21, &reglist, &reglist );
X    /* If the keyboard buffer contained CTRL-C, the program MIGHT exit */
X}
X#endif
X
X
X#if UNIX
X#include <signal.h>
Xstatic int
X    (*_break_rout)();
X
Xstatic
X_do_break()
X{
X    /* This routine is the one which actually gets called when signalled */
X    signal( SIGINT, SIG_IGN );		/* Ignore this signal until ready */
X    (*_break_rout)();			/* Call the routine */
X    signal( SIGINT, _do_break );	/* Ready */
X}
X
X
Xcheckbreak( rout )
Xint
X    (*rout)();
X{
X    if( _break_rout == (int (*)())0 )
X	signal( SIGINT, _do_break );
X    _break_rout = rout;
X}
X
X#endif
X
X/*** EOF mytime.c ***/
END_OF_util/mytime.c
if test 1629 -ne `wc -c <util/mytime.c`; then
    echo shar: \"util/mytime.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f util/vstring.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"util/vstring.c\"
else
echo shar: Extracting \"util/vstring.c\" \(2899 characters\)
sed "s/^X//" >util/vstring.c <<'END_OF_util/vstring.c'
X/*LINTLIBRARY*/
X#include <stdio.h>
X
X#include "adltypes.h"
X#include "virtmem.h"
X
X#define MINTEMP (-10000) /* Minimum temp value */
X
Xstatic char
X   *temptab,		/* Storage for temporary strings */
X   *savetab;		/* Storage for saved strings */
X
Xstatic int32
X    *ndxtab,		/* Index page area */
X    numc = 1L;		/* Number of characters in strings */
X
Xint16
X    strdirty = 0,	/* Do we need to flush the strings? */
X    numtemp  = 1,	/* Number of temporary chars */
X    *num_save,		/* Number of saved chars */
X    nums     = 1;	/* Number of string table entries */
X
X
Xstruct pagetab
X    strpages;		/* Page table for virtmem */
X
X
Xint16
Xnumstr()
X{
X    return nums;
X}
X
X
Xint32
Xnumchar()
X{
X    return numc;
X}
X
X
Xint16
Xnewtstr( s )
Xchar
X    *s;
X{
X    int16
X	t;
X
X    strcpy( &temptab[ numtemp ], s );
X    t = numtemp;
X    numtemp += strlen( s ) + 1;
X    return -t;
X}
X
X
Xint16
Xvs_save( n )
Xint16
X    n;
X{
X    int16 t;
X    char *virtstr();
X
X    if( n >= 0 )
X	return n;
X    strcpy( &savetab[ *num_save ], virtstr( n ) );
X    t = *num_save;
X    *num_save += strlen( &savetab[ *num_save ] ) + 1;
X    return MINTEMP - t;
X}
X
X
Xvsflush()
X{
X    if( strdirty )
X	vm_flush( &strpages );
X    numtemp = 1;
X}
X
X
Xencode( s )
Xchar
X    *s;
X{
X    while( *s )
X	*s++ ^= CODE_CHAR;
X}
X
X
Xdecode( s )
Xchar
X    *s;
X{
X    while( *s )
X	*s++ ^= CODE_CHAR;
X}
X
X
Xint16
Xnewstr( s )
Xchar
X    *s;
X{
X    char
X	t[ 512 ];
X
X    ndxtab[ nums ] = numc;	/* Put current char index into str tab */
X    strcpy( t, s );		/* Get a working copy of s */
X    encode( t );		/* Make it unreadable by human eyes */
X    s = t;
X    while( *s )			/* Write the string out */
X	vm_put8( *s++, numc++, &strpages );
X    vm_put8( (char)0, numc++, &strpages );
X    return nums++;
X}
X
X
Xstatic char *
Xtvirt( id )
Xint16
X    id;
X{
X    if( id <= MINTEMP )
X	return &savetab[ MINTEMP - id ];
X    else
X	return &temptab[ -id ];
X}
X
X
Xchar *
Xvirtstr( id )
Xint16
X    id;
X{
X    int32
X	adr;			/* Address of the string in the file */
X    char
X	ch,			/* Current char of the string */
X	*s;			/* Pointer to current char */
X    static char
X	tvs[ 512 ];		/* Save area */
X
X    if( id < 0 )
X	/* This was a temp string - return one. */
X	return tvirt( id );
X
X    adr = ndxtab[ id ];
X    s = tvs;
X
X    /* Read in the string */
X    for( ch=vm_get8( adr++, &strpages ); ch; ch=vm_get8( adr++, &strpages ) )
X	*s++ = ch;
X    *s = '\0';
X
X    decode( tvs );
X    return tvs;
X}
X
X
Xvsinit( strf, stri, init, temp, save, ns, ndx )
Xint
X    strf;				/* The swap file		*/
Xint32
X    stri;				/* Offset into the swap file	*/
Xint16
X    init;				/* Read the first page in?	*/
Xchar
X    *temp;				/* Temp string area		*/
Xchar
X    *save;				/* Save string area		*/
Xint16
X    *ns;				/* Area for # of save strings	*/
Xint32
X    *ndx;				/* Index table			*/
X{
X    strdirty = !init;
X    vm_init( strf, stri, &strpages, strdirty );
X    num_save = ns;
X    temptab = temp;
X    savetab = save;
X    ndxtab = ndx;
X}
X
X/*** EOF vstring.h ***/
END_OF_util/vstring.c
if test 2899 -ne `wc -c <util/vstring.c`; then
    echo shar: \"util/vstring.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 10 \(of 11\).
cp /dev/null ark10isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 11 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
    echo Making adl.doc
    (cd man; cat doc.aa doc.ab doc.ac >adl.doc; rm doc.a[a-c])
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
