From: Martin Westergaard Jorgensen Date: Wed, 12 Aug 2009 09:41:51 +0000 (+0200) Subject: Fixed RTI2 format X-Git-Url: https://git.sesse.net/?p=freerainbowtables;a=commitdiff_plain;h=6e9b9a5c1f65e66d3198979deb694447793bae19 Fixed RTI2 format --- diff --git a/Client Applications/converti2/converti2.cpp b/Client Applications/converti2/converti2.cpp index dec2b64..a73fd95 100644 --- a/Client Applications/converti2/converti2.cpp +++ b/Client Applications/converti2/converti2.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include "Public.h" #include "MemoryPool.h" using namespace std; @@ -461,6 +462,13 @@ void ConvertRainbowTable(string sPathName, string sResultFileName, unsigned int //printf("Diffsize is %u\n", diffSize); // then write the distance amount of 00's + if(diffSize > 1000) { + printf("WARNING! The distance to the next prefix is %i. Do you want to continue writing %i bytes of 0x00? Press y to continue", diffSize, diffSize); + if(getch() != 'y') { + printf("Aborting..."); + exit(1); + } + } for(int j = 1; j < diffSize; j++) { fwrite(&zero, 1, m_indexrowsizebytes, pFileIndex); @@ -612,7 +620,7 @@ int main(int argc, char* argv[]) sResultFile = vPathName[i].substr(n+1, vPathName[i].length()) + "i2"; else sResultFile = vPathName[i] + "i2"; // Resulting file is .rt, not .rti - printf("Using %i of 64 bits\n", (sptl + eptl + usecp)); + printf("Using %i of 64 bits. sptl: %i, eptl: %i, cp: %i. Chains will be %i bytes in size\n", (sptl + eptl + usecp), sptl, eptl, usecp, ((sptl + eptl + usecp) / 8)); if(sptl + eptl + usecp > 64) { exit(1); diff --git a/Client Applications/converti2/converti2.suo b/Client Applications/converti2/converti2.suo index 396b14a..3e8c05b 100644 Binary files a/Client Applications/converti2/converti2.suo and b/Client Applications/converti2/converti2.suo differ diff --git a/Client Applications/converti2/converti2.vcproj b/Client Applications/converti2/converti2.vcproj index dbbdaf0..0103995 100644 --- a/Client Applications/converti2/converti2.vcproj +++ b/Client Applications/converti2/converti2.vcproj @@ -41,7 +41,7 @@ @@ -191,11 +191,11 @@ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > diff --git a/Client Applications/rti2rto/rti2rto.suo b/Client Applications/rti2rto/rti2rto.suo index 3fdc2e6..023dd88 100644 Binary files a/Client Applications/rti2rto/rti2rto.suo and b/Client Applications/rti2rto/rti2rto.suo differ diff --git a/Client Applications/rti2rto/rti2rto.vcproj b/Client Applications/rti2rto/rti2rto.vcproj index 6dc5986..2dc3546 100644 --- a/Client Applications/rti2rto/rti2rto.vcproj +++ b/Client Applications/rti2rto/rti2rto.vcproj @@ -41,7 +41,7 @@ @@ -207,27 +207,27 @@ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > diff --git a/Common/rt api/Public.cpp b/Common/rt api/Public.cpp index 60d7072..f917d37 100644 --- a/Common/rt api/Public.cpp +++ b/Common/rt api/Public.cpp @@ -9,7 +9,9 @@ #endif #ifdef _WIN32 -#include "boinc_win.h" + #ifdef BOINC + #include "boinc_win.h" + #endif #else #include "config.h" #include @@ -21,9 +23,10 @@ #include #endif -#include "filesys.h" -#include "boinc_api.h" - +#ifdef BOINC + #include "filesys.h" + #include "boinc_api.h" +#endif #include "Public.h" #ifdef _WIN32 @@ -88,7 +91,8 @@ bool GetHybridCharsets(string sCharset, vector& vCharset) } return true; } -bool ReadLinesFromFile(string sPathName, vector& vLine) +#ifdef BOINC +bool boinc_ReadLinesFromFile(string sPathName, vector& vLine) { vLine.clear(); char input_path[512]; @@ -134,6 +138,46 @@ bool ReadLinesFromFile(string sPathName, vector& vLine) return true; } +#endif +bool ReadLinesFromFile(string sPathName, vector& vLine) +{ + vLine.clear(); + FILE *file = fopen(sPathName.c_str(), "rb"); + if (file != NULL) + { + unsigned int len = GetFileLen(file); + char* data = new char[len + 1]; + fread(data, 1, len, file); + data[len] = '\0'; + string content = data; + content += "\n"; + delete data; + + unsigned int i; + for (i = 0; i < content.size(); i++) + { + if (content[i] == '\r') + content[i] = '\n'; + } + + int n; + while ((n = content.find("\n", 0)) != -1) + { + string line = content.substr(0, n); + line = TrimString(line); + if (line != "") + vLine.push_back(line); + content = content.substr(n + 1); + } + + fclose(file); + } + else + return false; + + return true; +} + bool SeperateString(string s, string sSeperator, vector& vPart) { diff --git a/Common/rt api/Public.h b/Common/rt api/Public.h index a2f5657..3a315ae 100644 --- a/Common/rt api/Public.h +++ b/Common/rt api/Public.h @@ -70,6 +70,7 @@ typedef struct unsigned int GetFileLen(FILE* file); string TrimString(string s); +bool boinc_ReadLinesFromFile(string sPathName, vector& vLine); bool ReadLinesFromFile(string sPathName, vector& vLine); bool SeperateString(string s, string sSeperator, vector& vPart); string uint64tostr(uint64 n); diff --git a/Common/rt api/RTIReader.cpp b/Common/rt api/RTIReader.cpp index d96edc3..b72dbe2 100644 --- a/Common/rt api/RTIReader.cpp +++ b/Common/rt api/RTIReader.cpp @@ -4,7 +4,16 @@ RTIReader::RTIReader(string Filename) { m_pIndex = NULL; m_pFile = fopen(Filename.c_str(), "rb"); - FILE *pFileIndex = fopen(Filename.append(".index").c_str(), "rb"); + if(m_pFile == NULL) { + printf("could not open file %s\n", Filename.c_str()); + return; + } + string sIndex = Filename.append(".index").c_str(); + FILE *pFileIndex = fopen(sIndex.c_str(), "rb"); + if(pFileIndex == NULL) { + printf("could not open index file %s\n", sIndex.c_str()); + return; + } m_chainPosition = 0; // Load the index file