]> git.sesse.net Git - freerainbowtables/blobdiff - Common/rt api/RTIReader.cpp
(C)
[freerainbowtables] / Common / rt api / RTIReader.cpp
index 3134e918cde56d464746f00a9315ff5443ecb6c7..2215f46af6b27adfca4205276c48722f5f519bac 100644 (file)
@@ -1,3 +1,26 @@
+/*
+ * freerainbowtables is a project for generating, distributing, and using
+ * perfect rainbow tables
+ *
+ * Copyright 2010, 2011 Martin Westergaard Jørgensen <martinwj2005@gmail.com>
+ * Copyright 2010, 2011 James Nobis <frt@quelrod.net>
+ *
+ * This file is part of freerainbowtables.
+ *
+ * freerainbowtables is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * freerainbowtables is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with freerainbowtables.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
 #include "RTIReader.h"
 
 RTIReader::RTIReader(string Filename)
@@ -17,16 +40,16 @@ RTIReader::RTIReader(string Filename)
        m_chainPosition = 0;
 
        // Load the index file
-       unsigned int nIndexFileLen = GetFileLen(pFileIndex);
-       unsigned int nFileLen = GetFileLen(m_pFile);
+       long nIndexFileLen = GetFileLen(pFileIndex);
+       long nFileLen = GetFileLen(m_pFile);
        unsigned int nTotalChainCount = nFileLen / 8;
        if (nFileLen % 8 != 0)
-               printf("file length mismatch (%u bytes)\n", nFileLen);
+               printf("file length mismatch (%lu bytes)\n", nFileLen);
        else
        {
                // File length check
                if (nIndexFileLen % 11 != 0)
-                       printf("index file length mismatch (%u bytes)\n", nIndexFileLen);
+                       printf("index file length mismatch (%lu bytes)\n", nIndexFileLen);
                else
                {
                        if(m_pIndex != NULL) {
@@ -38,7 +61,7 @@ RTIReader::RTIReader(string Filename)
 #endif
                        m_pIndex = new (nothrow) IndexChain[nIndexFileLen / 11];
                        if(m_pIndex == NULL) {
-                               printf("\nFailed allocating %i MB memory.\n", nIndexFileLen / 11 / (1024 * 1024));
+                               printf("\nFailed allocating %ld MB memory.\n", nIndexFileLen / 11 / (1024 * 1024));
                                exit(-2);
                        }
 #ifdef _MEMORYDEBUG
@@ -46,9 +69,9 @@ RTIReader::RTIReader(string Filename)
 #endif                 
                        memset(m_pIndex, 0x00, sizeof(IndexChain) * (nIndexFileLen / 11));
                        fseek(pFileIndex, 0, SEEK_SET);
-                       int nRead = 0;
-                       UINT4 nRows;
-                       for(nRows = 0; (nRows * 11) < nIndexFileLen; nRows++)
+                       //int nRead = 0;
+                       uint32 nRows;
+                       for(nRows = 0; (nRows * 11) < (uint32)nIndexFileLen; nRows++)
                        {
                                if(fread(&m_pIndex[nRows].nPrefix, 5, 1, pFileIndex) != 1) break;                                                       
                                if(fread(&m_pIndex[nRows].nFirstChain, 4, 1, pFileIndex) != 1) break;                                                   
@@ -90,13 +113,13 @@ RTIReader::RTIReader(string Filename)
 
 }
 
-int RTIReader::ReadChains(unsigned int &numChains, RainbowChain *pData)
+int RTIReader::ReadChains(uint32 &numChains, RainbowChain *pData)
 {      
        // We HAVE to reset the data to 0x00's or we will get in trouble
        memset(pData, 0x00, sizeof(RainbowChain) * numChains);
        unsigned int readChains = 0;
        unsigned int chainsleft = GetChainsLeft();
-       for(UINT4 i = 0; i < m_nIndexSize; i++)
+       for(uint32 i = 0; i < m_nIndexSize; i++)
        {
                if(m_chainPosition + readChains > m_pIndex[i].nFirstChain + m_pIndex[i].nChainCount) // We found the matching index
                        continue;
@@ -120,7 +143,7 @@ int RTIReader::ReadChains(unsigned int &numChains, RainbowChain *pData)
        return 0;
 }
 
-UINT4 RTIReader::GetChainsLeft()
+uint32 RTIReader::GetChainsLeft()
 {      
        return (GetFileLen(m_pFile) / 8) - m_chainPosition;
 }