
#include <sys/types.h>

#include <sys/stat.h>
#include <time.h>
#include <setjmp.h>
/*#include <stdio.h>*/

#include "apl.h"


#ifdef QDOS
#include <fcntl.h>
#include <qdos.h>

long _MNEED=40*1024;
long _STACK=16*1024;
char _PROG_NAME[]="APL11";

int  my_conread(struct UFB *,void *,unsigned int);
int  (*_conread)()= my_conread;
#endif


data	zero;
data	one;
data	pi;
data	maxexp;		/* the largest value such that exp(maxexp) is defined */
data	datum;
data	getdat();
int		funtrace;	/* function trace enabled */
int		labgen;		/* label processing being done */
int		apl_term;	/* flag set if apl terminal mapping req'd */
jmp_buf	gbl_env;	/* Used for setexit/reset */
jmp_buf reset_env;



struct
/*{
	double	fuzz;
	int	iorg;
	int	digits;
	int	width;
} */ THREAD thread;



struct item *stack[STKS], **sp;

struct nlist nlist[NLS];


struct si *gsip;




int		integ,
		column,
		intflg,
		echoflg,
		offexit,		/* if != 0, require ")off" to exit */
		prwsflg,
		ifile,
		wfile,
		debug,
		ttystat[3];

long	startTime;
char	*pcp;			/* global copy of arg to exec */
int     rowsz,
		mencflg,
		aftrace;

char    *mencptr;

int		oldlb[MAXLAB],
		pt,
		syze,
		pas1,
		ibeam36,
		protofile,
		lastop;			/* last (current) operator exec'ed */

char	*scr_file,		/* scratch file name */
	*ws_file;		/* apl workspace file */
int     lineNumber;



struct
/*{
	char	rank;
	char	type;
	int		size;
	int		dimk;
	int		delk;
	int		dim[MRANK];
	int		del[MRANK];
	int		idx[MRANK];
}*/ IDX idx;

#ifdef QDOS
int  my_conread(struct UFB *sufb,void *lbuf,unsigned int lbsize)
{ int res;
  res= io_fline(sufb->ufbfh,-1L,lbuf,lbsize);
/*  if(res<-1) _oserr=res;
  _oserr=0; */
  return (res<0 ? 0 : res);
}
#endif


