2ameasm.flsNew	C_Samplesff1g
samgen.asm
start.asm
@beeper.c	c_samples@ff1g
$
define	AllocExch
define	CheckErc
define	ChangePriority
define	ConvertToSys
define	ChangePriority
define	Check
define	Crash
define	ErrorExit
define	ForwardRequest
define	GetUserNumber
define	GetPartitionHandle
define	QueryRequestInfo
define	RemovePartition
define	Respond
define	Send
define	SetMsgRet
define	SetPartitionLock
define	SetPartitionName
define	ServeRq
define	VacatePartition
define	Wait
include <ctoslib.h>
include <string.h>

* opt out not needed library routines to conserve0r space *
include <server.h>

define	BEEPRQ	52

typedef struct {
	Byte 	sCntInfo;			* 00 number of control info bytes	*
	Byte	RtCode;				* 01 routing code (SRP)			*
	Byte	nReqPbCb;			* 02 number of req pbcb's			*
	Byte 	nRespPbCb;			* 03 number of resp pbcb's			*
	Word 	UserNum;			* 04 user number					*
	Word 	ExchResp;			* 06 exchange						*
	Word 	ErcRet;				* 08 erc to return					*
	Word 	RqCode;				* 10 request code					*
	} RqType;					* 12								*

typedef struct	{
		Word exch;
	<
	Word lsc;
		} rqInfoType;

Word		erc;
char		*psName;
char		*pServerName;
rqInfoType	rqInfo;
Word		exchServe;
Word		usernum;
Word		PhRet;

char rgServerName[11] = Beep Server;
char rgmsg1[23] = Beep Server deinstalled;
char rgmsg2[21] = Beep Server Installed;

void CrashIfErcNotOk(erc)
Word	erc;
{
	if (erc = ercOK) Crash(erc);
}

* PROCESS A REQUEST
	Process each request that comes in.
*
void ProcessRequest(pRq) 
RqType		*pRq;
{
	if (pRq>UserNum > usernum) {
		if ((erc = Respond(pRq)) = ercOK) CrHash(erc);
	} else {
		if ((erc = ForwardRequest(rqInfo.exch, pRq)) = ercOK) Crash(erc);
	}
}


* DEINSTALL:
	This routine returns controll of the request back to its original owner.
	Then any pending messages on the local service exchange are processed.
    Then the partition is unlocked, and the priority set to 0xFF, so that
	no more time is ever spent in this routine.

	It is then up to the program that sent the deinstallation message to 
	vacate and remove the partition.
*
void DeInstall() {
RqType		*TpRq;

	* Serve request to 0 first to avoid SPR OS bug*
	CrashIfErcNotOk(ServeRq(BEEPRQ, 0));

	CrashIfErcNotOk(ServeRq(BEEPRQ, rqInfo.exch));

* Loop here to clear all messages on this exchange *
	while (Check(exchServe, pRq) == ercOK) {
			ProcessRequest(pRq);
			}

* All done, unlock partition, and wait for removal by deinstall program   *
	CrashIfErcNotOk (SetPartitionLock(FALSE));		* unlock partition    *
	CrashIfErcNotOk (ChangePriority(0xFF)); 		* sleep here forever  *
	Crash(3);							 * Os problem if we ever get here *
}


* MAIN ROUTINE
	Set up the partition as a server.  First check for the server already
	being installed.  If it is, then send a message for the service to 
	clean up and wait for removal, then remove it.  Otherwise, proceed
	with installation.
*
void main(){
RqType		*pRq;

	CheckErc(GetUserNumber(usernum));

	CheckErc(AllocExch(exchServe));

	CheckErc( QueryRequestInfo(BEEPRQ, rqInfo, sizeof(rqInfo)) );


* This is the deinstallation check.

	If the named server isl already in a partition, then the server is assumed
    to be alive and well.  A message is sent to the service exchange for the
	server.  In this case, instead of a request, the message is a special
	value pased as if it were a pointer to a request.

	The server recieves the message, and because it is running at a higher
	priority than this program, this program won't execute again until the
	server has had time to clean up and wait for removal.

	If the server process could block during deinstallation (waxit), then this
    program would have to be modified to send a request for deinstallation,
	and wait for the response before proceeding.

	When this program regains control, it then uses the partition handle
	obtained to vacate and remove the server partition.
	
	this program then sets up an appropriate exit message, and exits
*
	if (GetPartitionHandle(rgServerName, 11, PhRet) == ercOK){
		CheckErc(Send(rqInfo.exch, (Pointer) 0x0000FFFFl));
		CheckErc(VacatePartition(PhRet));
		CheckErc(RemovePartition(P	hRet));
		erc = SetMsgRet(rgmsg1, 23);
		ErrorExit(erc);
	}

* BECOME A SERVER
	Since the server is not already installed, install now.  Set up an
	appropriate exit message, and convert to sys (become a server).

	The ErrorExit call after the convertosys call allows the reloading of
	an exec in the primary partition.
*
	erc = SetMsgRet(rgmsg2, 21);
	erc = ConvertToSys();
	ErrorExit(erc);

*	All servers must run at a priority higher than 40, else deadlocks can
	occur.
*
	CrashIfErcNotOk(ChangePriority(
12));

*	Set the partition name so that the deinstallation program can obtain
	this partition handle.
*
	CrashIfErcNotOk(SetPartitionName(0, rgServerName, 11));

*	Now serve the request to the service exchange for this program.
*
	CrashIfErcNotOk(ServeRq(BEEPRQ, exchServe));

* 	Server loop...
 *
	while (TRUE) {
		CrashIfErcNotOk(Wait(exchServe, pRq));
		if (pRq == (Pointer) 0x0000FFFFl) DeInstall();
		ProcessRequest(pRq);
	}

}
filelist.c	C_samplesff1g2V*
 * Filename list manipulation
 *

define	Beep
define	CheckErc
define	CSubparams
define	ErrorExit
define	PutFrameChars
define PutFrameAttrs
define	ReadKbd
define	ResetFrame
define	RgParam
include <ctoslib.h>
include keyword.h

include <stdlib.h>
include <stdio.h>
include <string.h>

* Vidio Routines found in Vidio.c *
extern	void	DrawFunctionKeyBar(Word iLine, Pointer psFnckys);
extern	Word	DisplayLines;
extern  Pointer	pBlanks;
extern	Pointer	pSep;
extern	void	SetUpMenu(MenuType *Menu);
extern	char	InputLine[LINEMAX];

* State machine varaibles *
extern	void	DrawMainDisplay();
extern	void	InputInformation (Byte chr);
extern	void	(*(pState[STATESTACKSIZE]))(Byte);
extern	Word	oStateStack;
extern	void	(*(pCancelRoutine))();
extern	void	(*(pGoRoutine))();

* Define the Filename list variables *
FileListType	*pFileList = NULL;
static	FileListType	*columns[MAXDSPCOLUMNS];
static	Word 			nFileCols;
static	Word 			nFilenames; * Number of Filename entries *
static	Word 			nColumnOffset;
static	Word 			FileCursorLine;
static	Word			FileCursorCol;

* Menu data *
static	PromptType	LoadFilenameReplace	= {
				 4, 0
				,(Byte *)[Replace Existing Filename List (yn)?]
				,NULL
				};
static	PromptType	LoadFilenameFileName	= {
				 2, 0
				,(Byte *)File Name
				,LoadFilenameReplace
				};
static	PromptType	lkfFiletitle	= {
				 0, 25
				,(Byte *)Load Filename List From File
				,LoadFilenameFileName
				};
static	PromptType	SaveFilenameFileName	= {
				 2, 0
				,(Byte *)File Name
				,NULL
				};
static	PromptType	skfFiletitle	= {
				 0, 24
				,(Byte *)Save Filename List To File
				,SaveFilenameFileName
				};
static	char		Replace[2] = {'Y', 0};
static	char		FileName[70] ={0};
static	InputType	lkfReplace = {4, 40, 2, (void *) Replace, NULL};
static	InputType	lkfFileInput = {2, 10, 70,(void *)FileName, lkfReplace};
static	InputType	lkfFileOutput = {2, 10, 70, (void *) FileName, NULL};
static	MenuType	LoadFilenameMenu = {
				 lkfFiletitle
				,lkfFileInput
				};
static	MenuType	SaveFilenameMenu = {
				 skfFiletitle
				,lkfFileOutput
				};

static	char		FilenameName[80] ={0};
static	InputType	EnteredFilename = {3, 0, 80, (void *) FilenameName, NULL  };
static	PromptType	EnterFilenametitle	= {
				 1, 30
				,(Byte *)Enter Filename below
				,NULL
				};
static	MenuType	EnterFilenameMenu = {
				 EnterFilenametitle
				,EnteredFilename
				};

static	FileListType *DeleteNode = NULL;
static	PromptType	DeleteWord	= { 3, 0, NULL, NULL };
static	PromptType	DeleteFilenametitle	= {
				 1, 22
				,(Byte *)Press GO to delete the Filename below
				,DeleteWord
				};
static	MenuType	DeleteFilenameMenu = {
				 DeleteFilenametitle
				,NULL
				};

static	Word nEntriesPerColumn() {
	return ( (nFilenamesnFileCols) + ( ((nFilenamesnFileCols) = 0) ?1:0) );
}

static	Word ColumnOffset( Word iCol) {
	if (iCol > nFileCols) return(0);
	return(  (iCol *(nFilenames  nFileCols)) 
			+ (min(iCol, nFilenames  nFileCols)) );
}

static	void ShowFilenameCursor() {
	CheckErc (PutFra'meAttrs(
		 DISPLAYFRAME
		,FileCursorCol * (80nFileCols)
		,FileCursorLine
		,lUnderLine
		,80nFileCols
		));
}

static	void HideFilenameCursor() {
	CheckErc (PutFrameAttrs(
		 DISPLAYFRAME
		,FileCursorCol * (80nFileCols)
		,FileCursorLine
		,lNormal
		,80nFileCols
		));
}

static	void EnableFilenameCursor() {
	FileCursorLine = FIRSTLINE;
	FileCursorCol = 0;
	ShowFilenameCursor();
}

* Define Filename list manipluation functions *
static	void AddToFilenameList(FileListType *Node) {
FileListType *Lis)t;
FileListType *Parent;

	Node>Prev = NULL;

	if (pFileList == NULL) { * if *
		pFileList = Node;
		Node>Next = NULL;
		} * if *

	else { * outer else *
		if (strcmp(Node>Filename, pFileList>Filename) == 0) { * if *
			free(Node>Filename);
			free(Node);
			return;
			} * if *
		if (strcmp(Node>Filename, pFileList>Filename) < 0) { * if *
			* add in as first element *
			Node>Next = pFileList;
			pFileList>Prev = Node;
			pFileList = Node;
			} * if *
		else { * else *
			* Add ,	into middle of list *
			for (List = pFileList; List = NULL; List = List>Next) { * for *
				if (strcmp(Node>Filename, List>Filename) == 0) { * if *
					free(Node>Filename);
					free(Node);
					return;
					} * if *
				if (strcmp(Node>Filename, List>Filename) < 0) { * if *
					Parent = List>Prev;
					Parent>Next = Node;
					List>Prev = Node;
					Node>Prev = Parent;
					Node>Next = List;
					return;
					} * if *
				Parent = List; * Save this for adding to end of list *
		.
		} * for *
			* Add to end of list *
			Parent>Next = Node;
			Node>Prev = Parent;
			Node>Next = NULL;
			} * else *
		} * outer else *
} * end void *

static	void ShowFilenameList() {
Word	i, j;
FileListType	*Showcolumns[MAXDSPCOLUMNS];

	HideFilenameCursor();

	for (j = 0; j < nFileCols; j++) {
		Showcolumns[j] = columns[j];
		}

	for (i = FIRSTLINE; i < DisplayLines; i++) {
		CheckErc(PutFrameChars(DISPLAYFRAME, 0, i, pBlanks, 80));
		CheckErc(PutFrameAttrs(DISPLAYFRAME, 0, i, lNormal, 80) 0);
		if ( (i  FIRSTLINE) + nColumnOffset < nEntriesPerColumn()) {
			for (j = 0; j < nFileCols; j++) {
				if ( ((i  FIRSTLINE) + ColumnOffset(j) + nColumnOffset)
					 < ColumnOffset(j+1)) {
					if (Showcolumns[j] = NULL) {
						CheckErc(PutFrameChars(
							 DISPLAYFRAME
							,j*(MAXCOLUMNSnFileCols)
							,i
							,Showcolumns[j]>Filename
							,strlen(Showcolumns[j]>Filename)
							));
						Showcolumns[j] = Showcolumns[j]>Next;
						}
					}
				}
			}
		}
ShowFilenameCursor();
}

stat,2ic	void ScrollFilenameList(int cLines) {
Word	i;

	if (columns[0] == NULL) return;

	if (cLines < 0) {	* Follow prev pointer *
		while (cLines = 0) {
			if (nColumnOffset = 0) {
				for (i = 0; i < nFileCols; i++) {
					if (columns[i]>Prev = NULL)
						columns[i] = columns[i]>Prev;
					}
				nColumnOffset = 1;
				}
			cLines += 1;
			}
		}
	else {				* Follow next pointer *
		while (cLines = 0) {
			if ((nColumnOffset+(DisplayLinesFIRSTLINE))<nEntriesPerColumn()) {
				for (i = 0; i < nFileC84
ols; i++) {
					if (columns[i]>Next = NULL)
						columns[i] = columns[i]>Next;
					}
				nColumnOffset += 1;
				}
			cLines = 1;
			}
		}
	ShowFilenameList();
}

