bool fRequestShutdown = false;
bool fShutdown = false;
bool fDaemon = false;
+bool fServer = false;
bool fCommandLine = false;
string strMiscWarning;
bool fTestNet = false;
bool fNoListen = false;
+bool fLogTimestamps = false;
}
if (fileout)
{
- //// Debug print useful for profiling
- //fprintf(fileout, " %"PRI64d" ", GetTimeMillis());
+ static bool fStartedNewLine = true;
+
+ // Debug print useful for profiling
+ if (fLogTimestamps && fStartedNewLine)
+ fprintf(fileout, "%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
+ if (pszFormat[strlen(pszFormat) - 1] == '\n')
+ fStartedNewLine = true;
+ else
+ fStartedNewLine = false;
+
va_list arg_ptr;
va_start(arg_ptr, pszFormat);
ret = vfprintf(fileout, pszFormat, arg_ptr);
string FormatMoney(int64 n, bool fPlus)
{
- string str = strprintf("%.08f", double(n > 0 ? n : -n)/double(COIN));
+ // Note: not using straight sprintf here because we do NOT want
+ // localized number formatting.
+ int64 n_abs = (n > 0 ? n : -n);
+ int64 quotient = n_abs/COIN;
+ int64 remainder = n_abs%COIN;
+ string str = strprintf("%"PRI64d".%08"PRI64d, quotient, remainder);
// Right-trim excess 0's before the decimal point:
int nTrim = 0;
bool ParseMoney(const char* pszIn, int64& nRet)
{
string strWhole;
- int64 nCents = 0;
+ int64 nUnits = 0;
const char* p = pszIn;
while (isspace(*p))
p++;
if (*p == '.')
{
p++;
- if (isdigit(*p))
+ int64 nMult = CENT*10;
+ while (isdigit(*p) && (nMult > 0))
{
- nCents = 10 * (*p++ - '0');
- if (isdigit(*p))
- nCents += (*p++ - '0');
+ nUnits += nMult * (*p++ - '0');
+ nMult /= 10;
}
break;
}
return false;
if (strWhole.size() > 14)
return false;
- if (nCents < 0 || nCents > 99)
+ if (nUnits < 0 || nUnits > COIN)
return false;
int64 nWhole = atoi64(strWhole);
- int64 nPreValue = nWhole * 100 + nCents;
- int64 nValue = nPreValue * CENT;
- if (nValue / CENT != nPreValue)
- return false;
- if (nValue / COIN != nWhole)
- return false;
+ int64 nValue = nWhole*COIN + nUnits;
+
nRet = nValue;
return true;
}
}
}
+string GetPidFile()
+{
+ namespace fs = boost::filesystem;
+ fs::path pathConfig(GetArg("-pid", "bitcoind.pid"));
+ if (!pathConfig.is_complete())
+ pathConfig = fs::path(GetDataDir()) / pathConfig;
+ return pathConfig.string();
+}
+
+void CreatePidFile(string pidFile, pid_t pid)
+{
+ FILE* file;
+ if (file = fopen(pidFile.c_str(), "w"))
+ {
+ fprintf(file, "%d\n", pid);
+ fclose(file);
+ }
+}
+
int GetFilesize(FILE* file)
{
int nSavePos = ftell(file);
printf("| nTimeOffset = %+"PRI64d" (%+"PRI64d" minutes)\n", nTimeOffset, nTimeOffset/60);
}
}
+
+
+
+
+
+
+
+
+
+string FormatVersion(int nVersion)
+{
+ if (nVersion%100 == 0)
+ return strprintf("%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100);
+ else
+ return strprintf("%d.%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100, nVersion%100);
+}
+
+string FormatFullVersion()
+{
+ string s = FormatVersion(VERSION) + pszSubVer;
+ if (VERSION_IS_BETA)
+ s += _("-beta");
+ return s;
+}
+
+
+
+
+