void readAll(FILE * f,char * c,unsigned char * zoek,int zoekl,int * tab,int * aantal,char * filename){ int startindex=1,tekstl,i=0,end=0; //start=index van het eerste char dat in de buffer zit int n=BUFFER_SIZE; //het aantal in te lezen chars in 1 keer DEFAULT= 1000000 int rollover = strlen(zoek)-1; //moet de grootte van de zoekstring zijn -1 //eerste maal inlezen i= fread(c+i,1,BUFFER_SIZE,f); if(i==0) //lege file return; c[i] = 0; bmSearch(zoek,zoekl,c,i,tab,aantal,startindex,filename); memmove(c,c+(n-rollover),rollover); //rollover vooraan zetten //lees BUFFER_SIZE characters in while(!feof(f)){ startindex=startindex+BUFFER_SIZE-rollover; //startindex updaten i = fread(c+rollover,1,BUFFER_SIZE-rollover,f); if(i== BUFFER_SIZE-rollover){ //niet op het einde c[BUFFER_SIZE]=0; tekstl=BUFFER_SIZE; } else{ c[i+rollover]=0; tekstl=i+rollover; } bmSearch(zoek,zoekl,c,tekstl,tab,aantal,startindex,filename); memmove(c,c+(n-rollover),rollover); //rollover vooraan zetten } }
// N.B. startAt is now zero based inline int __stdcall stringSearch(const BYTE* a, const int N, const BYTE* p, const int M, const int startAt) { // In order for it to be worth initiating the skip array, we have to have enough characters to search return N >= 512 ? bmSearch(a, N, p, M, /*NULL, */startAt) : bruteSearch(a, N, p, M, startAt); }