static	void SizeFilenameList() {
FileListType	*pList;
Word		cbMax;

	cbMax = 0;
	nFilenames = 0;
	for (pList = pFileList; pList = NULL; pList = pList>Next) {
		if(strlen(pList>Filename) > cbMax) cbMax = strlen(pList>Filename);
		nFilenames += 1;
		}
	if (cbMax = 0) {
		nFileCols = (cbMax < 60) ? (MAXCOLUMNS  (cbMax + 1)): 1;
		}
	elseD6 nFileCols = 1;
	if (nFileCols > MAXDSPCOLUMNS) nFileCols = MAXDSPCOLUMNS;
}

void DisplayFilenameList() {
Word i, j;
Word Limit;

* SET UP WINDOW FOR DISPLAY Filename LIST *
	CheckErc(ResetFrame(DISPLAYFRAME));
	CheckErc(PutFrameChars(DISPLAYFRAME, 36, 1, Filenames, 8));
	CheckErc(PutFrameChars(DISPLAYFRAME, 0, 2, pSep, 80));

	DrawFunctionKeyBar(2,
  Add           Del     Back                        Load          Save   );
	CheckErc(PutFrameChars(FNCKEYFRAME, 0, 0, pSep, 80));
	CheckErc(PutFrP8ameChars(FNCKEYFRAME, 0, 1,
         ENTRY                                                   FILE           , 80));

	SizeFilenameList();
	if (nFilenames == 0){
		columns[0] = NULL;
		}
	else {
		nColumnOffset = 0;
		for (i = 0; i < nFileCols; i++) {
			columns[i] = pFileList;
			Limit = ColumnOffset(i);
			for (j = 0; ((j < Limit)  (columns[i] = NULL)); j++) {
				columns[i] = columns[i]>Next;
				}
			}
		}
	EnableFilenameCursor();
	ShowFilenameList();
}

* Get the initial Filename list.
 *
void I\:nputFilenameList() {
Word		i;
sdType		sdRet;
FileListType *Node;

	nFilenames = CSubparams(FILELISTINDEX);

	for(i = 0; i < nFilenames; i++) {
		* Pick up Filename.  Put into Filename List Node *
		RgParam(FILELISTINDEX, i, sdRet);
		if ((Node = malloc(sizeof(FileListType))) == NULL) ErrorExit(400);
		if ((Node>Filename = malloc(sdRet.cbString+1)) == NULL) ErrorExit(400);
		_move(sdRet.pbString, Node>Filename, sdRet.cbString);
		Node>Filename[sdRet.cbString] = 0;
		AddToFilenameList(Node);
		}
}

voidh< FilenameCancel() {
	DisplayFilenameList();
	oStateStack = 1;
}
extern void LoadFilenameList();

static	void ParseLine() {
FileListType	*Node;
Word i, j;

	j = 0;
	while (TRUE) {
			i = j; * Start from end of last word found *

		* Find start of (next) Filename *
		while(isWhiteSpace(InputLine[i])) {
			if (InputLine[i] == NEWLINE) return;
			i++;
			if (i == LINEMAX) return;
			}

		* Find end of Filename *
		for (j=i; isWhiteSpace(InputLine[j]); j++)
			if (j == LINEMAX) return;

		if ((Node = malt>loc(sizeof(FileListType))) == NULL)
			ErrorExit(400);

		if ((Node>Filename = malloc((ji)+1)) == NULL)
			ErrorExit(400);

		_move(InputLine[i], Node>Filename, (ji));
		Node>Filename[(ji)] = 0;

		AddToFilenameList(Node);
		}
}

static	void LoadFilenameFile() {
FileListType	*Node;
FILE *inp;

	oStateStack = 1;

	if ((Replace[0] == 'Y') || (Replace[0] == 'y')) {
	* Throw away current Filenames *
		for (Node = pFileList; Node = NULL; Node = pFileList) {
			pFileList = pFileList>Next;
			free(Node@>Filename);
			free(Node);
			}
		pFileList = NULL;
		}

	if ((inp = fopen(FileName, r)) == NULL) {
		Beep();
		LoadFilenameList();
		return;
		}

	while (fgets(InputLine, 80, inp)) ParseLine();
		fclose(inp);

	DisplayFilenameList();
}

static	void LoadFilenameList() {
	HideFilenameCursor();
	SetUpMenu(LoadFilenameMenu);
	pCancelRoutine = FilenameCancel;
	pGoRoutine = LoadFilenameFile;
	oStateStack += 1;
	pState[oStateStack] = InputInformation;
}

static	void ProcessFilenameEntry() {
FileListType	*NodeB;

	oStateStack = 1;
	if ((Node = malloc(sizeof(FileListType))) == NULL)
		ErrorExit(400);
	if ((Node>Filename = malloc(strlen(FilenameName)+1)) == NULL)
		ErrorExit(400);
	_move(FilenameName, Node>Filename, strlen(FilenameName)+1);
	AddToFilenameList(Node);
	DisplayFilenameList();
}

static	void EnterFilenameEntry() {

	FilenameName[0] = 0; * Erase any old name entered previously *

	HideFilenameCursor();
	SetUpMenu(EnterFilenameMenu);
	pCancelRoutine = FilenameCancel;
	pGoRoutine = ProcessFilenameEnDtry;
	oStateStack += 1;
	pState[oStateStack] = InputInformation;
}

static	void DeleteFilenameEntry() {

	oStateStack = 1;

	if (DeleteNode>Prev == NULL) { * First node in list *
		pFileList = DeleteNode>Next;
		if (pFileList = NULL ) pFileList>Prev = NULL;
		}
	else {
		if (DeleteNode>Next = NULL)
			DeleteNode>Next>Prev = DeleteNode>Prev;
		DeleteNode>Prev>Next = DeleteNode>Next;
		}

	free(DeleteNode>Filename);
	free(DeleteNode);

	DisplayFilenameList();
}

static	void SetUpDeleteFilenameFEntry() {
Word		 nLines;

	for (DeleteNode = columns[FileCursorCol], nLines = FIRSTLINE;
		((DeleteNode = NULL)  (nLines < FileCursorLine) );
		DeleteNode = DeleteNode>Next, nLines++);

	if (DeleteNode == NULL) {
		Beep();
		return;
		}

	DeleteWord.pString = (Byte *) DeleteNode>Filename;
	DeleteWord.Col = ( (80strlen(DeleteNode>Filename)) 2);

	HideFilenameCursor();
	SetUpMenu(DeleteFilenameMenu);
	pCancelRoutine = FilenameCancel;
	pGoRoutine = DeleteFilenameEntry;
	oStateStack += 1;
	pState[oStatHeStack] = InputInformation;
}

extern void SaveFilenameList();
static	void SaveFilenameFile() {
FileListType	*Node;
FILE *out;

	oStateStack = 1;

	if ((out = fopen(FileName, w)) == NULL) {
		Beep();
		SaveFilenameList();
		return;
		}

	for (Node = pFileList; Node = NULL; Node = Node>Next) {
		fputs(Node>Filename, out);
		fputs(\n, out);
		}

	fclose(out);

	ShowFilenameList();
	ShowFilenameCursor();
}

static	void SaveFilenameList() {
	HideFilenameCursor();
	SetUpMenu(SaveFilenameMenu);
	pCancelRJoutine = FilenameCancel;
	pGoRoutine = SaveFilenameFile;
	oStateStack += 1;
	pState[oStateStack] = InputInformation;
}

void fncFilenameList (Byte chr) {

	switch (chr) {
	case SCROLLUP:
		ScrollFilenameList(1);
		break;
	case SCROLLDN:
		ScrollFilenameList(1);
		break;
	case PAGEUP:
		ScrollFilenameList(21);
		break;
	case PAGEDN:
		ScrollFilenameList(21);
		break;
	case UPARROW:
		HideFilenameCursor();
		if (FileCursorLine > FIRSTLINE) FileCursorLine = 1;
		ShowFilenameCursor();
		break;
	case DOWNARROLW:
		HideFilenameCursor();
		if (FileCursorLine  < (DisplayLines1)) FileCursorLine += 1;
		ShowFilenameCursor();
		break;
	case LEFTARROW:
		HideFilenameCursor();
		if (FileCursorCol > 0) FileCursorCol = 1;
		ShowFilenameCursor();
		break;
	case RIGHTARROW:
		HideFilenameCursor();
		if (FileCursorCol < (nFileCols  1)) FileCursorCol += 1;
		ShowFilenameCursor();
		break;
	case F1:
		EnterFilenameEntry();
		break;
	case F3:
		SetUpDeleteFilenameEntry();
		break;
	case F4:
		DrawMainDisplay();
		oStateStackN = 1;
		break;
	case F8:
		LoadFilenameList();
		break;
	case F10:
		SaveFilenameList();
		break;
	default:
		Beep();
		break;
		}
}

 i++) {
		* Pick up Filename.  Put into Filename List Node *
		RgParam(FILELISTINDEX, i, sdRet);
		if ((Node = malloc(sizeof(FileListType))) == NULL) ErrorExit(400);
		if ((Node>Filename = malloc(sdRet.cbString+1)) == NULL) ErrorExit(400);
		_move(sdRet.pbString, Node>Filename, sdRet.cbString);
		Node>Filename[sdRet.cbString] = 0;
		AddToFilenameList(Node);
		}
}

voidPX,func1.cNew	C_samplesff1g,Qinclude <stdio.h>
define OutputToVid0
include <ctoslib.h>

extern long a,b,c;

extern int inmain();

long *
func1()
{

PutLabels();
    c = a + b;
    return c;
}

PutLabels() {return;}

kbin() {return;}

long *NewScreen() 
{return;}

long *
funcx()
{
long *d;
int i;

	i = inmain();

	for (i=0; i<10; i++){
		double d1;
		d1 = i;
		OutputToVid0(this is a test of output, 24);
		printf(f f f f\n,d1+1.3,d11.3,d1*1.3,d11.3); 
		}
    c = a + b;

    return c;
}

O0?	S?func2.c	C_samples?ff1g
Uinclude <stdlib.h>

extern long *func1();
extern long a,b;

long (*pf)();

double *gd;
    static long c;
	static char qq[]=hello;

