11 #ifndef BITCOIN_UTIL_H 12 #define BITCOIN_UTIL_H 14 #if defined(HAVE_CONFIG_H) 29 #include <boost/filesystem/path.hpp> 30 #include <boost/signals2/signal.hpp> 31 #include <boost/thread/exceptions.hpp> 38 #ifdef ENABLE_DASH_DEBUG 60 boost::signals2::signal<std::string (const char* psz)>
Translate;
63 extern std::map<std::string, std::string>
mapArgs;
64 extern std::map<std::string, std::vector<std::string> >
mapMultiArgs;
84 inline std::string
_(
const char* psz)
87 return rv ? (*rv) : psz;
98 #define LogPrintf(...) LogPrint(NULL, __VA_ARGS__) 104 #define MAKE_ERROR_AND_LOG_FUNC(n) \ 106 template<TINYFORMAT_ARGTYPES(n)> \ 107 static inline int LogPrint(const char* category, const char* format, TINYFORMAT_VARARGS(n)) \ 109 if(!LogAcceptCategory(category)) return 0; \ 110 return LogPrintStr(tfm::format(format, TINYFORMAT_PASSARGS(n))); \ 113 template<TINYFORMAT_ARGTYPES(n)> \ 114 static inline bool error(const char* format, TINYFORMAT_VARARGS(n)) \ 116 LogPrintStr("ERROR: " + tfm::format(format, TINYFORMAT_PASSARGS(n)) + "\n"); \ 143 bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest);
146 const boost::filesystem::path &
GetDataDir(
bool fNetSpecific =
true);
153 void CreatePidFile(
const boost::filesystem::path &path, pid_t pid);
155 void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
157 boost::filesystem::path GetSpecialFolderPath(
int nFolder,
bool fCreate =
true);
162 void runCommand(
const std::string& strCommand);
167 return c ==
'-' || c ==
'/';
180 std::string
GetArg(
const std::string& strArg,
const std::string& strDefault);
189 int64_t
GetArg(
const std::string& strArg, int64_t nDefault);
198 bool GetBoolArg(
const std::string& strArg,
bool fDefault);
207 bool SoftSetArg(
const std::string& strArg,
const std::string& strValue);
233 std::string
HelpMessageOpt(
const std::string& option,
const std::string& message);
259 catch (
const boost::thread_interrupted&)
264 catch (
const std::exception& e) {
303 #endif // BITCOIN_UTIL_H const boost::filesystem::path & GetBackupsDir()
boost::filesystem::path GetMasternodeConfigFile()
std::string GetThreadName()
std::string SafeIntVersionToString(uint32_t nVersion)
Copy of the IntVersionToString, that returns "Invalid version" string instead of throwing std::bad_ca...
void RenameThread(const char *name)
void ReadConfigFile(std::map< std::string, std::string > &mapSettingsRet, std::map< std::string, std::vector< std::string > > &mapMultiSettingsRet)
std::map< std::string, std::vector< std::string > > mapMultiArgs
std::string HelpMessageGroup(const std::string &message)
static const bool DEFAULT_LOGTIMEMICROS
boost::signals2::signal< std::string(const char *psz)> Translate
void CreatePidFile(const boost::filesystem::path &path, pid_t pid)
uint32_t StringVersionToInt(const std::string &strVersion)
Converts version strings to 4-byte unsigned integer.
static const bool DEFAULT_LOGTIMESTAMPS
std::map< std::string, std::string > mapArgs
bool SoftSetArg(const std::string &strArg, const std::string &strValue)
const char *const BITCOIN_PID_FILENAME
static const bool DEFAULT_LOGIPS
const boost::filesystem::path & GetDataDir(bool fNetSpecific=true)
static int LogPrint(const char *category, const char *format)
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
void TraceThread(const char *name, Callable func)
static bool error(const char *format)
void ParseParameters(int argc, const char *const argv[])
static const bool DEFAULT_LOGTHREADNAMES
void runCommand(const std::string &strCommand)
#define MAKE_ERROR_AND_LOG_FUNC(n)
void SetThreadPriority(int nPriority)
const char *const BITCOIN_CONF_FILENAME
std::string strMiscWarning
bool IsSwitchChar(char c)
bool TryCreateDirectory(const boost::filesystem::path &p)
void PrintExceptionContinue(const std::exception *pex, const char *pszThread)
bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest)
void FileCommit(FILE *fileout)
boost::filesystem::path GetConfigFile()
std::string IntVersionToString(uint32_t nVersion)
Converts version as 4-byte unsigned integer to string.
boost::filesystem::path GetTempPath()
std::string GetArg(const std::string &strArg, const std::string &strDefault)
bool LogAcceptCategory(const char *category)
int RaiseFileDescriptorLimit(int nMinFD)
boost::filesystem::path GetPidFile()
void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length)
CTranslationInterface translationInterface
bool TruncateFile(FILE *file, unsigned int length)
bool GetBoolArg(const std::string &strArg, bool fDefault)
int LogPrintStr(const std::string &str)
volatile bool fReopenDebugLog
boost::filesystem::path GetDefaultDataDir()
std::string HelpMessageOpt(const std::string &option, const std::string &message)
std::string _(const char *psz)