From 6559655218b21f07e1fff3e89f6a265277d6c779 Mon Sep 17 00:00:00 2001 From: jed Date: Tue, 5 Jun 2012 14:06:21 -0700 Subject: [PATCH] compile on windows --- newcoin.vcxproj | 6 ++++-- newcoin.vcxproj.filters | 18 ++++++++++++------ src/Amount.cpp | 2 +- src/ECIES.cpp | 1 - src/RPCServer.cpp | 6 +++--- src/utils.cpp | 28 ++++++++++++++++++++++++++++ src/utils.h | 4 ++++ 7 files changed, 52 insertions(+), 13 deletions(-) diff --git a/newcoin.vcxproj b/newcoin.vcxproj index 6cb762b945..7a2042a555 100644 --- a/newcoin.vcxproj +++ b/newcoin.vcxproj @@ -103,7 +103,6 @@ - @@ -112,12 +111,14 @@ + - + + @@ -129,6 +130,7 @@ + diff --git a/newcoin.vcxproj.filters b/newcoin.vcxproj.filters index c9ffce30c5..c83fa06654 100644 --- a/newcoin.vcxproj.filters +++ b/newcoin.vcxproj.filters @@ -81,9 +81,6 @@ Source Files - - Source Files - Source Files @@ -123,9 +120,6 @@ Source Files - - Source Files - Source Files @@ -237,6 +231,18 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + diff --git a/src/Amount.cpp b/src/Amount.cpp index cefa268af0..cd4cd3bc5a 100644 --- a/src/Amount.cpp +++ b/src/Amount.cpp @@ -100,7 +100,7 @@ bool STAmount::setValue(const std::string& sAmount, const std::string& sCurrency if (bInteger) { - uValue = sAmount.empty() ? 0 : boost::lexical_cast(sAmount); + uValue = sAmount.empty() ? 0 : boost::lexical_cast(sAmount); iOffset = 0; } else diff --git a/src/ECIES.cpp b/src/ECIES.cpp index 400817549e..447794f93a 100644 --- a/src/ECIES.cpp +++ b/src/ECIES.cpp @@ -1,4 +1,3 @@ - #include #include #include diff --git a/src/RPCServer.cpp b/src/RPCServer.cpp index 0a2f4a87a3..d856b8947c 100644 --- a/src/RPCServer.cpp +++ b/src/RPCServer.cpp @@ -248,7 +248,7 @@ Json::Value RPCServer::authorize(const uint256& uLedger, // Find the index of the account from the master generator, so we can generate the public and private keys. NewcoinAddress naMasterAccountPublic; - uint iIndex = -1; // Compensate for initial increment. + unsigned int iIndex = -1; // Compensate for initial increment. // XXX Stop after Config.account_probe_max // Don't look at ledger entries to determine if the account exists. Don't want to leak to thin server that these accounts are @@ -945,7 +945,7 @@ Json::Value RPCServer::doPasswordSet(Json::Value& params) NewcoinAddress naMasterXPublic; NewcoinAddress naRegularXPublic; - uint iIndex = -1; // Compensate for initial increment. + unsigned int iIndex = -1; // Compensate for initial increment. int iMax = theConfig.ACCOUNT_PROBE_MAX; // YYY Could probe peridoically to see if accounts exists. @@ -1295,7 +1295,7 @@ Json::Value RPCServer::accounts(const uint256& uLedger, const NewcoinAddress& na // YYY Don't want to leak to thin server that these accounts are related. // YYY Would be best to alternate requests to servers and to cache results. - uint uIndex = 0; + unsigned int uIndex = 0; do { NewcoinAddress naAccount; diff --git a/src/utils.cpp b/src/utils.cpp index 6a75ead202..ffe4406183 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -102,4 +102,32 @@ DH* DH_der_load_hex(const std::string& strDer) return DH_der_load(strBuf); } +#ifdef WIN32 +#define _WINSOCK_ +#include + +//#include "Winsock2.h" +//#include +// from: http://stackoverflow.com/questions/3022552/is-there-any-standard-htonl-like-function-for-64-bits-integers-in-c +// but we don't need to check the endianness +uint64_t htobe64(uint64_t value) +{ + // The answer is 42 + //static const int num = 42; + + // Check the endianness + //if (*reinterpret_cast(&num) == num) + //{ + const uint32_t high_part = htonl(static_cast(value >> 32)); + const uint32_t low_part = htonl(static_cast(value & 0xFFFFFFFFLL)); + + return (static_cast(low_part) << 32) | high_part; + //} else + //{ + // return value; + //} +} + +#endif + // vim:ts=4 diff --git a/src/utils.h b/src/utils.h index e0f3869480..54cb56c1c4 100644 --- a/src/utils.h +++ b/src/utils.h @@ -19,6 +19,10 @@ #define MIN(x,y) ((x) > (y) ? (y) : (x)) #endif +#ifdef WIN32 +extern uint64_t htobe64(uint64_t value); +#endif + boost::posix_time::ptime ptEpoch(); int iToSeconds(boost::posix_time::ptime ptWhen); boost::posix_time::ptime ptFromSeconds(int iSeconds);