| 6620 | } |
| 6621 | |
| 6622 | bool forceReadFileAddressEth(char *fileName) { |
| 6623 | /* Here we read the original file as usual */ |
| 6624 | FILE *fileDescriptor; |
| 6625 | bool validAddress; |
| 6626 | uint64_t numberItems,i; |
| 6627 | size_t r; |
| 6628 | uint8_t rawvalue[50]; |
| 6629 | char aux[100],*hextemp; |
| 6630 | fileDescriptor = fopen(fileName,"r"); |
| 6631 | if(fileDescriptor == NULL) { |
| 6632 | fprintf(stderr,"[E] Error opening the file %s, line %i\n",fileName,__LINE__ - 2); |
| 6633 | return false; |
| 6634 | } |
| 6635 | /*Count lines in the file*/ |
| 6636 | numberItems = 0; |
| 6637 | while(!feof(fileDescriptor)) { |
| 6638 | hextemp = fgets(aux,100,fileDescriptor); |
| 6639 | trim(aux," \t\n\r"); |
| 6640 | if(hextemp == aux) { |
| 6641 | r = strlen(aux); |
| 6642 | if(r >= 40) { |
| 6643 | numberItems++; |
| 6644 | } |
| 6645 | } |
| 6646 | } |
| 6647 | fseek(fileDescriptor,0,SEEK_SET); |
| 6648 | |
| 6649 | MAXLENGTHADDRESS = 20; /*20 bytes beacuase we only need the data in binary*/ |
| 6650 | N = numberItems; |
| 6651 | |
| 6652 | printf("[+] Allocating memory for %" PRIu64 " elements: %.2f MB\n",numberItems,(double)(((double) sizeof(struct address_value)*numberItems)/(double)1048576)); |
| 6653 | addressTable = (struct address_value*) malloc(sizeof(struct address_value)*numberItems); |
| 6654 | checkpointer((void *)addressTable,__FILE__,"malloc","addressTable" ,__LINE__ -1 ); |
| 6655 | |
| 6656 | |
| 6657 | if(!initBloomFilter(&bloom,N)) |
| 6658 | return false; |
| 6659 | |
| 6660 | i = 0; |
| 6661 | while(i < numberItems) { |
| 6662 | validAddress = false; |
| 6663 | memset(aux,0,100); |
| 6664 | memset(addressTable[i].value,0,sizeof(struct address_value)); |
| 6665 | hextemp = fgets(aux,100,fileDescriptor); |
| 6666 | trim(aux," \t\n\r"); |
| 6667 | r = strlen(aux); |
| 6668 | if(r >= 40 && r <= 42){ |
| 6669 | switch(r) { |
| 6670 | case 40: |
| 6671 | if(isValidHex(aux)){ |
| 6672 | hexs2bin(aux,rawvalue); |
| 6673 | bloom_add(&bloom, rawvalue ,sizeof(struct address_value)); |
| 6674 | memcpy(addressTable[i].value,rawvalue,sizeof(struct address_value)); |
| 6675 | i++; |
| 6676 | validAddress = true; |
| 6677 | } |
| 6678 | break; |
| 6679 | case 42: |
no test coverage detected