#include "all.h"
#include <math.h>
#ifdef __TURBOC__
#include "conio.h"
#include "bios.h"
#endif
int gotfile;
int gle_debug;
int dev_eps=0;
extern int trace_on;
int text_expand(int n);
int g_get_type(char *s);
int gle_redraw(void);
int scr_init(void);
int scr_end(void);
#define true (!false)
#define false 0
#define dbg if (gle_debug>0)
#ifdef __TURBOC__
	extern unsigned _stklen=45000;
#endif

typedef char (*TEXT)[];
int int_edt(char *fname);
int scrinsert(int y);
int scrdeleteline(int y);
int fner(char *s);
int fner_clear(void);
int setoutfile(char *s);
int lineset(int i,char *ss);
int lineinsert(int y, char *ss);
int textinsert(int y);
char *sline(int i);
int text_load(char *f);
int print_out(void);
char *line(int i);
int ncpy(char *d, char *s, int n);
/*------------ GLOBAL VARIABLES --------------*/
char input_file[90];
char *(*gtxt)[];   /* gtxt is a pointer to an array of poiter to char */
int ngtxt=0;
/*---------------------------------------------------------------------------*/
main(int argc, char **argv)
{
char dtype[60];
char fname[60];
static int i,ask_debug,spawn_print,call_menu;
	strcpy(fname,"test.gle");
	for (i=1;i<argc;i++) {
		strupr( argv[i] );
		if (strcmp( argv[i] , "/TRACE")==0) trace_on = true;
		else if (strcmp( argv[i] , "/DEBUG")==0) ask_debug = true;
		else if (strcmp( argv[i] , "/PRINT")==0) spawn_print = true;
		else if (strcmp( argv[i] , "/MENU")==0) call_menu = true;
		else if (strcmp( argv[i] , "/EPS")==0) dev_eps = true;
		else if (strncmp( argv[i] , "/OUT", 4)==0) setoutfile(argv[i]);
		else if (isalpha(*argv[i])) {strcpy(fname, argv[i]); gotfile = true;}
	}
/*	if (argc>1) strcpy(fname,*(++argv)); else strcpy(fname,"test.gle");*/
	scr_init();

	if (strchr(fname,'.')==NULL) strcat(fname,".c");
	strcpy(input_file,fname);
	text_expand(500); /* Initially allocate 500 lines of text */
	text_load(fname);

	int_edt(fname);
	scr_end();
}
char output_file[80];
setoutfile(char *q)
{
	char *s;
	s = strchr(q,'=');
	if (s==NULL) return;
	strcpy(output_file,s+1);
}

/* extras because of missing stuff in gle */
char *tk[500];
char tkbuff[500];
int ntk;
char srclin[300];
char outbuff[300];
int ngerror;
d_tidyup()
{}
gle_redraw()
{}
d_message(char *s)
{
	printf("%s",s);
}
char *gle_top()
{
	char *s;
#ifdef __TURBOC__
	s = getenv("CGLE_TOP");
	if (s!=NULL) return s;
	return "c:\\gle\\";
#else
	return "cgle_top:";
#endif
}
char *gledir(char *fname)
{
     static char fbuff[80];
     strcpy(fbuff,gle_top());
     strcat(fbuff,fname);
     return &fbuff[0];
}
g_get_usersize(double *a, double *b)
{}
g_message(char *s)
{
	printf("%s\n",s);
}
int noscreenio=false;
int abort_flag=false;
freeafont()
{}








