| 6700 | |
| 6701 | |
| 6702 | bool forceReadFileXPoint(char *fileName) { |
| 6703 | /* Here we read the original file as usual */ |
| 6704 | FILE *fileDescriptor; |
| 6705 | uint64_t numberItems,i; |
| 6706 | size_t r,lenaux; |
| 6707 | uint8_t rawvalue[100]; |
| 6708 | char aux[1000],*hextemp; |
| 6709 | Tokenizer tokenizer_xpoint; //tokenizer |
| 6710 | fileDescriptor = fopen(fileName,"r"); |
| 6711 | if(fileDescriptor == NULL) { |
| 6712 | fprintf(stderr,"[E] Error opening the file %s, line %i\n",fileName,__LINE__ - 2); |
| 6713 | return false; |
| 6714 | } |
| 6715 | /*Count lines in the file*/ |
| 6716 | numberItems = 0; |
| 6717 | while(!feof(fileDescriptor)) { |
| 6718 | hextemp = fgets(aux,1000,fileDescriptor); |
| 6719 | trim(aux," \t\n\r"); |
| 6720 | if(hextemp == aux) { |
| 6721 | r = strlen(aux); |
| 6722 | if(r >= 40) { |
| 6723 | numberItems++; |
| 6724 | } |
| 6725 | } |
| 6726 | } |
| 6727 | fseek(fileDescriptor,0,SEEK_SET); |
| 6728 | |
| 6729 | MAXLENGTHADDRESS = 20; /*20 bytes beacuase we only need the data in binary*/ |
| 6730 | |
| 6731 | printf("[+] Allocating memory for %" PRIu64 " elements: %.2f MB\n",numberItems,(double)(((double) sizeof(struct address_value)*numberItems)/(double)1048576)); |
| 6732 | addressTable = (struct address_value*) malloc(sizeof(struct address_value)*numberItems); |
| 6733 | checkpointer((void *)addressTable,__FILE__,"malloc","addressTable" ,__LINE__ - 1); |
| 6734 | |
| 6735 | N = numberItems; |
| 6736 | |
| 6737 | if(!initBloomFilter(&bloom,N)) |
| 6738 | return false; |
| 6739 | |
| 6740 | i = 0; |
| 6741 | while(i < N) { |
| 6742 | memset(aux,0,1000); |
| 6743 | hextemp = fgets(aux,1000,fileDescriptor); |
| 6744 | memset((void *)&addressTable[i],0,sizeof(struct address_value)); |
| 6745 | if(hextemp == aux) { |
| 6746 | trim(aux," \t\n\r"); |
| 6747 | stringtokenizer(aux,&tokenizer_xpoint); |
| 6748 | hextemp = nextToken(&tokenizer_xpoint); |
| 6749 | lenaux = strlen(hextemp); |
| 6750 | if(isValidHex(hextemp)) { |
| 6751 | switch(lenaux) { |
| 6752 | case 64: /*X value*/ |
| 6753 | r = hexs2bin(aux,(uint8_t*) rawvalue); |
| 6754 | if(r) { |
| 6755 | memcpy(addressTable[i].value,rawvalue,20); |
| 6756 | bloom_add(&bloom,rawvalue,MAXLENGTHADDRESS); |
| 6757 | } |
| 6758 | else { |
| 6759 | fprintf(stderr,"[E] error hexs2bin\n"); |
no test coverage detected