00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <string.h>
00004
00005
00006 #include "../../getopt.h"
00007 #include "../../report.h"
00008 #include "../../lexer.h"
00009 #include "../../sym.h"
00010 #include "../../expression.h"
00011 #include "../../syntax.h"
00012 #include "../../reader.h"
00013 #include "../../myalloc.h"
00014 #include "../../builder.h"
00015 #include "../../memory.h"
00016 #include "../../execute.h"
00017 #include "../../buildnum.h"
00018 #include "../../conftree.h"
00019 #include "../../filesys.h"
00020 #include "../../errcodes.h"
00021 #include "../../testalloc.h"
00022 #include "../../modumana.h"
00023
00024 int GetC(void *f){ return getc((FILE *)f); }
00025
00026 #ifdef WIN32
00027 main(int argc, char *argv[]){
00028 #else
00029 char **_environ;
00030 main(int argc, char *argv[], char *env[]){
00031 #endif
00032 extern unsigned char szCommandArray[] ;
00033 extern unsigned long ulStartNode,
00034 ulNodeCounter,
00035 ulStringTableSize,
00036 ulGlobalVariables;
00037 void *pMEM;
00038 extern unsigned char szStringTable[];
00039
00040 tConfigTree MyCONF;
00041 ExecuteObject MyEXE;
00042 int iError;
00043 #define FULL_PATH_BUFFER_LENGTH 256
00044 char CmdLinBuffer[FULL_PATH_BUFFER_LENGTH],*s;
00045 #ifndef WIN32
00046 _environ = env;
00047 #endif
00048
00049 pMEM = alloc_InitSegment(malloc,free);
00050 if( pMEM == NULL ){
00051 fprintf(stderr,"No memory\n");
00052 exit(1);
00053 }
00054 cft_start(&MyCONF,alloc_Alloc,alloc_Free,pMEM,
00055 #ifdef WIN32
00056 "Software\\ScriptBasic\\config",
00057 "SCRIBA.INI",
00058 #else
00059 "SCRIBACONF",
00060 "/etc/scriba/basic.conf",
00061 #endif
00062 NULL);
00063
00064 MyEXE.memory_allocating_function = malloc;
00065 MyEXE.memory_releasing_function = free;
00066 MyEXE.reportptr = (void *)stderr;
00067 MyEXE.report = report_report;
00068 MyEXE.fErrorFlags = 0;
00069
00070 MyEXE.pConfig = &MyCONF;
00071 build_MagicCode(&(MyEXE.Ver));
00072
00073 build_MagicCode(&(MyEXE.Ver));
00074 MyEXE.fpStdinFunction = NULL;
00075 MyEXE.fpStdouFunction = NULL;
00076 MyEXE.fpEnvirFunction = NULL;
00077 MyEXE.CmdLineArgument = NULL;
00078
00079 s = cft_GetString(MyEXE.pConfig,"maxstep");
00080 MyEXE.GlobalStepLimit = s ? atol(s) : 0;
00081 s = cft_GetString(MyEXE.pConfig,"maxlocalstep");
00082 MyEXE.LocalStepLimit = s ? atol(s) : 0;
00083 s = cft_GetString(MyEXE.pConfig,"maxlevel");
00084 MyEXE.FunctionLevelLimit = s ? atol(s) : 0;
00085
00086 MyEXE.CommandArray = (pcNODE)szCommandArray ;
00087 MyEXE.StartNode = ulStartNode;
00088 MyEXE.CommandArraySize = ulNodeCounter;
00089 MyEXE.StringTable = szStringTable;
00090 MyEXE.cbStringTable = ulStringTableSize;
00091 MyEXE.cGlobalVariables = ulGlobalVariables;
00092 MyEXE.lGlobalStepCounter = 0L;
00093
00094 MyEXE.pCommandFunction = CommandFunction;
00095 MyEXE.CSymbolList = COMMANDSYMBOLS;
00096 MyEXE.fThreadedCommandTable = 0;
00097 MyEXE.pFunctionResult = NULL;
00098
00099 MyEXE.pST = NULL;
00100 MyEXE.modules = NULL;
00101
00102 MyEXE.pMemorySegment = alloc_InitSegment(MyEXE.memory_allocating_function,MyEXE.memory_releasing_function);
00103
00104 if( MyEXE.pMemorySegment == NULL )return 1;
00105
00106
00107 MyEXE.pMo = alloc_Alloc(sizeof(MemoryObject),MyEXE.pMemorySegment);
00108 if( MyEXE.pMo == NULL )return 1;
00109 MyEXE.pMo->memory_allocating_function = MyEXE.memory_allocating_function;
00110 MyEXE.pMo->memory_releasing_function = MyEXE.memory_releasing_function;
00111 MyEXE.cbStringTable = 0L;
00112 MyEXE.OptionsTable = NULL;
00113 memory_InitStructure(MyEXE.pMo);
00114
00115 s = cft_GetString(MyEXE.pConfig,"maxmem");
00116 if( s )alloc_SegmentLimit(MyEXE.pMo->pMemorySegment,atol(s));
00117
00118
00119 memory_RegisterTypes(MyEXE.pMo);
00120 if( hook_Init(&MyEXE, &(MyEXE.pHookers)) )return 1;
00121 if( modu_Preload(&MyEXE) )return 1;
00122
00123
00124
00125
00126
00127
00128 MyEXE.CmdLineArgument = CmdLinBuffer;
00129
00130 execute_Execute(&MyEXE,&iError);
00131 alloc_FinishSegment(MyEXE.pMo->pMemorySegment);
00132 alloc_FinishSegment(MyEXE.pMemorySegment);
00133 alloc_FinishSegment(MyCONF.pMemorySegment);
00134 #ifdef _DEBUG
00135 printf("Press any key ...\n");
00136 getchar();
00137 #endif
00138 exit(0);
00139 }
00140