/*****************************************************************************

	ZInit()

	This function initializes system-dependent variables and serves as
the place where system-dependent global variables are defined.

*****************************************************************************/

#include "ZPort.h"		/* define portability identifiers */
#include "ZFiles.h"		/* define file data block structures */
#include "DefTeco.h"		/* define general identifiers */

EXTERN	WORD	EtFlag;		/* ET mode control flag */
EXTERN	char	*FBfEnd;	/* end of file specification buffer */
EXTERN	char	*FBfPtr;	/* pointer into file specification buffer */
EXTERN	char	*WBfEnd;	/* end of wildcard filespec buffer */
EXTERN	char	*WBfPtr;	/* pointer into wildcard filespec buffer */




#ifdef UNKNOWN
DEFAULT ZInit(argc,argv)		/* initialize system-dependent stuff */
int argc;
char *argv[];
{
	puts("Terminating in function ZInit.\n");
	exit(1);
}
#endif





#ifdef vax11c

GLOBAL	char	FBfBeg[NAM$C_MAXRSS];	/* file specification buffer */
GLOBAL	struct	FAB IFab;		/* input file access block */
GLOBAL	struct	NAM INam;		/* input name block */
GLOBAL	struct	RAB IRab;		/* input file record access block */
GLOBAL	char	LBfBeg[NAM$C_MAXRSS];	/* last-file-edited specification */
GLOBAL	struct	message_vector msgvec = {
		2,			/* number of longwords in msgvec */
		15,			/* display all parts of message */
		0,			/* message code */
		0			/* RMS stv */
	};
GLOBAL	struct	FAB OFab;		/* output file access block */
GLOBAL	struct	NAM ONam;		/* output name block */
GLOBAL	struct	RAB ORab;		/* output file record access block */
GLOBAL	char	*TIBBeg;		/* SYS$INPUT buffer */
GLOBAL	char	*TIBEnd;		/* SYS$INPUT buffer end */
GLOBAL	char	*TIBERc;		/* ptr to end of record in buffer */
GLOBAL	char	*TIBPtr;		/* ptr to current char in record */
GLOBAL	char	TOBBeg[WBFINIT];	/* SYS$OUTPUT buffer */
GLOBAL	char	*TOBEnd;		/* SYS$OUTPUT buffer end (+1) */
GLOBAL	char	*TOBPtr;		/* SYS$OUTPUT buffer pointer */
GLOBAL	struct	FAB TIFab;		/* SYS$INPUT file access block */
GLOBAL	struct	RAB TIRab;		/* SYS$INPUT record access block */
GLOBAL	struct	FAB TOFab;		/* SYS$OUTPUT file access block */
GLOBAL	struct	RAB TORab;		/* SYS$OUTPUT record access block */
GLOBAL	short	TCChan = 0;		/* terminal command channel */
GLOBAL	short	TIChan = 0;		/* terminal input channel */
GLOBAL	short	TOChan = 0;		/* terminal output channel */
GLOBAL	struct	FAB WFab;		/* wildcard file access block */
GLOBAL	struct	NAM WNam;		/* wildcard name block */
GLOBAL	char	WBfBeg[NAM$C_MAXRSS];	/* wildcard file spec buffer */

char	WxpFBf[NAM$C_MAXRSS];		/* wildcard expanded filespec buffer */


DEFAULT ZInit(argc, argv)		/* initialize system-dependent stuff */
int argc;
char *argv[];
{

	EtFlag = ET_READ_LOWER;
	FBfPtr = FBfBeg;
	FBfEnd = &FBfBeg[NAM$C_MAXRSS-1];
	WBfPtr = WBfBeg;
	WBfEnd = &WBfBeg[NAM$C_MAXRSS-1];

	WNam = cc$rms_nam;		/* initialize NAM defaults */
	WNam.nam$l_esa = WxpFBf;	/* expanded file spec buffer address */
	WNam.nam$b_ess = NAM$C_MAXRSS;	/* expanded file spec buffer size */
	WNam.nam$l_rsa = FBfBeg;	/* resultant file spec buffer address */
	WNam.nam$b_rss = NAM$C_MAXRSS;	/* resultant file spec buffer size */

	WFab = cc$rms_fab;		/* initialize FAB defaults */
	WFab.fab$l_fna = WBfBeg;	/* address of wildcard file spec */
	WFab.fab$l_nam = &WNam;		/* address of NAM block */
	WFab.fab$b_fac = FAB$M_GET;	/* file access = read only */
}
#endif




#ifdef XENIX
#include <sgtty.h>		/* define sgttyb structure */

VOID	ZAbort();		/* cleanup and exit TECO */

GLOBAL	char	FBfBeg[FBF_SIZE];
GLOBAL	char	LBfBeg[FBF_SIZE];
GLOBAL	char	OFNam[FBF_SIZE];
GLOBAL	char	OTNam[FBF_SIZE];
GLOBAL	int	savd_tty_flags;	/* saved terminal flags */
GLOBAL	struct	sgttyb tty_cb;	/* terminal characteristics block */
GLOBAL	int	tty_fd = 0;	/* terminal file descriptor */
GLOBAL	BOOLEAN	tty_opened = NO;/* YES if tty_fd is valid */
GLOBAL	BOOLEAN tty_set = NO;	/* YES if the terminal has been set */
GLOBAL	char	WBfBeg[FBF_SIZE];


DEFAULT ZInit()				/* initialize system-dependent stuff */
{
	EtFlag = ET_	READ_LOWER;
	FBfPtr = FBfBeg;
	FBfEnd = &FBfBeg[FBF_SIZE-1];
	WBfPtr = WBfBeg;
	WBfEnd = &WBfBeg[FBF_SIZE-1];
}
#endif