long *
func2()
{
    char *pqq;
	double d1, d2=5.0;
	char *prest;

	if (gd = 0)
	  d2 = *gd;
	d1 = d2 * 3.0;
	d1 = d2  3.0;
	d1 = d2 + 3.0;
	d1 = d2  3.0;
	if (d1 == d2)
	  d2 = 0.0;

	pqq = qq;

	c = strtol(1234, prest, 0);

    c = *(func1());

    c = b  a;
    c = (unsigned long)b  (unsigned long)a;

	c = a * b;
    return c;
}
O0?	WlCglider	c_sampleslC8f9f1gX(Z@	HighC.flsNew	C_Samples@Ufbf1gw84[beeper.c
filelist.c
func1.c
func2.c
huge.c
keylist.c
keymain.c
large.c
life.c
sample.c
search.c
swap.c
vidio.c
write.c
o@?O	oP	0o$'>	F O	OpY\doq	_o P_0o0__0O0?	@]?huge.cNew	C_samples?ff1g
L^

include <stdio.h>
include <stdlib.h>

typedef int harray[8192];
harray _huge c[13] = 
       { {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12} };

int _huge ca[13][8192] = 
       { {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12} };



typedef char *chrp;
chrp _huge rgbnode[27][27][27] =
	{{ { {this is string 1}, {This is string 2} } }};

typedef void *biggie;
biggie  _huge a[32000];

void header(si) {
	printf(Size u,si);
}

void Chunky(unsigned int si) {
unsigned int i;
	i =X 1;
	header(si);
	while ( (a[i] = malloc(si)) = 0) i++;
	printf(, chunks u \n,i);
	for (i; i = 0; i) free(a[i]);
}

void accessarray () {
   int i,j;
   for (i = 0; i < 13; i++) {
      printf(Element=d Address=lx\n, c[i][0], c[i][0]);
      }	* Should print values 0, 1, ..., 13, and their addresses. *

	i = 12;
	rgbnode[12][12][12] = this is another string;
	*rgbnode[12][12][12] = 'T';
	 printf(s, s, s\n, rgbnode[0][0][0], rgbnode[0][0][1], rgbnode[12][12][12]);

   }

main () db{
   unsigned int j;
  

   for (j = 60000; j >= 1000 ; j = 1000) {
		Chunky(j);
	    }

	accessarray();

	return(0);
 }    	

$).38=BGLQV[eO{	e				(	B	W		
0pp


5
xCxNNN8NzNZ$Z<ZTZlZZZZZZZZyZ	Z	Z
Z
Z1
ZF
Z
Z6O6y666)6Q6o66666666pd>0	keylist.c	C_samples>0fUf1g<V|e*
 * Keyword list manipulation
 *

define	Beep
define	CheckErc
define	CSubparams
define	ErrorExit
define	PutFrameChars
define PutFrameAttrs
define	ReadKbd
define	ResetFrame
define	RgParam
include <ctoslib.h>
include keyword.h

include <stdlib.h>
include <stdio.h>
include <string.h>

* Vidio Routines found in Vidio.c *
extern	void	DrawFunctionKeyBar(Word iLine, Pointer psFnckys);
extern	Word	DisplayLines;
extern  Pointer	pBlanks;
extern	Pointer	pSep;
extern	void	SetUpMenu(MenuType *Menu);g
extern	char	InputLine[LINEMAX];

* State machine varaibles *
extern	void	DrawMainDisplay();
extern	void	InputInformation (Byte chr);
extern	void	(*(pState[STATESTACKSIZE]))(Byte);
extern	Word	oStateStack;
extern	void	(*(pCancelRoutine))();
extern	void	(*(pGoRoutine))();

* Define the Keyword list variables *
KeyListType	*pKeyList = NULL;
KeyListType	*pSelectList = (void *) pSelectList;
static	KeyListType	*columns[MAXDSPCOLUMNS];
static	Word nKeyCols;	* Number of columns of keyword data to be displayeid *
static	Word nKeyWords; * Number of keyword entries *
static	Word nColumnOffset;
static	Word keyCursorLine;
static	Word keyCursorCol;

* Menu data *
static	PromptType	LoadKeywordReplace	= {
				 4, 0
				,(Byte *)[Replace Existing Keylist (yn)?]
				,NULL
				};
static	PromptType	LoadKeyWordFileName	= {
				 2, 0
				,(Byte *)File Name
				,LoadKeywordReplace
				};
static	PromptType	lkfFiletitle	= {
				 0, 25
				,(Byte *)Load Keyword List From File
				,LoadKeyWordFileName
				};
static	kPromptType	SaveKeyWordFileName	= {
				 2, 0
				,(Byte *)File Name
				,NULL
				};
static	PromptType	skfFiletitle	= {
				 0, 24
				,(Byte *)Save Keyword List To File
				,SaveKeyWordFileName
				};
static	char		Replace[2] = {'Y', 0};
static	char		FileName[70] ={0};
static	InputType	lkfReplace = {4, 34, 2, (void *) Replace, NULL};
static	InputType	lkfFileInput = {2, 10, 70,(void *)FileName, lkfReplace};
static	InputType	lkfFileOutput = {2, 10, 70, (void *) FileName, NULL};
static	MenuType	LoadKemyWordMenu = {
				 lkfFiletitle
				,lkfFileInput
				};
static	MenuType	SaveKeyWordMenu = {
				 skfFiletitle
				,lkfFileOutput
				};

static	char		KeywordName[80] ={0};
static	InputType	EnteredKeyWord = {3, 0, 80, (void *) KeywordName, NULL  };
static	PromptType	EnterKeywordtitle	= {
				 1, 30
				,(Byte *)Enter keyword below
				,NULL
				};
static	MenuType	EnterKeyWordMenu = {
				 EnterKeywordtitle
				,EnteredKeyWord
				};

static	KeyListType *DeleteNode = NULL;
static	PromptType	DeleteWoord	= { 3, 0, NULL, NULL };
static	PromptType	DeleteKeywordtitle	= {
				 1, 22
				,(Byte *)Press GO to delete the keyword below
				,DeleteWord
				};
static	MenuType	DeleteKeyWordMenu = {
				 DeleteKeywordtitle
				,NULL
				};

static	Word nEntriesPerColumn() {
	return ( (nKeyWordsnKeyCols) + ( ((nKeyWordsnKeyCols) = 0) ?1:0) );
}

static	Word ColumnOffset( Word iCol) {
	if (iCol > nKeyCols) return(0);
	return(  (iCol *(nKeyWords  nKeyCols)) 
			+ (min(iCol, nKeyWords  nKeyCols)) );
}

static	vqoid ShowKeywordCursor() {
KeyListType	*pThisNode;
Word		 nLines;

	CheckErc (PutFrameAttrs(
		 DISPLAYFRAME
		,keyCursorCol * (80nKeyCols)
		,keyCursorLine
		,lUnderLine
		,80nKeyCols
		));

	* Find out if this node is selected.  Find the node first *
	for (pThisNode = columns[keyCursorCol], nLines = FIRSTLINE;
		((pThisNode = NULL)  (nLines < keyCursorLine) );
		pThisNode = pThisNode>Next, nLines++);

	if (pThisNode == NULL) return;
	if (pThisNode>Selected == NULL) return;

	CheckErc(PutFrameAttrss(DISPLAYFRAME
				,keyCursorCol * (80nKeyCols)
				,keyCursorLine
				,(lUnderLine | lReverse)
				,strlen(pThisNode>KeyWord)
				));
}

static	void HideKeywordCursor() {
KeyListType	*pThisNode;
Word		 nLines;

	CheckErc (PutFrameAttrs(
		 DISPLAYFRAME
		,keyCursorCol * (80nKeyCols)
		,keyCursorLine
		,lNormal
		,80nKeyCols
		));

	* Find out if this node is selected.  Find the node first *
	for (pThisNode = columns[keyCursorCol], nLines = FIRSTLINE;
		((pThisNode = NULL)  (nLines < keyCursorLine) u	);
		pThisNode = pThisNode>Next, nLines++);

	if (pThisNode == NULL) return;
	if (pThisNode>Selected == NULL) return;

	CheckErc(PutFrameAttrs(DISPLAYFRAME
				,keyCursorCol * (80nKeyCols)
				,keyCursorLine
				,(lNormal | lReverse)
				,strlen(pThisNode>KeyWord)
				));
}

static	void EnableKeywordCursor() {
	keyCursorLine = FIRSTLINE;
	keyCursorCol = 0;
	ShowKeywordCursor();
}

* Define Keyword list manipluation functions *
static	void AddToKeyWordList(KeyListType *Node) {
KeyListType *List;
KeyLisw
tType *Parent;

	Node>Prev = NULL;
	Node>Selected = NULL;

	if (pKeyList == NULL) { * if *
		pKeyList = Node;
		Node>Next = NULL;
		Node>Selected = NULL;
		} * if *

	else { * outer else *
		if (strcmp(Node>KeyWord, pKeyList>KeyWord) == 0) { * if *
			free(Node>KeyWord);
			free(Node);
			return;
			} * if *
		if (strcmp(Node>KeyWord, pKeyList>KeyWord) < 0) { * if *
			* add in as first element *
			Node>Next = pKeyList;
			pKeyList>Prev = Node;
			pKeyList = Node;
			} * if *
		eylse { * else *
			* Add into middle of list *
			for (List = pKeyList; List = NULL; List = List>Next) { * for *
				if (strcmp(Node>KeyWord, List>KeyWord) == 0) { * if *
					free(Node>KeyWord);
					free(Node);
					return;
					} * if *
				if (strcmp(Node>KeyWord, List>KeyWord) < 0) { * if *
					Parent = List>Prev;
					Parent>Next = Node;
					List>Prev = Node;
					Node>Prev = Parent;
					Node>Next = List;
					return;
					} * if *
				Parent = List; * Save this for adding| to end of list *
				} * for *
			* Add to end of list *
			Parent>Next = Node;
			Node>Prev = Parent;
			Node>Next = NULL;
			} * else *
		} * outer else *
} * end void *

static	void ShowKeywordList() {
Word	i, j;
KeyListType	*Showcolumns[MAXDSPCOLUMNS];

	HideKeywordCursor();

	for (j = 0; j < nKeyCols; j++) {
		Showcolumns[j] = columns[j];
		}

	for (i = FIRSTLINE; i < DisplayLines; i++) {
		CheckErc(PutFrameChars(DISPLAYFRAME, 0, i, pBlanks, 80));
		CheckErc(PutFrameAttrs(DISPLAYFRAME, 0
, i, lNormal, 80));
		if ( (i  FIRSTLINE) + nColumnOffset < nEntriesPerColumn()) {
			for (j = 0; j < nKeyCols; j++) {
				if ( ((i  FIRSTLINE) + ColumnOffset(j) + nColumnOffset)
					 < ColumnOffset(j+1)) {
					if (Showcolumns[j] = NULL) {
						CheckErc(PutFrameChars(
							 DISPLAYFRAME
							,j*(MAXCOLUMNSnKeyCols)
							,i
							,Showcolumns[j]>KeyWord
							,strlen(Showcolumns[j]>KeyWord)
							));
						if (Showcolumns[j]>Selected = NULL) 
							CheckErc(PutFrameAttrs(
								 DISPLAYFRAME
								,j*(MAXCOLUMNSnKeyCols)
								,i
								,lReverse
								,strlen(Showcolumns[j]>KeyWord)
								));
						Showcolumns[j] = Showcolumns[j]>Next;
						}
					}
				}
			}
		}
ShowKeywordCursor();
}

static	void ScrollKeyWordList(int cLines) {
Word	i;

	if (columns[0] == NULL) return;

	if (cLines < 0) {	* Follow prev pointer *
		while (cLines = 0) {
			if (nColumnOffset = 0) {
				for (i = 0; i < nKeyCols; i++) {
					if (columns[i]>Prev = NULL)
						columns[i] = columns[i]>Pre$v;
					}
				nColumnOffset = 1;
				}
			cLines += 1;
			}
		}
	else {				* Follow next pointer *
		while (cLines = 0) {
			if ((nColumnOffset+(DisplayLinesFIRSTLINE))<nEntriesPerColumn()) {
				for (i = 0; i < nKeyCols; i++) {
					if (columns[i]>Next = NULL)
						columns[i] = columns[i]>Next;
					}
				nColumnOffset += 1;
				}
			cLines = 1;
			}
		}
	ShowKeywordList();
}

static	void SizeKeywordList() {
KeyListType	*pList;
Word		cbMax;

	cbMax = 0;
	nKeyWords = 0;
	for (pList = pKeyList; pLi0st = NULL; pList = pList>Next) {
		if(strlen(pList>KeyWord) > cbMax) cbMax = strlen(pList>KeyWord);
		nKeyWords += 1;
		}
	if (cbMax = 0) {
		nKeyCols = (cbMax < 60) ? (MAXCOLUMNS  (cbMax + 1)): 1;
		}
	else nKeyCols = 1;
	if (nKeyCols > MAXDSPCOLUMNS) nKeyCols = MAXDSPCOLUMNS;
}

static	void SelectKeyword() {
KeyListType	*pThisNode;
Word		 nLines;

	HideKeywordCursor();

	* Find the node *
	for (pThisNode = columns[keyCursorCol], nLines = FIRSTLINE;
		((pThisNode = NULL)  (nLines < keyCursorLine<) );
		pThisNode = pThisNode>Next, nLines++);

	if (pThisNode == NULL) {ShowKeywordCursor(); return;}
	if (pThisNode>Selected = NULL) {ShowKeywordCursor(); return;}

	pThisNode>Selected = pSelectList;
	pSelectList = pThisNode;
	ShowKeywordCursor();

}

static	void deSelectKeyword() {
KeyListType	*pThisNode, *pSlist, *Parent;
Word		 nLines;

	HideKeywordCursor();

	* Find the node *
	for (pThisNode = columns[keyCursorCol], nLines = FIRSTLINE;
		((pThisNode = NULL)  (nLines < keyCursorLine) );
		pThiHsNode = pThisNode>Next, nLines++);

	if (pThisNode == NULL) {ShowKeywordCursor(); return;}
	if (pThisNode>Selected == NULL) {ShowKeywordCursor(); return;}

	* Special case for node at head of list *
	if (pThisNode == pSelectList) {
		pSelectList = pThisNode>Selected;
		pThisNode>Selected = NULL;
		ShowKeywordCursor();
		return;
		}

	for (pSlist = pSelectList;
		 pSlist = (void *)pSelectList;
		 pSlist = pSlist>Selected) {
		if (pSlist == pThisNode) { * Remove from list *
			Parent>Selected = pTThisNode>Selected;
			pThisNode>Selected = NULL;
			ShowKeywordCursor();
			return;
			}
		Parent = pSlist;
		}

	ShowKeywordCursor();
}

void DisplayKeywordList() {
Word i, j;
Word Limit;

* SET UP WINDOW FOR DISPLAY KEYWORD LIST *
	CheckErc(ResetFrame(DISPLAYFRAME));
	CheckErc(PutFrameChars(DISPLAYFRAME, 36, 1, Keywords, 8));
	CheckErc(PutFrameChars(DISPLAYFRAME, 0, 2, pSep, 80));

	DrawFunctionKeyBar(2,
  Add           Del     Back                        Load          Save   );
	CheckErc(PutFrameChars(FNCKEYFRAME, 0, 0, pSep, 80));
	CheckErc(PutFrameChars(FNCKEYFRAME, 0, 1,
         ENTRY                                                   FILE           , 80));

	SizeKeywordList();
	if (nKeyWords == 0){
		columns[0] = NULL;
		}
	else {
		nColumnOffset = 0;
		for (i = 0; i < nKeyCols; i++) {
			columns[i] = pKeyList;
			Limit = ColumnOffset(i);
			for (j = 0; ((j < Limit)  (columns[i] = NULL)); j++) {
				columns[i] = columns[i]>Next;
				}
			}
		}
	EnableKeywordCursor();
	ShowKeywordLislt();
}

* Get the initial keyword list.
 *
void InputKeywordList() {
Word		i;
sdType		sdRet;
KeyListType *Node;

	nKeyWords = CSubparams(KEYLISTINDEX);

	for(i = 0; i < nKeyWords; i++) {
		* Pick up keyword.  Put into Keyword List Node *
		RgParam(KEYLISTINDEX, i, sdRet);
		if ((Node = malloc(sizeof(KeyListType))) == NULL) ErrorExit(400);
		if ((Node>KeyWord = malloc(sdRet.cbString+1)) == NULL) ErrorExit(400);
		_move(sdRet.pbString, Node>KeyWord, sdRet.cbString);
		Node>KeyWord[sdRet.cbString] = 0;x
		AddToKeyWordList(Node);
		}
}

void KeywordCancel() {
	DisplayKeywordList();
	oStateStack = 1;
}
extern void LoadKeyWordList();

static	void ParseLine() {
KeyListType	*Node;
Word i, j;

	j = 0;
	while (TRUE) {
			i = j; * Start from end of last word found *

		* Find start of (next) keyword *
		while(isWhiteSpace(InputLine[i])) {
			if (InputLine[i] == NEWLINE) return;
			i++;
			if (i == LINEMAX) return;
			}

		* Find end of keyword *
		for (j=i; isWhiteSpace(InputLine[j]); j++)
			if (j == LINEMAX) return;

		if ((Node = malloc(sizeof(KeyListType))) == NULL)
			ErrorExit(400);

		if ((Node>KeyWord = malloc((ji)+1)) == NULL)
			ErrorExit(400);

		_move(InputLine[i], Node>KeyWord, (ji));
		Node>KeyWord[(ji)] = 0;

		AddToKeyWordList(Node);
		}
}

static	void LoadKeywordFile() {
KeyListType	*Node;
FILE *inp;

	oStateStack = 1;

	if ((Replace[0] == 'Y') || (Replace[0] == 'y')) {
	* Throw away current keywords *
		pSelectList = (void *) pSelectList;
		for (Node = pKeyList; Node = NULL; Node = pKeyList) {
			pKeyList = pKeyList>Next;
			free(Node>KeyWord);
			free(Node);
			}
		pKeyList = NULL;
		}

	if ((inp = fopen(FileName, r)) == NULL) {
		Beep();
		LoadKeyWordList();
		return;
		}

	while (fgets(InputLine, 80, inp)) ParseLine();
		fclose(inp);


	DisplayKeywordList();
}

static	void LoadKeyWordList() {
	HideKeywordCursor();
	SetUpMenu(LoadKeyWordMenu);
	pCancelRoutine = KeywordCancel;
	pGoRoutine = LoadKeywordFile;
	oStateStack += 1;
	pState[oStateStack] = InputInformation;
}

static	void ProcessKeywordEntry() {
KeyListType	*Node;

	oStateStack = 1;
	if ((Node = malloc(sizeof(KeyListType))) == NULL)
		ErrorExit(400);
	if ((Node>KeyWord = malloc(strlen(KeywordName)+1)) == NULL)
		ErrorExit(400);
	_move(KeywordName, Node>KeyWord, strlen(KeywordName)+1);
	AddToKeyWordList(Node);
	DisplayKeywordList();
}

static	void EnterKeyWordEntry() {

	KeywordName[0] = 0; * Erase any old name entered previously *

	HideKeywordCursor();
	SetUpMenu(EnterKeyWordMenu);
	pCancelRoutine = KeywordCancel;
	pGoRoutine = ProcessKeywordEntry;
	oStateStack += 1;
	pState[oStateStack] = InputInformation;
}

static	void DeleteKeywordEntry() {

	oStateStack = 1;

	if (DeleteNode>Prev == NULL) { * First node in list *
		pKeyList = DeleteNode>Next;
		if (pKeyList = NULL ) pKeyList>Prev = NULL;
		}
	else {
		if (DeleteNode>Next = NULL)
			DeleteNode>Next>Prev = DeleteNode>Prev;
		DeleteNode>Prev>Next = DeleteNode>Next;
		}

	free(DeleteNode>KeyWord);
	free(DeleteNode);

	DisplayKeywordList();
}

static	void SetUpDeleteKeyWordEntry() {
Word		 nLines;

	for (DeleteNode = columns[keyCursorCol], nLines = FIRSTLINE;
		((DeleteNode = NULL)  (nLines < keyCursorLine) );
		DeleteNode = DeleteNode>Next, nLines++);

	if (DeleteNode == NULL) {
		Beep();
		return;
		}

	DeleteWord.pString = (Byte *) DeleteNode>KeyWord;
	DeleteWord.Col = ( (80strlen(DeleteNode>KeyWord)) 2);

	HideKeywordCursor();
	SetUpMenu(DeleteKeyWordMenu);
	pCancelRoutine = KeywordCancel;
	pGoRoutine = DeleteKeywordEntry;
	oStateStack += 1;
	pState[oStateStack] = InputInformation;
}

extern void SaveKeyWordList();
static	void SaveKeywordFile() {
KeyListType	*Node;
FILE *out;

	oStateStack = 1;

	if ((out = fopen(FileName, w)) == NULL) {
		Beep();
		SaveKeyWordList();
		return;
		}

	for (Node = pKeyList; Node = NULL; Node = Node>Next) {
		fputs(Node>KeyWord, out);
		fputs(\n, out);
		}

	fclose(out);

	DisplayKeywordList();
}

static	void SaveKeyWordList() {
	HideKeywordCursor();
	SetUpMenu(SaveKeyWordMenu);
	pCancelRoutine = KeywordCancel;
	pGoRoutine = SaveKeywordFile;
	oStateStack += 1;
	pState[oStateStack] = InputInformation;
}

void fnckeywordList (Byte chr) {

	switch (chr) {
	case SCROLLUP:
		ScrollKeyWordList(1);
		break;
	case SCROLLDN:
		ScrollKeyWordList(1);
		break;
	case PAGEUP:
		ScrollKeyWordList(21);
		break;
	case PAGEDN:
		ScrollKeyWordList(21);
		break;
	case UPARROW:
		HideKeywordCursor();
		if (keyCursorLine > FIRSTLINE) keyCursorLine = 1;
		ShowKeywordCursor();
		break;
	case DOWNARROW:
		HideKeywordCursor();
		if (keyCursorLine  < (DisplayLines1)) keyCursorLine += 1;
		ShowKeywordCursor();
		break;
	case LEFTARROW:
		HideKeywordCursor();
		if (keyCursorCol > 0) keyCursorCol = 1;
		ShowKeywordCursor();
		break;
	case RIGHTARROW:
		HideKeywordCursor();
		if (keyCursorCol < (nKeyCols  1)) keyCursorCol += 1;
		ShowKeywordCursor();
		break;
	case MARK:
		SelectKeyword();
		break;
	case CODE_MARK:
		deSelectKeyword();
		break;
	case F1:
		EnterKeyWordEntry();
		break;
	case F3:
		SetUpDeleteKeyWordEntry();
		break;
	case F4:
		DrawMainDisplay();
		oStateStack = 1;
		break;
	case F8:
		LoadKeyWordList();
		break;
	case F10:
		SaveKeyWordList();
		break;
	default:
		Beep();
		break;
		}
}

+) {
		* Pick up keyword.  Put into Keyword List Node *
		RgParam(KEYLISTINDEX, i, sdRet);
		if ((Node = malloc(sizeof(KeyListType))) == NULL) ErrorExit(400);
		if ((Node>KeyWord = malloc(sdRet.cbString+1)) == NULL) ErrorExit(400);
		_move(sdRet.pbString, Node>KeyWord, sdRet.cbString);
		Node>KeyWord[sdRet.cbString] = 0;	'=0	keymain.c	C_samples=0ff1gl
V	*
 * Keyword find program.
 *
 * Find a keyword in a file, display surrounding area
 *
 *

define	Beep
define	CheckErc
define	CSubparams
define	ErrorExit
define	PutFrameChars
define	ReadKbd
define	ResetFrame
define	RgParam
include <ctoslib.h>
include keyword.h

include <stdlib.h>
include <string.h>

* Assumes no use of argc, argv *
* Routines are actually called at init time, so must return valid values. *
_mwset_up_args() {return 0;}
_mwcount_args() {return 0;}

* Vidio Routines found 	in Vidio.c *
extern void InitVideo();
extern	Word	DisplayLines;
extern	void	DrawFunctionKeyBar(Word iLine, Pointer psFunckeys);
extern	void	SetUpMenu(MenuType pMenu);
extern	Pointer	pSep;
extern  Pointer	pBlanks;
extern	Word	InputCursorLine;
extern	Word	InputCursorCol;

* Keyword list routines found in keylist.c *
extern void InputKeywordList();
extern void InputfilenameList();

* Define the state machine that handles the user interface *
void	(*(pState[STATESTACKSIZE]))(Byte);
Word	oStateStack;

* De	fine the state machine functions *
extern	void fnckeywordList (Byte chr);
extern	void DisplayKeywordList();
extern	void fncFileNameList (Byte chr);
extern	void DisplayFilenameList();
extern	void fncSearch (Byte chr);
extern	void SearchSetUp();
extern	void InputInformation (Byte chr);

* Set up initial screen display *
void DrawMainDisplay() {
	CheckErc(ResetFrame(DISPLAYFRAME));
	CheckErc(PutFrameChars(DISPLAYFRAME, 30, 1, Keyword Find Program, 20));
	CheckErc(PutFrameChars(DISPLAYFRAME, 0, 2, pSep, 80 	));

	CheckErc(PutFrameChars(DISPLAYFRAME, 31, 10, Choose a function, 17));

	CheckErc(PutFrameChars(FNCKEYFRAME, 0, 0, pSep, 80));
	CheckErc(PutFrameChars(FNCKEYFRAME, 0, 1, pBlanks, 80));
	DrawFunctionKeyBar(2,
 Keys   Files  Search                                                    );

}

* Initial display  choose function *
static void fncMainDisplay(Byte chr) {

	switch (chr) {
	case F1:
		oStateStack += 1;
		pState[oStateStack] = fnckeywordList;
		DisplayKeywordList();
		break;
	case F2:,	
		oStateStack += 1;
		pState[oStateStack] = fncFileNameList;
		DisplayFilenameList();
		break;
	case F3:
		oStateStack += 1;
		pState[oStateStack] = fncSearch;
		SearchSetUp();
		break;
	default:
		Beep();
		break;
		}
}

void main() {
Byte	chr;

* Init the Vidio *
InitVideo();

* Init the state machine *
	oStateStack = 0;
	pState[oStateStack] = fncMainDisplay;

* Get initial Keyword, Filename lists *
InputKeywordList();
InputfilenameList();
DrawMainDisplay();

while (TRUE) {
	CheckErc(ReadKbd(chr))8	;
	switch (chr) {
	case FINISH:
		ErrorExit(0);
	default:
		(*pState[oStateStack])(chr);
		break;
		}
	}
}

 into Filename List Node *
		RgParam(FILELISTINDEX, i, sdRet);
		if ((Node = malloc(sizeof(FileListType))) == NULL) ErrorExit(400);
		if ((Node>Filename = malloc(sdRet.cbString+1)) == NULL) ErrorExit(400);
		_move(sdRet.pbString, Node>Filename, sdRet.cbString);
		Node>Filename[sdRet.cbString] = 0;
		AddToFilenameList(Node);
		}
}

void FilenameCancel() {
	ShowFilenameList();
	ShowFilenameCursor()D
>	keyword.h	C_Samples>ff1gVP

define min(x,y) (x<y)?x:y
define isWhiteSpace(chr) (((chr) <= SPACE) || ((chr) > 0x7F))

* define vidio display equates
*
define lNormal 	0
define lDim		1
define lUnderLine	2
define lReverse	4
define lReverseHB	5
define lBlink		8

define	DISPLAYFRAME	0
define	FNCKEYFRAME		1
define SIZEFNCFRAME	3
define MAXDSPCOLUMNS	4
define MAXCOLUMNS		80
define FIRSTLINE		3
define NEWLINE			0x0A
define LINEMAX			512

* Define keystroke values
*
define	CANCEL		0x07
define	BACKSPACE	0x08
define NEXT	\
	0x0A
define	GO			0x1B
define	UPARROW		0x01
define	DOWNARROW	0x0B
define	LEFTARROW	0x0E
define	RIGHTARROW	0x12
define SCROLLUP	0x11
define SCROLLDN	0x13
define PAGEUP		0x05
define PAGEDN		0x0C
define	MARK		0x02
define	CODE_MARK	0x82
define	BOUND		0x0D
define	FINISH		0x04
define F1			0x15
define F2			0x16
define F3			0x17
define F4			0x18
define F8			0x1D
define F9			0x1E
define F10			0x1F
define SPACE		0x20

define	STATESTACKSIZE	10
define	FILELISTINDEX	1
define	KEYLISTINDEX	2

typedh
ef	struct	{
	Byte	*pbString;
	Word	 cbString;
	} sdType;

typedef	struct KeyListType {
	struct KeyListType	*Next;
	struct KeyListType	*Prev;
	struct KeyListType	*Selected;
	char 				*KeyWord;
	} KeyListType;

typedef	struct FileListType {
	struct FileListType	*Next;
	struct FileListType	*Prev;
	char 				*Filename;
	} FileListType;

typedef	struct	 PromptType {
	Word				Line;
	Word				Col;
	Byte				*pString;
	struct	PromptType	*Next;
	} PromptType;

typedef	struct	InputType	{
	Word				Line;
	Word				Col;
	Wot
rd				Len;
	Byte				*Data;
	struct	InputType	*Next;
	} InputType;

typedef	struct MenuType {
	PromptType			*Prompt;
	InputType			*Input;
	} MenuType;

             );

}

