]> git.sesse.net Git - freerainbowtables/blobdiff - Client Applications/rcracki_mt/Public.cpp
0.6.5 release synced from rcracki.sourceforge.net
[freerainbowtables] / Client Applications / rcracki_mt / Public.cpp
index 0aba1a8943311706202a6cbef4afde7d8f340e0f..41a95155ec9f47c41bf25630d5bf70aa69148481 100644 (file)
@@ -7,7 +7,7 @@
  * Copyright 2009, 2010 DaniĆ«l Niggebrugge <niggebrugge@fox-it.com>\r
  * Copyright 2009, 2010 James Nobis <frt@quelrod.net>\r
  *\r
- * This file is part of racrcki_mt.\r
+ * This file is part of rcracki_mt.\r
  *\r
  * rcracki_mt is free software: you can redistribute it and/or modify\r
  * it under the terms of the GNU General Public License as published by\r
@@ -22,7 +22,7 @@
  * along with rcracki_mt.  If not, see <http://www.gnu.org/licenses/>.\r
  */\r
 \r
-#ifdef _WIN32\r
+#if defined(_WIN32) && !defined(__GNUC__)\r
        #pragma warning(disable : 4786 4267 4018)\r
 #endif\r
 \r
 \r
 #ifdef _WIN32\r
        #include <windows.h>\r
+#endif\r
+\r
+#if defined(_WIN32) && !defined(__GNUC__)\r
+       #include <windows.h>\r
        #include <time.h>\r
 \r
        #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)\r
@@ -161,8 +165,8 @@ bool GetHybridCharsets(string sCharset, vector<tCharset>& vCharset)
        if(sCharset.substr(0, 6) != "hybrid") // Not hybrid charset\r
                return false;\r
 \r
-       UINT4 nEnd = (int) sCharset.rfind(')');\r
-       UINT4 nStart = (int) sCharset.rfind('(');\r
+       string::size_type nEnd = sCharset.rfind(')');\r
+       string::size_type nStart = (int) sCharset.rfind('(');\r
        string sChar = sCharset.substr(nStart + 1, nEnd - nStart - 1);\r
        vector<string> vParts;\r
        SeperateString(sChar, ",", vParts);\r
@@ -202,8 +206,8 @@ bool ReadLinesFromFile(string sPathName, vector<string>& vLine)
                                content[i] = '\n';\r
                }\r
 \r
-               int n;\r
-               while ((n = content.find("\n", 0)) != -1)\r
+               string::size_type n;\r
+               while ((n = content.find("\n", 0)) != string::npos)\r
                {\r
                        string line = content.substr(0, n);\r
                        line = TrimString(line);\r
@@ -241,8 +245,8 @@ bool SeperateString(string s, string sSeperator, vector<string>& vPart)
        unsigned int i;\r
        for (i = 0; i < sSeperator.size(); i++)\r
        {\r
-               int n = s.find(sSeperator[i]);\r
-               if (n != -1)\r
+               string::size_type n;\r
+               if ( (n = s.find(sSeperator[i])) != string::npos)\r
                {\r
                        vPart.push_back(s.substr(0, n));\r
                        s = s.substr(n + 1);\r
@@ -301,7 +305,7 @@ string HexToStr(const unsigned char* pData, int nLen)
 \r
 uint64 GetAvailPhysMemorySize()\r
 {\r
-#ifdef _WIN32\r
+#if defined(_WIN32)\r
        MEMORYSTATUS ms;\r
        GlobalMemoryStatus(&ms);\r
        return ms.dwAvailPhys;\r
@@ -331,6 +335,7 @@ string GetApplicationPath()
        GetModuleFileName(NULL, fullPath, FILENAME_MAX);\r
 #else\r
        char szTmp[32];\r
+       // XXX linux/proc file system dependen\r
        sprintf(szTmp, "/proc/%d/exe", getpid());\r
        int bytes = readlink(szTmp, fullPath, FILENAME_MAX);\r
        if(bytes >= 0)\r
@@ -339,12 +344,12 @@ string GetApplicationPath()
 \r
        string sApplicationPath = fullPath;\r
 #ifdef _WIN32\r
-       int nIndex = sApplicationPath.find_last_of('\\');\r
+       string::size_type nIndex = sApplicationPath.find_last_of('\\');\r
 #else\r
-       int nIndex = sApplicationPath.find_last_of('/');\r
+       string::size_type nIndex = sApplicationPath.find_last_of('/');\r
 #endif\r
 \r
-       if (nIndex != -1)\r
+       if ( nIndex != string::npos )\r
                sApplicationPath = sApplicationPath.substr(0, nIndex+1);\r
 \r
        //printf ("\n\nDebug: The application directory is %s\n", sApplicationPath.c_str());\r