h28826
s 00109/00001/00598
d D 1.10 80/09/10 12:52:04 lcd 10 9
c Added IODopen table
e
s 00105/00001/00494
d D 1.9 80/09/10 11:25:50 lcd 9 8
c Added SPver, phys_mem_rec, swap_alloc_table and segLink.
e
s 00004/00002/00491
d D 1.8 80/09/09 18:34:56 lcd 8 7
c Fixed boundary problems
e
s 00133/00028/00360
d D 1.7 80/09/09 16:25:06 lcd 7 6
c Added Next and Prev
e
s 00006/00006/00382
d D 1.6 80/09/09 02:21:21 lcd 6 5
c Changed "struct" command to "table"
e
s 00201/00119/00187
d D 1.5 80/09/09 02:05:31 lcd 5 4
c Added pcs_st, QUEhead and map
e
s 00061/00000/00245
d D 1.4 80/09/08 23:01:44 lcd 4 3
c Moved struct command interpreter from main.c
e
s 00080/00006/00165
d D 1.3 80/09/07 15:21:03 lcd 3 2
c Added GST structure.
e
s 00004/00002/00167
d D 1.2 80/09/07 13:21:17 lcd 2 1
c Cleaned up.
e
s 00169/00000/00000
d D 1.1 80/05/16 08:12:20 lcd 1 0
e
u
sunix
lcd
U
t
T
I 1
#

#include "globals.h"
#include <stdio.h>

/*
D 6
 *	struct.c: structure definitions and formatting
E 6
I 6
 *	table.c: structure definitions and formatting
E 6
 */

D 6
CONST	char	*_S_struct	"%W%";
E 6
I 6
CONST	char	*_S_table	"%W%";
E 6

I 4
D 5
#define	NOrec	0
#define	UPTrec	1
#define GSTrec	2
E 5
I 5
#define	UPTrec		0
#define GSTrec		1
#define SLOTSrec	2
#define PCSTrec		3
#define	QUErec		4
#define MAPrec		5
D 9
#define	NOrec		6
E 9
I 9
#define SPVrec		6
#define PHYSrec		7
#define SWAPrec		8
#define LINKrec		9
D 10
#define	NOrec		10
E 10
I 10
#define DOrec		10
#define	NOrec		11
E 10
E 9
E 5

VAR	struct strtable 
	{	COMMAND	strcod;
		char	*strnam;
	} strtab[] {	UPTrec, "upt",
			GSTrec, "gst",
I 5
			SLOTSrec, "slots",
			PCSTrec, "pcs_st",
			QUErec, "QUEhead",
			MAPrec, "maps",
I 9
			SPVrec, "SPver",
			PHYSrec, "phys_mem_rec",
			SWAPrec, "swap_alloc_table",
			LINKrec, "segLink",
I 10
			DOrec, "IODopen",
E 10
E 9
E 5
			NOrec, "",
		   };

I 5
	long	strsizes[NOrec];
	long	stradrs[NOrec];
	char	*bufsadr[NOrec];
	integer	bufsiz[NOrec];
	integer	(*pradr[NOrec])();
I 7
	long	tabind[NOrec];
E 7
E 5


D 5
Strinit()

{	UPTinit();
	GSTinit();
}


/*
 *	Struct: print out various structures
 */

Struct()

