int AllocSetups() { SETUPPARAMETERS *sp; LONG LargeSize, SmallSize, SmallEsize, TermsInSmall, IOsize; int MaxPatches, MaxFpatches, error = 0, i, size; UBYTE *s; #ifndef WITHPTHREADS int j; #endif sp = GetSetupPar((UBYTE *)"threads"); if ( sp->value > 0 ) AM.totalnumberofthreads = sp->value+1; AM.OutBuffer = (UBYTE *)Malloc1(AM.OutBufSize+1,"OutputBuffer"); AP.PreAssignStack =(LONG *)Malloc1(AP.MaxPreAssignLevel*sizeof(LONG *),"PreAssignStack"); for ( i = 0; i < AP.MaxPreAssignLevel; i++ ) AP.PreAssignStack[i] = 0; AC.iBuffer = (UBYTE *)Malloc1(AC.iBufferSize+1,"statement buffer"); AC.iStop = AC.iBuffer + AC.iBufferSize-2; AP.preStart = (UBYTE *)Malloc1(AP.pSize,"instruction buffer"); AP.preStop = AP.preStart + AP.pSize - 3; /* AP.PreIfStack is already allocated in StartPrepro(), but to be sure we "if" the freeing */ if ( AP.PreIfStack ) M_free(AP.PreIfStack,"PreIfStack"); AP.PreIfStack = (int *)Malloc1(AP.MaxPreIfLevel*sizeof(int), "Preprocessor if stack"); AP.PreIfStack[0] = EXECUTINGIF; sp = GetSetupPar((UBYTE *)"insidefirst"); AM.ginsidefirst = AC.minsidefirst = AC.insidefirst = sp->value; /* We need to consider eliminating this variable */ sp = GetSetupPar((UBYTE *)"maxtermsize"); AM.MaxTer = sp->value*sizeof(WORD); if ( AM.MaxTer < 200*(LONG)(sizeof(WORD)) ) AM.MaxTer = 200*(LONG)(sizeof(WORD)); if ( AM.MaxTer > MAXPOSITIVE - 200*(LONG)(sizeof(WORD)) ) AM.MaxTer = MAXPOSITIVE - 200*(LONG)(sizeof(WORD)); AM.MaxTer /= (LONG)sizeof(WORD); AM.MaxTer *= (LONG)sizeof(WORD); /* Allocate workspace. */ sp = GetSetupPar((UBYTE *)"workspace"); AM.WorkSize = sp->value; #ifdef WITHPTHREADS #else AT.WorkSpace = (WORD *)Malloc1(AM.WorkSize*sizeof(WORD),(char *)(sp->parameter)); AT.WorkTop = AT.WorkSpace + AM.WorkSize; AT.WorkPointer = AT.WorkSpace; #endif /* Fixed indices */ sp = GetSetupPar((UBYTE *)"constindex"); if ( ( sp->value+100+5*WILDOFFSET ) > MAXPOSITIVE ) { MesPrint("Setting of %s in setupfile too large","constindex"); AM.OffsetIndex = MAXPOSITIVE - 5*WILDOFFSET - 100; MesPrint("value corrected to maximum allowed: %d",AM.OffsetIndex); } else AM.OffsetIndex = sp->value + 1; AC.FixIndices = (WORD *)Malloc1((AM.OffsetIndex)*sizeof(WORD),(char *)(sp->parameter)); AM.WilInd = AM.OffsetIndex + WILDOFFSET; AM.DumInd = AM.OffsetIndex + 2*WILDOFFSET; AM.IndDum = AM.DumInd + WILDOFFSET; #ifndef WITHPTHREADS AR.CurDum = AN.IndDum = AM.IndDum; #endif AM.mTraceDum = AM.IndDum + 2*WILDOFFSET; sp = GetSetupPar((UBYTE *)"parentheses"); AM.MaxParLevel = sp->value+1; AC.tokenarglevel = (WORD *)Malloc1((sp->value+1)*sizeof(WORD),(char *)(sp->parameter)); /* Space during calculations */ sp = GetSetupPar((UBYTE *)"maxnumbersize"); /* size = ( sp->value + 11 ) & (-4); AM.MaxTal = size - 2; if ( AM.MaxTal > (AM.MaxTer/sizeof(WORD)-2)/2 ) AM.MaxTal = (AM.MaxTer/sizeof(WORD)-2)/2; if ( AM.MaxTal < (AM.MaxTer/sizeof(WORD)-2)/4 ) AM.MaxTal = (AM.MaxTer/sizeof(WORD)-2)/4; */ /* There is too much confusion about MaxTal cq maxnumbersize. It seems better to fix it at its maximum value. This way we only worry about maxtermsize. This can be understood better by the 'innocent' user. */ if ( sp->value == 0 ) { AM.MaxTal = (AM.MaxTer/sizeof(WORD)-2)/2; } else { size = ( sp->value + 11 ) & (-4); AM.MaxTal = size - 2; if ( (size_t)AM.MaxTal > (size_t)((AM.MaxTer/sizeof(WORD)-2)/2) ) AM.MaxTal = (AM.MaxTer/sizeof(WORD)-2)/2; } AM.MaxTal &= -sizeof(WORD)*2; sp->value = AM.MaxTal; AC.cmod = (UWORD *)Malloc1(AM.MaxTal*4*sizeof(UWORD),(char *)(sp->parameter)); AM.gcmod = AC.cmod + AM.MaxTal; AC.powmod = AM.gcmod + AM.MaxTal; AM.gpowmod = AC.powmod + AM.MaxTal; /* The IO buffers for the input and output expressions. Fscr[2] will be assigned in a later stage for hiding expressions from the regular action. That will make the program faster. */ sp = GetSetupPar((UBYTE *)"scratchsize"); AM.ScratSize = sp->value/sizeof(WORD); if ( AM.ScratSize < 4*AM.MaxTer ) AM.ScratSize = 4*AM.MaxTer; AM.HideSize = AM.ScratSize; sp = GetSetupPar((UBYTE *)"hidesize"); if ( sp->value > 0 ) { AM.HideSize = sp->value/sizeof(WORD); if ( AM.HideSize < 4*AM.MaxTer ) AM.HideSize = 4*AM.MaxTer; } sp = GetSetupPar((UBYTE *)"factorizationcache"); AM.fbuffersize = sp->value; #ifdef WITHPTHREADS sp = GetSetupPar((UBYTE *)"threadscratchsize"); AM.ThreadScratSize = sp->value/sizeof(WORD); sp = GetSetupPar((UBYTE *)"threadscratchoutsize"); AM.ThreadScratOutSize = sp->value/sizeof(WORD); #endif #ifndef WITHPTHREADS for ( j = 0; j < 2; j++ ) { WORD *ScratchBuf; ScratchBuf = (WORD *)Malloc1(AM.ScratSize*sizeof(WORD),"scratchsize"); AR.Fscr[j].POsize = AM.ScratSize * sizeof(WORD); AR.Fscr[j].POfull = AR.Fscr[j].POfill = AR.Fscr[j].PObuffer = ScratchBuf; AR.Fscr[j].POstop = AR.Fscr[j].PObuffer + AM.ScratSize; PUTZERO(AR.Fscr[j].POposition); } AR.Fscr[2].PObuffer = 0; #endif sp = GetSetupPar((UBYTE *)"threadbucketsize"); AC.ThreadBucketSize = AM.gThreadBucketSize = AM.ggThreadBucketSize = sp->value; sp = GetSetupPar((UBYTE *)"threadloadbalancing"); AC.ThreadBalancing = AM.gThreadBalancing = AM.ggThreadBalancing = sp->value; sp = GetSetupPar((UBYTE *)"threadsortfilesynch"); AC.ThreadSortFileSynch = AM.gThreadSortFileSynch = AM.ggThreadSortFileSynch = sp->value; /* The size for shared memory window for oneside MPI2 communications */ sp = GetSetupPar((UBYTE *)"shmwinsize"); AM.shmWinSize = sp->value/sizeof(WORD); if ( AM.shmWinSize < 4*AM.MaxTer ) AM.shmWinSize = 4*AM.MaxTer; /* The sort buffer */ sp = GetSetupPar((UBYTE *)"smallsize"); SmallSize = sp->value; sp = GetSetupPar((UBYTE *)"smallextension"); SmallEsize = sp->value; sp = GetSetupPar((UBYTE *)"largesize"); LargeSize = sp->value; sp = GetSetupPar((UBYTE *)"termsinsmall"); TermsInSmall = sp->value; sp = GetSetupPar((UBYTE *)"largepatches"); MaxPatches = sp->value; sp = GetSetupPar((UBYTE *)"filepatches"); MaxFpatches = sp->value; sp = GetSetupPar((UBYTE *)"sortiosize"); IOsize = sp->value; if ( IOsize < AM.MaxTer ) { IOsize = AM.MaxTer; sp->value = IOsize; } #ifndef WITHPTHREADS #ifdef WITHZLIB for ( j = 0; j < 2; j++ ) { AR.Fscr[j].ziosize = IOsize; } #endif #endif AM.S0 = 0; AM.S0 = AllocSort(LargeSize,SmallSize,SmallEsize,TermsInSmall ,MaxPatches,MaxFpatches,IOsize); #ifdef WITHZLIB AM.S0->file.ziosize = IOsize; #ifndef WITHPTHREADS AR.FoStage4[0].ziosize = IOsize; AR.FoStage4[1].ziosize = IOsize; AT.S0 = AM.S0; #endif #else #ifndef WITHPTHREADS AT.S0 = AM.S0; #endif #endif #ifndef WITHPTHREADS AR.FoStage4[0].POsize = ((IOsize+sizeof(WORD)-1)/sizeof(WORD))*sizeof(WORD); AR.FoStage4[1].POsize = ((IOsize+sizeof(WORD)-1)/sizeof(WORD))*sizeof(WORD); #endif sp = GetSetupPar((UBYTE *)"subsmallsize"); AM.SSmallSize = sp->value; sp = GetSetupPar((UBYTE *)"subsmallextension"); AM.SSmallEsize = sp->value; sp = GetSetupPar((UBYTE *)"sublargesize"); AM.SLargeSize = sp->value; sp = GetSetupPar((UBYTE *)"subtermsinsmall"); AM.STermsInSmall = sp->value; sp = GetSetupPar((UBYTE *)"sublargepatches"); AM.SMaxPatches = sp->value; sp = GetSetupPar((UBYTE *)"subfilepatches"); AM.SMaxFpatches = sp->value; sp = GetSetupPar((UBYTE *)"subsortiosize"); AM.SIOsize = sp->value; sp = GetSetupPar((UBYTE *)"spectatorsize"); AM.SpectatorSize = sp->value; /* The next code is just for the moment (26-jan-1997) because we have the new parts combined with the old. Once the old parts are gone from the program, we can eliminate this code too. */ sp = GetSetupPar((UBYTE *)"functionlevels"); AM.maxFlevels = sp->value + 1; #ifdef WITHPTHREADS #else AT.Nest = (NESTING)Malloc1((LONG)sizeof(struct NeStInG)*AM.maxFlevels,"functionlevels"); AT.NestStop = AT.Nest + AM.maxFlevels; AT.NestPoin = AT.Nest; #endif sp = GetSetupPar((UBYTE *)"maxwildcards"); AM.MaxWildcards = sp->value; #ifdef WITHPTHREADS #else AT.WildMask = (WORD *)Malloc1((LONG)AM.MaxWildcards*sizeof(WORD),"maxwildcards"); #endif sp = GetSetupPar((UBYTE *)"compresssize"); if ( sp->value < 2*AM.MaxTer ) sp->value = 2*AM.MaxTer; AM.CompressSize = sp->value; #ifndef WITHPTHREADS AR.CompressBuffer = (WORD *)Malloc1((AM.CompressSize+10)*sizeof(WORD),"compresssize"); AR.CompressPointer = AR.CompressBuffer; AR.ComprTop = AR.CompressBuffer + AM.CompressSize; #endif sp = GetSetupPar((UBYTE *)"bracketindexsize"); if ( sp->value < 20*AM.MaxTer ) sp->value = 20*AM.MaxTer; AM.MaxBracketBufferSize = sp->value/sizeof(WORD); sp = GetSetupPar((UBYTE *)"dotchar"); AO.FortDotChar = ((UBYTE *)(sp->value))[0]; sp = GetSetupPar((UBYTE *)"commentchar"); AP.cComChar = AP.ComChar = ((UBYTE *)(sp->value))[0]; sp = GetSetupPar((UBYTE *)"procedureextension"); /* Check validity first. */ s = (UBYTE *)(sp->value); if ( FG.cTable[*s] != 0 ) { MesPrint(" Illegal string for procedure extension %s",(UBYTE *)sp->value); error = -2; } else { s++; while ( *s ) { if ( *s == ' ' || *s == '\t' || *s == '\n' ) { MesPrint(" Illegal string for procedure extension %s",(UBYTE *)sp->value); error = -2; break; } s++; } } AP.cprocedureExtension = strDup1((UBYTE *)(sp->value),"procedureExtension"); AP.procedureExtension = strDup1(AP.cprocedureExtension,"procedureExtension"); sp = GetSetupPar((UBYTE *)"totalsize"); if ( sp->value != 2 ) AM.PrintTotalSize = sp->value; sp = GetSetupPar((UBYTE *)"continuationlines"); AM.FortranCont = sp->value; if ( AM.FortranCont <= 0 ) AM.FortranCont = 1; sp = GetSetupPar((UBYTE *)"oldorder"); AM.OldOrderFlag = sp->value; sp = GetSetupPar((UBYTE *)"resettimeonclear"); AM.resetTimeOnClear = sp->value; sp = GetSetupPar((UBYTE *)"nospacesinnumbers"); AO.NoSpacesInNumbers = AM.gNoSpacesInNumbers = AM.ggNoSpacesInNumbers = sp->value; sp = GetSetupPar((UBYTE *)"indentspace"); AO.IndentSpace = AM.gIndentSpace = AM.ggIndentSpace = sp->value; sp = GetSetupPar((UBYTE *)"nwritestatistics"); AC.StatsFlag = AM.gStatsFlag = AM.ggStatsFlag = 1-sp->value; sp = GetSetupPar((UBYTE *)"nwritefinalstatistics"); AC.FinalStats = AM.gFinalStats = AM.ggFinalStats = 1-sp->value; sp = GetSetupPar((UBYTE *)"nwritethreadstatistics"); AC.ThreadStats = AM.gThreadStats = AM.ggThreadStats = 1-sp->value; sp = GetSetupPar((UBYTE *)"nwriteprocessstatistics"); AC.ProcessStats = AM.gProcessStats = AM.ggProcessStats = 1-sp->value; sp = GetSetupPar((UBYTE *)"oldparallelstatistics"); AC.OldParallelStats = AM.gOldParallelStats = AM.ggOldParallelStats = sp->value; sp = GetSetupPar((UBYTE *)"oldfactarg"); AC.OldFactArgFlag = AM.gOldFactArgFlag = AM.ggOldFactArgFlag = sp->value; sp = GetSetupPar((UBYTE *)"oldgcd"); AC.OldGCDflag = AM.gOldGCDflag = AM.ggOldGCDflag = sp->value; sp = GetSetupPar((UBYTE *)"wtimestats"); if ( sp->value == 2 ) sp->value = AM.ggWTimeStatsFlag; AC.WTimeStatsFlag = AM.gWTimeStatsFlag = AM.ggWTimeStatsFlag = sp->value; sp = GetSetupPar((UBYTE *)"sorttype"); if ( StrICmp((UBYTE *)"lowfirst",(UBYTE *)sp->value) == 0 ) { AC.lSortType = SORTLOWFIRST; } else if ( StrICmp((UBYTE *)"highfirst",(UBYTE *)sp->value) == 0 ) { AC.lSortType = SORTHIGHFIRST; } else { MesPrint(" Illegal SortType specification: %s",(UBYTE *)sp->value); error = -2; } sp = GetSetupPar((UBYTE *)"processbucketsize"); AM.hProcessBucketSize = AM.gProcessBucketSize = AC.ProcessBucketSize = AC.mProcessBucketSize = sp->value; /* The store caches (code installed 15-aug-2006 JV) */ sp = GetSetupPar((UBYTE *)"numstorecaches"); AM.NumStoreCaches = sp->value; sp = GetSetupPar((UBYTE *)"sizestorecache"); AM.SizeStoreCache = sp->value; #ifndef WITHPTHREADS /* Install the store caches (15-aug-2006 JV) Note that in the case of PTHREADS this is done in InitializeOneThread */ AT.StoreCache = AT.StoreCacheAlloc = 0; if ( AM.NumStoreCaches > 0 ) { STORECACHE sa, sb; size = sizeof(struct StOrEcAcHe)+AM.SizeStoreCache; size = ((size-1)/sizeof(size_t)+1)*sizeof(size_t); AT.StoreCacheAlloc = (STORECACHE)Malloc1(size*AM.NumStoreCaches,"StoreCaches"); AT.StoreCache = AT.StoreCacheAlloc; sa = AT.StoreCache; for ( j = 0; j < AM.NumStoreCaches; j++ ) { sb = (STORECACHE)(VOID *)((UBYTE *)sa+size); if ( j == AM.NumStoreCaches-1 ) { sa->next = 0; } else { sa->next = sb; } SETBASEPOSITION(sa->position,-1); SETBASEPOSITION(sa->toppos,-1); sa = sb; } } #endif /* And now some order sensitive things */ if ( AM.Path == 0 ) { sp = GetSetupPar((UBYTE *)"path"); AM.Path = strDup1((UBYTE *)(sp->value),"path"); } if ( AM.IncDir == 0 ) { sp = GetSetupPar((UBYTE *)"incdir"); AM.IncDir = strDup1((UBYTE *)(sp->value),"incdir"); } /* if ( AM.TempDir == 0 ) { sp = GetSetupPar((UBYTE *)"tempdir"); AM.TempDir = strDup1((UBYTE *)(sp->value),"tempdir"); } */ return(error); }
int DoTail(int argc, UBYTE **argv) { int errorflag = 0, onlyversion = 1; UBYTE *s, *t, *copy; int threadnum = 0; argc--; argv++; AM.LogType = -1; AM.HoldFlag = AM.qError = AM.Interact = AM.FileOnlyFlag = 0; AM.InputFileName = AM.LogFileName = AM.IncDir = AM.TempDir = AM.TempSortDir = #ifdef WITHMPI AM.SetupDir = AM.SetupFile = 0; #else AM.SetupDir = AM.SetupFile = AM.Path = 0; #endif if ( argc < 1 ) { onlyversion = 0; goto printversion; } while ( argc >= 1 ) { s = *argv++; argc--; if ( *s == '-' || ( *s == '/' && ( argc > 0 || AM.Interact ) ) ) { s++; switch (*s) { case 'c': /* Error checking only */ AM.qError = 1; break; case 'D': case 'd': /* Next arg is define preprocessor var. */ t = copy = strDup1(*argv,"Dotail"); while ( *t && *t != '=' ) t++; if ( *t == 0 ) { if ( PutPreVar(copy,(UBYTE *)"1",0,0) < 0 ) return(-1); } else { *t++ = 0; if ( PutPreVar(copy,t,0,0) < 0 ) return(-1); t[-1] = '='; } M_free(copy,"-d prevar"); argv++; argc--; break; case 'f': /* Output only to regular log file */ AM.FileOnlyFlag = 1; AM.LogType = 0; break; case 'F': /* Output only to log file. Further like L. */ AM.FileOnlyFlag = 1; AM.LogType = 1; break; case 'h': /* For old systems: wait for key before exit */ AM.HoldFlag = 1; break; #ifdef WITHINTERACTION case 'i': /* Interactive session (not used yet) */ AM.Interact = 1; break; #endif case 'I': /* Next arg is dir for inc/prc/sub files */ TAKEPATH(AM.IncDir) break; case 'l': /* Make regular log file */ if ( s[1] == 'l' ) AM.LogType = 1; /*compatibility! */ else AM.LogType = 0; break; case 'L': /* Make log file with only final statistics */ AM.LogType = 1; break; case 'M': /* Multirun. Name of tempfiles will contain PID */ AM.MultiRun = 1; break; case 'm': /* Read number of threads */ case 'w': /* Read number of workers */ t = s++; threadnum = 0; while ( *s >= '0' && *s <= '9' ) threadnum = 10*threadnum + *s++ - '0'; if ( *s ) { #ifdef WITHMPI if ( PF.me == MASTER ) #endif printf("Illegal value for option m or w: %s\n",t); errorflag++; } /* if ( threadnum == 1 ) threadnum = 0; */ threadnum++; break; /* case 'n': Reserved for number of slaves without MPI */ case 'p': #ifdef WITHEXTERNALCHANNEL /*There are two possibilities: -p|-pipe*/ if(s[1]=='i'){ if( (s[2]=='p')&&(s[3]=='e')&&(s[4]=='\0') ){ argc--; /*Initialize pre-set external channels, see the file extcmd.c:*/ if(initPresetExternalChannels(*argv++,AX.timeout)<1){ #ifdef WITHMPI if ( PF.me == MASTER ) #endif printf("Error initializing preset external channels\n"); errorflag++; } AX.timeout=-1;/*This indicates that preset channels are initialized from cmdline*/ }else{ #ifdef WITHMPI if ( PF.me == MASTER ) #endif printf("Illegal option in call of FORM: %s\n",s); errorflag++; } }else #else if ( s[1] ) { if ( ( s[1]=='i' ) && ( s[2] == 'p' ) && (s[3] == 'e' ) && ( s[4] == '\0' ) ){ #ifdef WITHMPI if ( PF.me == MASTER ) #endif printf("Illegal option: Pipes not supported on this system.\n"); } else { #ifdef WITHMPI if ( PF.me == MASTER ) #endif printf("Illegal option: %s\n",s); } errorflag++; } else #endif { /* Next arg is a path variable like in environment */ TAKEPATH(AM.Path) } break; case 'q': /* Quiet option. Only output. Same as -si */ AM.silent = 1; break; case 'R': /* recover from saved snapshot */ AC.CheckpointFlag = -1; break; case 's': /* Next arg is dir with form.set to be used */ if ( ( s[1] == 'o' ) && ( s[2] == 'r' ) && ( s[3] == 't' ) ) { if(s[4]== '=' ) { AM.TempSortDir = s+5; } else { AM.TempSortDir = *argv++; argc--; } } else if ( s[1] == 'i' ) { /* compatibility: silent/quiet */ AM.silent = 1; } else { TAKEPATH(AM.SetupDir) } break; case 'S': /* Next arg is setup file */ TAKEPATH(AM.SetupFile) break; case 't': /* Next arg is directory for temp files */ if ( s[1] == 's' ) { s++; AM.havesortdir = 1; TAKEPATH(AM.TempSortDir) } else { TAKEPATH(AM.TempDir) } break; case 'T': /* Print the total size used at end of job */ AM.PrintTotalSize = 1; break; case 'v': printversion:; #ifdef WITHMPI if ( PF.me == MASTER ) #endif { char buffer[100], *s = buffer; sprintf(s,"%s %s (%s)",FORMNAME,VERSIONSTR,PRODUCTIONDATE); while ( *s ) s++; sprintf(s," %d-bits",(WORD)(sizeof(WORD)*16)); while ( *s ) s++; printf("%s\n",buffer); } if ( onlyversion ) return(1); goto NoFile; case 'y': /* Preprocessor dumps output. No compilation. */ AP.PreDebug = PREPROONLY; break; default: if ( FG.cTable[*s] == 1 ) { AM.SkipClears = 0; t = s; while ( FG.cTable[*t] == 1 ) AM.SkipClears = 10*AM.SkipClears + *t++ - '0'; if ( *t != 0 ) { #ifdef WITHMPI if ( PF.me == MASTER ) #endif printf("Illegal numerical option in call of FORM: %s\n",s); errorflag++; } } else { #ifdef WITHMPI if ( PF.me == MASTER ) #endif printf("Illegal option in call of FORM: %s\n",s); errorflag++; } break; }
int ProcessOption(UBYTE *s1, UBYTE *s2, int filetype) { SETUPPARAMETERS *sp; int n, giveback = 0, error = 0; UBYTE *s, *t, *s2ret; LONG x; sp = GetSetupPar(s1); if ( sp ) { /* We check now whether there are `' variables to be looked up in the environment. This is new (30-may-2008). This is only allowed in s2. */ restart:; { UBYTE *s3,*s4,*s5,*s6, c, *start; int n1,n2,n3; s = s2; while ( *s ) { if ( *s == '\\' ) s += 2; else if ( *s == '`' ) { start = s; s++; while ( *s && *s != '\'' ) { if ( *s == '\\' ) s++; s++; } if ( *s == 0 ) { MesPrint("%s: Illegal use of ` character for parameter %s" ,proop1[filetype],s1); return(1); } c = *s; *s = 0; s3 = (UBYTE *)getenv((char *)(start+1)); if ( s3 == 0 ) { MesPrint("%s: Cannot find environment variable %s for parameter %s" ,proop1[filetype],start+1,s1); return(1); } *s = c; s++; n1 = start - s2; s4 = s3; n2 = 0; while ( *s4 ) { if ( *s4 == '\\' ) { s4++; n2++; } s4++; n2++; } s4 = s; n3 = 0; while ( *s4 ) { if ( *s4 == '\\' ) { s4++; n3++; } s4++; n3++; } s4 = (UBYTE *)Malloc1((n1+n2+n3+1)*sizeof(UBYTE),"environment in setup"); s5 = s2; s6 = s4; while ( n1-- > 0 ) *s6++ = *s5++; s5 = s3; while ( n2-- > 0 ) *s6++ = *s5++; s5 = s; while ( n3-- > 0 ) *s6++ = *s5++; *s6 = 0; if ( giveback ) M_free(s2,"environment in setup"); s2 = s4; giveback = 1; goto restart; } else s++; } } n = sp->type; s2ret = s2; switch ( n ) { case NUMERICALVALUE: ParseNumber(x,s2); if ( *s2 == 'K' ) { x = x * 1000; s2++; } else if ( *s2 == 'M' ) { x = x * 1000000; s2++; } else if ( *s2 == 'G' ) { x = x * 1000000000; s2++; } else if ( *s2 == 'T' ) { x = x * 1000000000000; s2++; } if ( *s2 && *s2 != ' ' && *s2 != '\t' ) { MesPrint("%s: Numerical value expected for parameter %s" ,proop1[filetype],s1); error = 1; break; } sp->value = x; sp->flags = USEDFLAG; break; case STRINGVALUE: if ( StrICmp(s1,(UBYTE *)"tempsortdir") == 0 ) AM.havesortdir = 1; s = s2; t = s2; while ( *s ) { if ( *s == ' ' || *s == '\t' ) break; if ( *s == '\\' ) s++; *t++ = *s++; } *t = 0; if ( sp->flags == USEDFLAG && sp->value != 0 ) M_free((VOID *)(sp->value),"Process option"); sp->value = (LONG)strDup1(s2,"Process option"); sp->flags = USEDFLAG; break; case PATHVALUE: if ( StrICmp(s1,(UBYTE *)"incdir") == 0 ) { AM.IncDir = 0; } else if ( StrICmp(s1,(UBYTE *)"path") == 0 ) { if ( AM.Path ) M_free(AM.Path,"path"); AM.Path = 0; } else { MesPrint("Setups: %s not yet implemented",s1); error = 1; break; } if ( sp->flags == USEDFLAG && sp->value != 0 ) M_free((VOID *)(sp->value),"Process option"); sp->value = (LONG)strDup1(s2,"Process option"); sp->flags = USEDFLAG; break; case ONOFFVALUE: if ( tolower(*s2) == 'o' && tolower(s2[1]) == 'n' && ( s2[2] == 0 || s2[2] == ' ' || s2[2] == '\t' ) ) sp->value = 1; else if ( tolower(*s2) == 'o' && tolower(s2[1]) == 'f' && tolower(s2[2]) == 'f' && ( s2[3] == 0 || s2[3] == ' ' || s2[3] == '\t' ) ) sp->value = 0; else { MesPrint("%s: Unrecognized option for parameter %s: %s" ,proop1[filetype],s1,s2); error = 1; break; } sp->flags = USEDFLAG; break; case DEFINEVALUE: /* if ( sp->value ) M_free((UBYTE *)(sp->value),"Process option"); sp->value = (LONG)strDup1(s2,"Process option"); */ if ( TheDefine(s2,2) ) error = 1; break; default: Error1("Error in setupparameter table for:",s1); error = 1; break; } } else { MesPrint("%s: Keyword not recognized: %s",proop1[filetype],s1); error = 1; } if ( giveback ) M_free(s2ret,"environment in setup"); return(error); }