| 6547 | } |
| 6548 | |
| 6549 | bool forceReadFileAddress(char *fileName) { |
| 6550 | /* Here we read the original file as usual */ |
| 6551 | FILE *fileDescriptor; |
| 6552 | bool validAddress; |
| 6553 | uint64_t numberItems,i; |
| 6554 | size_t r,raw_value_length; |
| 6555 | uint8_t rawvalue[50]; |
| 6556 | char aux[100],*hextemp; |
| 6557 | fileDescriptor = fopen(fileName,"r"); |
| 6558 | if(fileDescriptor == NULL) { |
| 6559 | fprintf(stderr,"[E] Error opening the file %s, line %i\n",fileName,__LINE__ - 2); |
| 6560 | return false; |
| 6561 | } |
| 6562 | |
| 6563 | /*Count lines in the file*/ |
| 6564 | numberItems = 0; |
| 6565 | while(!feof(fileDescriptor)) { |
| 6566 | hextemp = fgets(aux,100,fileDescriptor); |
| 6567 | trim(aux," \t\n\r"); |
| 6568 | if(hextemp == aux) { |
| 6569 | r = strlen(aux); |
| 6570 | if(r > 20) { |
| 6571 | numberItems++; |
| 6572 | } |
| 6573 | } |
| 6574 | } |
| 6575 | fseek(fileDescriptor,0,SEEK_SET); |
| 6576 | MAXLENGTHADDRESS = 20; /*20 bytes beacuase we only need the data in binary*/ |
| 6577 | |
| 6578 | printf("[+] Allocating memory for %" PRIu64 " elements: %.2f MB\n",numberItems,(double)(((double) sizeof(struct address_value)*numberItems)/(double)1048576)); |
| 6579 | addressTable = (struct address_value*) malloc(sizeof(struct address_value)*numberItems); |
| 6580 | checkpointer((void *)addressTable,__FILE__,"malloc","addressTable" ,__LINE__ -1 ); |
| 6581 | |
| 6582 | if(!initBloomFilter(&bloom,numberItems)) |
| 6583 | return false; |
| 6584 | |
| 6585 | i = 0; |
| 6586 | while(i < numberItems) { |
| 6587 | validAddress = false; |
| 6588 | memset(aux,0,100); |
| 6589 | memset(addressTable[i].value,0,sizeof(struct address_value)); |
| 6590 | hextemp = fgets(aux,100,fileDescriptor); |
| 6591 | trim(aux," \t\n\r"); |
| 6592 | r = strlen(aux); |
| 6593 | if(r > 0 && r <= 40) { |
| 6594 | if(r<40 && isValidBase58String(aux)) { //Address |
| 6595 | raw_value_length = 25; |
| 6596 | b58tobin(rawvalue,&raw_value_length,aux,r); |
| 6597 | if(raw_value_length == 25) { |
| 6598 | //hextemp = tohex((char*)rawvalue+1,20); |
| 6599 | bloom_add(&bloom, rawvalue+1 ,sizeof(struct address_value)); |
| 6600 | memcpy(addressTable[i].value,rawvalue+1,sizeof(struct address_value)); |
| 6601 | i++; |
| 6602 | validAddress = true; |
| 6603 | } |
| 6604 | } |
| 6605 | if(r == 40 && isValidHex(aux)) { //RMD |
| 6606 | hexs2bin(aux,rawvalue); |
no test coverage detected