diff options
author | s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b> | 2010-01-28 00:31:00 +0000 |
---|---|---|
committer | s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b> | 2010-01-28 00:31:00 +0000 |
commit | 80264be428b7ec7692e6633a0f21232c63a0b62c (patch) | |
tree | 2cef9a44c911d1a80ef48bc74d50e7cc86b512b9 /util.cpp | |
parent | 95d839f15c2ae418939bbecdc95228f00ea4466d (diff) |
simplify AddAddress,
readcompactsize limit,
fixed a 64-bit compile error in serialize.h,
change status "# blocks" to "# confirmations" and widen the column.
Diffstat (limited to 'util.cpp')
-rw-r--r-- | util.cpp | 77 |
1 files changed, 76 insertions, 1 deletions
@@ -8,8 +8,8 @@ map<string, string> mapArgs;
map<string, vector<string> > mapMultiArgs;
bool fDebug = false;
-bool fPrintToDebugger = false;
bool fPrintToConsole = false;
+bool fPrintToDebugger = false;
char pszSetDataDir[MAX_PATH] = "";
bool fShutdown = false;
@@ -75,6 +75,8 @@ void RandAddSeed() void RandAddSeedPerfmon()
{
+ RandAddSeed();
+
// This can take up to 2 seconds, so only do it every 10 minutes
static int64 nLastPerfmon;
if (GetTime() < nLastPerfmon + 10 * 60)
@@ -129,6 +131,79 @@ uint64 GetRand(uint64 nMax) +inline int OutputDebugStringF(const char* pszFormat, ...)
+{
+ int ret = 0;
+ if (fPrintToConsole || wxTheApp == NULL)
+ {
+ // print to console
+ va_list arg_ptr;
+ va_start(arg_ptr, pszFormat);
+ ret = vprintf(pszFormat, arg_ptr);
+ va_end(arg_ptr);
+ }
+ else
+ {
+ // print to debug.log
+ char pszFile[MAX_PATH+100];
+ GetDataDir(pszFile);
+ strlcat(pszFile, "/debug.log", sizeof(pszFile));
+ FILE* fileout = fopen(pszFile, "a");
+ if (fileout)
+ {
+ //// Debug print useful for profiling
+ //fprintf(fileout, " %"PRI64d" ", wxGetLocalTimeMillis().GetValue());
+ va_list arg_ptr;
+ va_start(arg_ptr, pszFormat);
+ ret = vfprintf(fileout, pszFormat, arg_ptr);
+ va_end(arg_ptr);
+ fclose(fileout);
+ }
+ }
+
+#ifdef __WXMSW__
+ if (fPrintToDebugger)
+ {
+ // accumulate a line at a time
+ static CCriticalSection cs_OutputDebugStringF;
+ CRITICAL_BLOCK(cs_OutputDebugStringF)
+ {
+ static char pszBuffer[50000];
+ static char* pend;
+ if (pend == NULL)
+ pend = pszBuffer;
+ va_list arg_ptr;
+ va_start(arg_ptr, pszFormat);
+ int limit = END(pszBuffer) - pend - 2;
+ int ret = _vsnprintf(pend, limit, pszFormat, arg_ptr);
+ va_end(arg_ptr);
+ if (ret < 0 || ret >= limit)
+ {
+ pend = END(pszBuffer) - 2;
+ *pend++ = '\n';
+ }
+ else
+ pend += ret;
+ *pend = '\0';
+ char* p1 = pszBuffer;
+ char* p2;
+ while (p2 = strchr(p1, '\n'))
+ {
+ p2++;
+ char c = *p2;
+ *p2 = '\0';
+ OutputDebugString(p1);
+ *p2 = c;
+ p1 = p2;
+ }
+ if (p1 != pszBuffer)
+ memmove(pszBuffer, p1, pend - p1 + 1);
+ pend -= (p1 - pszBuffer);
+ }
+ }
+#endif
+ return ret;
+}
// Safer snprintf
|