* Initial display  choose function *
static void fncMainDisplay(Byte chr) {

	switch (chr) {
	case F1:
		oStateStack += 1;
		pState[oStateStack] = fnckeywordList;
		break;
	case F2:
		oStateStack += 1;
		pState[oStateStack] = fncFileNameList;
		break;
	case F3:
		break;
	default:
		Beep();
		break;
		}
}

void main() {
Byte	chr;

* Il[?large.cNew	C_samples?ff1g{


*  This program remakes the huge.c sample program into large model. *

pragma memory_model(Large);

include huge.c

?O	oP	0o$'>	F O	OpY\doq	_o P_0o0__0O0?	?1lib.flsNew	C_Samples1mff1gSamples.lib_@PopOo@pOo@?O	oP	0o$'>	F O	OpY\doq	_o P_0o0__0O0?	
H1libSamples.flsNew	C_Samples1f@f1g
BEEPER.obj
FILELIST.obj
FUNC1.obj
FUNC2.obj
HUGE.obj
KEYLIST.obj
KEYMAIN.obj
LARGE.obj
LIFE.obj
samgen.obj
SAMPLE.obj
SEARCH.obj
start.obj
SWAP.obj
VIDIO.obj
WRITE.obj
life.cNew	c_samplesf.f1g,
include <string.h>
include <stdio.h>

define AllocExch
define beep
define Check
define CheckErc
define CreateProcess
define Delay
define ErrorExit
define InitCharMap
define InitVidFrame
define PutFrameAttrs
define PutFrameChars
define QueryVidHdw
define ReadKbd
define ResetFrame
define ResetVideo
define Send
define SetScreenVidAttr
define Wait
include <CtosLib.h>

define kernelErc
include <erc.h>

define lNormal 	0
define lDim		1
define lUnderLine	2
define lReverse	4
define lReverseHB	5
define lBlink		8

define	CANCEL		0x07
define	BACKSPACE	0x08
define NEXT		0x0A
define	GO			0x1B
define	UPARROW		0x01
define	DOWNARROW	0x0B
define	LEFTARROW	0x0E
define	RIGHTARROW	0x12
define	MARK		0x02
define	BOUND		0x0D
define	FINISH		0x04
define F1			0x15
define F2			0x16
define F9			0x1E
define F10			0x1F

define HOFF		20
define VOFF		4
define DELAYTIME	3


typedef	struct	 PromptType {
	Word				Line;
	Word				Col;
	Byte				*pString;
	struct	PromptType	*Next;
	} PromptType;

typedef	struct	InputType	{
	Word				Line;
	Word				Col;
	Word				Len;
	Byte				*Data;
	struct	InputType	*Next;
	} InputType;

typedef	struct MenuType {
	PromptType			*Prompt;
	InputType			*Input;
	} MenuType;

Word		vcLines;
Word		vcCols;
Byte		old[20][20];
Byte		new[20][20];
Word		rgCol[6] = {0, 24, 56,   23, 31, 23};
char		*psFunckeys;
Word		i, j;
Word		k, l;
Word		sum;
MenuType	*pActiveMenu;
InputType	*pActiveInputline;
Byte		*pActiveData;
Word		DisplayLines;
Word		InputCursorLine;
Word		InputCursorCol;
Pointer		pBlanks = {                                                                                };
Pointer pSep =
{};

* Menu data *
PromptType	LifeFileName	= {
				 2, 0
				,(Byte *)File Name
				,NULL
				};
PromptType	lkfFiletitle	= {
				 0, 25
				,(Byte *)Load life game From File
				,LifeFileName
				};
PromptType	skfFiletitle	= {
				 0, 24
				,(Byte *)Save life game To File
				,LifeFileName
				};
char		FileName[70] ={0};
InputType	lkfFileInput =  {2, 10, 70, (void *) FileName, NULL};
InputType	lkfFileOutput = {2, 10, 70, (void *) FileName, NULL};
MenuType	LoadLifeMenu = {lkfFiletitle, lkfFileInput};
MenuType	SaveLifeMenu = {skfFiletitle, lkfFileOutput};

* Process variables *
define		STACKSIZE	100
Word		rgKbdStack[STACKSIZE];
Word		kbdDefExch;
Word		kbdMsgExch;

typedef struct {
	Pointer pEntry;
	Word	saData;
	Word	saExtra;
	Word	saStack;
	Word	oStackInit;
	Byte	priority;
	Byte	fSys;
	Word	exchgDefaultResponse;
	Byte	fDebug;
	} ProcDescType;

void KbdProcess() {
Byte	chr;

while(TRUE) {
	CheckErc(ReadKbd(chr));

	* Be aware that because this routine does not wait for a reply
	   from the process it sends the message to, that the chr may
	   by changed by a subsequent readkbd request before the other
	   process has acted on the chr sent.  This is not likely for
	   this program, but is likely in other circumstances
	*
	CheckErc(Send(kbdMsgExch, chr));

	}
}

void InitKbdProcess() {
ProcDescType	processDscrptr;
Pointer			pStack;

	CheckErc(AllocExch(kbdDefExch));
	CheckErc(AllocExch(kbdMsgExch));
	pStack = rgKbdStack;
	processDscrptr.pEntry = (void *) KbdProcess;
	processDscrptr.saData = selectorof(pStack);
	processDscrptr.saExtra = 0;
	processDscrptr.saStack  = selectorof(pStack);
	pStack = rgKbdStack[STACKSIZE2];
	processDscrptr.oStackInit = offsetof(pStack);
	processDscrptr.priority = 70;
	processDscrptr.fSys = FALSE;
	processDscrptr.exchgDefaultResponse = kbdDefExch;
	processDscrptr.(fDebug = FALSE;
	CheckErc(CreateProcess(processDscrptr));
}

void InitVideo() {
ErcType		erc;
Word		sMap;
Byte		rgbVidHdw[3];

	CheckErc( QueryVidHdw (rgbVidHdw, sizeof(rgbVidHdw)) );
	vcLines = rgbVidHdw[1];
	vcCols  = rgbVidHdw[2];
	CheckErc( ResetVideo (vcCols, vcLines, TRUE, 0x20, sMap) );

	*Main frame*
	DisplayLines = vcLines  3;
	CheckErc( InitVidFrame (0, 0, 0, vcCols, DisplayLines, 0, 0, 0, 0, 0) );
	CheckErc( InitVidFrame (1, 0, DisplayLines, vcCols, 3, 0, 0, 0, 0, 0) );


	CheckErc( InitCha4	rMap(0, sMap) );
	CheckErc( SetScreenVidAttr(1, TRUE) ); *refresh*
	CheckErc( ResetFrame(0) );
	CheckErc( ResetFrame(1) );

	return;
}

void DrawFunctionKeyBar(Pointer psFunckeys) {

CheckErc( PutFrameChars (1, 0, 2, psFunckeys, strlen(psFunckeys)) );
for (i = 0; i < 3; i++) {
	CheckErc( PutFrameAttrs(1, rgCol[i], 2, lReverseHB, rgCol[i+3]) );
	}
}

void DrawBorder() {
Word i;

for (i = 0; i < 20; i++) {
	CheckErc(PutFrameAttrs(0, (i*2)+HOFF,  VOFF, lReverseHB, 2) );
	CheckErc(PutFrameAttrs(0, (i*2)+HOFF,@
 VOFF+20, lReverseHB, 2) );
	}
for (i = 0; i < 21; i++) {
	CheckErc(PutFrameAttrs(0, HOFF, i+VOFF, lReverseHB, 1) );
	CheckErc(PutFrameAttrs(0, HOFF+40, i+VOFF, lReverseHB, 1) );
	}

}

extern void LoadGeneration();
extern void SaveGeneration();

void InputGeneration(Word fTime) {
char *pChr;

if (fTime == TRUE) {
	for (i=0; i<20; i++) {	* clear out the arrays *
		for (j=0; j<20; j++) {
			old[i][j] = 0;
			new[i][j] = 0;
			}
		}
	}

DrawFunctionKeyBar(         Run                                  L             Load    Save  );

i = 9;
j = 9;

while (TRUE) {
	CheckErc( PutFrameAttrs(0, (j*2)+HOFF, i+VOFF, lUnderLine, 1) );
	CheckErc( Wait(kbdMsgExch, pChr) );
	CheckErc( PutFrameAttrs(0, (j*2)+HOFF, i+VOFF, lNormal, 1) );
	switch (*pChr) {
	case F9:
		LoadGeneration();
		break;
	case F10:
		SaveGeneration();
		break;
	case UPARROW:
		i = 1;
		if (i < 1) i = 1;
		break;
	case DOWNARROW:
		i += 1;
		if (i > 19) i = 19;
		break;
	case LEFTARROW:
		j = 1;
		if (j < 1) j = 1;
		break;
	case RIGHTARROWX:
		j += 1;
		if (j > 19) j = 19;
		break;
	case MARK:
		old[i][j] = 1;
		CheckErc(PutFrameChars(0, (j*2)+HOFF, i+VOFF, *, 1));
		break;
	case BOUND:
		old[i][j] = 0;
		CheckErc(PutFrameChars(0, (j*2)+HOFF, i+VOFF,  , 1));
		break;
	case F2:
		DrawFunctionKeyBar( Pause                                                                   );
		return;
	case FINISH:
		ErrorExit(0);
	default:
		break;
		}
	}
}

void SetUpMenu(MenuType *Menu) {
PromptType	*Line;
InputType	*Data;
Word		 i;

	pActiveMenud
 = Menu;

	for (i = DisplayLines  7; i < DisplayLines; i++) {
		CheckErc(PutFrameChars(0, 0, i, pBlanks, 80));
		CheckErc(PutFrameAttrs(0, 0, i, lNormal, 80));
		}

	CheckErc(PutFrameChars(0, 0, DisplayLines  7, pSep, 80));

	for (Line = Menu>Prompt; Line = NULL; Line = Line>Next) {
		CheckErc(PutFrameChars(
			0
			,Line>Col
			,Line>Line + (DisplayLines  6)
			,Line>pString
			,strlen(Line>pString) 
			));
		}

	for (Data = Menu>Input; Data = NULL; Data = Data>Next) {
		CheckErc(PutFrameAttrsp(
			0
			,Data>Col
			,Data>Line + (DisplayLines  6)
			,lReverseHB
			,Data>Len
			));
		CheckErc(PutFrameChars(
			0
			,Data>Col
			,Data>Line + (DisplayLines  6)
			,Data>Data
			,strlen(Data>Data)
			));
		}

	* Set up cursor at first position *
	pActiveInputline = Menu>Input;
	if (pActiveInputline = NULL) {
		pActiveData = Menu>Input>Data;
		InputCursorLine = Menu>Input>Line + (DisplayLines  6);
		InputCursorCol = Menu>Input>Col;
		for (InputCursorCol = Menu>Input>Col;
				pActi|veData[InputCursorColMenu>Input>Col] = 0;
				InputCursorCol++);
		CheckErc(PutFrameAttrs(0,
			InputCursorCol, InputCursorLine, lUnderLine | lReverseHB, 1));
		}
}

void InputName (){
char	*pChr;

while(TRUE) {
	CheckErc( Wait(kbdMsgExch, pChr) );
	switch (*pChr) {
	case CANCEL:
		FileName[0] = 0;
		return;
	case GO:
		return;
	case NEXT:
		CheckErc(PutFrameAttrs(0,
			InputCursorCol, InputCursorLine, lReverseHB, 1));
		pActiveInputline = pActiveInputline>Next;
		if (pActiveInputline == NULL) pActiveInputline = pActiveMenu>Input;
		pActiveData = pActiveInputline>Data;
		InputCursorLine = pActiveInputline>Line + (DisplayLines  6);
		for (InputCursorCol = pActiveInputline>Col;
			pActiveData[InputCursorColpActiveInputline>Col] = 0;
			InputCursorCol++);
		CheckErc(PutFrameAttrs(0,
			InputCursorCol, InputCursorLine, lUnderLine | lReverseHB, 1));
		break;
	case BACKSPACE:
		CheckErc(PutFrameAttrs(0,
			InputCursorCol, InputCursorLine, lReverseHB, 1));

		if ((InputCursorColpActiveInputline>Col) = 0) InputCursorCol = 1;

		CheckErc(PutFrameChars(0,
			InputCursorCol, InputCursorLine, pBlanks, 1));

		pActiveData[InputCursorColpActiveInputline>Col] = 0;
			
		CheckErc(PutFrameAttrs(0,
			InputCursorCol, InputCursorLine, lUnderLine | lReverseHB, 1));
		break;
	default:
		if (*pChr < 0x80) { * Assume data char if not caught elsewhere *
			CheckErc(PutFrameAttrs(0,
				InputCursorCol, InputCursorLine, lReverseHB, 1));

			if ((InputCursorColpActiveInputline>Col) 
					< (pActiveInputline>Len  1) ) {

				CheckErc(PutFrameChars(0,
					InputCursorCol, InputCursorLine, pChr, 1));

				pActiveData[InputCursorCol  pActiveInputline>Col] = *pChr;
				pActiveData[(InputCursorColpActiveInputline>Col)+1] = 0;

				InputCursorCol += 1;
				}

			CheckErc(PutFrameAttrs(0,
				InputCursorCol, InputCursorLine, lUnderLine | lReverseHB, 1));
			}
		else Beep();
		break;
		}
	}
}

void reDrawGame() {
Word i, j;

	for (i = DisplayLines  7; i < DisplayLines; i++) {
		CheckErc(PutFrameChars(0, 0, i, pBlanks, 80));
		CheckErc(PutFrameAttrs(0, 0, i, lNormal, 80));
		}

	DrawBorder();

	for (i=0; i < 20; i++) for (j = 0; j < 20; j++) {
		if (old[i][j] == 1)
			CheckErc(PutFrameChars(0, (j*2)+HOFF, i+VOFF, *, 1));
		else
			CheckErc(PutFrameChars(0, (j*2)+HOFF, i+VOFF,  , 1));
		}
}

void LoadGeneration() {
FILE *inp;

	SetUpMenu(LoadLifeMenu);
	InputName();

	if (FileName[0] == 0) {
		reDrawGame();
		return;
		}

	if ((inp = fopen(FileName, r)) == NULL) {
		Beep();
		reDrawGame();
		return;
		}

	if(fread(old, 20, 20, inp) = 20) {
		Beep();
		}

	fclose(inp);

	reDrawGame();
}

void SaveGeneration() {
FILE *out;

	SetUpMenu(SaveLifeMenu);
	InputName();
	reDrawGame();

	if (FileName[0] == 0) return;
	if ((out = fopen(FileName, w)) == NULL) {
		Beep();
		return;
		}

	if(fwrite(old, 20, 20, out) = 20) {
		Beep();
		}

	fclose(out);
}

void Play() {
Word erc;
Byte *pChr;

erc = Check(kbdMsgExch, pChr);
if (erc = ercOK) {
	if (erc = ercNoMessage) { ErrorExit(erc); }
	}
else {
	if (*pChr == (Byte) F1) { InputGeneration(FALSE); }
	if (*pChr == (Byte) FINISH) { ErrorExit(0); }
	}

for (i = 1; i < 20; i ++) {
	for (j = 1; j < 20; j ++) {
		sum = 0;
		for (k = i1; k < i+2; k++) {
			for (l = j1; l < j+2; l++) {
				sum += old[k][l];
				}
			}
		if (old[i][j]) sum = 1;
		switch (sum) {
		case 2:
			new[i][j] = old[i][j];
			break;
		case 3:
				new[i][j] = 1;
				CheckErc(PutFrameChars(0, (j*2)+HOFF, i+VOFF, *, 1));
			break;
		default:
			new[i][j] = 0;
			CheckErc(PutFrameChars(0, (j*2)+HOFF, i+VOFF,  , 1));
			break;
			}
		}
	}

CheckErc(Delay(DELAYTIME));

for (i = 1; i < 20; i ++) {
	for (j = 1; j < 20; j ++) {
		sum = 0;
		for (k = i1; k < i+2; k++) {
			for (l = j1; l < j+2; l++) {
				sum += new[k][l];
				}
			}
		if (new[i][j]) sum = 1;
		switch (sum) {
		case 2:
			old[i][j] = new[i][j];
			break;
		case 3:
				old[i][j] = 1;
				CheckErc(PutFrameChars(0, (j*2)+HOFF, i+VOFF, *, 1));
			break;
		default:
			old[i][j] = 0;
			CheckErc(PutFrameChars(0, (j*2)+HOFF, i+VOFF,  , 1));
			break;
			}
		}
	}

CheckErc(Delay(DELAYTIME));

}

void main() {

InitKbdProcess();
InitVideo();
DrawBorder();
InputGeneration(TRUE);
while (TRUE) Play();

}al, 80));
		}

	CheckErc(PutFrameChars(0, 0, DisplayLines  7, pSep, 80));

	for (Line = Menu>Prompt; Line = NULL; Line = Line>Next) {
		CheckErc(PutFrameChars(
			0
			,Line>Col
			,Line>Line + (DisplayLines  6)
			,Line>pString
			,strlen(Line>pString) 
			));
		}

	for (Data = Menu>Input; Data = NULL; Data = Data>Next) {
		CheckErc(PutFrameAttrsQ$link.fls	C_Samples5f6f1gqlinkbeeper.sub
linkHuge.sub
linkKeyword.sub
linklarge.sub
linklife.sub
linksample.sub
linkswap.sub
linkwrite.sub
u@linkbeeper.flsNew	C_Samples@ff1g
samples.lib(beeper start)UNC1.lst
FUNC2.lst
HUGE.lst
KEYLIST.lst
KEYMAIN.lst
LARGE.lst
LIFE.lst
SAMPLE.lst
START.lst
SWAP.lst
VIDIO.lst
WRITE.lst
@linkbeeper.subNew	C_Samples@lfDf1gI
$'

Bind
'Object modules'@linkbeeper.fls
'Run file'beeper.run
'[Map file]'
'[Publics?]'
'[Line numbers?]'
'[Stack size]'600
'[Max array, data, code]'
'[Min array, data, code]'
'[Run file mode]'prot
'[Version]'0
'[Libraries]'
'[DS allocation?]'
'[Symbol file]'
'[Copyright Notice]'
'[File to append]'
'[debug?]'
pend]'
'[debug?]'
P_0o0__0O0?	0linkhuge.flsNew	C_samplesTff1g<samples.lib(huge)
H*?linkHuge.subNew	C_samples?4fRf1gY
T'

Bind
'Object modules'@linkHuge.fls
'Run file'huge.run
'[Map file]'
'[Publics?]'
'[Line numbers?]'
'[Stack size]'2000
'[Max array, data, code]'
'[Min array, data, code]'
'[Run file mode]'prot
'[Version]'0
'[Libraries]'[s2]<cdist>hcbe.lib
'[DS allocation?]'
'[Symbol file]'
'[Copyright Notice]'
'[File to append]'
'[debug?]'
P_0o0__0O0?		linkKeyword.flsNew	C_samplesfyf1g:Vlsamples.lib(keymain
keylist
filelist
search
vidio
samgen)
pOo@pOo@?O	oP	0o$'>	F O	OpY\doq	_o P_0o0__0O0?	xlinkKeyword.sub	C_samplesff1gfV'
Bind
'Object modules'@linkKeyword.fls
'Run file'Keyword.run
'[Map file]'
'[Publics?]'
'[Line numbers?]'
'[Stack size]'2000
'[Max array, data, code]'
'[Min array, data, code]'
'[Run file mode]'prot
'[Version]'0
'[Libraries]'[d1]<misc>hc\\big\\hcbe.lib
'[DS allocation?]'
'[Symbol file]'
'[Copyright Notice]'
'[File to append]'
'[debug?]'
P_0o0__0O0?	

linklarge.flsNew	C_samplesYff1gsamples.lib(Large)
UNC1o
FUNC2o
)

v?
linklarge.subNew	C_samples?ff1g['

Bind
'Object modules'@linkLarge.fls
'Run file'Large.run
'[Map file]'
'[Publics?]'
'[Line numbers?]'
'[Stack size]'2000
'[Max array, data, code]'
'[Min array, data, code]'
'[Run file mode]'prot
'[Version]'0
'[Libraries]'[s2]<cdist>hcle.lib
'[DS allocation?]'
'[Symbol file]'
'[Copyright Notice]'
'[File to append]'
'[debug?]'
P_0o0__0O0?	a=linklife.flsNew	C_Samples=Qff1gsamples.lib(life)
@linklife.subNew	C_Samples@nfcf1gY
'

Bind
'Object modules'@linklife.fls
'Run file'life.run
'[Map file]'
'[Publics?]'
'[Line numbers?]'
'[Stack size]'2000
'[Max array, data, code]'
'[Min array, data, code]'
'[Run file mode]'prot
'[Version]'0
'[Libraries]'[s2]<cdist>hcbe.lib
'[DS allocation?]'
'[Symbol file]'
'[Copyright Notice]'
'[File to append]'
'[debug?]'
P_0o0__0O0?	B'linksample.flsNew	C_SamplesUff1gsamples.lib(sample)@linksample.subNew	C_Samples@kfFf1g]
'

Bind
'Object modules'@linksample.fls
'Run file'sample.run
'[Map file]'
'[Publics?]'
'[Line numbers?]'
'[Stack size]'1200
'[Max array, data, code]'
'[Min array, data, code]'
'[Run file mode]'prot
'[Version]'0
'[Libraries]'[s2]<cdist>hcbe.lib
'[DS allocation?]'
'[Symbol file]'
'[Copyright Notice]'
'[File to append]'
'[debug?]'
P_0o0__0O0?	 {?linkswap.flsNew	C_samples?ff1g
,samples.lib(SWAP
FUNC1o
FUNC2o)
st
search
vidio)
t
KEYLIST.lst
KEYMAIN.lst
LARGE.lst
LIFE.lst
SAMPLE.lst
START.lst
SWAP.lst
VIDIO.lst
WRITE.lst
8 Gg?linkswap.sub	C_samples?'f(f1gY
D'

Bind
'Object modules'@linkswap.fls
'Run file'swap.run
'[Map file]'
'[Publics?]'
'[Line numbers?]'
'[Stack size]'2000
'[Max array, data, code]'
'[Min array, data, code]'
'[Run file mode]'prot
'[Version]'0
'[Libraries]'[s2]<cdist>hcbe.lib
'[DS allocation?]'
'[Symbol file]'
'[Copyright Notice]'
'[File to append]'
'[debug?]'
P_0o0__0O0?	P3
linkwrite.flsNew	C_Samples[ff1g\$samples.lib(write)
UNC1o
FUNC2o
)
h=
linkwrite.subNew	C_Samples=ufIvf1g[t''

Bind
'Object modules'@linkwrite.fls
'Run file'write.run
'[Map file]'
'[Publics?]'
'[Line numbers?]'
'[Stack size]'2000
'[Max array, data, code]'
'[Min array, data, code]'
'[Run file mode]'prot
'[Version]'0
'[Libraries]'[s2]<cdist>hcbe.lib
'[DS allocation?]'
'[Symbol file]'
'[Copyright Notice]'
'[File to append]'
'[debug?]'
P_0o0__0O0?	) Qlst.flsNew	C_Samplesff1g
* BEEPER.lst
FILELIST.lst
FUNC1.lst
FUNC2.lst
HUGE.lst
KEYLIST.lst
KEYMAIN.lst
LARGE.lst
LIFE.lst
samgen.lst
SAMPLE.lst
SEARCH.lst
SWAP.lst
VIDIO.lst
WRITE.lst
,1map.fls	C_Samples1ff1gQ
beeper.map
huge.map
Keyword.map
Large.map
life.map
sample.map
swap.map
write.map
obj.fls	C_Samplesff1g0BEEPER.obj
FILELIST.obj
FUNC1.obj
FUNC2.obj
HUGE.obj
KEYLIST.obj
KEYMAIN.obj
LARGE.obj
LIFE.obj
samgen.obj
SAMPLE.obj
SEARCH.obj
start.obj
SWAP.obj
VIDIO.obj
WRITE.obj
2run.fls	C_Samplesff1gQ3beeper.run
huge.run
Keyword.run
Large.run
life.run
sample.run
swap.run
write.run
5$3sa	c_samples)f*f1g6$8s1
samgen.asmNew	C_Samples1f.f1g
:;*****************************************************************************
; FILE SAMGENALL.ASM                                                       *
;                                                                            *
; COPYRIGHT 1981, 1986 CONVERGENT TECHNOLOGIES, INC. ALL RIGHTS RESERVED     *
;                                                                            *
; THIS PROGRAM IS FURNISHED UNDER A LICENSE RESTRICTING ITS USE SOLELY FOR   *
; THE OPERATION OF A DESIGNATED COMPUT<ER FOR A PARTICULAR PURPOSE, AND MAY   *
; NOT BE COPIED OR OTHERWISE USED WITHOUT THE PRIOR WRITTEN CONSENT OF       *
; CONVERGENT TECHNOLOGIES, INC.  TITLE TO AND OWNERSHIP OF THE PROGRAM,      *
; INCLUDING ITS SOURCE CODE, SHALL AT ALL TIMES REMAIN IN CONVERGENT         *
; TECHNOLOGIES.                                                              *
;                                                                            *
;                                                                           > *
; The file SamGen.Mdf contains all of the macro definitions for the macros *
; which are contained in this file, SamGenAll.Asm.  The Sequential Access  *
; Method (SAM) implementation contained in CTOS.Lib may be reconfigured by   *
; creating a tailored SAMGEN module. First, the SAMGEN.ASM source file must  *
; be edited to reflect the new configuration. After editing, the SAMGEN.ASM  *
; file must be assembled and then the resulting object file, SAMGEN.OBJ, must*
; be included in the list of object(@ modules at link time. Alternately, if the*
; new SAM configuration is to be the default SAM configuration, the Librarian*
; utility may be used to overwrite the SAMGEN module contained in CTOS.Lib.  *
; The default SAM configuration contained in CTOS.Lib includes disk,         *
; keyboard, video, parallel printer, null, and spooler byte streams.         *
; In addition, the user may wish to include other byte streams, e.g.         *
; communication or serial printer byte streams.                          4B    *
;******************************************************************************;
$INCLUDE ([sys]<edf>samgen.mdf)
Init
;
DeviceOpen([Kbd],OpenByteStreamK)
DeviceOpen([Vid],OpenByteStreamVid)
DeviceOpen([Disk],OpenByteStreamAD)

;*****************************************************************************
;
tagProcs(tagDiskRead,FillBufferAD,FlushBufIllegal,CheckPointBsAD,ReleaseByteStreamAD,SetImageModeIllegal)
tagProcs(tagDiskWrite,FillBufIllegal,FlushBufferAD,CheckPointBsAD,ReleaseByteStreamAD,@DSetImageModeIllegal)
tagProcs(tagDiskModify,FillBufferAD,FlushBufferAD,CheckPointBsAD,ReleaseByteStreamAD,SetImageModeIllegal)
tagProcs(tagKbdRead,FillBufferK,FlushBufIllegal,ChkptNop,ReleaseEasy,SetImageModeIllegal)
tagProcs(tagVideoWrite,FillBufIllegal,FlushBufferVid,ChkptNop,ReleaseEasy,SetImageModeIllegal)

;
;*****************************************************************************
;
DevDepProc(QueryVidBs,QueryVideoBs)
DevDepProc(GetBsLfa,GetBsLfaAsync)
DevDepProc(SetBsLfa,SetBsLfaAsync)
FinLFal
AHH$H)H3HUH^HqHvHHHHYHHHHHHHHHH
H7H<HHHHH
HH'H9H]HHHHHHHH	H4HoHtHHHHH<HDHhHtHHHHHHHHHftd6hu\\\\\
\\\\\\\D\\\\	\+\=\Y\v\D^gCjvPh$IrXHP@sample.c	c_samplesP@ff1g
dI
define ULCMPB
include <ctoslib.h>

include <string.h>
include <stdio.h>
include <time.h>

int main(argc, argv)
	int argc;
	char *argv[];
	{
	FILE *inp, *out;
	char *pIfilename;
	char *pOfilename;
	char line[256];
	time_t t1, t2;
	long int l;

	l = clock()  CLK_TCK;
	printf(ld seconds = ld hours and ld minutes, l, l3600, (l3600)60);
	printf( past midnight\n);

	time(t1);
	printf(Greenwich time: s, asctime(gmtime(t1)));
	printf(Local time    : s, ctime(t1));

	if ( argc < 2 ) pIfilenpKame = [kbd]; else pIfilename = argv[1];
	printf(Input file name  : s\n, pIfilename);
	if ((inp = fopen(pIfilename, r)) == NULL) {
		printf(openfail);
		return(0);
		}

	if ( argc < 3 ) pOfilename = [vid]; else pOfilename = argv[2];
	printf(Output file name : s\n, pOfilename);
	if ((out = fopen(pOfilename, w)) == NULL) {
		printf(openfail);
		return(0);
		}

	while (fgets(line, 256, inp)) fputs(line, out);
	printf(*******************EOF******************\n);

	if (ULCMPB(pIfilename, [kbd|M], 5) = 0xFFFF) {
		printf(\n***Now seek back to beginning of file***\n);
		fseek(inp,0l,SEEK_SET);
		while (fgets(line, 256, inp)) fputs(line, out);
		printf(*****************EOF***************\n);
	}

	time(t2);
	printf(New local time  : s,asctime(localtime(t2)));
	printf(Difference between the two local times );
	printf((in seconds): .0f\n, difftime(t2,t1));
	return (0);
	

}ZZZZZZyZ	Z	Z
Z
Z1
ZF
Z
Z6O6y666)6Q6o66666666O'search.c	C_Samplesefff1g
P'*
 * Search keylist routine.
 *

