SUB RunTimeFunctions LOCAL X1$ LOCAL O1$ ' "%o" LOCAL D1$ ' "%.15G" LOCAL D2$ ' "%.19LG" LOCAL T0$ ' "%H:%M:%S" LOCAL T1$ ' "%H" LOCAL T2$ ' "%M" LOCAL T3$ ' "%S" LOCAL T4$ ' "%p" LOCAL T5$ ' "%Y" LOCAL T6$ ' "%m" LOCAL T7$ ' "%d" LOCAL T8$ ' "%A" LOCAL T9$ ' "%w" LOCAL T10$ ' "%j" LOCAL T11$ ' "%V" [ISO week date standard (ISO-8601)] LOCAL T12$ ' "%m/%d/%y" LOCAL T13$ ' %A, %B %d, %Y [DAY OF WEEK, MONTH NAME, DAY, FULL YEAR] LOCAL TDIR$ D1$ = VCHR$(8,34,37,32,46,49,53,71,34) D2$ = VCHR$(9,34,37,32,46,49,57,76,71,34) O1$ = VCHR$(4,34,37,111,34) T0$ = VCHR$(10,34,37,72,58,37,77,58,37,83,34) T1$ = VCHR$(4,34,37, 72,34) T2$ = VCHR$(4,34,37, 77,34) T3$ = VCHR$(4,34,37, 83,34) T4$ = VCHR$(4,34,37,112,34) T5$ = VCHR$(4,34,37, 89,34) T6$ = VCHR$(4,34,37,109,34) T7$ = VCHR$(4,34,37,100,34) T8$ = VCHR$(4,34,37, 65,34) T9$ = VCHR$(4,34,37,119,34) T10$ = VCHR$(4,34,37,106,34) T11$ = VCHR$(4,34,37, 86,34) T12$ = VCHR$(10,34,37,109,47,37,100,47,37,121,34) T13$ = VCHR$(15,34,37,65,44,32,37,66,32,37,100,44,32,37,89,34) X1$ = VCHR$(4,34,37,88,34) TDIR$= ENC$("/tmp/mbc.XXXXXXXX") 'U1$ = VCHR$(7,37,39,42,46,42,32,102) FPRINT Outfile,"" FPRINT Outfile,"// *************************************************" FPRINT Outfile,"// " + $BCX_STR_RUNTIME FPRINT Outfile,"// *************************************************" FPRINT Outfile,"" IF NoRT=TRUE THEN EXIT SUB IF UseFlag THEN IF Use_Turbo THEN FPRINT Outfile,"char *BCX_TmpStr (size_t Bites)" FPRINT Outfile,"{" FPRINT Outfile," static int StrCnt;" FPRINT Outfile," static char *StrFunc[",TurboSize,"];" FPRINT Outfile," StrCnt=((StrCnt+1) &",TurboSize-1,");" FPRINT Outfile," #if defined BCX_MAX_VAR_SIZE" FPRINT Outfile," if(Bites*sizeof(char)>BCX_MAX_VAR_SIZE)" FPRINT Outfile," {" FPRINT Outfile," printf(";ENC$("Buffer Overflow caught in BCX_TmpStr - requested space of %d EXCEEDS %d\\n");",(int)(Bites*sizeof(char)),BCX_MAX_VAR_SIZE);" FPRINT Outfile," abort();" FPRINT Outfile," }" FPRINT Outfile," #endif" FPRINT Outfile," StrFunc[StrCnt]=(char*)realloc(StrFunc[StrCnt],Bites + 128);" FPRINT Outfile," return (char*)memset(StrFunc[StrCnt],0,Bites+128);" FPRINT Outfile,"}\n\n" ELSE FPRINT Outfile,"char *BCX_TmpStr (size_t Bites)" FPRINT Outfile,"{" FPRINT Outfile," static int StrCnt;" FPRINT Outfile," static char *StrFunc[65535];" FPRINT Outfile," StrCnt=(StrCnt + 1) & 65535;" FPRINT Outfile," if(StrFunc[StrCnt]) free (StrFunc[StrCnt]);" FPRINT Outfile," #if defined BCX_MAX_VAR_SIZE" FPRINT Outfile," if(Bites*sizeof(char)>BCX_MAX_VAR_SIZE)" FPRINT Outfile," {" FPRINT Outfile," printf(",ENC$("Buffer Overflow caught in BCX_TmpStr - requested space of %d EXCEEDS %d\\n"),",(int)(Bites*sizeof(char)),BCX_MAX_VAR_SIZE);" FPRINT Outfile," abort();" FPRINT Outfile," }" FPRINT Outfile," #endif" FPRINT Outfile," return StrFunc[StrCnt]=(char*)calloc(Bites+128,sizeof(char));" FPRINT Outfile,"}\n\n" END IF END IF IF Use_CopyFile THEN FPRINT Outfile,"void CopyFile (char *InFile,char *TmpFile,int OverWrite)" FPRINT Outfile,"{" FPRINT Outfile," #define BLOCKCOPYSIZE (10 * 1000*1024)" FPRINT Outfile," char* tmp=0;" FPRINT Outfile," UINT blocks=1;" FPRINT Outfile," UINT overage=0;" FPRINT Outfile," UINT i;" FPRINT Outfile," FILE *FP1,*FP2;" FPRINT Outfile," if(!OverWrite)" FPRINT Outfile," {" FPRINT Outfile," if(Exist(TmpFile)) return;" FPRINT Outfile," }" FPRINT Outfile," if(Exist(InFile))" FPRINT Outfile," {" FPRINT Outfile," UINT length = lof(InFile);" FPRINT Outfile," if(length > BLOCKCOPYSIZE)" FPRINT Outfile," {" FPRINT Outfile," blocks = length/BLOCKCOPYSIZE;" FPRINT Outfile," overage= length % BLOCKCOPYSIZE;" FPRINT Outfile," length = BLOCKCOPYSIZE;" FPRINT Outfile," }" FPRINT Outfile,"" FPRINT Outfile," tmp=(char*)calloc(16+length,1);" FPRINT Outfile,"" FPRINT Outfile," if((FP1=fopen(InFile,",ENC$("rb"),"))==0)" FPRINT Outfile," {" FPRINT Outfile," fprintf(stderr,",ENC$("Can't open file %s\\n"),",InFile);" FPRINT Outfile," exit(1);" FPRINT Outfile," }" FPRINT Outfile," if((FP2=fopen(TmpFile,",ENC$("wb+"),"))==0)" FPRINT Outfile," {" FPRINT Outfile," fprintf(stderr,",ENC$("Can't open file %s\\n"),",TmpFile);" FPRINT Outfile," exit(1);" FPRINT Outfile," }" FPRINT Outfile," for(i=0; i0)" FPRINT Outfile," {" FPRINT Outfile," fread(tmp,1,overage,FP1);" FPRINT Outfile," fwrite(tmp,1,overage,FP2);" FPRINT Outfile," }" FPRINT Outfile," fclose(FP2); fclose(FP1);" FPRINT Outfile," if(tmp) free(tmp);" FPRINT Outfile," struct stat st;" FPRINT Outfile," if(stat(InFile, &st) != -1)" FPRINT Outfile," chmod(TmpFile,st.st_mode);" FPRINT Outfile," }" FPRINT Outfile,"}\n\n" END IF IF Use_Str_Cmp THEN FPRINT Outfile,"int str_cmp (char *a, char *b)" FPRINT Outfile,"{" FPRINT Outfile," int counter=0;" FPRINT Outfile," for(;;)" FPRINT Outfile," {" FPRINT Outfile," if((a[counter]^b[counter]))" FPRINT Outfile," {" FPRINT Outfile," if((UINT) a[counter]>= (UINT) b[counter])" FPRINT Outfile," return 1;" FPRINT Outfile," return -1;" FPRINT Outfile," }" FPRINT Outfile," if(!a[counter]) return 0;" FPRINT Outfile," counter++;" FPRINT Outfile," }" FPRINT Outfile,"}\n\n" END IF IF Use_Eof THEN FPRINT Outfile,"int EoF (FILE* stream)" FPRINT Outfile,"{" FPRINT Outfile," int c, status = ((c = fgetc(stream)) == EOF);" FPRINT Outfile," ungetc(c,stream);" FPRINT Outfile," return status;" FPRINT Outfile,"}\n\n" END IF IF Use_Cint THEN FPRINT Outfile,"int Cint (double A)" FPRINT Outfile,"{" FPRINT Outfile," return (A >=0 ? (int)(A+0.5) : (int)(A-0.5));" FPRINT Outfile,"}\n\n" END IF IF Use_Clng THEN FPRINT Outfile,"long CLNG (double A)" FPRINT Outfile,"{" FPRINT Outfile," float r=.5;" FPRINT Outfile," double a=A-(long)A;" FPRINT Outfile," if(A<0) { r=-.5; a=-a; }" FPRINT Outfile," if(((long)A % 2)==0&&a<=.5)" FPRINT Outfile," return (long)A;" FPRINT Outfile," else" FPRINT Outfile," return (long)(A+r);" FPRINT Outfile,"}\n\n" END IF IF Use_Left THEN FPRINT Outfile,"char *left (char *S, int length)" FPRINT Outfile,"{" FPRINT Outfile," int tmplen = strlen(S);" FPRINT Outfile," if(length<1) return BCX_TmpStr(1);" FPRINT Outfile," if(lengthtmplen||start<1) return BCX_TmpStr(1);" FPRINT Outfile," if (length<0 || length>(tmplen-start)+1)" FPRINT Outfile," length = (tmplen-start)+1;" FPRINT Outfile," strtmp = BCX_TmpStr(length);" FPRINT Outfile," return (char*)memcpy(strtmp,&S[start-1],length);" FPRINT Outfile,"}\n\n" END IF IF Use_Trim THEN FPRINT Outfile,"char *trim (char *S)" FPRINT Outfile,"{" FPRINT Outfile," while(*S==32 || *S==9 || *S==10 || *S==11 || *S==13)" ' tab ,carriage return, vertical tab, newline, space FPRINT Outfile," S++;" FPRINT Outfile," int i = strlen(S);" FPRINT Outfile," while( i>0 && (S[i-1]==32 || S[i-1]==9 || S[i-1]==10" FPRINT Outfile," || S[i-1]==11 || S[i-1]==13))" FPRINT Outfile," i--;" FPRINT Outfile," char *strtmp=BCX_TmpStr(i);" FPRINT Outfile," return (char*)memcpy(strtmp,S,i);" FPRINT Outfile,"}\n\n" END IF IF Use_Ltrim THEN FPRINT Outfile,"char *ltrim (char *S, char c)" FPRINT Outfile,"{" FPRINT Outfile," if(S[0]==0) return S;" FPRINT Outfile," while((*S==32 || *S==c) && *S !=0) S++;" FPRINT Outfile," char *strtmp = BCX_TmpStr(strlen(S));" FPRINT Outfile," return strcpy(strtmp,S);" FPRINT Outfile,"}\n\n" END IF IF Use_Rtrim THEN FPRINT Outfile,"char *rtrim (char *S,char c)" FPRINT Outfile,"{" FPRINT Outfile," if(S[0]==0) return S;" FPRINT Outfile," int i = strlen(S);" FPRINT Outfile," while(i>0 && (S[i-1]==c || S[i-1]==32))" FPRINT Outfile," i--;" FPRINT Outfile," char *strtmp = BCX_TmpStr(i);" FPRINT Outfile," return (char*)memcpy(strtmp,S,i);" FPRINT Outfile,"}\n\n" END IF IF Use_Strim THEN FPRINT Outfile,"char *strim (char *src)" FPRINT Outfile,"{" FPRINT Outfile," char *strtmp = BCX_TmpStr(strlen(src));" FPRINT Outfile," char *dst = strtmp;" FPRINT Outfile," while (isspace((unsigned char)*src)) src++;" FPRINT Outfile," do" FPRINT Outfile," {" FPRINT Outfile," while (*src && !isspace((unsigned char)*src)) *dst++ = *src++;" FPRINT Outfile," if (*src)" FPRINT Outfile," {" FPRINT Outfile," *dst++ = *src++;" FPRINT Outfile," while (isspace((unsigned char)*src)) src++;" FPRINT Outfile," }" FPRINT Outfile," } while (*src);" FPRINT Outfile," if (isspace((unsigned char)*(--dst))) *dst = 0;" FPRINT Outfile," return strtmp;" FPRINT Outfile,"}\n\n" END IF IF Use_Command THEN FPRINT Outfile,"char *command (int nArg)" FPRINT Outfile," {" FPRINT Outfile," int i = 0;" FPRINT Outfile," char *retstr=BCX_TmpStr(1);" FPRINT Outfile," if(nArg < i) // return entire commandline" FPRINT Outfile," {" FPRINT Outfile," retstr = BCX_TmpStr(G_argc * 2048);" FPRINT Outfile," for(i=1; i < G_argc; i++)" FPRINT Outfile," {" FPRINT Outfile," strcat(retstr, G_argv[i]);" FPRINT Outfile," strcat(retstr, SPC);" FPRINT Outfile," }" FPRINT Outfile," }" FPRINT Outfile," else if(nArg < G_argc)" FPRINT Outfile," {" FPRINT Outfile," retstr = BCX_TmpStr(strlen(G_argv[nArg]) + 1);" FPRINT Outfile," strcpy(retstr, G_argv[nArg]);" FPRINT Outfile," }" FPRINT Outfile," return retstr;" FPRINT Outfile,"}\n\n" END IF IF Use_Extract THEN FPRINT Outfile,"char *extract (char *mane, char *match)" FPRINT Outfile,"{" FPRINT Outfile," char *a;" FPRINT Outfile," char *strtmp = BCX_TmpStr(strlen(mane));" FPRINT Outfile," if(*match!=0)" FPRINT Outfile," {" FPRINT Outfile," a=_strstr_(mane,match);" FPRINT Outfile," if(a) return (char*)memcpy(strtmp,mane,a-mane);" FPRINT Outfile," }" FPRINT Outfile," return strcpy(strtmp,mane);" FPRINT Outfile,"}\n\n" END IF IF Use_Remain THEN FPRINT Outfile,"char *remain (char *mane, char *mat)" FPRINT Outfile,"{" FPRINT Outfile," char *p = strstr(mane,mat);" FPRINT Outfile," if(p)" FPRINT Outfile," {" FPRINT Outfile," p+=(strlen(mat));" FPRINT Outfile," return p;" FPRINT Outfile," }" FPRINT Outfile," return mane;" FPRINT Outfile,"}\n\n" END IF IF Use_Replace THEN FPRINT Outfile,"char *replace (char *src, char *pat, char *rep)" FPRINT Outfile,"{" FPRINT Outfile," size_t patsz, repsz, tmpsz, delta;" FPRINT Outfile," char *strtmp, *p, *q, *r;" FPRINT Outfile," if (!pat || !*pat)" FPRINT Outfile," {" FPRINT Outfile," strtmp = BCX_TmpStr(strlen(src));" FPRINT Outfile," if (!strtmp) return NULL;" FPRINT Outfile," return strcpy(strtmp, src);" FPRINT Outfile," }" FPRINT Outfile," repsz = strlen(rep);" FPRINT Outfile," patsz = strlen(pat);" FPRINT Outfile," for (tmpsz=0, p=src; (q=_strstr_(p,pat))!=0; p=q+patsz)" FPRINT Outfile," tmpsz += (size_t) (q - p) + repsz;" FPRINT Outfile," tmpsz += strlen(p);" FPRINT Outfile," strtmp = BCX_TmpStr(tmpsz);" FPRINT Outfile," if (!strtmp) return NULL;" FPRINT Outfile," for (r=strtmp,p=src; (q=_strstr_(p,pat))!=0;p=q+patsz)" FPRINT Outfile," {" FPRINT Outfile," delta = (size_t) (q-p);" FPRINT Outfile," memcpy(r,p,delta); r += delta;" FPRINT Outfile," strcpy(r,rep); r += repsz;" FPRINT Outfile," }" FPRINT Outfile," strcpy(r,p);" FPRINT Outfile," return strtmp;" FPRINT Outfile,"}\n\n" END IF IF Use_Reverse THEN FPRINT Outfile,"char *reverse (char *s)" FPRINT Outfile,"{" FPRINT Outfile," int j=strlen(s);" FPRINT Outfile," char *rstr = BCX_TmpStr(j);" FPRINT Outfile," while(j) rstr[--j] = *(s++);" FPRINT Outfile," return rstr;" FPRINT Outfile,"}\n\n" END IF IF Use_Findfirst THEN FPRINT Outfile,"char *findfirst (char *filespec, FILE_FIND_DATA *FindData)" FPRINT Outfile,"{" FPRINT Outfile," struct dirent *dp;" FPRINT Outfile," struct stat st;" FPRINT Outfile,"" FPRINT Outfile," if(FindData->FileHandle)" FPRINT Outfile," closedir(FindData->FileHandle);" FPRINT Outfile,"" FPRINT Outfile," strcpy(FindData->path, BcxSplitPath(filespec, FDRV|FPATH));" FPRINT Outfile," strcpy(FindData->cFileSpec,BcxSplitPath(filespec, FNAME|FEXT));" FPRINT Outfile," if(*FindData->path==0) strcpy(FindData->path, ",ENC$("."),");" FPRINT Outfile,"" FPRINT Outfile," FindData->FileHandle=opendir(FindData->path);" FPRINT Outfile,"" FPRINT Outfile," while(FindData->FileHandle)" FPRINT Outfile," {" FPRINT Outfile," dp=readdir(FindData->FileHandle);" FPRINT Outfile," if(dp==NULL) break;" FPRINT Outfile,"" FPRINT Outfile," if(like(dp->d_name,FindData->cFileSpec))" FPRINT Outfile," {" FPRINT Outfile," strcpy(FindData->cFileName,dp->d_name);" FPRINT Outfile," lstat(join(2,FindData->path,dp->d_name), &st);" FPRINT Outfile," FindData->dwFileAttributes = st.st_mode;" FPRINT Outfile," return FindData->cFileName;" FPRINT Outfile," }" FPRINT Outfile," }" FPRINT Outfile,"" FPRINT Outfile," *FindData->cFileName=0;" FPRINT Outfile," return FindData->cFileName;" FPRINT Outfile,"}\n\n" END IF IF Use_Findnext THEN FPRINT Outfile,"char *findnext (FILE_FIND_DATA *FindData)" FPRINT Outfile,"{" FPRINT Outfile," struct dirent *dp;" FPRINT Outfile," struct stat st;" FPRINT Outfile,"" FPRINT Outfile," while(FindData->FileHandle)" FPRINT Outfile," {" FPRINT Outfile," dp=readdir(FindData->FileHandle);" FPRINT Outfile," if(dp==NULL) break;" FPRINT Outfile,"" FPRINT Outfile," if(like(dp->d_name,FindData->cFileSpec))" FPRINT Outfile," {" FPRINT Outfile," strcpy(FindData->cFileName,dp->d_name);" FPRINT Outfile," lstat(join(2,FindData->path,dp->d_name), &st);" FPRINT Outfile," FindData->dwFileAttributes = st.st_mode;" FPRINT Outfile," return FindData->cFileName;" FPRINT Outfile," }" FPRINT Outfile," }" FPRINT Outfile,"" FPRINT Outfile," *FindData->cFileName=0;" FPRINT Outfile," return FindData->cFileName;" FPRINT Outfile,"}\n\n" END IF IF Use_Ucase THEN FPRINT Outfile,"char *ucase (char *S)" FPRINT Outfile,"{" FPRINT Outfile," char *strtmp = BCX_TmpStr(strlen(S));" FPRINT Outfile," return _strupr_(strcpy(strtmp,S));" FPRINT Outfile,"}\n\n" END IF IF Use_Lcase THEN FPRINT Outfile,"char *lcase (char *S)" FPRINT Outfile,"{" FPRINT Outfile," char *strtmp = BCX_TmpStr(strlen(S));" FPRINT Outfile," return _strlwr_(strcpy(strtmp,S));" FPRINT Outfile,"}\n\n" END IF IF Use_Mcase THEN FPRINT Outfile,"char *mcase (char *S)" FPRINT Outfile,"{" FPRINT Outfile," char *strtmp = BCX_TmpStr(strlen(S)+1);" FPRINT Outfile," char *s = strtmp;" FPRINT Outfile," _strlwr_(strcpy(strtmp,S));" FPRINT Outfile," while(*s)" FPRINT Outfile," {" FPRINT Outfile," if(islower(*s))" FPRINT Outfile," {" FPRINT Outfile," *s-=32;" FPRINT Outfile," while(isalpha(*++s));" FPRINT Outfile," }" FPRINT Outfile," s++;" FPRINT Outfile," }" FPRINT Outfile," return strtmp;" FPRINT Outfile,"}\n\n" END IF IF Use_Remove THEN FPRINT Outfile,"char *RemoveStr (char *a, char *b)" FPRINT Outfile,"{" FPRINT Outfile," char *strtmp, *p, *d;" FPRINT Outfile," int tmplen;" FPRINT Outfile," strtmp = d = BCX_TmpStr(strlen(a));" FPRINT Outfile," if(!b || !*b) return strcpy(strtmp,a);" FPRINT Outfile," p=_strstr_(a,b); tmplen = strlen(b);" FPRINT Outfile," while(p)" FPRINT Outfile," {" FPRINT Outfile," memcpy(d,a,p-a);" FPRINT Outfile," d+= (p-a);" FPRINT Outfile," a=p+tmplen;" FPRINT Outfile," p=_strstr_(a,b);" FPRINT Outfile," }" FPRINT Outfile," strcpy(d,a);" FPRINT Outfile," return strtmp;" FPRINT Outfile,"}\n\n" END IF IF Use_IRemove THEN FPRINT Outfile,"char *IRemoveStr (char *a, char *b)" FPRINT Outfile,"{" FPRINT Outfile," char *strtmp, *p, *d;" FPRINT Outfile," int tmplen;" FPRINT Outfile," strtmp = d = BCX_TmpStr(strlen(a));" FPRINT Outfile," if(!b || !*b) return strcpy(strtmp,a);" FPRINT Outfile," p=_stristr_(a,b); tmplen = strlen(b);" FPRINT Outfile," while(p)" FPRINT Outfile," {" FPRINT Outfile," memcpy(d,a,p-a);" FPRINT Outfile," d+= (p-a);" FPRINT Outfile," a=p+tmplen;" FPRINT Outfile," p=_stristr_(a,b);" FPRINT Outfile," }" FPRINT Outfile," strcpy(d,a);" FPRINT Outfile," return strtmp;" FPRINT Outfile,"}\n\n" END IF IF Use_Ins THEN FPRINT Outfile,"char *ins (char *S, int i, char *a)" FPRINT Outfile,"{" FPRINT Outfile," int j = strlen(S);" FPRINT Outfile," if(i<1 || i>j+1) return S;" FPRINT Outfile," char *strtmp = BCX_TmpStr(j + strlen(a));" FPRINT Outfile," memcpy(strtmp,S,--i);" FPRINT Outfile," strcpy(&strtmp[i],a);" FPRINT Outfile," return strcat(strtmp,&S[i]);" FPRINT Outfile,"}\n\n" END IF IF Use_Del THEN FPRINT Outfile,"char *del (char *S, int i, int j)" FPRINT Outfile,"{" FPRINT Outfile," int ln = strlen(S);" FPRINT Outfile," if(i<1 || i>ln) return S;" FPRINT Outfile," char *strtmp = BCX_TmpStr(ln);" FPRINT Outfile," memcpy(strtmp,S,--i);" FPRINT Outfile," return strcat(strtmp,&S[i+j]);" FPRINT Outfile,"}\n\n" END IF IF Use_Str THEN FPRINT Outfile,"char *str (double d)" FPRINT Outfile,"{" FPRINT Outfile," char *strtmp = BCX_TmpStr(16);" FPRINT Outfile," sprintf(strtmp,";D1$;",d);" FPRINT Outfile," return strtmp;" FPRINT Outfile,"}\n\n" END IF IF Use_Strl THEN FPRINT Outfile,"char *strl (long double d)" FPRINT Outfile,"{" FPRINT Outfile," char *strtmp = BCX_TmpStr(27);" FPRINT Outfile," sprintf(strtmp,";D2$;",d);" FPRINT Outfile," return strtmp;" FPRINT Outfile,"}\n\n" END IF IF Use_Curdir THEN FPRINT Outfile,"char *curdir (void)" FPRINT Outfile,"{" FPRINT Outfile," char *strtmp = BCX_TmpStr(2048);" FPRINT Outfile," char *res=getcwd(strtmp, 1024);" FPRINT Outfile," return strtmp;" FPRINT Outfile,"}\n\n" END IF IF Use_Hex THEN FPRINT Outfile,"char *hex (int a)" FPRINT Outfile,"{" FPRINT Outfile," char *strtmp = BCX_TmpStr(16);" FPRINT Outfile," sprintf(strtmp,";enc$("%02X");",a);" FPRINT Outfile," return strtmp;" FPRINT Outfile,"}\n\n" END IF IF Use_Tempdir THEN FPRINT Outfile,"char *tempdir (void)" FPRINT Outfile,"{" FPRINT Outfile," char *strtmp = BCX_TmpStr(2048);" FPRINT Outfile," if(!Exist(";enc$("/tmp/mbc.compiler");")) {" FPRINT Outfile," mkdir (";enc$("/tmp/mbc.compiler");",0755);" FPRINT Outfile," }" FPRINT Outfile," strcpy(strtmp,";enc$("/tmp/mbc.compiler");");" FPRINT Outfile," return strtmp;" FPRINT Outfile,"}\n\n" END IF IF Use_Sysdir THEN FPRINT Outfile,"char *sysdir (void)" FPRINT Outfile,"{" FPRINT Outfile," char *strtmp = BCX_TmpStr(2048);" FPRINT Outfile," GetSystemDirectory (strtmp,2048);" FPRINT Outfile," return strtmp;" FPRINT Outfile,"}\n\n" END IF IF Use_Repeat THEN FPRINT Outfile,"char *repeat (int count, char *a)" FPRINT Outfile,"{" FPRINT Outfile," char *strtmp = BCX_TmpStr((1+count)*strlen(a));" FPRINT Outfile," while(count-->0) strtmp = strcat(strtmp, a);" FPRINT Outfile," return strtmp;" FPRINT Outfile,"}\n\n" END IF IF Use_String THEN FPRINT Outfile,"char *stringx (int count, int a)" FPRINT Outfile,"{" FPRINT Outfile," if(count<1) return BCX_TmpStr(1);" FPRINT Outfile," char *strtmp = BCX_TmpStr(count);" FPRINT Outfile," return (char*)memset(strtmp,a,count);" FPRINT Outfile,"}\n\n" END IF IF Use_Shell THEN FPRINT Outfile,"void Shell (char *cmd)" FPRINT Outfile,"{" FPRINT Outfile," int res=system(cmd);" FPRINT Outfile,"}\n\n" END IF IF Use_Space THEN FPRINT Outfile,"char *space (int count)" FPRINT Outfile,"{" FPRINT Outfile," if(count<1) return BCX_TmpStr(1);" FPRINT Outfile," char *strtmp = BCX_TmpStr(count);" FPRINT Outfile," return (char*)memset(strtmp,32,count);" FPRINT Outfile,"}\n\n" END IF IF Use_Time THEN FPRINT Outfile,"char *timef (int t)" FPRINT Outfile,"{" FPRINT Outfile," time_t elapse_time;" FPRINT Outfile," struct tm *tp;" FPRINT Outfile," char *strtmp = BCX_TmpStr(256);" FPRINT Outfile," time (&elapse_time);" FPRINT Outfile," tp = localtime(&elapse_time);" FPRINT Outfile," switch (t)" FPRINT Outfile," {" FPRINT Outfile," case 0:" FPRINT Outfile," strftime(strtmp,256,",T0$, ",tp); break;" FPRINT Outfile," case 1:" FPRINT Outfile," strftime(strtmp,256,",T1$, ",tp); break;" FPRINT Outfile," case 2:" FPRINT Outfile," strftime(strtmp,256,",T2$, ",tp); break;" FPRINT Outfile," case 3:" FPRINT Outfile," strftime(strtmp,256,",T3$, ",tp); break;" FPRINT Outfile," case 4:" FPRINT Outfile," strftime(strtmp,256,",T4$, ",tp); break;" FPRINT Outfile," case 5:" FPRINT Outfile," strftime(strtmp,256,",T5$, ",tp); break;" FPRINT Outfile," case 6:" FPRINT Outfile," strftime(strtmp,256,",T6$, ",tp); break;" FPRINT Outfile," case 7:" FPRINT Outfile," strftime(strtmp,256,",T7$, ",tp); break;" FPRINT Outfile," case 8:" FPRINT Outfile," strftime(strtmp,256,",T8$, ",tp); break;" FPRINT Outfile," case 9:" FPRINT Outfile," strftime(strtmp,256,",T9$, ",tp); break;" FPRINT Outfile," case 10:" FPRINT Outfile," strftime(strtmp,256,",T10$, ",tp); break;" FPRINT Outfile," case 11:" FPRINT Outfile," strftime(strtmp,256,",T11$, ",tp); break;" FPRINT Outfile," case 12:" FPRINT Outfile," strftime(strtmp,256,",T12$, ",tp); break;" FPRINT Outfile," case 13:" FPRINT Outfile," strftime(strtmp,256,",T13$, ",tp); break;" FPRINT Outfile," }" FPRINT Outfile," return strtmp;" FPRINT Outfile,"}\n\n" END IF IF Use_Enclose THEN FPRINT Outfile,"char *enc (char *A, int L, int R)" FPRINT Outfile,"{" FPRINT Outfile," char *BCX_RetStr = BCX_TmpStr(strlen(A)+3);" FPRINT Outfile," if(L==0) L=34;" FPRINT Outfile," if(R==0) R=L;" FPRINT Outfile," sprintf(BCX_RetStr,",ENC$("%c%s%c%s"),",L,A,R,",ENC$("\0"),");" FPRINT Outfile," return BCX_RetStr;" FPRINT Outfile,"}\n\n" END IF IF Use_Chr THEN FPRINT Outfile,"char *chr (int a,int b,int c,int d,int e,int f,int g,int h,int i,int j)" FPRINT Outfile,"{" FPRINT Outfile," char *strtmp = BCX_TmpStr(11);" FPRINT Outfile," strtmp[0] = a;" FPRINT Outfile," strtmp[1] = b;" FPRINT Outfile," strtmp[2] = c;" FPRINT Outfile," strtmp[3] = d;" FPRINT Outfile," strtmp[4] = e;" FPRINT Outfile," strtmp[5] = f;" FPRINT Outfile," strtmp[6] = g;" FPRINT Outfile," strtmp[7] = h;" FPRINT Outfile," strtmp[8] = i;" FPRINT Outfile," strtmp[9] = j;" FPRINT Outfile," strtmp[10] = 0;" FPRINT Outfile," return strtmp;" FPRINT Outfile,"}\n\n" END IF IF Use_VChr THEN FPRINT Outfile,"char *vchr(int charcount, ...)" FPRINT Outfile,"{" FPRINT Outfile," int c = 0, i = charcount;" FPRINT Outfile," char *s_ = BCX_TmpStr(charcount + 1);" FPRINT Outfile," va_list marker;" FPRINT Outfile," s_[i] = 0;" FPRINT Outfile," va_start(marker, charcount);" FPRINT Outfile," while(i-- > 0) s_[c++] = va_arg(marker,int);" FPRINT Outfile," va_end(marker);" FPRINT Outfile," return s_;" FPRINT Outfile,"}\n\n" END IF IF Use_Join THEN FPRINT Outfile,"char * join(int n, ...)" FPRINT Outfile,"{" FPRINT Outfile," int i = n, tmplen = 0;" FPRINT Outfile," char *strtmp, *s_;" FPRINT Outfile,"" FPRINT Outfile," va_list marker;" FPRINT Outfile," va_start(marker, n); // Initialize variable arguments" FPRINT Outfile," while(i-- > 0)" FPRINT Outfile," {" FPRINT Outfile," s_ = va_arg(marker, char *);" FPRINT Outfile," if(s_) tmplen += strlen(s_);" FPRINT Outfile," }" FPRINT Outfile," strtmp = BCX_TmpStr(tmplen);" FPRINT Outfile," va_end(marker); // Reset variable arguments" FPRINT Outfile," i = n;" FPRINT Outfile," va_start(marker, n); // Initialize variable arguments" FPRINT Outfile," while(i-- > 0)" FPRINT Outfile," {" FPRINT Outfile," s_ = va_arg(marker, char *);" FPRINT Outfile," if(s_) strcat(strtmp, s_);" FPRINT Outfile," }" FPRINT Outfile," va_end(marker); // Reset variable arguments" FPRINT Outfile," return strtmp;" FPRINT Outfile,"}\n\n" END IF IF Use_Environ THEN FPRINT Outfile,"char* Environ(char *S)" FPRINT Outfile,"{" FPRINT Outfile," char *strtmp, *tmp;" FPRINT Outfile,"" FPRINT Outfile," tmp = getenv(S);" FPRINT Outfile," if(tmp != NULL) {" FPRINT Outfile," strtmp = BCX_TmpStr(strlen(tmp)+1);" FPRINT Outfile," return strcpy(strtmp, tmp);" FPRINT Outfile," }" FPRINT Outfile," return BCX_TmpStr(1);" FPRINT Outfile,"}\n\n" END IF IF Use_Oct THEN FPRINT Outfile,"char *oct (int a)" FPRINT Outfile,"{" FPRINT Outfile," char *strtmp = BCX_TmpStr(2048);" FPRINT Outfile," sprintf(strtmp,";O1$;",a);" FPRINT Outfile," return strtmp;" FPRINT Outfile,"}\n\n" END IF IF Use_Bin THEN FPRINT Outfile,"char* Bin(int number)" FPRINT Outfile,"{" FPRINT Outfile," char *strtmp = BCX_TmpStr(2048);" FPRINT Outfile," itoa(number,strtmp,2);" FPRINT Outfile," return strtmp;" FPRINT Outfile,"}\n\n" END IF IF Use_Pause THEN FPRINT Outfile,"void Pause(void)" FPRINT Outfile,"{" FPRINT Outfile," printf(", ENC$("\\n%s\\n"), ",", ENC$("Press any key to continue . . ."), ");" FPRINT Outfile," _getch_(TRUE);" FPRINT Outfile,"}\n\n" END IF IF Use_Keypress THEN FPRINT Outfile,"int keypress(void)" FPRINT Outfile,"{" FPRINT Outfile," return _getch_(TRUE);" FPRINT Outfile,"}\n\n" END IF IF Use_Inkey THEN FPRINT Outfile,"char* inkey(void)" FPRINT Outfile,"{" FPRINT Outfile," char *strtmp = BCX_TmpStr(2);" FPRINT Outfile," strtmp[0] = _getch_(FALSE);" FPRINT Outfile," if(strtmp[0] == -1) strtmp[0] = 0;" FPRINT Outfile," return strtmp;" FPRINT Outfile,"}\n\n" END IF IF Use_InkeyD THEN FPRINT Outfile,"int inkeyd(void)" FPRINT Outfile,"{" FPRINT Outfile," return _getch_(TRUE);" FPRINT Outfile,"}\n\n" END IF '/***** 2010-12-08 Added to support INSTAT -AIR *****/ IF Use_Instat THEN FPRINT Outfile,"int kbhit(void)" FPRINT Outfile,"{" FPRINT Outfile," struct termios oldt, newt;" FPRINT Outfile," int ch;" FPRINT Outfile," int oldf;" FPRINT Outfile," tcgetattr(STDIN_FILENO, &oldt);" FPRINT Outfile," newt = oldt;" FPRINT Outfile," newt.c_lflag &= ~(ICANON | ECHO);" FPRINT Outfile," tcsetattr(STDIN_FILENO, TCSANOW, &newt);" FPRINT Outfile," oldf = fcntl(STDIN_FILENO, F_GETFL, 0);" FPRINT Outfile," fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK);" FPRINT Outfile," ch = getchar();" FPRINT Outfile," tcsetattr(STDIN_FILENO, TCSANOW, &oldt);" FPRINT Outfile," fcntl(STDIN_FILENO, F_SETFL, oldf);" FPRINT Outfile," if(ch != EOF)" FPRINT Outfile," {" FPRINT Outfile," ungetc(ch, stdin);" FPRINT Outfile," return 1;" FPRINT Outfile," }" FPRINT Outfile," return 0;" FPRINT Outfile,"}\n\n" END IF IF Use_GetCh THEN FPRINT Outfile,"int _getch_(int waitkey)" FPRINT Outfile,"{" FPRINT Outfile," struct termios initial_settings, new_settings;" FPRINT Outfile," unsigned char ch;" FPRINT Outfile,"" FPRINT Outfile," tcgetattr(0,&initial_settings);" FPRINT Outfile," new_settings = initial_settings;" FPRINT Outfile," new_settings.c_lflag &= ~ICANON;" FPRINT Outfile," new_settings.c_lflag &= ~ECHO;" FPRINT Outfile," new_settings.c_lflag &= ~ISIG;" FPRINT Outfile," new_settings.c_cc[VMIN] = waitkey;" FPRINT Outfile," new_settings.c_cc[VTIME] = 0;" FPRINT Outfile," tcsetattr(0, TCSANOW, &new_settings);" FPRINT Outfile,"" FPRINT Outfile," //read(0,&ch,1);" FPRINT Outfile," ch = getchar();" FPRINT Outfile," tcsetattr(0, TCSANOW, &initial_settings);" FPRINT Outfile," return ch;" FPRINT Outfile,"}\n\n" END IF IF Use_Now THEN FPRINT Outfile,"char *now (void)" FPRINT Outfile,"{" FPRINT Outfile," time_t elapse_time;" FPRINT Outfile," struct tm *tp;" FPRINT Outfile," char *strtmp = BCX_TmpStr(2048);" FPRINT Outfile," time(&elapse_time);" FPRINT Outfile," tp=localtime(&elapse_time);" FPRINT Outfile," strftime(strtmp,256,", ENC$("%m/%d/%y %I:%M:%S: %p"), ",tp);" FPRINT Outfile," return strtmp;" FPRINT Outfile,"}" END IF IF Use_AppExePath THEN FPRINT Outfile,"char *AppExePath (void)" FPRINT Outfile,"{" FPRINT Outfile," char fullpath[MAX_PATH];" FPRINT Outfile," int length;" !#if defined (__APPLE__) FPRINT Outfile," pid_t pid = getpid();" FPRINT Outfile," length = proc_pidpath (pid, fullpath, sizeof(fullpath));" !#else FPRINT Outfile," length = readlink(", ENC$("/proc/self/exe"),", fullpath, MAX_PATH);" !#endif FPRINT Outfile," if(length < 1) return BCX_TmpStr(1);" FPRINT Outfile,"" FPRINT Outfile," fullpath[length] = 0;" FPRINT Outfile," return BcxSplitPath(fullpath, FDRV|FPATH);" FPRINT Outfile,"}\n\n" END IF IF Use_AppExeName THEN FPRINT Outfile,"char *AppExeName (void)" FPRINT Outfile,"{" FPRINT Outfile," return BcxSplitPath(G_argv[0], FNAME|FEXT);" FPRINT Outfile,"}\n\n" END IF IF Use_TempFileName THEN FPRINT Outfile,"char * TempFileName (char *dr, char *prefix)" FPRINT Outfile,"{" FPRINT Outfile," static unsigned int count;" FPRINT Outfile," char *f, *tmpstr = BCX_TmpStr(MAX_PATH);" FPRINT Outfile," int i, length;" FPRINT Outfile,"" FPRINT Outfile," if(!count) srand(time(0));" FPRINT Outfile,"" FPRINT Outfile," if(dr) strcpy(tmpstr, dr);" FPRINT Outfile," length = strlen(tmpstr);" FPRINT Outfile," if(length && (tmpstr[length-1] != '\\\\' && tmpstr[length-1] != '/'))" FPRINT Outfile," tmpstr[length++] = '/';" FPRINT Outfile," if(prefix) strcpy(&tmpstr[length], prefix);" FPRINT Outfile," f = &tmpstr[strlen(tmpstr)];" FPRINT Outfile,"" FPRINT Outfile," do {" FPRINT Outfile," count++;" FPRINT Outfile," for(i=0; i<5; i+=1)" FPRINT Outfile," {" FPRINT Outfile," do {" FPRINT Outfile," f[i]=(char)(rnd()*122);" FPRINT Outfile," }while((f[i]<65)||(f[i]>90&&f[i]<97));" FPRINT Outfile," }" FPRINT Outfile," snprintf(&f[5],3,",ENC$("%x"),", count);" FPRINT Outfile," } while (Exist(tmpstr));" FPRINT Outfile,"" FPRINT Outfile," return tmpstr;" FPRINT Outfile,"}\n\n" END IF IF Use_Boolstr THEN FPRINT Outfile,"char * BoolStr (int a)" FPRINT Outfile,"{" FPRINT Outfile," char *BCX_RetStr=BCX_TmpStr(5);" FPRINT Outfile," if(a) return strcpy(BCX_RetStr,",ENC$("True"),");" FPRINT Outfile," return strcpy(BCX_RetStr,",ENC$("False"),");" FPRINT Outfile,"}\n\n" END IF IF Use_Using THEN FPRINT Outfile,"char *Using (char *Mask, double Num)" FPRINT Outfile,"{" FPRINT Outfile," int Spaces = 0;" FPRINT Outfile," int CntDec = 0;" FPRINT Outfile," int Decimals = 0;" FPRINT Outfile," int Dollar = 0;" FPRINT Outfile," char* BCX_RetStr = BCX_TmpStr(512);" FPRINT Outfile," char Buf_1[512]={0};" FPRINT Outfile," char* p = Mask;" FPRINT Outfile," char* r;" FPRINT Outfile," int len;" FPRINT Outfile,"" FPRINT Outfile," while (*p)" FPRINT Outfile," {" FPRINT Outfile," if (*p == 36) Dollar++;" FPRINT Outfile," if (*p == 32) Spaces++;" FPRINT Outfile," if ((*p == 32 || *p == 35)&& CntDec) Decimals++;" FPRINT Outfile," if (*p == 46) CntDec = 1;" FPRINT Outfile," p++;" FPRINT Outfile," }" FPRINT Outfile," sprintf(Buf_1,", ENC$("%1.*f"), ",Decimals,Num);" FPRINT Outfile,"" FPRINT Outfile," len = strlen(Buf_1)-Decimals-(Decimals>0?1:0);" FPRINT Outfile," r = BCX_RetStr+Dollar+Spaces;" FPRINT Outfile," p = Buf_1;" FPRINT Outfile," while (*p)" FPRINT Outfile," {" FPRINT Outfile," *r++ = *p++;" FPRINT Outfile," if (--len>2 && *(p-1) != '-' && len % 3 == 0)" FPRINT Outfile," {" FPRINT Outfile," *r++ = ',';" FPRINT Outfile," }" FPRINT Outfile," }" FPRINT Outfile," if(Dollar) BCX_RetStr[Spaces]=36;" FPRINT Outfile," if(Spaces) memset(BCX_RetStr,32,Spaces);" FPRINT Outfile,"" FPRINT Outfile," return BCX_RetStr;" FPRINT Outfile,"}\n\n" END IF IF Use_SearchPath THEN FPRINT Outfile,"char *SEARCHPATH (char *szFile)" FPRINT Outfile,"{" FPRINT Outfile," char *BCX_RetStr=BCX_TmpStr(MAX_PATH+1);" FPRINT Outfile," PCHAR lpbs=0;" FPRINT Outfile," SearchPath(0,szFile,0,MAX_PATH,BCX_RetStr,&lpbs);" FPRINT Outfile," if(lpbs) *lpbs=0;" FPRINT Outfile," return BCX_RetStr;" FPRINT Outfile,"}\n\n" END IF IF Use_Instrrev THEN FPRINT Outfile,"int InstrRev (char *s, char *p, int os, int sens)" FPRINT Outfile,"{" FPRINT Outfile," int sl, pl, ox;" FPRINT Outfile," int (*cmp)(const char *, const char *, size_t );" FPRINT Outfile,"" FPRINT Outfile," if (!s || !p) return 0;" FPRINT Outfile," sl = strlen(s); pl = strlen(p);" FPRINT Outfile," if (os > sl || sl == 0 || pl == 0 || (ox = sl - pl) < 0)" FPRINT Outfile," return 0;" FPRINT Outfile,"" FPRINT Outfile," if (os <= 0) " FPRINT Outfile," os = ox ;" FPRINT Outfile," else if(os >= pl)" FPRINT Outfile," os = os - pl ;" FPRINT Outfile," else" FPRINT Outfile," return 0;" FPRINT Outfile,"" FPRINT Outfile," cmp = (sens ? strncasecmp : strncmp);" FPRINT Outfile," do { if (cmp(s + os , p, pl) == 0)" FPRINT Outfile," return os+1;" FPRINT Outfile," } while (os--);" FPRINT Outfile," return 0;" FPRINT Outfile,"}\n\n" END IF IF Use_Instr THEN FPRINT Outfile,"int instr_b(char* mane,char* match,int offset,int sensflag)" FPRINT Outfile,"{" FPRINT Outfile," char *s;" FPRINT Outfile," if (!mane || !match || ! *match || offset>(int)strlen(mane)) return 0;" FPRINT Outfile," if (sensflag)" FPRINT Outfile," s = _stristr_(offset>0 ? mane+offset-1 : mane,match);" FPRINT Outfile," else" FPRINT Outfile," s = _strstr_(offset>0 ? mane+offset-1 : mane,match);" FPRINT Outfile," return s ? (int)(s-mane)+1 : 0;" FPRINT Outfile,"}\n\n" END IF IF UseLCaseTbl THEN FPRINT Outfile,"char *MakeLCaseTbl (void)" FPRINT Outfile,"{" FPRINT Outfile," static char tbl[256];" FPRINT Outfile," if(!tbl['a'])" FPRINT Outfile," {" FPRINT Outfile," int i; for (i=0; i < 256; i++)" FPRINT Outfile," tbl[i] = (char)(int)tolower(i);" FPRINT Outfile," }" FPRINT Outfile," return tbl;" FPRINT Outfile,"}\n\n" END IF IF Use_Stristr THEN FPRINT Outfile,"char *_stristr_(char *String, char *Pattern)" FPRINT Outfile,"{" FPRINT Outfile," int mi=-1;" FPRINT Outfile," char *LowCase = MakeLCaseTbl();" FPRINT Outfile," while(Pattern[++mi])" FPRINT Outfile," {" FPRINT Outfile," if(String[mi]==0) return 0;" FPRINT Outfile," if(LowCase[(unsigned char)String[mi]]!=LowCase[(unsigned char)Pattern[mi]])" FPRINT Outfile," { String++; mi=-1; }" FPRINT Outfile," }" FPRINT Outfile," return String;" FPRINT Outfile,"}\n\n" END IF IF Use_StrStr THEN FPRINT Outfile,"char *_strstr_(char *String, char *Pattern)" FPRINT Outfile,"{" FPRINT Outfile," int mi=-1;" FPRINT Outfile," while(Pattern[++mi])" FPRINT Outfile," {" FPRINT Outfile," if(String[mi]==0) return 0;" FPRINT Outfile," if(String[mi]!=Pattern[mi])" FPRINT Outfile," { String++; mi=-1; }" FPRINT Outfile," }" FPRINT Outfile," return String;" FPRINT Outfile,"}\n\n" END IF IF Use_Inchr THEN FPRINT Outfile,"int inchr (char *A, char *B)" FPRINT Outfile,"{" FPRINT Outfile," char* C=A;" FPRINT Outfile," while(*C)" FPRINT Outfile," {" FPRINT Outfile," if(*C==*B) return C-A+1;" FPRINT Outfile," C++;" FPRINT Outfile," }" FPRINT Outfile," return 0;" FPRINT Outfile,"}\n\n" END IF IF Use_Asc THEN FPRINT Outfile,"extern int asc (char *z,int index)" FPRINT Outfile,"{" FPRINT Outfile," return (unsigned char) z[index];" FPRINT Outfile,"}\n\n" END IF IF Use_Sgn THEN FPRINT Outfile,"double sgn (double a)" FPRINT Outfile,"{" FPRINT Outfile," if(a<0) return -1;" FPRINT Outfile," if(a>0) return 1;" FPRINT Outfile," return 0;" FPRINT Outfile,"}\n\n" END IF IF Use_Round THEN FPRINT Outfile,"double Round (double n, int d)" FPRINT Outfile,"{" FPRINT Outfile," return (floor((n)*pow(10.0,(d))+0.5)/pow(10.0,(d)));" FPRINT Outfile,"}\n\n" END IF IF Use_Embed THEN FPRINT Outfile,"char* GetResource (int *resource)" FPRINT Outfile,"{" FPRINT Outfile," char *BCX_RetStr={0};" FPRINT Outfile," static char* dat;" FPRINT Outfile," memset(&dat,0,sizeof(char *));" FPRINT Outfile," dat=(char*)resource;" FPRINT Outfile," BCX_RetStr=BCX_TmpStr(strlen(dat));" FPRINT Outfile," strcpy(BCX_RetStr,dat);" FPRINT Outfile," return BCX_RetStr;" FPRINT Outfile,"}\n\n" END IF IF Use_Exist THEN FPRINT Outfile,"bool Exist (char *szFilePath)" FPRINT Outfile,"{" FPRINT Outfile," int retstat;" FPRINT Outfile," struct stat sb;" FPRINT Outfile," retstat = stat(szFilePath, &sb);" FPRINT Outfile," if(retstat != -1)" FPRINT Outfile," return TRUE;" FPRINT Outfile," return FALSE;" FPRINT Outfile,"}\n\n" END IF IF Use_Tally THEN FPRINT Outfile,"int tally (char *szLine, char *szChar, int sensflag)" FPRINT Outfile,"{" FPRINT Outfile," if(!*szChar) return 0;" FPRINT Outfile," int mlen = strlen(szChar);" FPRINT Outfile," int iCount = 0;" FPRINT Outfile," char *p = (sensflag == 0 ? _strstr_(szLine, szChar) : _stristr_(szLine, szChar));" FPRINT Outfile," while (p)" FPRINT Outfile," {" FPRINT Outfile," iCount++;" FPRINT Outfile," p+=mlen;" FPRINT Outfile," p = (sensflag == 0 ? _strstr_(p, szChar) : _stristr_(p, szChar));" FPRINT Outfile," }" FPRINT Outfile," return iCount;" FPRINT Outfile,"}\n\n" END IF IF Use_Timer THEN FPRINT Outfile,"float timer (void)" FPRINT Outfile,"{" FPRINT Outfile," return ((double)clock()/CLOCKS_PER_SEC);" FPRINT Outfile,"}\n\n" END IF IF Use_Rnd THEN FPRINT Outfile,"float rnd (void)" FPRINT Outfile,"{" FPRINT Outfile," return (float)rand()/RAND_MAX;" FPRINT Outfile,"}\n\n" END IF IF Use_Exp THEN FPRINT Outfile,"double Exp (double arg)" FPRINT Outfile,"{" FPRINT Outfile," return pow(2.718281828459045,arg);" FPRINT Outfile,"}\n\n" END IF IF Use_Randomize THEN FPRINT Outfile,"void randomize (unsigned int seed)" FPRINT Outfile,"{" FPRINT Outfile," srand(seed);" FPRINT Outfile,"}\n\n" END IF IF Use_Max THEN FPRINT Outfile,"double _MAX_ (double a, double b)" FPRINT Outfile,"{" FPRINT Outfile," if(a>b)" FPRINT Outfile," return a;" FPRINT Outfile," return b;" FPRINT Outfile,"}\n\n" END IF IF Use_Min THEN FPRINT Outfile,"double _MIN_ (double a, double b)" FPRINT Outfile,"{" FPRINT Outfile," if(asrclen++ || st<1) return;" FPRINT Outfile," int replen = strlen(rep);" FPRINT Outfile," if(replen < length || length==-1) length=replen;" FPRINT Outfile," if((st+length) > srclen) length=srclen-st;" FPRINT Outfile," memcpy(&src[st-1],rep,length);" FPRINT Outfile,"}\n\n" END IF IF Use_Swap THEN FPRINT Outfile,"void swap ( UCHAR* A, UCHAR* B, int length)" FPRINT Outfile,"{" FPRINT Outfile," UCHAR t;" FPRINT Outfile," while(length--)" FPRINT Outfile," {" FPRINT Outfile," t = *A;" FPRINT Outfile," *(A++) = *B;" FPRINT Outfile," *(B++) = t;" FPRINT Outfile," }" FPRINT Outfile,"}\n\n" END IF IF Use_Like THEN FPRINT Outfile,"int like (char *raw, char *pat)" FPRINT Outfile,"{" FPRINT Outfile," char a, b, d;" FPRINT Outfile," char *r, *p;" FPRINT Outfile," int star = 0;" FPRINT Outfile," for(;;) {" FPRINT Outfile," if ((d = *pat++)==0) return (star || !*raw);" FPRINT Outfile," else if (d == '*') star = 1;" FPRINT Outfile," else if (d == '?') { if (!*raw++) return 0; }" FPRINT Outfile," else break;" FPRINT Outfile," }" FPRINT Outfile," b = d;" FPRINT Outfile," do if ((a = *raw++) == b) {" FPRINT Outfile," r = raw;" FPRINT Outfile," p = pat;" FPRINT Outfile," do {" FPRINT Outfile," if ((d = *p++) == '*')" FPRINT Outfile," if (like(r, p - 1)) return 1;" FPRINT Outfile," else break;" FPRINT Outfile," else if (!d) {" FPRINT Outfile," if (!*r) return 1;" FPRINT Outfile," else break;" FPRINT Outfile," }" FPRINT Outfile," } while (*r++ == d || d == '?');" FPRINT Outfile," } while (star && a);" FPRINT Outfile," return 0;" FPRINT Outfile,"}\n\n" END IF IF Use_Lof THEN FPRINT Outfile,"DWORD lof (char *FileName)" FPRINT Outfile,"{" FPRINT Outfile,"" FPRINT Outfile," int retstat;" FPRINT Outfile," struct stat sb;" FPRINT Outfile," retstat = stat(FileName, &sb);" FPRINT Outfile," if(retstat != -1)" FPRINT Outfile," return sb.st_size;" FPRINT Outfile," return 0;" FPRINT Outfile,"}\n\n" END IF IF Use_Iif THEN FPRINT Outfile,"double iif (bool cond, double tp, double fp)" FPRINT Outfile,"{" FPRINT Outfile," if(cond) return tp;" FPRINT Outfile," return fp;" FPRINT Outfile,"}\n\n" END IF IF Use_sziif THEN FPRINT Outfile,"char * sziif (bool i, char *a, char *b)" FPRINT Outfile,"{" FPRINT Outfile," if(i) return a;" FPRINT Outfile," return b;" FPRINT Outfile,"}\n\n" END IF IF Use_DynamicA THEN FPRINT Outfile,"void *CreateArr(void *a, int elem_size, int update, int num_dims, ... )" FPRINT Outfile,"{" FPRINT Outfile," va_list ap;" FPRINT Outfile," void *RetPtr;" FPRINT Outfile,"" FPRINT Outfile," va_start(ap, num_dims);" FPRINT Outfile," RetPtr = CreateArr_internal(a, elem_size, update, num_dims, ap);" FPRINT Outfile," va_end(ap);" FPRINT Outfile," return (RetPtr);" FPRINT Outfile,"}\n\n" FPRINT Outfile,"void *CreateArr_internal(void *a, int elem_size, int update, int num_dims, va_list ap)" FPRINT Outfile,"{" FPRINT Outfile," size_t s, s1, s2;" FPRINT Outfile," void **vp;" FPRINT Outfile," va_list marker;" FPRINT Outfile," " FPRINT Outfile,"#ifdef va_copy" FPRINT Outfile," va_copy(marker, ap);" FPRINT Outfile,"#else" FPRINT Outfile," marker = ap;" FPRINT Outfile,"#endif" FPRINT Outfile," s = va_arg(marker, size_t);" FPRINT Outfile," s2 = s + 2;" FPRINT Outfile," if(num_dims == 1)" FPRINT Outfile," {" FPRINT Outfile," if(update && a)" FPRINT Outfile," a=realloc(a,s2*elem_size);" FPRINT Outfile," else" FPRINT Outfile," a=calloc(s2,elem_size);" FPRINT Outfile," return a;" FPRINT Outfile," }" FPRINT Outfile," else" FPRINT Outfile," if(update && a)" FPRINT Outfile," {" FPRINT Outfile," s1 = 0;" FPRINT Outfile," vp = (void**)a;" FPRINT Outfile," while(*vp && s1 <= s)" FPRINT Outfile," {" FPRINT Outfile," vp++;" FPRINT Outfile," s1++;" FPRINT Outfile," }" FPRINT Outfile," if(s1 > s)" FPRINT Outfile," {" FPRINT Outfile," vp--;" FPRINT Outfile," DestroyArr(vp, num_dims, 0);" FPRINT Outfile," }" FPRINT Outfile," a=realloc(a,s2*sizeof(int));" FPRINT Outfile," s1 = 0;" FPRINT Outfile," vp = (void**)a;" FPRINT Outfile," while(*vp && s1 <= s)" FPRINT Outfile," {" FPRINT Outfile," vp++;" FPRINT Outfile," s1++;" FPRINT Outfile," }" FPRINT Outfile," while(s1 < s2)" FPRINT Outfile," {" FPRINT Outfile," *(((int *)vp)) = 0;" FPRINT Outfile," vp++;" FPRINT Outfile," s1++;" FPRINT Outfile," }" FPRINT Outfile," }" FPRINT Outfile," else" FPRINT Outfile," a=calloc(s2*sizeof(int),1);" FPRINT Outfile," vp = (void**)a;" FPRINT Outfile," if(--num_dims > 0)" FPRINT Outfile," {" FPRINT Outfile," for(s1 = 0; s1 < s; s1++)" FPRINT Outfile," {" FPRINT Outfile," vp[s1] = CreateArr_internal(vp[s1], elem_size, update, num_dims, marker);" FPRINT Outfile," }" FPRINT Outfile," }" FPRINT Outfile," return a;" FPRINT Outfile,"}\n\n" FPRINT Outfile,"void DestroyArr (void** a,int num_dims, int top_free)" FPRINT Outfile,"{" FPRINT Outfile," int i = 0;" FPRINT Outfile," static int s = 0;" FPRINT Outfile," if(num_dims == 1)" FPRINT Outfile," {" FPRINT Outfile," free(a);" FPRINT Outfile," return;" FPRINT Outfile," }" FPRINT Outfile," s++;" FPRINT Outfile," num_dims--; " FPRINT Outfile," while(a[i])" FPRINT Outfile," {" FPRINT Outfile," DestroyArr((void**)a[i], num_dims, top_free);" FPRINT Outfile," if(num_dims > 1)" FPRINT Outfile," free(a[i]);" FPRINT Outfile," a[i++]=NULL;" FPRINT Outfile," }" FPRINT Outfile," s--;" FPRINT Outfile," if(s == 0 && top_free)" FPRINT Outfile," free(a);" FPRINT Outfile,"}\n\n" END IF IF Use_Idxqsort THEN FPRINT Outfile,"int IdxCompare (const void *one, const void *two)" FPRINT Outfile,"{" FPRINT Outfile," int *ptr1 = (int *)(one);" FPRINT Outfile," int *ptr2 = (int *)(two);" FPRINT Outfile," return strcasecmp (pppStr[Key][*ptr1],pppStr[Key][*ptr2]);" FPRINT Outfile,"}\n\n" END IF IF Use_IdxqsortSt THEN FPRINT Outfile,"int IdxCompareSt (const void* one, const void* two)" FPRINT Outfile,"{" FPRINT Outfile,"#define compare1 cmp1+(StructSize * (*(UINT *)(one)))" FPRINT Outfile,"#define compare2 cmp1+(StructSize * (*(UINT *)(two)))" FPRINT Outfile,"" FPRINT Outfile," if (Key==0)" 'String FPRINT Outfile," return strcasecmp(compare1, compare2);" FPRINT Outfile,"" FPRINT Outfile," if (Key==1)" 'Integer FPRINT Outfile," {" FPRINT Outfile," if (*(int*)(compare1) < *(int*)(compare2)) return -1;" FPRINT Outfile," if (*(int*)(compare1) > *(int*)(compare2)) return 1;" FPRINT Outfile," return 0;" FPRINT Outfile," }" FPRINT Outfile,"" FPRINT Outfile," if (Key==2)" 'Double FPRINT Outfile," {" FPRINT Outfile," if (*(double*)(compare1) < *(double*)(compare2)) return -1;" FPRINT Outfile," if (*(double*)(compare1) > *(double*)(compare2)) return 1;" FPRINT Outfile," return 0;" FPRINT Outfile," }" FPRINT Outfile,"" FPRINT Outfile," if (Key==3)" 'Unsigned integer FPRINT Outfile," {" FPRINT Outfile," if (*(UINT*)(compare1) < *(UINT*)(compare2)) return -1;" FPRINT Outfile," if (*(UINT*)(compare1) > *(UINT*)(compare2)) return 1;" FPRINT Outfile," }" FPRINT Outfile,"return 0;" FPRINT Outfile,"}\n\n" END IF IF Use_PtrqsortSt THEN FPRINT Outfile,"int PtrCompareSt (const void* one, const void* two)" FPRINT Outfile,"{" FPRINT Outfile,"#define pcompare1 ((char*)(one)+OffSet)" FPRINT Outfile,"#define pcompare2 ((char*)(two)+OffSet)" FPRINT Outfile,"" FPRINT Outfile," if (Key==0)" FPRINT Outfile," return strcasecmp(pcompare1, pcompare2);" FPRINT Outfile,"" FPRINT Outfile," if (Key==1)" FPRINT Outfile," {" FPRINT Outfile," if (*(int*)(pcompare1) < *(int*)(pcompare2)) return -1;" FPRINT Outfile," if (*(int*)(pcompare1) > *(int*)(pcompare2)) return 1;" FPRINT Outfile," return 0;" FPRINT Outfile," }" FPRINT Outfile,"" FPRINT Outfile," if (Key==2)" FPRINT Outfile," {" FPRINT Outfile," if (*(double*)(pcompare1) < *(double*)(pcompare2)) return -1;" FPRINT Outfile," if (*(double*)(pcompare1) > *(double*)(pcompare2)) return 1;" FPRINT Outfile," return 0;" FPRINT Outfile," }" FPRINT Outfile,"" FPRINT Outfile," if (Key==3)" FPRINT Outfile," {" FPRINT Outfile," if (*(UINT*)(pcompare1) < *(UINT*)(pcompare2)) return -1;" FPRINT Outfile," if (*(UINT*)(pcompare1) > *(UINT*)(pcompare2)) return 1;" FPRINT Outfile," }" FPRINT Outfile,"return 0;" FPRINT Outfile,"}\n\n" END IF IF Use_Strqsorta THEN FPRINT Outfile,"int StrCompareA (const void *arg1, const void *arg2)" FPRINT Outfile,"{" FPRINT Outfile," char *v1 = (char*) arg1;" FPRINT Outfile," char *v2 = (char*) arg2;" FPRINT Outfile," return strcasecmp (v1,v2);" FPRINT Outfile,"}\n\n" END IF IF Use_Strqsortd THEN FPRINT Outfile,"int StrCompareD (const void *arg1, const void *arg2)" FPRINT Outfile,"{" FPRINT Outfile," char *v1 = (char*) arg1;" FPRINT Outfile," char *v2 = (char*) arg2;" FPRINT Outfile," return strcasecmp (v2,v1);" FPRINT Outfile,"}\n\n" END IF IF Use_DynStrqsorta THEN FPRINT Outfile,"int DynStrCompareA (const void *arg1, const void *arg2)" FPRINT Outfile,"{" FPRINT Outfile," char *v1 = *(char **) arg1;" FPRINT Outfile," char *v2 = *(char **) arg2;" FPRINT Outfile," return strcasecmp(v1, v2);" FPRINT Outfile,"}\n\n" END IF IF Use_DynStrqsortd THEN FPRINT Outfile,"int DynStrCompareD (const void *arg1, const void *arg2)" FPRINT Outfile,"{" FPRINT Outfile," char *v1 = *(char **) arg1;" FPRINT Outfile," char *v2 = *(char **) arg2;" FPRINT Outfile," return strcasecmp(v2, v1);" FPRINT Outfile,"}\n\n" END IF IF Use_Numqsortaint THEN FPRINT Outfile,"int NumCompareAint (const void *one, const void *two)" FPRINT Outfile,"{" FPRINT Outfile," int *ptr1 = (int *)(one);" FPRINT Outfile," int *ptr2 = (int *)(two);" FPRINT Outfile," if (*ptr1 < *ptr2) return -1;" FPRINT Outfile," else if (*ptr1 == *ptr2) return 0;" FPRINT Outfile," else return 1;" FPRINT Outfile,"}\n\n" END IF IF Use_Numqsortdint THEN FPRINT Outfile,"int NumCompareDint (const void *one, const void *two)" FPRINT Outfile,"{" FPRINT Outfile," int *ptr1 = (int *)(one);" FPRINT Outfile," int *ptr2 = (int *)(two);" FPRINT Outfile," if (*ptr1 > *ptr2) return -1;" FPRINT Outfile," else if (*ptr1 == *ptr2) return 0;" FPRINT Outfile," else return 1;" FPRINT Outfile,"}\n\n" END IF IF Use_Numqsortafloat THEN FPRINT Outfile,"int NumCompareAfloat (const void *one, const void *two)" FPRINT Outfile,"{" FPRINT Outfile," float *ptr1 = (float *)(one);" FPRINT Outfile," float *ptr2 = (float *)(two);" FPRINT Outfile," if (*ptr1 < *ptr2) return -1;" FPRINT Outfile," else if (*ptr1 == *ptr2) return 0;" FPRINT Outfile," else return 1;" FPRINT Outfile,"}\n\n" END IF IF Use_Numqsortdfloat THEN FPRINT Outfile,"int NumCompareDfloat (const void *one, const void *two)" FPRINT Outfile,"{" FPRINT Outfile," float *ptr1 = (float *)(one);" FPRINT Outfile," float *ptr2 = (float *)(two);" FPRINT Outfile," if (*ptr1 > *ptr2) return -1;" FPRINT Outfile," else if (*ptr1 == *ptr2) return 0;" FPRINT Outfile," else return 1;" FPRINT Outfile,"}\n\n" END IF IF Use_Numqsortadouble THEN FPRINT Outfile,"int NumCompareAdouble (const void *one, const void *two)" FPRINT Outfile,"{" FPRINT Outfile," double *ptr1 = (double *)(one);" FPRINT Outfile," double *ptr2 = (double *)(two);" FPRINT Outfile," if (*ptr1 < *ptr2) return -1;" FPRINT Outfile," else if (*ptr1 == *ptr2) return 0;" FPRINT Outfile," else return 1;" FPRINT Outfile,"}\n\n" END IF IF Use_Numqsortddouble THEN FPRINT Outfile,"int NumCompareDdouble (const void *one, const void *two)" FPRINT Outfile,"{" FPRINT Outfile," double *ptr1 = (double *)(one);" FPRINT Outfile," double *ptr2 = (double *)(two);" FPRINT Outfile," if (*ptr1 > *ptr2) return -1;" FPRINT Outfile," else if (*ptr1 == *ptr2) return 0;" FPRINT Outfile," else return 1;" FPRINT Outfile,"}\n\n" END IF IF Use_FillArray THEN FPRINT Outfile,"int fillarray(char *input, int ArrayType, int MaxCnt, void *Array)" FPRINT Outfile,"{" FPRINT Outfile," if(MaxCnt < 1) return -1;" FPRINT Outfile," int c = 0, cnt=-1, cnt2;" FPRINT Outfile," char A[65535];" FPRINT Outfile," int *intptr = (int *)Array;" FPRINT Outfile," float *floatptr = (float *)Array;" FPRINT Outfile," double *doubleptr = (double *)Array;" FPRINT Outfile," long double *ldoubleptr = (long double *)Array;" FPRINT Outfile," for(;;)" FPRINT Outfile," {" FPRINT Outfile," cnt2=0;" FPRINT Outfile," while(input[++cnt]!=',')" FPRINT Outfile," {" FPRINT Outfile," if(input[cnt]==0) break;" FPRINT Outfile," A[cnt2++]=input[cnt];" FPRINT Outfile," }" FPRINT Outfile," A[cnt2]=0;" FPRINT Outfile," if(cnt2==0||c==MaxCnt) break;" FPRINT Outfile," " FPRINT Outfile," if(ArrayType==2)" FPRINT Outfile," intptr[c++] = atoi(A);" FPRINT Outfile," else if(ArrayType==3)" FPRINT Outfile," floatptr[c++] = atof(A);" FPRINT Outfile," else if(ArrayType==4)" FPRINT Outfile," doubleptr[c++] = atof(A);" FPRINT Outfile," else if(ArrayType==5)" FPRINT Outfile," ldoubleptr[c++] = atof(A);" FPRINT Outfile,"" FPRINT Outfile," if(input[cnt]==0) break;" FPRINT Outfile," } " FPRINT Outfile," return (c-1);" FPRINT Outfile,"}\n\n" END IF IF Use_Loc THEN FPRINT Outfile,"int loc(FILE *fp, int fplen)" FPRINT Outfile,"{" FPRINT Outfile," fpos_t t;" FPRINT Outfile," fgetpos(fp, &t);" FPRINT Outfile,"#if defined( __POCC__ )" FPRINT Outfile," t.off %= fplen;" FPRINT Outfile," return (int)t.off;" FPRINT Outfile,"#else" FPRINT Outfile," t %= fplen;" FPRINT Outfile," return (int)t;" FPRINT Outfile,"#endif" FPRINT Outfile,"}\n\n" END IF IF Use_Rec THEN FPRINT Outfile,"int rec(FILE *fp, int fplen)" FPRINT Outfile,"{" FPRINT Outfile," fpos_t t;" FPRINT Outfile," fgetpos(fp, &t);" FPRINT Outfile,"#if defined( __POCC__ )" FPRINT Outfile," t.off /= fplen;" FPRINT Outfile," return (int)++t.off;" FPRINT Outfile,"#else" FPRINT Outfile," t /= fplen;" FPRINT Outfile," return (int)++t;" FPRINT Outfile,"#endif" FPRINT Outfile,"}\n\n" END IF IF Use_RecCount THEN FPRINT Outfile,"int reccount(FILE *fp, int fplen)" FPRINT Outfile,"{" FPRINT Outfile," fpos_t t;" FPRINT Outfile," fseek(fp,0,SEEK_END);" FPRINT Outfile," fgetpos(fp, &t);" FPRINT Outfile,"#if defined( __POCC__ )" FPRINT Outfile," t.off /= fplen;" FPRINT Outfile," return (int)t.off;" FPRINT Outfile,"#else" FPRINT Outfile," t /= fplen;" FPRINT Outfile," return (int)t;" FPRINT Outfile,"#endif" FPRINT Outfile,"}\n\n" END IF IF Use_Scan THEN FPRINT Outfile,"int scan(char *input, char *format, ... )" FPRINT Outfile,"{" FPRINT Outfile," int c,d ;" FPRINT Outfile," char *s_;" FPRINT Outfile," int *intptr;" FPRINT Outfile," float *floatptr;" FPRINT Outfile," double *doubleptr;" FPRINT Outfile," char A[50][65535];" FPRINT Outfile," va_list marker;" FPRINT Outfile," c = 0;" FPRINT Outfile," d = Split(A,input,"; ENC$(",") ; ");" FPRINT Outfile," va_start(marker, format); //Initialize arguments" FPRINT Outfile," while(d && *format)" FPRINT Outfile," {" FPRINT Outfile," if(*format == '%') format++;" FPRINT Outfile," if(*format == 's')" FPRINT Outfile," {" FPRINT Outfile," s_ = va_arg(marker, char *);" FPRINT Outfile," strcpy(s_, A[c]);" FPRINT Outfile," c++;" FPRINT Outfile," d--;" FPRINT Outfile," }" FPRINT Outfile," if(*format == 'd')" FPRINT Outfile," {" FPRINT Outfile," intptr = va_arg(marker, int *);" FPRINT Outfile," *intptr = atoi(A[c]);" FPRINT Outfile," c++;" FPRINT Outfile," d--;" FPRINT Outfile," }" FPRINT Outfile," if(*format == 'g')" FPRINT Outfile," {" FPRINT Outfile," floatptr = va_arg(marker, float *);" FPRINT Outfile," *floatptr = atof(A[c]);" FPRINT Outfile," c++;" FPRINT Outfile," d--;" FPRINT Outfile," }" FPRINT Outfile," if(*format == 'l')" FPRINT Outfile," {" FPRINT Outfile," format++;" FPRINT Outfile," doubleptr = va_arg(marker, double *);" FPRINT Outfile," *doubleptr = atof(A[c]);" FPRINT Outfile," c++;" FPRINT Outfile," d--;" FPRINT Outfile," }" FPRINT Outfile," format++;" FPRINT Outfile," }" FPRINT Outfile," va_end(marker); // Reset variable arguments" FPRINT Outfile," if(d) return(1); // More data than variables" FPRINT Outfile," if(*format == 0) return(0); // OK" FPRINT Outfile," return(-1); // More variables than data" FPRINT Outfile,"}\n\n" END IF IF Use_Split THEN FPRINT Outfile,"int Split (char Buf[][65535], char *T, char *Delim, int Flg)" FPRINT Outfile,"{" FPRINT Outfile," int Begin = 0;" FPRINT Outfile," int Count = 0;" FPRINT Outfile," int Quote = 0;" FPRINT Outfile," int Index,i;" FPRINT Outfile," int lenT = strlen(T);" FPRINT Outfile," char Chr34[2]={34,0};" FPRINT Outfile," for(Index=1;Index<=lenT;Index++)" FPRINT Outfile," {" FPRINT Outfile," if(instr_b(Delim,mid(T,Index,1))&&!Quote)" FPRINT Outfile," {" FPRINT Outfile," strcpy(Buf[Count],(char*)mid(T,Begin,Index-Begin));" FPRINT Outfile," if ((Flg & 2) == 0) // 0 if old version" FPRINT Outfile," Count++;" FPRINT Outfile," else" FPRINT Outfile," if (Buf[Count][0] != 0) Count++;" FPRINT Outfile," Begin=0;" FPRINT Outfile," if((Flg & 1) == 1) // 1 if true" FPRINT Outfile," strcpy(Buf[Count++],(char*)mid(T,Index,1));" FPRINT Outfile," }" FPRINT Outfile," else" FPRINT Outfile," {" FPRINT Outfile," if(strcmp(mid(T,Index,1),Chr34)==0) Quote=!Quote;" FPRINT Outfile," if(Begin==0) Begin=Index;" FPRINT Outfile," }" FPRINT Outfile," }" FPRINT Outfile," if(Begin)" FPRINT Outfile," strcpy(Buf[Count++],(char*)mid(T,Begin,Index-Begin));" FPRINT Outfile," if((Flg & 1) == 0) // 0 if false" FPRINT Outfile," for(i=0;i= 'a' && ch <= 'f') || (ch >= '0' && ch <= '9'))" FPRINT Outfile," dwOut |=((int)ch - (ch>'9' ? 'a'-10 : '0')) << ((dwLen - szInput) << 2);" FPRINT Outfile," }" FPRINT Outfile," return dwOut;" FPRINT Outfile,"}\n\n" END IF IF Use_Verify THEN FPRINT Outfile,"int Verify (char *Src, char *Allowed)" FPRINT Outfile,"{" FPRINT Outfile," int i, j;" FPRINT Outfile," for (i=1; i<=strlen(Src); i++)" FPRINT Outfile," {" FPRINT Outfile," j=VerifyInstr(Allowed,mid(Src,i,1));" FPRINT Outfile," if (!j) return 0;" FPRINT Outfile," }" FPRINT Outfile," return TRUE;" FPRINT Outfile,"}\n\n" FPRINT Outfile,"int VerifyInstr(char* mane,char* match,int offset)" FPRINT Outfile,"{" FPRINT Outfile," char *s;" FPRINT Outfile," if (!mane || !match || !*match || offset>(int)strlen(mane)) return 0;" FPRINT Outfile," s = strstr (offset>0 ? mane+offset-1 : mane,match);" FPRINT Outfile," return s ? (int)(s-mane)+1 : 0;" FPRINT Outfile,"}\n\n" END IF IF Use_Retain THEN FPRINT Outfile,"char *Retain (char *Text, char *ValidChars)" FPRINT Outfile,"{" FPRINT Outfile," char *BCX_RetStr=BCX_TmpStr(strlen(Text));" FPRINT Outfile," char *temp=BCX_RetStr;" FPRINT Outfile," while(*Text)" FPRINT Outfile," {" FPRINT Outfile," if(strchr(ValidChars,*Text)) *(temp++) = *Text;" FPRINT Outfile," Text++;" FPRINT Outfile," }" FPRINT Outfile," return BCX_RetStr;" FPRINT Outfile,"}\n\n" END IF IF Use_LoadFile THEN FPRINT Outfile,"char* LoadFile (char *N)" FPRINT Outfile,"{" FPRINT Outfile," FILE* FP1;" FPRINT Outfile," char* BCX_RetStr;" FPRINT Outfile," if(Exist(N))" FPRINT Outfile," {" FPRINT Outfile," BCX_RetStr=BCX_TmpStr(lof(N));" FPRINT Outfile," if((FP1=fopen(N,", ENC$("rb"), "))!=0)" FPRINT Outfile," GET(FP1,BCX_RetStr,lof(N));" FPRINT Outfile," fclose(FP1);" FPRINT Outfile," return BCX_RetStr;" FPRINT Outfile," }" FPRINT Outfile," else" FPRINT Outfile," {" FPRINT Outfile," BCX_RetStr=BCX_TmpStr(64);" FPRINT Outfile," return strcpy(BCX_RetStr,", ENC$("File Not Found"), ");" FPRINT Outfile," }" FPRINT Outfile,"}\n\n" END IF IF Use_Freefile THEN FPRINT Outfile,"FILE* FreeFile (void)" FPRINT Outfile,"{" FPRINT Outfile," static FILE *pf;" FPRINT Outfile," if(pf){free(pf);pf=NULL;}" FPRINT Outfile," pf = (FILE*)calloc(sizeof(FILE*),sizeof(FILE*));" FPRINT Outfile," return pf;" FPRINT Outfile,"}\n\n" END IF IF Use_Run THEN FPRINT Outfile,"int Run (char* Cmdline, int ShowHide, int WaitState)" FPRINT Outfile,"{" FPRINT Outfile," int processId;" FPRINT Outfile," char *s, *p, *cmd_line;" FPRINT Outfile,"" FPRINT Outfile," cmd_line=(char*)malloc(strlen(Cmdline)+1);" FPRINT Outfile," if(cmd_line==NULL) return -2;" FPRINT Outfile,"" FPRINT Outfile," strcpy(cmd_line, Cmdline);" FPRINT Outfile," p = s = cmd_line;" FPRINT Outfile," processId=fork();" FPRINT Outfile," if(processId==0)" FPRINT Outfile," {" FPRINT Outfile," PCHAR argv[30];" FPRINT Outfile," int i=0;" FPRINT Outfile," while(*p)" FPRINT Outfile," {" FPRINT Outfile," if(*p==34)" FPRINT Outfile," {" FPRINT Outfile," while(*(++p)!=34) {}" FPRINT Outfile," }" FPRINT Outfile," if(*p==32)" FPRINT Outfile," {" FPRINT Outfile," while(*(p+1)==32) p++;" FPRINT Outfile," argv[i++]=s;" FPRINT Outfile," *p=0; s=p+1;" FPRINT Outfile," }" FPRINT Outfile," p++;" FPRINT Outfile," }" FPRINT Outfile," argv[i] = s;" FPRINT Outfile," argv[i+1]= 0;" FPRINT Outfile," execvp(argv[0],argv);" FPRINT Outfile," printf(",ENC$("Failed to run%s\\n"),",argv[0]);" FPRINT Outfile," exit(-1);" FPRINT Outfile," }" FPRINT Outfile," else if(processId!=-1)" FPRINT Outfile," {" FPRINT Outfile," if(WaitState) waitpid(processId,NULL,0);" FPRINT Outfile," }" FPRINT Outfile," waitpid(-1,NULL,WNOHANG);" FPRINT Outfile," free(cmd_line), cmd_line=NULL;" FPRINT Outfile," return processId;" FPRINT Outfile,"}\n\n" END IF IF Use_Download THEN FPRINT Outfile,"int Download (char *URL,char *Localname)" FPRINT Outfile,"{" FPRINT Outfile," int RetVal;" '~ FPRINT Outfile," RetVal=BCX_DynaCall (", ENC$("URLDownloadToFile"), "," ; '~ FPRINT Outfile, ENC$("urlmon.dll"), ",5,NULL,URL,Localname,0,NULL);" FPRINT Outfile," return RetVal=!RetVal;" FPRINT Outfile,"}\n\n" END IF IF Use_PeekStr THEN FPRINT Outfile,"char *peekstr (LPVOID Src, int Count)" FPRINT Outfile,"{" FPRINT Outfile," char *Des=BCX_TmpStr(Count);" FPRINT Outfile," memmove(Des,Src,Count);" FPRINT Outfile," return Des;" FPRINT Outfile,"}\n\n" END IF IF Use_QBColor THEN FPRINT Outfile,"int qbcolor (int N)" FPRINT Outfile,"{" FPRINT Outfile," switch (N)" FPRINT Outfile," {" FPRINT Outfile," case 0 : return RGB(0,0,0);" FPRINT Outfile," case 1 : return RGB(0,0,128);" FPRINT Outfile," case 2 : return RGB(0,128,0);" FPRINT Outfile," case 3 : return RGB(0,128,128);" FPRINT Outfile," case 4 : return RGB(196,0,0);" FPRINT Outfile," case 5 : return RGB(128,0,128);" FPRINT Outfile," case 6 : return RGB(128,64,0);" FPRINT Outfile," case 7 : return RGB(196,196,196);" FPRINT Outfile," case 8 : return RGB(128,128,128);" FPRINT Outfile," case 9 : return RGB(0,0, 255);" FPRINT Outfile," case 10 : return RGB(0,255,0);" FPRINT Outfile," case 11 : return RGB(0,255,255);" FPRINT Outfile," case 12 : return RGB(255,0,0);" FPRINT Outfile," case 13 : return RGB(255,0,255);" FPRINT Outfile," case 14 : return RGB(255,255,0);" FPRINT Outfile," case 15 : return RGB(255,255,255);" FPRINT Outfile," case 16 : return RGB(164,164,164);" FPRINT Outfile," case 17 : return RGB(128,160,255);" FPRINT Outfile," case 18 : return RGB(160,255,160);" FPRINT Outfile," case 19 : return RGB(160,255,255);" FPRINT Outfile," case 20 : return RGB(255,160,160);" FPRINT Outfile," case 21 : return RGB(255,160,255);" FPRINT Outfile," case 22 : return RGB(255,255,160);" FPRINT Outfile," case 23 : return RGB(212,212,212);" FPRINT Outfile," case 24 : return RGB(180,180,180);" FPRINT Outfile," case 25 : return RGB(188,220,255);" FPRINT Outfile," case 26 : return RGB(220,255,220);" FPRINT Outfile," case 27 : return RGB(220,255,255);" FPRINT Outfile," case 28 : return RGB(255,220,220);" FPRINT Outfile," case 29 : return RGB(255,220,255);" FPRINT Outfile," case 30 : return RGB(255,255,220);" FPRINT Outfile," case 31 : return RGB(228,228,228);" FPRINT Outfile," }" FPRINT Outfile,"return 0;" FPRINT Outfile,"}\n\n" END IF IF Use_Cvi THEN FPRINT Outfile,"short CVI (char *s)" FPRINT Outfile,"{" FPRINT Outfile," return ((short*)s)[0];" FPRINT Outfile,"}\n\n" END IF IF Use_Mki THEN FPRINT Outfile,"char *MKI (short cvt)" FPRINT Outfile,"{" FPRINT Outfile," static char temp[3];" FPRINT Outfile," return (char *)memmove(temp,&cvt,2);" FPRINT Outfile,"}\n\n" END IF IF Use_Cvl THEN FPRINT Outfile,"long CVL (char *s)" FPRINT Outfile,"{" FPRINT Outfile," return ((long*)s)[0];" FPRINT Outfile,"}\n\n" END IF IF Use_Mkl THEN FPRINT Outfile,"char *MKL (int cvt)" FPRINT Outfile,"{" FPRINT Outfile," static char temp[5];" FPRINT Outfile," return (char *) memmove(temp,&cvt,4);" FPRINT Outfile,"}\n\n" END IF IF Use_Cvs THEN FPRINT Outfile,"float CVS (char *s)" FPRINT Outfile,"{" FPRINT Outfile," return ((float*)s)[0];" FPRINT Outfile,"}\n\n" END IF IF Use_Mks THEN FPRINT Outfile,"char *MKS (float cvt)" FPRINT Outfile,"{" FPRINT Outfile," static char temp[5];" FPRINT Outfile," return (char *) memmove(temp,&cvt,4);" FPRINT Outfile,"}\n\n" END IF IF Use_Cvd THEN FPRINT Outfile,"double CVD (char *s)" FPRINT Outfile,"{" FPRINT Outfile," return ((double*)s)[0];" FPRINT Outfile,"}\n\n" END IF IF Use_Cvld THEN FPRINT Outfile,"long double CVLD (char *s)" FPRINT Outfile,"{" FPRINT Outfile," return ((long double*)s)[0];" FPRINT Outfile,"}\n\n" END IF IF Use_Mkd THEN FPRINT Outfile,"char *MKD (double cvt)" FPRINT Outfile,"{" FPRINT Outfile," static char temp[9];" FPRINT Outfile," return (char *) memmove(temp,&cvt,8);" FPRINT Outfile,"}\n\n" END IF IF Use_Mkld THEN FPRINT Outfile,"char *MKLD (long double cvt)" FPRINT Outfile,"{" FPRINT Outfile," static char temp[11];" FPRINT Outfile," return (char *) memmove(temp,&cvt,10);" FPRINT Outfile,"}\n\n" END IF IF Use_BcxSplitPath THEN FPRINT Outfile,"char *BcxSplitPath (char *FPath, int mask)" FPRINT Outfile,"{" FPRINT Outfile," if(!FPath) return BCX_TmpStr(1);" FPRINT Outfile," char *BCX_RetStr=BCX_TmpStr(strlen(FPath));" FPRINT Outfile," char tmp[MAX_PATH*4];" FPRINT Outfile," _splitpath_(FPath,tmp,&tmp[MAX_PATH],&tmp[MAX_PATH*2],&tmp[MAX_PATH*3]);" FPRINT Outfile," if(mask & FDRV) strcat(BCX_RetStr,tmp);" FPRINT Outfile," if(mask & FPATH)strcat(BCX_RetStr,&tmp[MAX_PATH]);" FPRINT Outfile," if(mask & FNAME)strcat(BCX_RetStr,&tmp[MAX_PATH*2]);" FPRINT Outfile," if(mask & FEXT) strcat(BCX_RetStr,&tmp[MAX_PATH*3]);" FPRINT Outfile," return BCX_RetStr;" FPRINT Outfile,"}\n\n" FPRINT Outfile," void _splitpath_(const char* path, char* drv, char* dir, char* name, char* ext)" FPRINT Outfile," {" FPRINT Outfile," const char* pend; /* end of processed string */" FPRINT Outfile," const char* p; /* search pointer */" FPRINT Outfile," const char* s; /* copy pointer */" FPRINT Outfile," " FPRINT Outfile," /* extract drive name */" FPRINT Outfile," if (path[0] && path[1]==':') {" FPRINT Outfile," if (drv) {" FPRINT Outfile," *drv++ = *path++;" FPRINT Outfile," *drv++ = *path++;" FPRINT Outfile," *drv = 0;" FPRINT Outfile," }" FPRINT Outfile," } else if (drv)" FPRINT Outfile," *drv = 0;" FPRINT Outfile," " FPRINT Outfile," /* search for end of string or stream separator */" FPRINT Outfile," for(pend=path; *pend && *pend!=':'; )" FPRINT Outfile," pend++;" FPRINT Outfile," " FPRINT Outfile," /* search for begin of file extension */" FPRINT Outfile," for(p=pend; p > path && *--p != '\\\\' && *p!='/'; )" FPRINT Outfile," if (*p == '.') {" FPRINT Outfile," pend = p;" FPRINT Outfile," break;" FPRINT Outfile," }" FPRINT Outfile," " FPRINT Outfile," if (ext)" FPRINT Outfile," {" FPRINT Outfile," s=pend;" FPRINT Outfile," do{ *ext++ = *s; } while(*s++);" FPRINT Outfile," }" FPRINT Outfile," /* search for end of directory name */" FPRINT Outfile," for(p=pend; p > path; )" FPRINT Outfile," if (*--p == '\\\\' || *p == '/') {" FPRINT Outfile," p++;" FPRINT Outfile," break;" FPRINT Outfile," }" FPRINT Outfile," " FPRINT Outfile," if (name) {" FPRINT Outfile," for(s=p; stally(Source,TokenChar)+1)" FPRINT Outfile," {" FPRINT Outfile," BCX_RetStr=BCX_TmpStr(1);" FPRINT Outfile," if(RetVal)free(RetVal);" FPRINT Outfile," return BCX_RetStr;" FPRINT Outfile," }" FPRINT Outfile," while(*Copy)" FPRINT Outfile," {" FPRINT Outfile," if(*Copy==TokenChar[0]) Find++;" FPRINT Outfile," if(Find==n) break;" FPRINT Outfile," Copy++;" FPRINT Outfile," Posn++;" FPRINT Outfile," }" FPRINT Outfile," if(n==tally(Source,TokenChar)+1)" FPRINT Outfile," {" FPRINT Outfile," Posn=LenSrc;" FPRINT Outfile," Copy=Source+Posn;" FPRINT Outfile," while(*Copy&&Source[Posn]!=TokenChar[0])" FPRINT Outfile," {" FPRINT Outfile," Posn--;" FPRINT Outfile," Copy--;" FPRINT Outfile," }" FPRINT Outfile," }" FPRINT Outfile," strcpy(RetVal,(char*)mid(Source,1,Posn));" FPRINT Outfile," strcpy(RetVal,(char*)mid(RetVal,InstrRev(RetVal,TokenChar)));" FPRINT Outfile," BCX_RetStr=BCX_TmpStr(LenSrc);" FPRINT Outfile," strcpy(BCX_RetStr,(char*)RemoveStr(RetVal,TokenChar));" FPRINT Outfile," if(RetVal)free(RetVal);" FPRINT Outfile," return BCX_RetStr;" FPRINT Outfile,"}\n\n" END IF IF Use_iReplace THEN FPRINT Outfile,"char *iReplace (char *src, char *pat, char *rep)" FPRINT Outfile,"{" FPRINT Outfile," size_t patsz, repsz, tmpsz, delta;" FPRINT Outfile," char *strtmp, *p, *q, *r;" FPRINT Outfile," if (!pat || !*pat)" FPRINT Outfile," {" FPRINT Outfile," strtmp = BCX_TmpStr(strlen(src));" FPRINT Outfile," if (!strtmp) return NULL;" FPRINT Outfile," return strcpy(strtmp, src);" FPRINT Outfile," }" FPRINT Outfile," repsz = strlen(rep);" FPRINT Outfile," patsz = strlen(pat);" FPRINT Outfile," for (tmpsz=0, p=src;(q=_stristr_(p,pat))!=0; p=q+patsz)" FPRINT Outfile," tmpsz += (size_t) (q - p) + repsz;" FPRINT Outfile," tmpsz += strlen(p);" FPRINT Outfile," strtmp = BCX_TmpStr(tmpsz);" FPRINT Outfile," if (!strtmp) return NULL;" FPRINT Outfile," for (r=strtmp,p=src;(q=_stristr_(p,pat))!=0;p=q+patsz)" FPRINT Outfile," {" FPRINT Outfile," delta = (size_t) (q-p);" FPRINT Outfile," memcpy(r,p,delta); r += delta;" FPRINT Outfile," strcpy(r,rep); r += repsz;" FPRINT Outfile," }" FPRINT Outfile," strcpy(r,p);" FPRINT Outfile," return strtmp;" FPRINT Outfile,"}\n\n" END IF IF Use_WideToAnsi THEN FPRINT Outfile,"char* WideToAnsi (wchar_t *WideStr, UINT CodePage,DWORD dwFlags)" FPRINT Outfile,"{" FPRINT Outfile," char *BCX_RetStr={0};" FPRINT Outfile," UINT uLen;" FPRINT Outfile," uLen=wcstombs(NULL, WideStr, 0); //WideCharToMultiByte(CodePage,dwFlags,WideStr,-1,0,0,0,0);" FPRINT Outfile," BCX_RetStr=(char*)BCX_TmpStr(uLen);" FPRINT Outfile," wcstombs(BCX_RetStr, WideStr, uLen); //WideCharToMultiByte(CodePage,dwFlags,WideStr,-1,BCX_RetStr,uLen,0,0);" FPRINT Outfile," return BCX_RetStr;" FPRINT Outfile,"}\n\n" END IF IF Use_SysStr THEN FPRINT Outfile,"BSTR SysStr (char * szIn, int widstr, int bfree)" FPRINT Outfile,"{" FPRINT Outfile," static BSTR bStr[32];" FPRINT Outfile," static int index;" FPRINT Outfile," if(bfree)" FPRINT Outfile," {" FPRINT Outfile," for(index=0; index<32; index+=1) " FPRINT Outfile," SysFreeString(bStr[index]);" FPRINT Outfile," return 0;" FPRINT Outfile," }" FPRINT Outfile," index=(++index & 31);" FPRINT Outfile," SysFreeString(bStr[index]);" FPRINT Outfile," int length=strlen(szIn);" FPRINT Outfile," if(widstr)" FPRINT Outfile," {" FPRINT Outfile," bStr[index]=SysAllocStringLen(NULL, (2*length));" FPRINT Outfile," MultiByteToWideChar(CP_ACP,0,szIn,-1,bStr[index],(2*length+1));" FPRINT Outfile," }else{" FPRINT Outfile," bStr[index]=SysAllocStringByteLen(szIn, length);" FPRINT Outfile," }" FPRINT Outfile," return bStr[index];" FPRINT Outfile,"}\n\n" END IF IF Use_AnsiToWide THEN FPRINT Outfile,"wchar_t *AnsiToWide (char *AnsiStr, UINT CodePage,DWORD dwFlags)" FPRINT Outfile,"{" FPRINT Outfile," UINT uLen;" FPRINT Outfile," wchar_t *WideStr;" FPRINT Outfile," uLen=mbstowcs(NULL, AnsiStr, 0); //MultiByteToWideChar(CodePage,dwFlags,AnsiStr,-1,0,0);" FPRINT Outfile," if(uLen<=1) return (wchar_t*)BCX_TmpStr(2);" FPRINT Outfile," WideStr = (wchar_t*)BCX_TmpStr(2*uLen);" FPRINT Outfile," mbstowcs(WideStr, AnsiStr, uLen); //MultiByteToWideChar(CodePage,dwFlags,AnsiStr,uLen,WideStr,uLen);" FPRINT Outfile," return WideStr;" FPRINT Outfile,"}\n\n" END IF IF Use_FileLocked THEN FPRINT Outfile,"int FileLocked (char *Filename)" FPRINT Outfile,"{" FPRINT Outfile," FILE *FP=fopen(Filename,", ENC$("rb+"), ");" FPRINT Outfile," if(FP==0) return 1;" FPRINT Outfile," fclose(FP);" FPRINT Outfile," return 0;" FPRINT Outfile,"}\n\n" END IF IF Use_ContainedIn THEN FPRINT Outfile,"int containedin(char * Token,char **Contain ,int c)" FPRINT Outfile," {" FPRINT Outfile," int i=0;" FPRINT Outfile," while(Contain[i][0])" FPRINT Outfile," {" FPRINT Outfile," if(0 == ((c == 0 || c == 2) ? strcmp(Contain[i],Token) : strcasecmp(Contain[i],Token)))" FPRINT Outfile," {" FPRINT Outfile," return ((c < 2) ? 0 : i);" FPRINT Outfile," }" FPRINT Outfile," i++;" FPRINT Outfile," }" FPRINT Outfile," return -1;" FPRINT Outfile," }\n\n" END IF IF Use_FindInType THEN FPRINT Outfile,"int FindInType(char *Token,char *StOffset,int StSize,int start,int finish,int c,int *idx)" FPRINT Outfile," {" FPRINT Outfile," int j;" FPRINT Outfile," char *Srch;" FPRINT Outfile," int (*cmp)(const char*,const char*);" FPRINT Outfile," cmp = ((c == 0 || c == 2) ? strcmp : strcasecmp);" FPRINT Outfile," for(j=start; j<=finish; j++)" FPRINT Outfile," {" FPRINT Outfile," Srch = StOffset + ((idx==0) ? j*StSize : idx[j]*StSize);" FPRINT Outfile," if(cmp(Srch,Token)==0)" FPRINT Outfile," {" FPRINT Outfile," return ((c < 2) ? 0 : j);" FPRINT Outfile," }" FPRINT Outfile," }" FPRINT Outfile," return -1;" FPRINT Outfile," }\n\n" END IF IF Use_StartupCode THEN FPRINT Outfile,"int BCX_StartupCode_(void)" FPRINT Outfile,"{" FOR INTEGER i = 1 TO StartNdx FPRINT Outfile," " + StartSub$[i] + "();" NEXT FPRINT Outfile," return 1;" FPRINT Outfile,"}\n\n" END IF IF Use_ExitCode THEN FPRINT Outfile,"int BCX_ExitCode_(void)" FPRINT Outfile,"{" FOR INTEGER i = 1 TO ExitNdx FPRINT Outfile," atexit(" + ExitSub$[i] + ");" NEXT FPRINT Outfile," return 1;" FPRINT Outfile,"}\n\n" END IF if Use_Socket then FPRINT Outfile,"sockaddr_in sock_addr (char *ServerName,int port)" FPRINT Outfile,"{" FPRINT Outfile," in_addr iaHost;" FPRINT Outfile," hostent* lpHostEntry;" FPRINT Outfile," sockaddr_in saServer;" FPRINT Outfile," iaHost.s_addr=inet_addr(ServerName);" FPRINT Outfile," if(iaHost.s_addr==INADDR_NONE)" FPRINT Outfile," {" FPRINT Outfile," lpHostEntry=gethostbyname(ServerName);" FPRINT Outfile," }" FPRINT Outfile," else" FPRINT Outfile," {" FPRINT Outfile," lpHostEntry=gethostbyaddr((char*)&iaHost,sizeof(in_addr),AF_INET);" FPRINT Outfile," }" FPRINT Outfile," if(lpHostEntry==NULL)" FPRINT Outfile," {" FPRINT Outfile," printf("+enc$("Error! HOST NOT FOUND: %s\\n")+", ServerName);" FPRINT Outfile," }" FPRINT Outfile," else" FPRINT Outfile," {" FPRINT Outfile," saServer.sin_port=htons(port);" FPRINT Outfile," saServer.sin_family=AF_INET;" FPRINT Outfile," saServer.sin_addr=*(in_addr*)lpHostEntry->h_addr;" FPRINT Outfile," }" FPRINT Outfile," return saServer;" FPRINT Outfile,"}\n\n" FPRINT Outfile,"int connect_socket (sockaddr_in saServer)" FPRINT Outfile,"{" FPRINT Outfile," int Socket, nRet;" FPRINT Outfile," Socket=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);" FPRINT Outfile," if(Socket==-1)" FPRINT Outfile," {" FPRINT Outfile," return Socket;" FPRINT Outfile," }" FPRINT Outfile," nRet=connect(Socket,(sockaddr*)&saServer,sizeof(sockaddr_in));" FPRINT Outfile," if(nRet==-1)" FPRINT Outfile," {" FPRINT Outfile," close(Socket);" FPRINT Outfile," return nRet;" FPRINT Outfile," }" FPRINT Outfile," return Socket;" FPRINT Outfile,"}\n\n" FPRINT Outfile,"int BcxSocket (char *ServerName,int port)" FPRINT Outfile,"{" FPRINT Outfile," sockaddr_in saServer;" FPRINT Outfile," saServer=sock_addr(ServerName,port);" FPRINT Outfile," return connect_socket(saServer);" FPRINT Outfile,"}\n\n" FPRINT Outfile,"int BcxSocketSend (int Socket, char *szBuffer)" FPRINT Outfile,"{" FPRINT Outfile," static int nRet;" FPRINT Outfile," nRet=send(Socket,szBuffer,strlen(szBuffer),0);" FPRINT Outfile," if(nRet==-1)" FPRINT Outfile," {" FPRINT Outfile," close(Socket);" FPRINT Outfile," }" FPRINT Outfile," return nRet;" FPRINT Outfile,"}\n\n" FPRINT Outfile,"int BcxSocketRead (int Socket, char *szBuffer)" FPRINT Outfile,"{" FPRINT Outfile," return read(Socket,szBuffer,strlen(szBuffer));" FPRINT Outfile,"}\n\n" FPRINT Outfile,"void BcxSocketClose(int Socket) {" FPRINT Outfile," close(Socket);" FPRINT Outfile,"}\n\n" end if '/***** 2013-06-26 New REGEX Keywords -AIR *****/ '/***** 2018-12-12 Changed to regmatch -AIR *****/ IF Use_RegEx THEN FPRINT Outfile,"bool regmatch (char *buffer, char *pattern, REGEX* retval)" FPRINT Outfile,"{" FPRINT Outfile," static int t;" ' FPRINT Outfile," memset(&t,0,sizeof(t));" FPRINT Outfile," static int i;" ' FPRINT Outfile," memset(&i,0,sizeof(i));" FPRINT Outfile," static regex_t re;" ' FPRINT Outfile," memset(&re,0,sizeof(re));" FPRINT Outfile," t=regcomp( &re,pattern,REG_ICASE|REG_EXTENDED);" FPRINT Outfile," if(t)" FPRINT Outfile," {" FPRINT Outfile," regerror(t, &re,buffer,sizeof(buffer));" FPRINT Outfile," printf("+enc$("regex error: %s %s")+",buffer,pattern);" FPRINT Outfile," return 0;" FPRINT Outfile," }" FPRINT Outfile," t=regexec( &re,buffer,1023,(*retval).matches,0);" FPRINT Outfile," (*retval).count=re.re_nsub;" FPRINT Outfile," if(!t)" FPRINT Outfile," {" FPRINT Outfile," for(i=1; i<=(*retval).count; i+=1)" FPRINT Outfile," {" FPRINT Outfile," if((*retval).matches[i].rm_so>=0)" FPRINT Outfile," {" FPRINT Outfile," (*retval).results[i]=peekstr( &buffer[(*retval).matches[i].rm_so],((*retval).matches[i].rm_eo-(*retval).matches[i].rm_so));" FPRINT Outfile," }" FPRINT Outfile," }" FPRINT Outfile," }" FPRINT Outfile," regfree( &re);" FPRINT Outfile," if(!t)" FPRINT Outfile," {" FPRINT Outfile," return TRUE;" FPRINT Outfile," }" FPRINT Outfile," else" FPRINT Outfile," {" FPRINT Outfile," return FALSE;" FPRINT Outfile," }" FPRINT Outfile,"}\n\n" END IF END SUB 'RunTimeFunctions