{	char	word[MAXLINELENGTH];
	integer	index;

	getword( word );

	IF word[0] == eos
	THEN	printf("struct HELP:\n\n");
		printf("struct upt,<upt_index>\n");
		printf("struct gst,<gst_index>\n");

	ELSE	index = 0;

		LOOP	WHEN strtab[ index ].strcod == NOrec DO EXIT;

			WHEN imatch( word, strtab[ index ].strnam ) DO EXIT;

			inc( index );
		END;


		CASE strtab[ index ].strcod OF

		case NOrec	: BEGIN printf("?\n");
				  ENDCASE;
		case UPTrec	: BEGIN UPTdisp();
				  ENDCASE;
		case GSTrec	: BEGIN GSTdisp();
				  ENDCASE;
		END;
	END
END



E 5
E 4
TYPE	/* type declarations */

	struct Sseid	{
			char	nsp;
			char	uniq_id0;
			integer	uniq_id1;
			};

	struct Sminfo	{
			integer	mhead[2][2];
			integer mcnt[2];
			integer inProg;
			integer freeCnt;
			};

	struct Spinfo	{
			integer		delta;
D 2
			integer		disptch;
E 2
I 2
			char		disp1;
			char		disp2;
E 2
			integer		unique;
			};

	struct Stdinfo	{
			struct Sseid	parent;
			integer		family;
			integer		priority;
			integer		time_out;
			integer		rowner;
			integer		rgroup;
			integer		pselev;
			};

	struct Stiinfo	{
			char	seccat;
			char	intcat;
			long	compart;
			integer	owner;
			integer group;
			integer	tiida;
			long	tiiprv;
			};

	struct Supt	{
			integer	prcptr;
			integer	schinfo;
			struct Sminfo minfo;
			struct Spinfo pinfo;
			struct Stdinfo tdinfo;
			struct Stiinfo tiinfo;
			integer utiming;
			integer stiming;
			integer ktiming;
			};

I 3
	struct Sgst	{
			struct Sseid gseid;
			integer	gbits;
			integer gsize;
			integer mloc;
			integer sloc;
			integer acnt;
			integer ncnt;
			struct Stiinfo gstii;
			};

I 5
	struct Sslots	{
			integer	sltproc;
			integer	sltpar;
			integer	sltcnt;
			integer	slttim;
			};
E 5

E 3
D 5
CONST	UPTnam		"upt";
I 3
	GSTnam		"gst";
E 5
I 5
	struct Spcsid	{
			struct Sseid pcsseid;
			integer	pcsslot;
			};
E 5
E 3

D 5
VAR	struct Supt	uptable;
	long		UPTadr;
	long		UPTsiz;
E 5
I 5
	struct Sques	{
			integer	uq;
			integer	eq;
			integer	pq;
			integer	pwq;
			integer prq;
			};
E 5

I 5
	struct Smaps	{
			integer	msp;
			integer	mpar;
			integer	mpdr;
			integer	ppti;
			integer	mnrst;
			struct Sseid mseid;
			};

I 9
	struct Sopsto	{
			integer OSstart;
			integer OSsize;
			};
E 9

I 9
	struct Slink	{
			char	Lstat;
			integer	Lorg;	
			};
E 9

I 10
	struct Siopart	{
			char	inUseb;
			char	exclurb;
			char	excluwb;
			struct Sseid objsd;
			integer	writers;
			integer	readers;
			};

	struct Siodopen	{
			struct Siopart iodp;
			struct Stiinfo rights;
			struct Sseid subtype;
			char dClass;
			integer upath;
			integer inlink;
			integer outlink;
			};


E 10
VAR	struct Supt	uptable;
E 5
I 3
	struct Sgst	gstable;
D 5
	long		GSTadr;
	long		GSTsiz;
E 5
I 5
	struct Sslots	slotable;
	struct Spcsid	pcsstable;
	struct Sques	QUEhead;
	struct Smaps	maptable;
I 9
	char		SPver;
	struct Sopsto	physmem;
	struct Sopsto	swapalloc;
	struct Slink	segLink;
I 10
	struct Siodopen	IODopen;
E 10
E 9
E 5

E 3
/*
 *	printTii: print out TII struct
 */

D 5
PROCEDURE printTii( tii )
E 5
I 5
PROCEDURE printTii( tii, tabs )
E 5

CONST	struct Stiinfo *tii;
I 5
	char *tabs;
E 5

BEGIN	printf("\tsecurity_category\t%7o\n", (*tii).seccat );
D 5
	printf("\tintegrity_category\t%7o\n", (*tii).intcat );
	printf("\tsecurity_compart\t%14O\n", (*tii).compart );
	printf("\towner\t\t\t%7o\n", (*tii).owner );
	printf("\tgroup\t\t\t%7o\n", (*tii).group );
	printf("\tda\t\t\t%7o\n", (*tii).tiida );
	printf("\ttii_priv\t\t%14O\n", (*tii).tiiprv );
E 5
I 5
	printf("%s\tintegrity_category\t%7o\n", tabs, (*tii).intcat );
	printf("%s\tsecurity_compart%15O\n", tabs, (*tii).compart );
	printf("%s\towner\t\t\t%7o\n", tabs, (*tii).owner );
	printf("%s\tgroup\t\t\t%7o\n", tabs, (*tii).group );
	printf("%s\tda\t\t\t%7o\n", tabs, (*tii).tiida );
	printf("%s\ttii_priv\t%15O\n", tabs, (*tii).tiiprv );
E 5
END


/*
 *	printSeid: prints out SEID
 */

D 5
PROCEDURE printSeid( s )
E 5
I 5
PROCEDURE printSeid( s, tabs )
E 5

CONST	struct Sseid *s;
I 5
	char	*tabs;
E 5

D 5
BEGIN	printf("\tnsp\t\t%7o\n", (*s).nsp&0377 );
	printf("\tuniq_id0\t%7o\n", (*s).uniq_id0&0377 );
	printf("\tuniq_id1\t%7o\n", (*s).uniq_id1 );
E 5
I 5
D 7
BEGIN	printf("\tnsp\t%7o\n", (*s).nsp&0377 );
	printf("\t%suniq_id0%7o\n", tabs, (*s).uniq_id0&0377 );
	printf("\t%suniq_id1%7o\n", tabs, (*s).uniq_id1 );
E 7
I 7
BEGIN	printf("\tnsp\t%7d\n", (*s).nsp&0377 );
	printf("\t%suniq_id0%7d\n", tabs, (*s).uniq_id0&0377 );
	printf("\t%suniq_id1%7d\n", tabs, (*s).uniq_id1 );
E 7
E 5
END

/*
 *	uptprint: print out uptable
 */

PROCEDURE uptprint()

D 7
BEGIN	printf("proc_ptr\t%7o\n", uptable.prcptr );
E 7
I 7
BEGIN	printf("proc_ptr\t%7d\n", uptable.prcptr );
E 7
	printf("schinfo\t\t%7o\n", uptable.schinfo );
	printf("minfo\n");
	printf("\tmessage_head\t%7o %7o %7o %7o\n", uptable.minfo.mhead[0][0],
						    uptable.minfo.mhead[0][1],
						    uptable.minfo.mhead[1][0],
						    uptable.minfo.mhead[1][1] );
	printf("\tmess_count\t%7o %7o\n", uptable.minfo.mcnt[0], 
					  uptable.minfo.mcnt[1] );
	printf("\tiocInProgress\t%7o\n", uptable.minfo.inProg );
	printf("\tmessFreeCount\t%7o\n", uptable.minfo.freeCnt );
	printf("pinfo\n");
	printf("\tdelta_prio\t%7o\n", uptable.pinfo.delta );
D 2
	printf("\tdispatch_count\t%7o\n", uptable.pinfo.disptch );
E 2
I 2
	printf("\tdispatch_count\t%7o\n", uptable.pinfo.disp1 );
	printf("\tdispatch_sched\t%7o\n", uptable.pinfo.disp2 );
E 2
	printf("\tunique_id\t%7o\n", uptable.pinfo.unique );
	printf("tdinfo\n");
I 3
D 5
	printf("\tparent\n");
E 3
	printSeid( &uptable.tdinfo.parent );
E 5
I 5
	printf("\tparent");
	printSeid( &uptable.tdinfo.parent, "\t" );
E 5
	printf("\tfamily_name\t%7o\n", uptable.tdinfo.family );
	printf("\tpriority\t%7o\n", uptable.tdinfo.priority );
	printf("\ttime_out\t%7o\n", uptable.tdinfo.time_out );
	printf("\treal_owner\t%7o\n", uptable.tdinfo.rowner );
	printf("\treal_group\t%7o\n", uptable.tdinfo.rgroup );
D 3
	printf("\tpse_int_level\t%7o\n", uptable.tdinfo.pselev );
E 3
I 3
	printf("\tpse_int_level\t%7d\n", uptable.tdinfo.pselev );
E 3
D 5
	printf("tiinfo\n");
	printTii( &uptable.tiinfo );
E 5
I 5
	printf("tiinfo");
	printTii( &uptable.tiinfo, "" );
E 5
D 3
	printf("user_timing\t%7o\n", uptable.utiming );
	printf("supv_timing\t%7o\n", uptable.stiming );
	printf("kern_timing\t%7o\n", uptable.ktiming );
E 3
I 3
	printf("user_timing\t%7d\n", uptable.utiming );
	printf("supv_timing\t%7d\n", uptable.stiming );
	printf("kern_timing\t%7d\n", uptable.ktiming );
E 3
END

/*
D 5
 *	UPTinit: do initialization for upt
E 5
I 5
 *	gstprint: print out gst
E 5
 */

D 5
PROCEDURE UPTinit()
E 5
I 5
PROCEDURE gstprint()
E 5

D 5
BEGIN	getladdr( UPTnam, &UPTadr, &UPTsiz );
E 5
I 5
BEGIN	printf("gst_seid");
	printSeid( &gstable.gseid, "\t" );
	printf("gst_bits\t%7o\n", gstable.gbits );
D 7
	printf("gst_size\t%7d\n", gstable.gsize );
	printf("mem_loc\t\t%7d\n", gstable.mloc );
	printf("swap_loc\t%7d\n", gstable.sloc );
E 7
I 7
	printf("gst_size\t%7u\n", gstable.gsize );
	printf("mem_loc\t\t%7u\n", gstable.mloc );
	printf("swap_loc\t%7u\n", gstable.sloc );
E 7
	printf("attach_count\t%7d\n", gstable.acnt );
	printf("need_count\t%7d\n", gstable.ncnt );
	printf("gst_tii");
	printTii( &gstable.gstii, "" );
E 5
END

/*
D 5
 *	UPTdisp: display upt entry
E 5
I 5
 *	slotsprint: print out slots
E 5
 */

D 5
PROCEDURE UPTdisp()
E 5
I 5
PROCEDURE slotsprint()
E 5

D 5
BEGIN	VAR	long	entry;
		long	sizupt;
E 5
I 5
BEGIN	printf("proc\t%7o\n", slotable.sltproc );
	printf("slt_par\t%7o\n", slotable.sltpar );
	printf("slt_cnt\t%7o\n", slotable.sltcnt );
	printf("slt_tim\t%7o\n", slotable.slttim );
END
E 5

D 5
	getnum( &entry );
E 5
I 5
/*
 *	pcsstprint: print pcs_st table entry
 */
E 5

D 5
	IF entry == -1L
	THEN	printf("?\n");
E 5
I 5
PROCEDURE pcsstprint()
E 5

D 5
	ELSE	sizupt = sizeof( uptable );
E 5
I 5
BEGIN	printf("s_seid");
	printSeid( &pcsstable.pcsseid, "" );
	printf("slot\t%7o\n", pcsstable.pcsslot );
END
E 5

D 5
		entry = entry*sizupt + UPTadr;
E 5

D 3
		rdBlock( entry, sizeof( uptable ), &uptable );
E 3
I 3
D 5
		IF entry >= UPTadr+UPTsiz
		THEN	printf("?\n");
		ELSE	rdBlock( entry, sizeof( uptable ), &uptable );
			uptprint();
		END;
	END;
END
E 5
I 5
/*
 *	queprint: print out QUEhead
 */
E 5
E 3

I 5
PROCEDURE queprint()
E 5
D 3
		uptprint();
E 3
I 3

I 5
BEGIN	printf("user_level\t\t%7o\n", QUEhead.uq );
	printf("eligible_level\t\t%7o\n", QUEhead.eq );
	printf("primitive_level\t\t%7o\n", QUEhead.pq );
	printf("prim_wait_level\t\t%7o\n", QUEhead.pwq );
	printf("prim_ready_level\t%7o\n", QUEhead.prq );
END

E 5
/*
D 5
 *	gstprint: print out gst
E 5
I 5
 *	mapprint: print out map table
E 5
 */

D 5
PROCEDURE gstprint()
E 5
I 5
PROCEDURE mapprint()
E 5

D 5
BEGIN	printf("gst_seid\n");
	printSeid( &gstable.gseid );
	printf("gst_bits\t\t%7o\n", gstable.gbits );
	printf("gst_size\t\t%7d\n", gstable.gsize );
	printf("mem_loc\t\t%7d\n", gstable.mloc );
	printf("swap_loc\t\t%7d\n", gstable.sloc );
	printf("attach_count\t%7d\n", gstable.acnt );
	printf("need_count\t%7d\n", gstable.ncnt );
	printf("gst_tii");
	printTii( &gstable.gstii );
E 5
I 5
BEGIN	printf("m_sp\t%7o\n", maptable.msp );
	printf("m_par\t%7o\n", maptable.mpar );
	printf("m_pdr\t%7o\n", maptable.mpdr );
	printf("ppt_i\t%7o\n", maptable.ppti );
	printf("m_nrst\t");
	IF maptable.mnrst
	THEN	printf("   TRUE\n");
	ELSE	printf("  FALSE\n");
	END;
	printf("m_seid");
	printSeid( &maptable.mseid, "" );
E 5
END

I 9
/*
 *	spvprint: print out SPver entry
 */

PROCEDURE spvprint()

BEGIN	IF SPver == '\0'
	THEN	printf("PUfree\n");
	ELSE	printf("PUused\n");
	END
END

/*
 *	printopsto: print out opsto record
 */

PROCEDURE printopsto( opsto )

CONST	struct Sopsto *opsto;

BEGIN	printf("OSstart\t%7u\n", (*opsto).OSstart );
	printf("OSsize\t%7u\n", (*opsto).OSsize );
END


/*
 *	physprint: print out phys_mem_rec.
 */

PROCEDURE physprint()

BEGIN	printopsto( &physmem );
END

/*
 *	swapprint: print out swap alloc table
 */

PROCEDURE swapprint()

BEGIN	printopsto( &swapalloc );
END


/*
 *	linkprint: print out segLink
 */

PROCEDURE linkprint()

BEGIN	printf("Lstat\t");

	CASE segLink.Lstat OF

	case '\0'	: BEGIN	printf("   satt");
			  ENDCASE;
	case '\1'	: BEGIN	printf("   want");
			  ENDCASE;
	case '\2'	: BEGIN printf("   have");
			  ENDCASE;
	default		: BEGIN	printf("??");
			  ENDCASE;
	END

	printf("\nLorg\t%7d\n", segLink.Lorg );
END


I 10
/*
 *	iopartprint: print out IODopenPart
 */

CONST	char	*T	"    TRUE";
	char	*F	"   FALSE";


PROCEDURE iopartprint( iopart, tabs )

CONST	struct Siopart *iopart;
	char	*tabs;

BEGIN	VAR	char	newtabs[10];

	cat( newtabs, "\t", tabs, 0 );

	printf("\tinUse\t\t%s\n", (*iopart).inUseb? T : F );
	printf("%s\texclusive_read\t%s\n", tabs, (*iopart).exclurb? T : F );
	printf("%s\texclusive_write\t%s\n", tabs, (*iopart).excluwb? T : F );
	printf("%s\tobjSeid", tabs );
	printSeid( &((*iopart).objsd), newtabs );
	printf("%s\twriters\t\t%d\n", tabs, (*iopart).writers );
	printf("%s\treaders\t\t%d\n", tabs, (*iopart).readers );
END


/*
 *	devclsprint: print out deviceClass
 */

PROCEDURE devclsprint( devcls )

CONST	char	devcls;

BEGIN	CASE devcls OF

	case '\0'	: BEGIN	printf(" RK05 "); ENDCASE;
	case '\01'	: BEGIN	printf(" RWP04 "); ENDCASE;
	case '\02'	: BEGIN	printf(" RWP05 "); ENDCASE;
	case '\03'	: BEGIN	printf(" RWP06 "); ENDCASE;
	case '\04'	: BEGIN	printf(" RWS04 "); ENDCASE;
	case '\05'	: BEGIN	printf(" TWE16 "); ENDCASE;
	case '\06'	: BEGIN	printf(" TM11 "); ENDCASE;
	case '\07'	: BEGIN	printf(" TU56 "); ENDCASE;
	case '\010'	: BEGIN	printf(" DL11 "); ENDCASE;
	case '\011'	: BEGIN	printf(" DH11 "); ENDCASE;
	case '\012'	: BEGIN	printf(" PR11 "); ENDCASE;
	case '\013'	: BEGIN	printf(" PC11 "); ENDCASE;
	case '\014'	: BEGIN	printf(" LP11 "); ENDCASE;
	case '\015'	: BEGIN	printf(" IMP11B "); ENDCASE;
	case '\016'	: BEGIN	printf(" LHDH "); ENDCASE;
	case '\017'	: BEGIN	printf(" SUBTYPEDEVICE "); ENDCASE;
	default		: BEGIN printf(" ??? "); ENDCASE;
	END
END


/*
 *	iodoprint: print out iodopen entry
 */

PROCEDURE iodoprint()

BEGIN	printf("oPart");
	iopartprint( &IODopen.iodp, "" );
	printf("rights");
	printTii( &IODopen.rights, "" );
	printf("subtype");
	printSeid( &IODopen.subtype, "" );
	printf("deviceClass\t");
	devclsprint( IODopen.dClass );
	printf("\nunit_path\t%7u\n", IODopen.upath );
	printf("in_unit_link\t%7u\n", IODopen.inlink );
	printf("out_unit_link\t%7u\n", IODopen.outlink );
END
	




E 10
E 9
I 7
VAR	integer	lasttab;

E 7
/*
D 5
 *	GSTinit: do initialization for gst
E 5
I 5
D 6
 *	Strinit: struct initializer
E 6
I 6
 *	tabinit: table initializer
E 6
E 5
 */

D 5
PROCEDURE GSTinit()
E 5
I 5
D 6
PROCEDURE Strinit()
E 6
I 6
PROCEDURE tabinit()
E 6
E 5

D 5
BEGIN	getladdr( GSTnam, &GSTadr, &GSTsiz );
E 5
I 5
BEGIN	VAR	integer	index;

	index = 0;

	LOOP	WHEN index == NOrec DO EXIT;

		getladdr( strtab[index].strnam, 
			  &stradrs[index], 
			  &strsizes[index] );

I 7
		tabind[index] = -1L;

E 7
		inc( index );
	END

I 7
	lasttab = NOrec;

E 7
	bufsadr[UPTrec] = &uptable;	
	bufsiz[UPTrec] = sizeof( uptable );
	pradr[UPTrec] = uptprint;

	bufsadr[GSTrec] = &gstable;	
	bufsiz[GSTrec] = sizeof( gstable );
	pradr[GSTrec] = gstprint;

	bufsadr[SLOTSrec] = &slotable;	
	bufsiz[SLOTSrec] = sizeof( slotable );
	pradr[SLOTSrec] = slotsprint;

	bufsadr[PCSTrec] = &pcsstable;	
	bufsiz[PCSTrec] = sizeof( pcsstable );
	pradr[PCSTrec] = pcsstprint;

	bufsadr[QUErec] = &QUEhead;
	bufsiz[QUErec] = sizeof( QUEhead );
	pradr[QUErec] = queprint;

	bufsadr[MAPrec] = &maptable;
	bufsiz[MAPrec] = sizeof( maptable );
	pradr[MAPrec] = mapprint;
I 9

	bufsadr[SPVrec] = &SPver;
	bufsiz[SPVrec] = sizeof( SPver );
	pradr[SPVrec] = spvprint;

	bufsadr[PHYSrec] = &physmem;
	bufsiz[PHYSrec] = sizeof( physmem );
	pradr[PHYSrec] = physprint;

	bufsadr[SWAPrec] = &swapalloc;
	bufsiz[SWAPrec] = sizeof( swapalloc );
	pradr[SWAPrec] = swapprint;

	bufsadr[LINKrec] = &segLink;
	bufsiz[LINKrec] = sizeof( segLink );
	pradr[LINKrec] = linkprint;
I 10

	bufsadr[DOrec] = &IODopen;
	bufsiz[DOrec] = sizeof( IODopen );
	pradr[DOrec] = iodoprint;
E 10
E 9
E 5
END

I 5

E 5
/*
D 5
 *	GSTdisp: display gst entry
E 5
I 5
D 6
 *	Struct: print out various tables
E 6
I 6
D 7
 *	table: print out various tables
E 7
I 7
 *	Tabcmd: returns tabcmd index of table
E 7
E 6
E 5
 */

I 7
PROCEDURE integer Tabcmd( word )

CONST	char	*word;

BEGIN	VAR	integer	index;

	index = 0;

	LOOP	WHEN index == NOrec DO EXIT;

		WHEN imatch( word, strtab[ index ].strnam ) DO EXIT;

		inc( index );
	END;

	return( index );
END

/*
 *	Tabdisp: display table entry
 */

PROCEDURE Tabdisp( index, entry )

CONST	integer	index;
	long	entry;

BEGIN	VAR	long	lentry;
		long	temp;


	temp = bufsiz[index];

	lentry = entry*temp + stradrs[index];

D 8
	IF lentry >= stradrs[index]+strsizes[index]
E 8
I 8
	IF ( lentry >= stradrs[index]+strsizes[index] ) OR
	   ( lentry < stradrs[index] )
E 8
	THEN	printf("?\n");
		tabind[index] = -1L;
	ELSE	rdBlock( lentry, 
			 bufsiz[index],
			 bufsadr[index] );

		printf("%s: %ld\n", strtab[index].strnam, entry );

		(*pradr[index])();
	END
END

/*
*	table: print out various tables
*/

E 7
D 5
PROCEDURE GSTdisp()
E 5
I 5
D 6
Struct()
E 6
I 6
table()
E 6
E 5

BEGIN	VAR	long	entry;
D 5
		long	sizgst;
E 5
I 5
D 7
		char	word[MAXLINELENGTH];
		integer	index;
		long	temp;
E 7
I 7
	char	word[MAXLINELENGTH];
	integer	index;
	long	temp;
E 7
E 5

D 5
	getnum( &entry );
E 5
I 5
	getword( word );
E 5

D 5
	IF entry == -1L
	THEN	printf("?\n");
E 5
I 5
	index = 0;
E 5

D 5
	ELSE	sizgst = sizeof( gstable );
E 5
I 5
	IF word[0] == eos
	THEN	printf("Supported tables:\n\n");
E 5

D 5
		entry = entry*sizgst + GSTadr;
E 5
I 5
		LOOP	WHEN index == NOrec DO EXIT;
E 5

D 5
		IF entry >= GSTadr+GSTsiz
		THEN	printf("?\n");
		ELSE	rdBlock( entry, sizeof( gstable ), &gstable );
			gstprint();
E 5
I 5
			printf("%s\n", strtab[ index ].strnam );

			inc( index );
E 5
		END;
E 3
D 5
	END;
E 5
I 5

D 7
	ELSE	LOOP	WHEN index == NOrec DO EXIT;

			WHEN imatch( word, strtab[ index ].strnam ) DO EXIT;

			inc( index );
		END;


E 7
I 7
	ELSE	index = Tabcmd( word );
	
E 7
		IF index == NOrec
		THEN	printf("?\n");

		ELSE	getnum( &entry );

			IF entry == -1L
			THEN	entry = 0L;
			END;

D 7
			temp = bufsiz[index];
E 7
I 7
			Tabdisp( index, entry );
E 7

D 7
			entry = entry*temp + stradrs[index];
E 7
I 7
			tabind[index] = entry;
I 8
			lasttab = index;
E 8
		END
	END
END
E 7

D 7
			IF entry >= stradrs[index]+strsizes[index]
			THEN	printf("?\n");
			ELSE	rdBlock( entry, 
					 bufsiz[index],
					 bufsadr[index] );
E 7
I 7
/*
 *	next: display next element of table
 */
E 7

D 7
				(*pradr[index])();
			END;
E 7
I 7
PROCEDURE next()

BEGIN	VAR	char 	word[MAXLINELENGTH];
		integer	index;

	getword( word );

	IF word[0] == eos
	THEN	index = lasttab;
	ELSE	index = Tabcmd( word );
	END;

	IF index == NOrec
	THEN	printf("?\n");

	ELSE	lasttab = index;

D 8
		IF tabind[index] == -1L
E 8
I 8
		IF tabind[index] < 0
E 8
		THEN	printf("?\n");

		ELSE	tabind[index] += 1L;
			Tabdisp( index, tabind[index] );
		END
	END
END

/*
 *	prev: display prev element of table
 */

PROCEDURE prev()

BEGIN	VAR	char 	word[MAXLINELENGTH];
		integer	index;

	getword( word );

	IF word[0] == eos
	THEN	index = lasttab;
	ELSE	index = Tabcmd( word );
	END;

	IF index == NOrec
	THEN	printf("?\n");

	ELSE	lasttab = index;

		IF tabind[index] == 0L
		THEN	printf("?\n");

		ELSE	tabind[index] -= 1L;

			Tabdisp( index, tabind[index] );
E 7
		END
	END
E 5
END
E 1