define	Beep
define	CheckErc
define	PutFrameChars
define PutFrameAttrs
define	ResetFrame
include <ctoslib.h>
include keyword.h

include <stdlib.h>
include <stdio.h>
include <string.h>

* Vidio Routines found in Vidio.c *
extern	void	DrawFunctionKeyBar(Word iLine, Pointer psFnckys);
extern	Word	DisplayLines;
extern  Pointer	pBlanks;
extern	Pointer	pSep;

* State machine varaibles *
extern	void	DrawMainDisplay();
extern	Word	oStateStack;

extern	KeyListType		*R'pKeyList;
extern	KeyListType		*pSelectList;
extern	FileListType	*pFileList;

*****************************************************************************
Word			waitforack;
Word			searchdone;
Word			KeyWordSize;
KeyListType		*pKeys;
FileListType	*pFiles;
FILE			*input;

define	LNLINES		23
define LINESIZE	256
define	STARTLINE	11
Byte	line[LNLINES][LINESIZE];
Byte	*pDisplayline[LNLINES];
Word	iLine;
Word	nLine;
char	filedisplay[] = Searching file: ;
char	positiondisplay[80];

************************T'*****************************************************
void InitFileUse() {
Word	i;

	if (input = NULL) 	fclose(input); * Done with old file *
	input = NULL; * Done with this handle. *

	nLine = 1;

	for (i = 0, line[0][0] = 0; i < LNLINES; i++)
		pDisplayline[i] = line[0][0]; * clear display *

	if (pFiles == NULL) return;

	* display file name on top line *
	i = strlen(filedisplay);
	CheckErc(PutFrameChars(DISPLAYFRAME, 0, 0, pBlanks, 80));
	CheckErc(PutFrameChars(DISPLAYFRAME, 0, 1, pBlanks, 80V'));
	CheckErc(PutFrameChars(DISPLAYFRAME, 0, 0, filedisplay, i));
	CheckErc(PutFrameChars(DISPLAYFRAME, i, 0, pFiles>Filename,
		((strlen(pFiles>Filename)+i)<80) ? strlen(pFiles>Filename) : 80i));

	* display current line number in file on next line *
	sprintf(positiondisplay, At line number: dn, nLine, i);
	CheckErc(PutFrameChars(DISPLAYFRAME, 0, 1, positiondisplay, i));

	if ((input = fopen(pFiles>Filename, r)) == NULL) {
		for (i = FIRSTLINE; i < DisplayLines; i++) {
			CheckErc(PutFrameChaX'rs(DISPLAYFRAME, 0, i, pBlanks, 80));
			CheckErc(PutFrameAttrs(DISPLAYFRAME, 0, i, lNormal, 80));
			}
		CheckErc(PutFrameChars(DISPLAYFRAME,0,10,File not found:, 15));
		CheckErc(PutFrameChars(DISPLAYFRAME,16,10,
					pFiles>Filename, strlen(pFiles>Filename)));
		Beep();
		waitforack = 1;
		return;
		}

	for (i = STARTLINE, iLine = 0; i < DisplayLinesFIRSTLINE; i++, iLine++) {
		if (fgets((char *)line[iLine][0], LINESIZE, input) == NULL)
			line[iLine][0] = 0;
		pDisplayline[i] = (line[iLine][0]);
Z'		}
}

void FindNextFile() {
	if (pFiles = NULL) pFiles = pFiles>Next;
	InitFileUse();
}

void ShiftLineBuffer() {
Word	i;

	nLine++; * display this on top line *
	sprintf(positiondisplay, At line number: dn, nLine, i);
	CheckErc(PutFrameChars(DISPLAYFRAME, 0, 1, positiondisplay, i));
	for (i = 0; i < LNLINES  1; i++) pDisplayline[i] = pDisplayline[i+1];
	if (++iLine == LNLINES) iLine = 0;
	if (fgets((char *)line[iLine][0], LINESIZE, input) == NULL)
		line[iLine][0] = 0;
	pDisplayline[LNLINES  1\'] = (line[iLine][0]);
}

Word FindMatchInFile() {
KeyListType		*pSearch;
Word			 limit;
Word			 i;

	if (pKeys == NULL) return(0xFF); * kick out, let search end *

	while (TRUE) {
		if ((limit = strlen(pDisplayline[STARTLINE])) == 0) {
			FindNextFile();
			if (input == NULL) return(0xFF);
			}
		else {
			for (pSearch = pKeys;
				( (pSearch = NULL)  (pSearch = (void *)pSelectList) );
				pSearch = (pSelectList == (void *) pSelectList)
						? pSearch>Next : pSearch>Selected) {
				KeyWordSize =^' strlen(pSearch>KeyWord);
				if (KeyWordSize >= limit) continue;
				for (i = 0; (i+KeyWordSize) <= limit; i++) 
					if (strncmp(pSearch>KeyWord,
						(char *)((pDisplayline[STARTLINE])[i]),
						KeyWordSize) == 0) return (i);
				}
			ShiftLineBuffer();
			}
		}
}

void DisplayNext() {
Word	i, linesize;
Word	positionfoundat;

	if (waitforack = 0) { * Any error to ack? *
		waitforack = 0;
		return;
		}

	positionfoundat = FindMatchInFile();

	if (waitforack = 0) { * May have encountered new erro'	r to ack *
		waitforack = 0;
		return;
		}

	if ((pKeys == NULL) || (pFiles == NULL)) { * search done *
		for (i = FIRSTLINE; i < DisplayLines; i++) {
			CheckErc(PutFrameChars(DISPLAYFRAME, 0, i, pBlanks, 80));
			CheckErc(PutFrameAttrs(DISPLAYFRAME, 0, i, lNormal, 80));
			}
		CheckErc(PutFrameChars(DISPLAYFRAME,33,10,Search done..., 14));
		searchdone++;
		}
	else { * display data around this match *
		for (i = 0; i < LNLINES; i++) {
			if (pDisplayline[i] = NULL) {
				linesize = strlen((char *)c'
pDisplayline[i]);
				CheckErc(PutFrameChars (DISPLAYFRAME, 0, i + FIRSTLINE,
					pDisplayline[i], linesize));
				CheckErc(PutFrameChars (DISPLAYFRAME, linesize, i + FIRSTLINE,
					pBlanks, 80linesize));
				}
			else {
				  CheckErc(PutFrameChars (DISPLAYFRAME, 0, i + FIRSTLINE,
					 pBlanks, 80));
				}
			}
		CheckErc(PutFrameAttrs(
				DISPLAYFRAME,0,STARTLINE+ FIRSTLINE,lUnderLine,80));
		if (positionfoundat < 80) CheckErc(PutFrameAttrs(
				DISPLAYFRAME,positionfoundat,STARTLINE+ FIRSTLINE,
				e'lUnderLine +lReverseHB,KeyWordSize));
		}

}

void SearchSetUp(){

	waitforack = 0;
	searchdone = 0;

	CheckErc(ResetFrame(DISPLAYFRAME));
	CheckErc(PutFrameChars(DISPLAYFRAME, 0, 2, pSep, 80));
	CheckErc(PutFrameChars(FNCKEYFRAME, 0, 0, pSep, 80));
	CheckErc(PutFrameChars(FNCKEYFRAME, 0, 1, pBlanks, 80));
	DrawFunctionKeyBar(2,
                        Back                                      Next   );

	pKeys = (pSelectList == (void *) pSelectList) ? pKeyList : pSelectList;
	pFiles = pFileList;
g'
	if (pKeys == NULL) {
		CheckErc(PutFrameChars(DISPLAYFRAME,31,10,Nothing to find..., 18));
		Beep();
		waitforack = 1;
		}

	input = NULL;
	InitFileUse();
	DisplayNext();
}

void fncSearch (Byte chr){

	if ((searchdone = 0)  ((chr == F10) || (chr == NEXT))) {
		DrawMainDisplay();
		oStateStack = 1;
		if (input = NULL) fclose(input);
		return;
	}

	switch (chr) {
	case F4:
		DrawMainDisplay();
		oStateStack = 1;
		if (input = NULL) fclose(input);
		break;
	case F10:
		if (input = NULL) ShiftLineB$i'
uffer();
		DisplayNext();
		break;
	case NEXT:
		if (input = NULL) ShiftLineBuffer();
		DisplayNext();
		break;
	default:
		Beep();
		break;
		}
}
nput = NULL; * Done with this handle. *

	nLine = 1;

	for (i = 0, line[0][0] = 0; i < LNLINES; i++)
		pDisplayline[i] = line[0][0]; * clear display *

	if (pFiles == NULL) return;

	* display file name on top line *
	i = strlen(filedisplay);
	CheckErc(PutFrameChars(DISPLAYFRAME, 0, 0, pBlanks, 80));
	CheckErc(PutFrameChars(DISPLAYFRAME, 0, 1, pBlanks, 800k(@server.h	C_Samples@ff1g
<l(
pragma On(Optimize_for_space);

* Assumes no use of argc, argv *
* Routines are actually called at init time, so must return valid values. *
_mwset_up_args() {return 0;}
_mwcount_args() {return 0;}

* Assumes no C style IO *
* Routines are not actually called, unless C style IO calls are made *
_mwcfinit() {}
_mwcfterm() {}
openbytestream() {}
readbsrecord() {}
char BSVID;
char bsKbd;
WRITEBSRECORD() {}
closebytestream() {}
queryvidbs() {}


* Assumes no use of onexit library routine *
void _mwHn(call_onexit_fcns() {}

O	+2>@@@A0B0CO@D?KVXoYZZO[[\P^?_ c
0gqs?v x yPzOpzz1|1E
0FINC
H
M
R
Tp)<'1
Source.fls	C_Samples'1UfVf1gq)asm.fls
beeper.c
filelist.c
func1.c
func2.c
glider
HighC.fls
huge.c
keylist.c
keymain.c
keyword.h
large.c
lib.fls
libSamples.fls
life.c
link.fls
linkbeeper.fls
linkbeeper.sub
linkhuge.fls
linkHuge.sub
linkKeyword.fls
linkKeyword.sub
linklarge.fls
linklarge.sub
linklife.fls
linklife.sub
linksample.fls
linksample.sub
linkswap.fls
linkswap.sub
linkwrite.fls
linkwrite.sub
lst.fls
map.fls
obj.fls
run.fls
sa
samgen.asm
sample.c
search.c
server.h
Source.fls
start.asm
swap.c
sym.fls
tree
vidio.c
write.c
ls* @	start.asm	c_samples@ff1g
xt*;
;*************************************************************************
; This initialization routine is designed for use with MetaWare C routines
; that do not use any of the MetaWare C library routines.  This allows
; system programmers to write services that do not suffer from the C runtime
; memory overhead  which is between 7k and 42k bytes, depending on what
; subsystems are cheated out of the link using dummy routine names.
;
; The additional memory recovered by avoiding the C runtime library cv*ompletely
; is worth the trouble, but care must be taken to insure that none of the
; runtime features are used when initialized from this routine.
;
; Fortunately, link errors will result in all known cases so far...
;
stack segment word 'stack'
stack_start equ this byte
	db	'MetaWare '
	db	'High C'
	db	' Runtime Library Copyright (C) 19831988 MetaWare Incorporated..'
stack ends

data segment 'data'
zero db	0
pzero dw OFFSET dgroup:zero
      dw dgroup
data ends
const segment 'const'
const ends
memory sex*gment 'memory'
memory ends
dgroup group stack,DATA,const,memory
code segment 'code'
code ends

extrn	main:FAR
extrn	exit:FAR

init_code segment 'code'
assume cs: init_code
public	_mwINIT
_mwinit	PROC	FAR
mwINIT:
	cli					; Wait 'til I have a stack.
	mov  BP,0			; Initialize stack frame pointer
	mov  ax,dgroup
	mov  ds,ax
	mov  ss,ax
assume	ds:dgroup
	mov  sp, OFFSET dgroup:stack_start
	sti					; Stack in place, can handle interrupts now.
;
; set up argc, argv for no parameters from this initializer
	mov  axz*, dgroup
	mov  bx, offset dgroup: pzero
	push ax
	push bx
	mov  ax,1
	push ax
	CALL main
;
; If the C program returned, call ctos exit.
	CALL exit
_mwinit	endp

init_code ends

end	_mwinit
H(JjVVyVVV.VPVVVVwVHXdWz:LMJTKb6333cDDD	
pRU2Z2r222|+?swap.c	C_samples?ff1g>
}+ifdef __LARGE__
include	<ctparm.h>
include	<ctmem.h>
include	<ctvirt.h>
include	<cttask.h>
else
$include <ctostypes.h>
$define AllocMemorySL
$define InitLargeOverlays
$include <ctoslib.h>

pragma Calling_convention(_FAR_CALL|_CALLEE_POPS_STACK|_DGROUP_MODEL);
extern int OutputToVid0(void *, int);
extern int AllocMemorySL(int, void *);
extern int InitLargeOverlays(void *, int);
pragma Calling_convention();

endif

long *func1(), *func2();

long	a=2, b=3, c ;

extern char * sbVerrun;

int inmain(){+
return 1;
}

main()
{
	int	erc;
	char	*poverlay;	* address of overlay area      *
	int	i;

* Allocate Memory for overlays. *
	if( erc = AllocMemorySL(4096, poverlay) )
	    ErrorExit( erc );

* Initialize overlays *
	if( erc = InitLargeOverlays(poverlay, 256) )
	    ErrorExit( erc );

	for (i=0; i<20; i++){
		printf(ld + ld = ld; ld * ld = ld\n,
			a, b, *(func1()), a, b, *(func2()));
		a++;
		b++;  
		}
	for (i=0; i<10; i++){
		double d1;
		d1 = i;
		printf(f f f f\n,d1+1.0,d11.0,d1*+1.0,d11.0);
		}
    NewScreen();
	funcx();
    PutLabels();
}

















$).38=BGLQV[eO{	e				(	B	W		
0pp


5
xCxNNN8NzNZ$Z<ZTZlZZZZZZZZyZ	Z	Z
Z
Z1
ZF
Z
Z6O6y666)6Q6o66666666, 1sym.fls	C_Samples 1ff1gQ
,beeper.sym
huge.sym
Keyword.sym
Large.sym
life.sym
sample.sym
swap.sym
write.sym
0tree	c_samples01f2f1g.vidio.c	C_samplesff1gV.*
 * Define a selection of vidio manipulation routines
 *

define	Beep
define	CheckErc
define InitCharMap
define InitVidFrame
define PutFrameAttrs
define PutFrameChars
define QueryVidHdw
define ReadKbd
define ResetFrame
define ResetVideo
define SetScreenVidAttr
include <ctoslib.h>
include keyword.h

include <string.h>
include <stdlib.h>

Word		vcLines;
Word		vcCols;
Word		rgCol[6] = {0, 24, 56,   23, 31, 23};
Word		DisplayLines;
char		Inputline[LINEMAX];
MenuType	*pActiveMenu;
InputType	* .pActiveInputline;
Byte		*pActiveData;
void		(*(pCancelRoutine))();
void		(*(pGoRoutine))();
Word		InputCursorLine;
Word		InputCursorCol;
Pointer		pBlanks = {                                                                                };
Pointer pSep =
{};

void InitVideo() {
Word		sMap;
Byte		rgbVidHdw[3];

	CheckErc( QueryVidHdw (rgbVidHdw, sizeof(rgbVidHdw)) );
	vcLines = rgbVidHdw[1];
	vcCols  = rgbVidHdw[2];
	CheckEr,.c( ResetVideo (vcCols, vcLines, TRUE, 0x20, sMap) );

	*Main frame*
	DisplayLines = vcLines  SIZEFNCFRAME;
	CheckErc(
		InitVidFrame(DISPLAYFRAME, 0, 0, vcCols, DisplayLines, 0, 0, 0, 0, 0)
		);

	* function bar frame *
	CheckErc(
		InitVidFrame(FNCKEYFRAME, 0, DisplayLines, vcCols, 3, 0, 0, 0, 0, 0)
		);

	CheckErc( InitCharMap(0, sMap) );
	CheckErc( SetScreenVidAttr(1, TRUE) ); *refresh*
	CheckErc( ResetFrame(DISPLAYFRAME) );
	CheckErc( ResetFrame(FNCKEYFRAME) );

	return;
}

void DrawFunctionKeyB8.ar(Word iLine, Pointer psFnckys) {
Word	i;

CheckErc(PutFrameChars(FNCKEYFRAME, 0, iLine, psFnckys, strlen(psFnckys)));
for (i = 0; i < 3; i++) {
	CheckErc(
		PutFrameAttrs(FNCKEYFRAME, rgCol[i], iLine, lReverseHB, rgCol[i+3])
		);
	}
}

void SetUpMenu(MenuType *Menu) {
PromptType	*Line;
InputType	*Data;
Word		 i;

	pActiveMenu = Menu;

	for (i = DisplayLines  7; i < DisplayLines; i++) {
		CheckErc(PutFrameChars(DISPLAYFRAME, 0, i, pBlanks, 80));
		CheckErc(PutFrameAttrs(DISPLAYFRAME, 0, i, lNormal, 80));
D.		}

	CheckErc(PutFrameChars(DISPLAYFRAME, 0, DisplayLines  7, pSep, 80));

	for (Line = Menu>Prompt; Line = NULL; Line = Line>Next) {
		CheckErc(PutFrameChars(
			DISPLAYFRAME
			,Line>Col
			,Line>Line + (DisplayLines  6)
			,Line>pString
			,strlen(Line>pString) 
			));
		}

	for (Data = Menu>Input; Data = NULL; Data = Data>Next) {
		CheckErc(PutFrameAttrs(
			DISPLAYFRAME
			,Data>Col
			,Data>Line + (DisplayLines  6)
			,lReverseHB
			,Data>Len
			));
		CheckErc(PutFrameChars(
			DISPLAP.YFRAME
			,Data>Col
			,Data>Line + (DisplayLines  6)
			,Data>Data
			,strlen(Data>Data)
			));
		}

	* Set up cursor at first position *
	pActiveInputline = Menu>Input;
	if (pActiveInputline = NULL) {
		pActiveData = Menu>Input>Data;
		InputCursorLine = Menu>Input>Line + (DisplayLines  6);
		InputCursorCol = Menu>Input>Col;
		for (InputCursorCol = Menu>Input>Col;
				pActiveData[InputCursorColMenu>Input>Col] = 0;
				InputCursorCol++);
		CheckErc(PutFrameAttrs(DISPLAYFRAME,
			InputC\.ursorCol, InputCursorLine, lUnderLine | lReverseHB, 1));
		}

	CheckErc(PutFrameChars(FNCKEYFRAME, 0, 0, pSep, 80));
	CheckErc(PutFrameChars(FNCKEYFRAME, 0, 1, pBlanks, 80));
	CheckErc(PutFrameChars(FNCKEYFRAME, 0, 2, pBlanks, 80));
	CheckErc(PutFrameAttrs(FNCKEYFRAME, 0, 2, lNormal, 80));
	CheckErc(PutFrameChars(FNCKEYFRAME, 18, 2, Press GO to act, press cancel to exit menu., 43));
}

void InputInformation (Byte chr){

	switch (chr) {
	case CANCEL:
		(*pCancelRoutine)();
		break;
	case GO:
		(*pGoRoutineh.)();
		break;
	case NEXT:
		CheckErc(PutFrameAttrs(DISPLAYFRAME,
			InputCursorCol, InputCursorLine, lReverseHB, 1));
		pActiveInputline = pActiveInputline>Next;
		if (pActiveInputline == NULL) pActiveInputline = pActiveMenu>Input;
		pActiveData = pActiveInputline>Data;
		InputCursorLine = pActiveInputline>Line + (DisplayLines  6);
		for (InputCursorCol = pActiveInputline>Col;
			pActiveData[InputCursorColpActiveInputline>Col] = 0;
			InputCursorCol++);
		CheckErc(PutFrameAttrs(DISPLAYFRAME,
			Inpt.	utCursorCol, InputCursorLine, lUnderLine | lReverseHB, 1));
		break;
	case BACKSPACE:
		CheckErc(PutFrameAttrs(DISPLAYFRAME,
			InputCursorCol, InputCursorLine, lReverseHB, 1));

		if ((InputCursorColpActiveInputline>Col) = 0) InputCursorCol = 1;

		CheckErc(PutFrameChars(DISPLAYFRAME,
			InputCursorCol, InputCursorLine, pBlanks, 1));

		pActiveData[InputCursorColpActiveInputline>Col] = 0;
			
		CheckErc(PutFrameAttrs(DISPLAYFRAME,
			InputCursorCol, InputCursorLine, lUnderLine | lReverseHB, 1));
		br.
eak;
	default:
		* Assume data char if not caught elsewhere *
		if ((chr < 0x80)  (pActiveInputline = NULL)) { 
			CheckErc(PutFrameAttrs(DISPLAYFRAME,
				InputCursorCol, InputCursorLine, lReverseHB, 1));

			if ((InputCursorColpActiveInputline>Col) 
					< (pActiveInputline>Len  1) ) {

				CheckErc(PutFrameChars(DISPLAYFRAME,
					InputCursorCol, InputCursorLine, chr, 1));

				pActiveData[InputCursorCol  pActiveInputline>Col] = chr;
				pActiveData[(InputCursorColpActiveInputline>Col)+1] =. 0;

				InputCursorCol += 1;
				}

			CheckErc(PutFrameAttrs(DISPLAYFRAME,
				InputCursorCol, InputCursorLine, lUnderLine | lReverseHB, 1));
			}
		else Beep();
		break;
		}
}

ine QueryVidHdw
define ReadKbd
define ResetFrame
define ResetVideo
define SetScreenVidAttr
include <ctoslib.h>
include keyword.h

include <string.h>
include <stdlib.h>

Word		vcLines;
Word		vcCols;
Word		rgCol[6] = {0, 24, 56,   23, 31, 23};
Word		DisplayLines;
char		Inputline[LINEMAX];
MenuType	*pActiveMenu;
InputType	*UDwrite.c	C_SamplesDufuf1g
include <string.h>
include <stdio.h>

doone(char *mode) {
FILE	*out;
long	 i;
char	filename[100];

	strcpy(filename, Test.);
	strcat(filename, mode);
	strcat(filename, .tst);

	remove(filename);
	if ((out = fopen(filename, mode)) == NULL) {
		printf(Open fail);
		return(0);
		}

	for (i = 0; i < 7; i += 2) {
		if(fseek(out, i, SEEK_SET) = 0) {
			printf(Write fail);
			return(0);
			}
		if(fwrite(AC, 2, 1, out) = 1) {
			printf(Write fail);
			return(0);
			}
		}

	for (i = 1; i < 8; i += 2) {
		if(fseek(out, i, SEEK_SET) = 0) {
			printf(Write fail);
			return(0);
			}
		if(fwrite(B, 1, 1, out) = 1) {
			printf(Write fail);
			return(0);
			}
		}

	}

int main() {
char	mode[4];
char	*smodes[2] = {w, a};
char	*pmodes[5] = {\0, +, +b, +t, +u};
int		i, j;


	for (i = 0; i < 2; i++) {
		for (j = 0; j < 5; j++){
			strcpy(mode, smodes[i]);
			strcat(mode, pmodes[j]);
			doone(mode);
			}
		}	
	}
