
/* File TRACE.C
	Main function for the Refal Tracer.
	March 8 1987.
*/

# define DEFINE_EXTERNALS 1

#ifdef FOR_OS_WINDOWSNT
#	include <sys/timeb.h>
#	include <sys/types.h>
#endif

# include "version.h"
# include "rasl.h"
# include "decl.h"
# include "cdecl.h"
# include "ddecl.h"
# include "macros.h"
# include "dmacro.h"
# include "fileio.h"
# include "ifunc.h"
# include "tfunc.h"
# include <time.h>
# include <stdlib.h>


 /* For translator pgraph */
unsigned REFLONG ul_local_calls;
int flag_local_calculation = 0;

/* For copying of trace informations */
FILE * fp_debugInfo = NULL;

/* initialized  to zero by default. */
/*
static char def_imp [MAXWS + 1 + sizeof(REFLONG)];
static char def_stop [MAXWS + 1 + sizeof(REFLONG)];
static char def_nobreak [MAXWS + 1];
*/
static char def_imp [6/*MAXWS*/ + 1 + sizeof(REFLONG)];
static char def_stop [7/*MAXWS*/ + 1 + sizeof(REFLONG)];
static char def_nobreak [10/*MAXWS*/ + 1];

/* main entry to Refal tracer. */
int main (int argc, char * argv []) {

	/* print the version and copyright information. */
/*
	char * cp;
	version = VERSION_ENG;

	if ( (NULL != (cp = getenv ("LANG"))) &&
	     (((strncmp("ru_", cp, 3) == 0)) && ((strcmp(".UTF-8", cp+5) == 0)))
	   ) {
		version = VERSION;
	} else {
		version = VERSION_ENG;
		
	}
*/

   ri_rc_version ();

	printf (version, "Tracer", _refal_build_version);
	printf ("Copyright: Refal Systems Inc.\n");
        
        ri_options(argc,argv,1);

	/* define labels IMP and STOP. */
	def_imp [0] = 0;
	strcpy (def_imp + 1, "IMP$");
	IMP_ = 1 + def_imp + 4 + 1;/*MAXWS;*/
	*IMP_ = BUILT_IN;
	wrlong_to_mem (((REFLONG) 42L), (IMP_ + 1)); /* change this 42 if you change bif.c */
	def_stop [0] = 0;
	strcpy (def_stop + 1, "STOP$");
	STOP_ = 1 + def_stop + 5 + 1;/*MAXWS;*/
	*STOP_ = BUILT_IN;
	wrlong_to_mem (((REFLONG) 43L), (STOP_ + 1)); /* change this 43 if you change bif.c */
	/* define NOBREAK_ */
	def_nobreak [0] = 0;
	strcpy (def_nobreak + 1, "NOBREAK$");
	NOBREAK_ = 1 + def_nobreak + 8 + 1;/*MAXWS;*/
	*NOBREAK_ = NO_BREAK;

/*	memory_limit = 600;  / * about 4 meg. */
/*	memory_limit = 1200;  / * about 8 meg. */
/*	memory_limit = 1500;  / * about 10 meg. */
/*	memory_limit = 1800;  / * about 12 meg. */
/*	memory_limit = 2400;  / * about 16 meg. */
	memory_limit = 2800;  /* about 20 meg. */

    ri_memory();
	if (-1 == ri_common_stack ()) exit (1);
	
	ri_interrupt_init ();
/* The following two calls inserted by 7777, Nemytykh 21-02-2026 */
   ri_init_std_streems ();
   ri_init_unicode_case_groups ();
// *+/

	ri_init ();
	rd_init ();

   ri_init_time();	
   ri_inter ();

	return 0; /*exit (0);*/
}
