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

	Init()

This function initializes TECO-C.

If an error is detected in any of the functions called by this function,
a message is displayed and the program terminates.

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

#include "ZPort.h"		/* define portability identifiers */
#include "DefTeco.h"		/* define general identifiers */

extern	VOID	Mung();		/* if it's a MUNG command, handle it */
extern	VOID	MemIni();	/* allocate memory and initialize variables */
extern	VOID	ParsCL();	/* parse the command line */
extern	VOID	ZIniFl();	/* execute initialization file, if any */
extern	VOID	ZInit();	/* initialize variables */
extern	VOID	IniOpn();	/* open input/output file(s) */
extern	BOOLEAN	ZRembr();	/* remember last-file-edited */
extern	VOID	ZTrmnl();	/* open terminal input and output */

EXTERN	BOOLEAN	MemDf;		/* filename memory used? */
EXTERN	BOOLEAN	Swit_P;		/* was there a -p on the command line? */


VOID Init(argc, argv)		/* initialize TECO-C */
int argc;
char *argv[];
{
	ZInit();		/* initialize variables */
	ZTrmnl();		/* open terminal input and output */
	ParsCL(argc, argv);	/* parse the command line */
	MemIni();		/* allocate memory and initialize variables */
	ZIniFl();		/* execute initialization file, if any */
	if (Swit_P)		/* if it's a TECO program */
		Mung();		/* execute TECO program */
	else
		{
		MemDf = ZRembr();	/* use remembered last-file-edited? */
		IniOpn();		/* open file(s) */
		}
}
