diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj index 44d965f94..e8f4f2487 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj +++ b/Builds/VisualStudio2013/RippleD.vcxproj @@ -1839,11 +1839,6 @@ - - True - - - @@ -2484,45 +2479,45 @@ - + True - + - + - + True - + - + True - + - + - + - + - + True - + - + - + True - + - + True - + True @@ -3427,8 +3422,6 @@ - - diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters index 284c1171c..d906a128f 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters @@ -403,9 +403,6 @@ {4DAFFAEC-2D9A-42C0-210F-483796C162E9} - - {61C8064B-23D8-A490-1614-9D2BA78ADB68} - {FB5092D7-3AA5-4E7F-F783-C8A929D8B588} @@ -2826,12 +2823,6 @@ ripple\basics\utility - - ripple\basics\utility - - - ripple\basics\utility - ripple\basics\utility @@ -3600,56 +3591,56 @@ ripple\module\app\websocket - - ripple\module\core\functional + + ripple\module\core - - ripple\module\core\functional + + ripple\module\core - - ripple\module\core\functional + + ripple\module\core - - ripple\module\core\functional + + ripple\module\core - - ripple\module\core\functional + + ripple\module\core - - ripple\module\core\functional + + ripple\module\core - - ripple\module\core\functional + + ripple\module\core - - ripple\module\core\functional + + ripple\module\core - - ripple\module\core\functional + + ripple\module\core - - ripple\module\core\functional + + ripple\module\core - - ripple\module\core\functional + + ripple\module\core - - ripple\module\core\functional + + ripple\module\core - - ripple\module\core\functional + + ripple\module\core - - ripple\module\core\functional + + ripple\module\core - - ripple\module\core\functional + + ripple\module\core - - ripple\module\core\functional + + ripple\module\core - - ripple\module\core\functional + + ripple\module\core ripple\module\data\crypto @@ -4746,9 +4737,6 @@ ripple\unity - - ripple\unity - ripple\unity diff --git a/src/ripple/basics/utility/IniFile.cpp b/src/ripple/basics/utility/IniFile.cpp deleted file mode 100644 index 300a9292f..000000000 --- a/src/ripple/basics/utility/IniFile.cpp +++ /dev/null @@ -1,156 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include -#include - -namespace ripple { - -#define SECTION_DEFAULT_NAME "" - -Section ParseSection (std::string const& strInput, const bool bTrim) -{ - std::string strData (strInput); - std::vector vLines; - Section secResult; - - // Convert DOS format to unix. - boost::algorithm::replace_all (strData, "\r\n", "\n"); - - // Convert MacOS format to unix. - boost::algorithm::replace_all (strData, "\r", "\n"); - - boost::algorithm::split (vLines, strData, boost::algorithm::is_any_of ("\n")); - - // Set the default Section name. - std::string strSection = SECTION_DEFAULT_NAME; - - // Initialize the default Section. - secResult[strSection] = Section::mapped_type (); - - // Parse each line. - BOOST_FOREACH (std::string & strValue, vLines) - { - if (strValue.empty () || strValue[0] == '#') - { - // Blank line or comment, do nothing. - } - else if (strValue[0] == '[' && strValue[strValue.length () - 1] == ']') - { - // New Section. - - strSection = strValue.substr (1, strValue.length () - 2); - secResult[strSection] = Section::mapped_type (); - } - else - { - // Another line for Section. - if (bTrim) - boost::algorithm::trim (strValue); - - if (!strValue.empty ()) - secResult[strSection].push_back (strValue); - } - } - - return secResult; -} - -Section::mapped_type* SectionEntries (Section& secSource, std::string const& strSection) -{ - Section::iterator it; - Section::mapped_type* smtResult; - - it = secSource.find (strSection); - - if (it == secSource.end ()) - { - smtResult = 0; - } - else - { - //Section::mapped_type& vecEntries = it->second; - - smtResult = & (it->second); - } - - return smtResult; -} - -int SectionCount (Section& secSource, std::string const& strSection) -{ - Section::mapped_type* pmtEntries = SectionEntries (secSource, strSection); - - return pmtEntries ? pmtEntries->size () : 0; -} - -bool SectionSingleB (Section& secSource, std::string const& strSection, std::string& strValue) -{ - Section::mapped_type* pmtEntries = SectionEntries (secSource, strSection); - bool bSingle = pmtEntries && 1 == pmtEntries->size (); - - if (bSingle) - { - strValue = (*pmtEntries)[0]; - } - else if (pmtEntries) - { - WriteLog (lsWARNING, ParseSection) << boost::str (boost::format ("Section [%s]: requires 1 line not %d lines.") - % strSection - % pmtEntries->size ()); - } - - return bSingle; -} - -beast::StringPairArray -parseKeyValueSection (Section& secSource, beast::String const& strSection) -{ - beast::StringPairArray result; - - // yuck. - std::string const stdStrSection (strSection.toStdString ()); - - typedef Section::mapped_type Entries; - - Entries* const entries = SectionEntries (secSource, stdStrSection); - - if (entries != nullptr) - { - for (Entries::const_iterator iter = entries->begin (); iter != entries->end (); ++iter) - { - beast::String const line (iter->c_str ()); - - int const equalPos = line.indexOfChar ('='); - - if (equalPos != -1) - { - beast::String const key = line.substring (0, equalPos); - beast::String const value = line.substring (equalPos + 1, line.length ()); - - result.set (key, value); - } - } - } - - return result; -} - -} // ripple diff --git a/src/ripple/basics/utility/IniFile.h b/src/ripple/basics/utility/IniFile.h deleted file mode 100644 index 3f74968b9..000000000 --- a/src/ripple/basics/utility/IniFile.h +++ /dev/null @@ -1,48 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_INIFILE_H_INCLUDED -#define RIPPLE_INIFILE_H_INCLUDED - -#include - -namespace ripple { - -// VFALCO TODO Rename to IniFile and clean up -typedef std::map > Section; - -// VFALCO TODO Wrap this up in a class interface -// - -Section ParseSection (std::string const& strInput, const bool bTrim); -bool SectionSingleB (Section& secSource, std::string const& strSection, std::string& strValue); -int SectionCount (Section& secSource, std::string const& strSection); -Section::mapped_type* SectionEntries (Section& secSource, std::string const& strSection); - -/** Parse a section of lines as a key/value array. - - Each line is in the form =. - Spaces are considered part of the key and value. -*/ -beast::StringPairArray -parseKeyValueSection (Section& secSource, beast::String const& strSection); - -} // ripple - -#endif diff --git a/src/ripple/basics/utility/StringUtilities.h b/src/ripple/basics/utility/StringUtilities.h index 8b43b3e20..e3998dc29 100644 --- a/src/ripple/basics/utility/StringUtilities.h +++ b/src/ripple/basics/utility/StringUtilities.h @@ -23,22 +23,12 @@ #include #include #include +#include #include #include namespace ripple { -// String utility functions. - -// Ripple specific constant used for parsing qualities and other things -// -// VFALCO NOTE This does not belong here! -// NIKB TODO Why is this here instead of somewhere more sensible? What -// "other things" is this being used for? -#define QUALITY_ONE 1000000000 // 10e9 - -//------------------------------------------------------------------------------ - extern std::string strprintf (const char* format, ...); extern std::string urlEncode (std::string const& strSrc); diff --git a/src/ripple/module/app/book/Quality.h b/src/ripple/module/app/book/Quality.h index e3ffb7834..ae053c43c 100644 --- a/src/ripple/module/app/book/Quality.h +++ b/src/ripple/module/app/book/Quality.h @@ -29,6 +29,9 @@ namespace ripple { namespace core { +// Ripple specific constant used for parsing qualities and other things +#define QUALITY_ONE 1000000000 // 10e9 + /** Represents the logical ratio of output currency to input currency. Internally this is stored using a custom floating point representation, as the inverse of the ratio, so that quality will be descending in diff --git a/src/ripple/module/app/consensus/LedgerConsensus.cpp b/src/ripple/module/app/consensus/LedgerConsensus.cpp index fa88dacc2..6dc3372d4 100644 --- a/src/ripple/module/app/consensus/LedgerConsensus.cpp +++ b/src/ripple/module/app/consensus/LedgerConsensus.cpp @@ -17,6 +17,7 @@ */ //============================================================================== +#include #include #include diff --git a/src/ripple/module/app/ledger/Ledger.cpp b/src/ripple/module/app/ledger/Ledger.cpp index f949dc0f3..9c26df221 100644 --- a/src/ripple/module/app/ledger/Ledger.cpp +++ b/src/ripple/module/app/ledger/Ledger.cpp @@ -19,6 +19,8 @@ #include #include +#include +#include #include #include diff --git a/src/ripple/module/app/ledger/LedgerCleaner.cpp b/src/ripple/module/app/ledger/LedgerCleaner.cpp index 7a65b39d2..e6ddc2cd3 100644 --- a/src/ripple/module/app/ledger/LedgerCleaner.cpp +++ b/src/ripple/module/app/ledger/LedgerCleaner.cpp @@ -17,6 +17,7 @@ */ //============================================================================== +#include #include // namespace ripple { diff --git a/src/ripple/module/app/ledger/LedgerEntrySet.cpp b/src/ripple/module/app/ledger/LedgerEntrySet.cpp index 75ec07c64..0394a6be5 100644 --- a/src/ripple/module/app/ledger/LedgerEntrySet.cpp +++ b/src/ripple/module/app/ledger/LedgerEntrySet.cpp @@ -17,6 +17,8 @@ */ //============================================================================== +#include + namespace ripple { // #define META_DEBUG diff --git a/src/ripple/module/app/ledger/LedgerProposal.cpp b/src/ripple/module/app/ledger/LedgerProposal.cpp index c4f346061..3894e1952 100644 --- a/src/ripple/module/app/ledger/LedgerProposal.cpp +++ b/src/ripple/module/app/ledger/LedgerProposal.cpp @@ -17,6 +17,8 @@ */ //============================================================================== +#include + namespace ripple { LedgerProposal::LedgerProposal (uint256 const& pLgr, std::uint32_t seq, diff --git a/src/ripple/module/app/ledger/SerializedValidation.cpp b/src/ripple/module/app/ledger/SerializedValidation.cpp index a4d9abe59..620064cb4 100644 --- a/src/ripple/module/app/ledger/SerializedValidation.cpp +++ b/src/ripple/module/app/ledger/SerializedValidation.cpp @@ -17,6 +17,8 @@ */ //============================================================================== +#include + namespace ripple { SerializedValidation::SerializedValidation (SerializerIterator& sit, bool checkSignature) diff --git a/src/ripple/module/app/main/Application.cpp b/src/ripple/module/app/main/Application.cpp index eb5ec4400..1beb4d66d 100644 --- a/src/ripple/module/app/main/Application.cpp +++ b/src/ripple/module/app/main/Application.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -733,9 +734,8 @@ public: // if (!getConfig ().RUN_STANDALONE) m_peers = make_Overlay (m_mainIoPool, *m_resourceManager, *m_siteFiles, getConfig ().getModuleDatabasePath (), - *m_resolver, m_mainIoPool, m_peerSSLContext->get ()); - // add to Stoppable - add (*m_peers); + *m_resolver, m_mainIoPool, m_peerSSLContext->get ()); + add (*m_peers); // add to Stoppable // SSL context used for WebSocket connections. if (getConfig ().WEBSOCKET_SECURE) diff --git a/src/ripple/module/app/main/LoadManager.cpp b/src/ripple/module/app/main/LoadManager.cpp index edd58861a..2714b6771 100644 --- a/src/ripple/module/app/main/LoadManager.cpp +++ b/src/ripple/module/app/main/LoadManager.cpp @@ -17,6 +17,8 @@ */ //============================================================================== +#include +// REMOVE ASAP #include namespace ripple { diff --git a/src/ripple/module/app/main/LocalCredentials.cpp b/src/ripple/module/app/main/LocalCredentials.cpp index 44822f0cc..c7d78a45d 100644 --- a/src/ripple/module/app/main/LocalCredentials.cpp +++ b/src/ripple/module/app/main/LocalCredentials.cpp @@ -17,6 +17,8 @@ */ //============================================================================== +#include + namespace ripple { LocalCredentials::LocalCredentials () diff --git a/src/ripple/module/app/main/Main.cpp b/src/ripple/module/app/main/Main.cpp index 5a74f1f2d..37e5640bc 100644 --- a/src/ripple/module/app/main/Main.cpp +++ b/src/ripple/module/app/main/Main.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include diff --git a/src/ripple/module/app/main/NodeStoreScheduler.h b/src/ripple/module/app/main/NodeStoreScheduler.h index a016ddd70..c0a96de78 100644 --- a/src/ripple/module/app/main/NodeStoreScheduler.h +++ b/src/ripple/module/app/main/NodeStoreScheduler.h @@ -21,7 +21,7 @@ #define RIPPLE_APP_NODESTORESCHEDULER_H_INCLUDED #include -#include +#include #include #include diff --git a/src/ripple/module/app/misc/NetworkOPs.cpp b/src/ripple/module/app/misc/NetworkOPs.cpp index 880d44428..12d67a702 100644 --- a/src/ripple/module/app/misc/NetworkOPs.cpp +++ b/src/ripple/module/app/misc/NetworkOPs.cpp @@ -18,6 +18,9 @@ //============================================================================== #include +#include +#include +#include #include #include #include diff --git a/src/ripple/module/app/misc/SerializedTransaction.cpp b/src/ripple/module/app/misc/SerializedTransaction.cpp index 16c01313f..a7b8fada0 100644 --- a/src/ripple/module/app/misc/SerializedTransaction.cpp +++ b/src/ripple/module/app/misc/SerializedTransaction.cpp @@ -17,6 +17,7 @@ */ //============================================================================== +#include #include namespace ripple { diff --git a/src/ripple/module/app/paths/PathRequest.cpp b/src/ripple/module/app/paths/PathRequest.cpp index b4d9776ef..f4cac1cac 100644 --- a/src/ripple/module/app/paths/PathRequest.cpp +++ b/src/ripple/module/app/paths/PathRequest.cpp @@ -17,10 +17,11 @@ */ //============================================================================== -#include -#include - #include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/module/app/paths/cursor/ForwardLiquidityForAccount.cpp b/src/ripple/module/app/paths/cursor/ForwardLiquidityForAccount.cpp index 98da418a4..715a25760 100644 --- a/src/ripple/module/app/paths/cursor/ForwardLiquidityForAccount.cpp +++ b/src/ripple/module/app/paths/cursor/ForwardLiquidityForAccount.cpp @@ -17,6 +17,7 @@ */ //============================================================================== +#include #include namespace ripple { diff --git a/src/ripple/module/app/paths/cursor/ReverseLiquidityForAccount.cpp b/src/ripple/module/app/paths/cursor/ReverseLiquidityForAccount.cpp index 6fd6861db..feaee4687 100644 --- a/src/ripple/module/app/paths/cursor/ReverseLiquidityForAccount.cpp +++ b/src/ripple/module/app/paths/cursor/ReverseLiquidityForAccount.cpp @@ -17,6 +17,7 @@ */ //============================================================================== +#include #include namespace ripple { diff --git a/src/ripple/module/app/peers/UniqueNodeList.cpp b/src/ripple/module/app/peers/UniqueNodeList.cpp index 153e70c02..1eff80f40 100644 --- a/src/ripple/module/app/peers/UniqueNodeList.cpp +++ b/src/ripple/module/app/peers/UniqueNodeList.cpp @@ -17,8 +17,9 @@ */ //============================================================================== -#include #include +#include +#include #include #include #include @@ -1155,7 +1156,7 @@ private: if (!bReject) { - Section secSite = ParseSection (strSiteFile, true); + IniFileSections secSite = parseIniFile (strSiteFile, true); bool bGood = !err; if (bGood) @@ -1175,7 +1176,7 @@ private: // std::string strSite; - if (bGood && !SectionSingleB (secSite, SECTION_DOMAIN, strSite)) + if (bGood && !getSingleSection (secSite, SECTION_DOMAIN, strSite)) { bGood = false; @@ -1199,9 +1200,9 @@ private: // std::string strNodePublicKey; - if (bGood && !SectionSingleB (secSite, SECTION_PUBLIC_KEY, strNodePublicKey)) + if (bGood && !getSingleSection (secSite, SECTION_PUBLIC_KEY, strNodePublicKey)) { - // Bad [validation_public_key] Section. + // Bad [validation_public_key] IniFileSections. bGood = false; WriteLog (lsTRACE, UniqueNodeList) @@ -1431,8 +1432,9 @@ private: //-------------------------------------------------------------------------- - // Process Section [validators_url]. - void getValidatorsUrl (RippleAddress const& naNodePublic, Section secSite) + // Process IniFileSections [validators_url]. + void getValidatorsUrl (RippleAddress const& naNodePublic, + IniFileSections secSite) { std::string strValidatorsUrl; std::string strScheme; @@ -1440,7 +1442,7 @@ private: int iPort; std::string strPath; - if (SectionSingleB (secSite, SECTION_VALIDATORS_URL, strValidatorsUrl) + if (getSingleSection (secSite, SECTION_VALIDATORS_URL, strValidatorsUrl) && !strValidatorsUrl.empty () && parseUrl (strValidatorsUrl, strScheme, strDomain, iPort, strPath) && -1 == iPort @@ -1467,9 +1469,9 @@ private: //-------------------------------------------------------------------------- - // Process Section [ips_url]. - // If we have a Section with a single entry, fetch the url and process it. - void getIpsUrl (RippleAddress const& naNodePublic, Section secSite) + // Process IniFileSections [ips_url]. + // If we have a IniFileSections with a single entry, fetch the url and process it. + void getIpsUrl (RippleAddress const& naNodePublic, IniFileSections secSite) { std::string strIpsUrl; std::string strScheme; @@ -1477,7 +1479,7 @@ private: int iPort; std::string strPath; - if (SectionSingleB (secSite, SECTION_IPS_URL, strIpsUrl) + if (getSingleSection (secSite, SECTION_IPS_URL, strIpsUrl) && !strIpsUrl.empty () && parseUrl (strIpsUrl, strScheme, strDomain, iPort, strPath) && -1 == iPort @@ -1504,7 +1506,7 @@ private: //-------------------------------------------------------------------------- - // Given a Section with IPs, parse and persist it for a validator. + // Given a IniFileSections with IPs, parse and persist it for a validator. bool responseIps (std::string const& strSite, RippleAddress const& naNodePublic, const boost::system::error_code& err, int iStatus, std::string const& strIpsFile) { bool bReject = !err && iStatus != 200; @@ -1513,9 +1515,9 @@ private: { if (!err) { - Section secFile = ParseSection (strIpsFile, true); + IniFileSections secFile = parseIniFile (strIpsFile, true); - processIps (strSite, naNodePublic, SectionEntries (secFile, SECTION_IPS)); + processIps (strSite, naNodePublic, getIniFileSection (secFile, SECTION_IPS)); } fetchFinish (); @@ -1524,8 +1526,8 @@ private: return bReject; } - // After fetching a ripple.txt from a web site, given a Section with validators, parse and persist it. - bool responseValidators (std::string const& strValidatorsUrl, RippleAddress const& naNodePublic, Section secSite, std::string const& strSite, const boost::system::error_code& err, int iStatus, std::string const& strValidatorsFile) + // After fetching a ripple.txt from a web site, given a IniFileSections with validators, parse and persist it. + bool responseValidators (std::string const& strValidatorsUrl, RippleAddress const& naNodePublic, IniFileSections secSite, std::string const& strSite, const boost::system::error_code& err, int iStatus, std::string const& strValidatorsFile) { bool bReject = !err && iStatus != 200; @@ -1533,9 +1535,9 @@ private: { if (!err) { - Section secFile = ParseSection (strValidatorsFile, true); + IniFileSections secFile = parseIniFile (strValidatorsFile, true); - processValidators (strSite, strValidatorsUrl, naNodePublic, vsValidator, SectionEntries (secFile, SECTION_VALIDATORS)); + processValidators (strSite, strValidatorsUrl, naNodePublic, vsValidator, getIniFileSection (secFile, SECTION_VALIDATORS)); } getIpsUrl (naNodePublic, secSite); @@ -1550,7 +1552,7 @@ private: // Persist the IPs refered to by a Validator. // --> strSite: source of the IPs (for debugging) // --> naNodePublic: public key of the validating node. - void processIps (std::string const& strSite, RippleAddress const& naNodePublic, Section::mapped_type* pmtVecStrIps) + void processIps (std::string const& strSite, RippleAddress const& naNodePublic, IniFileSections::mapped_type* pmtVecStrIps) { auto db = getApp().getWalletDB ().getDB (); @@ -1622,7 +1624,7 @@ private: // --> strValidatorsSrc: source details for display // --> naNodePublic: remote source public key - not valid for local // --> vsWhy: reason for adding validator to SeedDomains or SeedNodes. - int processValidators (std::string const& strSite, std::string const& strValidatorsSrc, RippleAddress const& naNodePublic, ValidatorSource vsWhy, Section::mapped_type* pmtVecStrValidators) + int processValidators (std::string const& strSite, std::string const& strValidatorsSrc, RippleAddress const& naNodePublic, ValidatorSource vsWhy, IniFileSections::mapped_type* pmtVecStrValidators) { auto db = getApp().getWalletDB ().getDB (); std::string strNodePublic = naNodePublic.isValid () ? naNodePublic.humanNodePublic () : strValidatorsSrc; @@ -1722,24 +1724,24 @@ private: //-------------------------------------------------------------------------- // Process a ripple.txt. - void processFile (std::string const& strDomain, RippleAddress const& naNodePublic, Section secSite) + void processFile (std::string const& strDomain, RippleAddress const& naNodePublic, IniFileSections secSite) { // // Process Validators // - processValidators (strDomain, NODE_FILE_NAME, naNodePublic, vsReferral, SectionEntries (secSite, SECTION_VALIDATORS)); + processValidators (strDomain, NODE_FILE_NAME, naNodePublic, vsReferral, getIniFileSection (secSite, SECTION_VALIDATORS)); // // Process ips // - processIps (strDomain, naNodePublic, SectionEntries (secSite, SECTION_IPS)); + processIps (strDomain, naNodePublic, getIniFileSection (secSite, SECTION_IPS)); // // Process currencies // - Section::mapped_type* pvCurrencies; + IniFileSections::mapped_type* pvCurrencies; - if ((pvCurrencies = SectionEntries (secSite, SECTION_CURRENCIES)) && pvCurrencies->size ()) + if ((pvCurrencies = getIniFileSection (secSite, SECTION_CURRENCIES)) && pvCurrencies->size ()) { // XXX Process currencies. WriteLog (lsWARNING, UniqueNodeList) << "Ignoring currencies: not implemented."; @@ -1995,9 +1997,9 @@ private: // void nodeProcess (std::string const& strSite, std::string const& strValidators, std::string const& strSource) { - Section secValidators = ParseSection (strValidators, true); + IniFileSections secValidators = parseIniFile (strValidators, true); - Section::mapped_type* pmtEntries = SectionEntries (secValidators, SECTION_VALIDATORS); + IniFileSections::mapped_type* pmtEntries = getIniFileSection (secValidators, SECTION_VALIDATORS); if (pmtEntries) { diff --git a/src/ripple/module/app/transactors/SetAccount.cpp b/src/ripple/module/app/transactors/SetAccount.cpp index 69987c322..7ce1bbccf 100644 --- a/src/ripple/module/app/transactors/SetAccount.cpp +++ b/src/ripple/module/app/transactors/SetAccount.cpp @@ -17,6 +17,8 @@ */ //============================================================================== +#include + namespace ripple { class SetAccount diff --git a/src/ripple/module/app/transactors/Transactor.cpp b/src/ripple/module/app/transactors/Transactor.cpp index cb0040ab7..05d779d12 100644 --- a/src/ripple/module/app/transactors/Transactor.cpp +++ b/src/ripple/module/app/transactors/Transactor.cpp @@ -17,6 +17,7 @@ */ //============================================================================== +#include #include namespace ripple { diff --git a/src/ripple/module/core/functional/Config.cpp b/src/ripple/module/core/Config.cpp similarity index 69% rename from src/ripple/module/core/functional/Config.cpp rename to src/ripple/module/core/Config.cpp index 91b1d7151..a13a564c8 100644 --- a/src/ripple/module/core/functional/Config.cpp +++ b/src/ripple/module/core/Config.cpp @@ -17,7 +17,8 @@ */ //============================================================================== -#include +#include +#include #include namespace ripple { @@ -33,6 +34,137 @@ namespace ripple { #define DEFAULT_FEE_OFFER DEFAULT_FEE_DEFAULT #define DEFAULT_FEE_OPERATION 1 +#define SECTION_DEFAULT_NAME "" + +IniFileSections +parseIniFile (std::string const& strInput, const bool bTrim) +{ + std::string strData (strInput); + std::vector vLines; + IniFileSections secResult; + + // Convert DOS format to unix. + boost::algorithm::replace_all (strData, "\r\n", "\n"); + + // Convert MacOS format to unix. + boost::algorithm::replace_all (strData, "\r", "\n"); + + boost::algorithm::split (vLines, strData, + boost::algorithm::is_any_of ("\n")); + + // Set the default Section name. + std::string strSection = SECTION_DEFAULT_NAME; + + // Initialize the default Section. + secResult[strSection] = IniFileSections::mapped_type (); + + // Parse each line. + BOOST_FOREACH (std::string & strValue, vLines) + { + if (strValue.empty () || strValue[0] == '#') + { + // Blank line or comment, do nothing. + } + else if (strValue[0] == '[' && strValue[strValue.length () - 1] == ']') + { + // New Section. + + strSection = strValue.substr (1, strValue.length () - 2); + secResult[strSection] = IniFileSections::mapped_type (); + } + else + { + // Another line for Section. + if (bTrim) + boost::algorithm::trim (strValue); + + if (!strValue.empty ()) + secResult[strSection].push_back (strValue); + } + } + + return secResult; +} + +IniFileSections::mapped_type* +getIniFileSection (IniFileSections& secSource, std::string const& strSection) +{ + IniFileSections::iterator it; + IniFileSections::mapped_type* smtResult; + it = secSource.find (strSection); + if (it == secSource.end ()) + smtResult = 0; + else + smtResult = & (it->second); + return smtResult; +} + +int +countSectionEntries (IniFileSections& secSource, std::string const& strSection) +{ + IniFileSections::mapped_type* pmtEntries = + getIniFileSection (secSource, strSection); + + return pmtEntries ? pmtEntries->size () : 0; +} + +bool getSingleSection (IniFileSections& secSource, + std::string const& strSection, std::string& strValue) +{ + IniFileSections::mapped_type* pmtEntries = + getIniFileSection (secSource, strSection); + bool bSingle = pmtEntries && 1 == pmtEntries->size (); + + if (bSingle) + { + strValue = (*pmtEntries)[0]; + } + else if (pmtEntries) + { + WriteLog (lsWARNING, parseIniFile) << boost::str (boost::format ("Section [%s]: requires 1 line not %d lines.") + % strSection + % pmtEntries->size ()); + } + + return bSingle; +} + +beast::StringPairArray +parseKeyValueSection (IniFileSections& secSource, + beast::String const& strSection) +{ + beast::StringPairArray result; + + // yuck. + std::string const stdStrSection (strSection.toStdString ()); + + typedef IniFileSections::mapped_type Entries; + + Entries* const entries = getIniFileSection (secSource, stdStrSection); + + if (entries != nullptr) + { + for (Entries::const_iterator iter = entries->begin (); + iter != entries->end (); ++iter) + { + beast::String const line (iter->c_str ()); + + int const equalPos = line.indexOfChar ('='); + + if (equalPos != -1) + { + beast::String const key = line.substring (0, equalPos); + beast::String const value = line.substring (equalPos + 1, + line.length ()); + + result.set (key, value); + } + } + } + + return result; +} + /** Parses a set of strings into IP::Endpoint Strings which fail to parse are not included in the output. If a stream is provided, human readable diagnostic error messages are written for each @@ -42,7 +174,8 @@ namespace ripple { @param last The one-past-the-end of the string input sequence */ template -void parseAddresses (OutputSequence& out, InputIterator first, InputIterator last, +void +parseAddresses (OutputSequence& out, InputIterator first, InputIterator last, beast::Journal::Stream stream = beast::Journal::Stream ()) { while (first != last) @@ -50,7 +183,8 @@ void parseAddresses (OutputSequence& out, InputIterator first, InputIterator las auto const str (*first); ++first; { - beast::IP::Endpoint const addr (beast::IP::Endpoint::from_string (str)); + beast::IP::Endpoint const addr ( + beast::IP::Endpoint::from_string (str)); if (! is_unspecified (addr)) { out.push_back (addr); @@ -58,7 +192,8 @@ void parseAddresses (OutputSequence& out, InputIterator first, InputIterator las } } { - beast::IP::Endpoint const addr (beast::IP::Endpoint::from_string_altform (str)); + beast::IP::Endpoint const addr ( + beast::IP::Endpoint::from_string_altform (str)); if (! is_unspecified (addr)) { out.push_back (addr); @@ -257,9 +392,7 @@ void Config::load () } else { - std::string strConfigFile; - - strConfigFile.assign ((std::istreambuf_iterator (ifsConfig)), + file_contents.assign ((std::istreambuf_iterator (ifsConfig)), std::istreambuf_iterator ()); if (ifsConfig.bad ()) @@ -268,48 +401,48 @@ void Config::load () } else { - Section secConfig = ParseSection (strConfigFile, true); + IniFileSections secConfig = parseIniFile (file_contents, true); std::string strTemp; // XXX Leak - Section::mapped_type* smtTmp; + IniFileSections::mapped_type* smtTmp; - smtTmp = SectionEntries (secConfig, SECTION_VALIDATORS); + smtTmp = getIniFileSection (secConfig, SECTION_VALIDATORS); if (smtTmp) { validators = *smtTmp; } - smtTmp = SectionEntries (secConfig, SECTION_CLUSTER_NODES); + smtTmp = getIniFileSection (secConfig, SECTION_CLUSTER_NODES); if (smtTmp) { CLUSTER_NODES = *smtTmp; } - smtTmp = SectionEntries (secConfig, SECTION_IPS); + smtTmp = getIniFileSection (secConfig, SECTION_IPS); if (smtTmp) { IPS = *smtTmp; } - smtTmp = SectionEntries (secConfig, SECTION_IPS_FIXED); + smtTmp = getIniFileSection (secConfig, SECTION_IPS_FIXED); if (smtTmp) { IPS_FIXED = *smtTmp; } - smtTmp = SectionEntries (secConfig, SECTION_SNTP); + smtTmp = getIniFileSection (secConfig, SECTION_SNTP); if (smtTmp) { SNTP_SERVERS = *smtTmp; } - smtTmp = SectionEntries (secConfig, SECTION_RPC_STARTUP); + smtTmp = getIniFileSection (secConfig, SECTION_RPC_STARTUP); if (smtTmp) { @@ -321,27 +454,28 @@ void Config::load () Json::Value jvCommand; if (!jrReader.parse (strJson, jvCommand)) - throw std::runtime_error (boost::str (boost::format ("Couldn't parse [" SECTION_RPC_STARTUP "] command: %s") % strJson)); + throw std::runtime_error ( + boost::str (boost::format ( + "Couldn't parse [" SECTION_RPC_STARTUP "] command: %s") % strJson)); RPC_STARTUP.append (jvCommand); } } - if (SectionSingleB (secConfig, SECTION_DATABASE_PATH, DATABASE_PATH)) + if (getSingleSection (secConfig, SECTION_DATABASE_PATH, DATABASE_PATH)) DATA_DIR = DATABASE_PATH; + (void) getSingleSection (secConfig, SECTION_VALIDATORS_SITE, VALIDATORS_SITE); - (void) SectionSingleB (secConfig, SECTION_VALIDATORS_SITE, VALIDATORS_SITE); + (void) getSingleSection (secConfig, SECTION_PEER_IP, PEER_IP); - (void) SectionSingleB (secConfig, SECTION_PEER_IP, PEER_IP); - - if (SectionSingleB (secConfig, SECTION_PEER_PRIVATE, strTemp)) + if (getSingleSection (secConfig, SECTION_PEER_PRIVATE, strTemp)) PEER_PRIVATE = beast::lexicalCastThrow (strTemp); - if (SectionSingleB (secConfig, SECTION_PEERS_MAX, strTemp)) + if (getSingleSection (secConfig, SECTION_PEERS_MAX, strTemp)) PEERS_MAX = beast::lexicalCastThrow (strTemp); - smtTmp = SectionEntries (secConfig, SECTION_RPC_ADMIN_ALLOW); + smtTmp = getIniFileSection (secConfig, SECTION_RPC_ADMIN_ALLOW); if (smtTmp) { @@ -353,11 +487,11 @@ void Config::load () parsedAddresses.cbegin (), parsedAddresses.cend ()); } - (void) SectionSingleB (secConfig, SECTION_RPC_ADMIN_PASSWORD, RPC_ADMIN_PASSWORD); - (void) SectionSingleB (secConfig, SECTION_RPC_ADMIN_USER, RPC_ADMIN_USER); - (void) SectionSingleB (secConfig, SECTION_RPC_IP, m_rpcIP); - (void) SectionSingleB (secConfig, SECTION_RPC_PASSWORD, RPC_PASSWORD); - (void) SectionSingleB (secConfig, SECTION_RPC_USER, RPC_USER); + (void) getSingleSection (secConfig, SECTION_RPC_ADMIN_PASSWORD, RPC_ADMIN_PASSWORD); + (void) getSingleSection (secConfig, SECTION_RPC_ADMIN_USER, RPC_ADMIN_USER); + (void) getSingleSection (secConfig, SECTION_RPC_IP, m_rpcIP); + (void) getSingleSection (secConfig, SECTION_RPC_PASSWORD, RPC_PASSWORD); + (void) getSingleSection (secConfig, SECTION_RPC_USER, RPC_USER); insightSettings = parseKeyValueSection (secConfig, SECTION_INSIGHT); @@ -374,10 +508,10 @@ void Config::load () importNodeDatabase = parseKeyValueSection ( secConfig, ConfigSection::importNodeDatabase ()); - if (SectionSingleB (secConfig, SECTION_PEER_PORT, strTemp)) + if (getSingleSection (secConfig, SECTION_PEER_PORT, strTemp)) peerListeningPort = beast::lexicalCastThrow (strTemp); - if (SectionSingleB (secConfig, SECTION_PEER_PROXY_PORT, strTemp)) + if (getSingleSection (secConfig, SECTION_PEER_PROXY_PORT, strTemp)) { peerPROXYListeningPort = beast::lexicalCastThrow (strTemp); @@ -394,16 +528,16 @@ void Config::load () // //--------------------------------------- - if (SectionSingleB (secConfig, SECTION_RPC_PORT, strTemp)) + if (getSingleSection (secConfig, SECTION_RPC_PORT, strTemp)) m_rpcPort = beast::lexicalCastThrow (strTemp); - if (SectionSingleB (secConfig, "ledger_creator" , strTemp)) + if (getSingleSection (secConfig, "ledger_creator" , strTemp)) LEDGER_CREATOR = beast::lexicalCastThrow (strTemp); - if (SectionSingleB (secConfig, SECTION_RPC_ALLOW_REMOTE, strTemp)) + if (getSingleSection (secConfig, SECTION_RPC_ALLOW_REMOTE, strTemp)) RPC_ALLOW_REMOTE = beast::lexicalCastThrow (strTemp); - if (SectionSingleB (secConfig, SECTION_NODE_SIZE, strTemp)) + if (getSingleSection (secConfig, SECTION_NODE_SIZE, strTemp)) { if (strTemp == "tiny") NODE_SIZE = 0; @@ -426,55 +560,55 @@ void Config::load () } } - if (SectionSingleB (secConfig, SECTION_ELB_SUPPORT, strTemp)) + if (getSingleSection (secConfig, SECTION_ELB_SUPPORT, strTemp)) ELB_SUPPORT = beast::lexicalCastThrow (strTemp); - (void) SectionSingleB (secConfig, SECTION_WEBSOCKET_IP, WEBSOCKET_IP); + (void) getSingleSection (secConfig, SECTION_WEBSOCKET_IP, WEBSOCKET_IP); - if (SectionSingleB (secConfig, SECTION_WEBSOCKET_PORT, strTemp)) + if (getSingleSection (secConfig, SECTION_WEBSOCKET_PORT, strTemp)) WEBSOCKET_PORT = beast::lexicalCastThrow (strTemp); - (void) SectionSingleB (secConfig, SECTION_WEBSOCKET_PUBLIC_IP, WEBSOCKET_PUBLIC_IP); + (void) getSingleSection (secConfig, SECTION_WEBSOCKET_PUBLIC_IP, WEBSOCKET_PUBLIC_IP); - if (SectionSingleB (secConfig, SECTION_WEBSOCKET_PUBLIC_PORT, strTemp)) + if (getSingleSection (secConfig, SECTION_WEBSOCKET_PUBLIC_PORT, strTemp)) WEBSOCKET_PUBLIC_PORT = beast::lexicalCastThrow (strTemp); - (void) SectionSingleB (secConfig, SECTION_WEBSOCKET_PROXY_IP, WEBSOCKET_PROXY_IP); + (void) getSingleSection (secConfig, SECTION_WEBSOCKET_PROXY_IP, WEBSOCKET_PROXY_IP); - if (SectionSingleB (secConfig, SECTION_WEBSOCKET_PROXY_PORT, strTemp)) + if (getSingleSection (secConfig, SECTION_WEBSOCKET_PROXY_PORT, strTemp)) WEBSOCKET_PROXY_PORT = beast::lexicalCastThrow (strTemp); - if (SectionSingleB (secConfig, SECTION_WEBSOCKET_SECURE, strTemp)) + if (getSingleSection (secConfig, SECTION_WEBSOCKET_SECURE, strTemp)) WEBSOCKET_SECURE = beast::lexicalCastThrow (strTemp); - if (SectionSingleB (secConfig, SECTION_WEBSOCKET_PUBLIC_SECURE, strTemp)) + if (getSingleSection (secConfig, SECTION_WEBSOCKET_PUBLIC_SECURE, strTemp)) WEBSOCKET_PUBLIC_SECURE = beast::lexicalCastThrow (strTemp); - if (SectionSingleB (secConfig, SECTION_WEBSOCKET_PROXY_SECURE, strTemp)) + if (getSingleSection (secConfig, SECTION_WEBSOCKET_PROXY_SECURE, strTemp)) WEBSOCKET_PROXY_SECURE = beast::lexicalCastThrow (strTemp); - if (SectionSingleB (secConfig, SECTION_WEBSOCKET_PING_FREQ, strTemp)) + if (getSingleSection (secConfig, SECTION_WEBSOCKET_PING_FREQ, strTemp)) WEBSOCKET_PING_FREQ = beast::lexicalCastThrow (strTemp); - SectionSingleB (secConfig, SECTION_WEBSOCKET_SSL_CERT, WEBSOCKET_SSL_CERT); - SectionSingleB (secConfig, SECTION_WEBSOCKET_SSL_CHAIN, WEBSOCKET_SSL_CHAIN); - SectionSingleB (secConfig, SECTION_WEBSOCKET_SSL_KEY, WEBSOCKET_SSL_KEY); + getSingleSection (secConfig, SECTION_WEBSOCKET_SSL_CERT, WEBSOCKET_SSL_CERT); + getSingleSection (secConfig, SECTION_WEBSOCKET_SSL_CHAIN, WEBSOCKET_SSL_CHAIN); + getSingleSection (secConfig, SECTION_WEBSOCKET_SSL_KEY, WEBSOCKET_SSL_KEY); - if (SectionSingleB (secConfig, SECTION_RPC_SECURE, strTemp)) + if (getSingleSection (secConfig, SECTION_RPC_SECURE, strTemp)) RPC_SECURE = beast::lexicalCastThrow (strTemp); - SectionSingleB (secConfig, SECTION_RPC_SSL_CERT, RPC_SSL_CERT); - SectionSingleB (secConfig, SECTION_RPC_SSL_CHAIN, RPC_SSL_CHAIN); - SectionSingleB (secConfig, SECTION_RPC_SSL_KEY, RPC_SSL_KEY); + getSingleSection (secConfig, SECTION_RPC_SSL_CERT, RPC_SSL_CERT); + getSingleSection (secConfig, SECTION_RPC_SSL_CHAIN, RPC_SSL_CHAIN); + getSingleSection (secConfig, SECTION_RPC_SSL_KEY, RPC_SSL_KEY); - SectionSingleB (secConfig, SECTION_SSL_VERIFY_FILE, SSL_VERIFY_FILE); - SectionSingleB (secConfig, SECTION_SSL_VERIFY_DIR, SSL_VERIFY_DIR); + getSingleSection (secConfig, SECTION_SSL_VERIFY_FILE, SSL_VERIFY_FILE); + getSingleSection (secConfig, SECTION_SSL_VERIFY_DIR, SSL_VERIFY_DIR); - if (SectionSingleB (secConfig, SECTION_SSL_VERIFY, strTemp)) + if (getSingleSection (secConfig, SECTION_SSL_VERIFY, strTemp)) SSL_VERIFY = beast::lexicalCastThrow (strTemp); - if (SectionSingleB (secConfig, SECTION_VALIDATION_SEED, strTemp)) + if (getSingleSection (secConfig, SECTION_VALIDATION_SEED, strTemp)) { VALIDATION_SEED.setSeedGeneric (strTemp); @@ -485,7 +619,7 @@ void Config::load () } } - if (SectionSingleB (secConfig, SECTION_NODE_SEED, strTemp)) + if (getSingleSection (secConfig, SECTION_NODE_SEED, strTemp)) { NODE_SEED.setSeedGeneric (strTemp); @@ -496,40 +630,40 @@ void Config::load () } } - (void) SectionSingleB (secConfig, SECTION_PEER_SSL_CIPHER_LIST, PEER_SSL_CIPHER_LIST); + (void) getSingleSection (secConfig, SECTION_PEER_SSL_CIPHER_LIST, PEER_SSL_CIPHER_LIST); - if (SectionSingleB (secConfig, SECTION_PEER_SCAN_INTERVAL_MIN, strTemp)) + if (getSingleSection (secConfig, SECTION_PEER_SCAN_INTERVAL_MIN, strTemp)) // Minimum for min is 60 seconds. PEER_SCAN_INTERVAL_MIN = std::max (60, beast::lexicalCastThrow (strTemp)); - if (SectionSingleB (secConfig, SECTION_PEER_START_MAX, strTemp)) + if (getSingleSection (secConfig, SECTION_PEER_START_MAX, strTemp)) PEER_START_MAX = std::max (1, beast::lexicalCastThrow (strTemp)); - if (SectionSingleB (secConfig, SECTION_PEER_CONNECT_LOW_WATER, strTemp)) + if (getSingleSection (secConfig, SECTION_PEER_CONNECT_LOW_WATER, strTemp)) PEER_CONNECT_LOW_WATER = std::max (1, beast::lexicalCastThrow (strTemp)); - if (SectionSingleB (secConfig, SECTION_NETWORK_QUORUM, strTemp)) + if (getSingleSection (secConfig, SECTION_NETWORK_QUORUM, strTemp)) NETWORK_QUORUM = beast::lexicalCastThrow (strTemp); - if (SectionSingleB (secConfig, SECTION_VALIDATION_QUORUM, strTemp)) + if (getSingleSection (secConfig, SECTION_VALIDATION_QUORUM, strTemp)) VALIDATION_QUORUM = std::max (0, beast::lexicalCastThrow (strTemp)); - if (SectionSingleB (secConfig, SECTION_FEE_ACCOUNT_RESERVE, strTemp)) + if (getSingleSection (secConfig, SECTION_FEE_ACCOUNT_RESERVE, strTemp)) FEE_ACCOUNT_RESERVE = beast::lexicalCastThrow (strTemp); - if (SectionSingleB (secConfig, SECTION_FEE_OWNER_RESERVE, strTemp)) + if (getSingleSection (secConfig, SECTION_FEE_OWNER_RESERVE, strTemp)) FEE_OWNER_RESERVE = beast::lexicalCastThrow (strTemp); - if (SectionSingleB (secConfig, SECTION_FEE_OFFER, strTemp)) + if (getSingleSection (secConfig, SECTION_FEE_OFFER, strTemp)) FEE_OFFER = beast::lexicalCastThrow (strTemp); - if (SectionSingleB (secConfig, SECTION_FEE_DEFAULT, strTemp)) + if (getSingleSection (secConfig, SECTION_FEE_DEFAULT, strTemp)) FEE_DEFAULT = beast::lexicalCastThrow (strTemp); - if (SectionSingleB (secConfig, SECTION_FEE_OPERATION, strTemp)) + if (getSingleSection (secConfig, SECTION_FEE_OPERATION, strTemp)) FEE_CONTRACT_OPERATION = beast::lexicalCastThrow (strTemp); - if (SectionSingleB (secConfig, SECTION_LEDGER_HISTORY, strTemp)) + if (getSingleSection (secConfig, SECTION_LEDGER_HISTORY, strTemp)) { boost::to_lower (strTemp); @@ -540,7 +674,7 @@ void Config::load () else LEDGER_HISTORY = beast::lexicalCastThrow (strTemp); } - if (SectionSingleB (secConfig, SECTION_FETCH_DEPTH, strTemp)) + if (getSingleSection (secConfig, SECTION_FETCH_DEPTH, strTemp)) { boost::to_lower (strTemp); @@ -555,30 +689,30 @@ void Config::load () FETCH_DEPTH = 10; } - if (SectionSingleB (secConfig, SECTION_PATH_SEARCH_OLD, strTemp)) + if (getSingleSection (secConfig, SECTION_PATH_SEARCH_OLD, strTemp)) PATH_SEARCH_OLD = beast::lexicalCastThrow (strTemp); - if (SectionSingleB (secConfig, SECTION_PATH_SEARCH, strTemp)) + if (getSingleSection (secConfig, SECTION_PATH_SEARCH, strTemp)) PATH_SEARCH = beast::lexicalCastThrow (strTemp); - if (SectionSingleB (secConfig, SECTION_PATH_SEARCH_FAST, strTemp)) + if (getSingleSection (secConfig, SECTION_PATH_SEARCH_FAST, strTemp)) PATH_SEARCH_FAST = beast::lexicalCastThrow (strTemp); - if (SectionSingleB (secConfig, SECTION_PATH_SEARCH_MAX, strTemp)) + if (getSingleSection (secConfig, SECTION_PATH_SEARCH_MAX, strTemp)) PATH_SEARCH_MAX = beast::lexicalCastThrow (strTemp); - if (SectionSingleB (secConfig, SECTION_ACCOUNT_PROBE_MAX, strTemp)) + if (getSingleSection (secConfig, SECTION_ACCOUNT_PROBE_MAX, strTemp)) ACCOUNT_PROBE_MAX = beast::lexicalCastThrow (strTemp); - (void) SectionSingleB (secConfig, SECTION_SMS_FROM, SMS_FROM); - (void) SectionSingleB (secConfig, SECTION_SMS_KEY, SMS_KEY); - (void) SectionSingleB (secConfig, SECTION_SMS_SECRET, SMS_SECRET); - (void) SectionSingleB (secConfig, SECTION_SMS_TO, SMS_TO); - (void) SectionSingleB (secConfig, SECTION_SMS_URL, SMS_URL); + (void) getSingleSection (secConfig, SECTION_SMS_FROM, SMS_FROM); + (void) getSingleSection (secConfig, SECTION_SMS_KEY, SMS_KEY); + (void) getSingleSection (secConfig, SECTION_SMS_SECRET, SMS_SECRET); + (void) getSingleSection (secConfig, SECTION_SMS_TO, SMS_TO); + (void) getSingleSection (secConfig, SECTION_SMS_URL, SMS_URL); - if (SectionSingleB (secConfig, SECTION_VALIDATORS_FILE, strTemp)) + if (getSingleSection (secConfig, SECTION_VALIDATORS_FILE, strTemp)) { VALIDATORS_FILE = strTemp; } - if (SectionSingleB (secConfig, SECTION_DEBUG_LOGFILE, strTemp)) + if (getSingleSection (secConfig, SECTION_DEBUG_LOGFILE, strTemp)) DEBUG_LOGFILE = strTemp; } } diff --git a/src/ripple/module/core/functional/Config.h b/src/ripple/module/core/Config.h similarity index 90% rename from src/ripple/module/core/functional/Config.h rename to src/ripple/module/core/Config.h index bcc76503b..bef0c0bbc 100644 --- a/src/ripple/module/core/functional/Config.h +++ b/src/ripple/module/core/Config.h @@ -22,14 +22,61 @@ #include #include -#include #include +#include +#include #include #include +#include #include +#include namespace ripple { +typedef std::map> IniFileSections; + +IniFileSections +parseIniFile (std::string const& strInput, const bool bTrim); + +bool +getSingleSection (IniFileSections& secSource, + std::string const& strSection, std::string& strValue); + +int +countSectionEntries (IniFileSections& secSource, std::string const& strSection); + +IniFileSections::mapped_type* +getIniFileSection (IniFileSections& secSource, std::string const& strSection); + +/** Parse a section of lines as a key/value array. + Each line is in the form =. + Spaces are considered part of the key and value. +*/ +// DEPRECATED +beast::StringPairArray +parseKeyValueSection (IniFileSections& secSource, + beast::String const& strSection); + +//------------------------------------------------------------------------------ + +/** Holds unparsed configuration information. + The raw data sections are processed with intermediate parsers specific + to each module instead of being all parsed in a central location. +*/ +class BasicConfig +{ +public: + /** The entire, unprocessed content of the config file. + Normally clients should not need to look at this. + */ + std::string file_contents; + + /** Preprocessed contents of each section. */ + //std::map -#include +#include #include namespace ripple { diff --git a/src/ripple/module/core/functional/JobQueue.cpp b/src/ripple/module/core/JobQueue.cpp similarity index 98% rename from src/ripple/module/core/functional/JobQueue.cpp rename to src/ripple/module/core/JobQueue.cpp index b4c184a93..2d0ec6b16 100644 --- a/src/ripple/module/core/functional/JobQueue.cpp +++ b/src/ripple/module/core/JobQueue.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/module/core/functional/JobQueue.h b/src/ripple/module/core/JobQueue.h similarity index 98% rename from src/ripple/module/core/functional/JobQueue.h rename to src/ripple/module/core/JobQueue.h index 677a4d862..0266c44ed 100644 --- a/src/ripple/module/core/functional/JobQueue.h +++ b/src/ripple/module/core/JobQueue.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_CORE_JOBQUEUE_H_INCLUDED #define RIPPLE_CORE_JOBQUEUE_H_INCLUDED -#include +#include #include #include diff --git a/src/ripple/module/core/functional/JobTypeData.h b/src/ripple/module/core/JobTypeData.h similarity index 97% rename from src/ripple/module/core/functional/JobTypeData.h rename to src/ripple/module/core/JobTypeData.h index a9ba98304..99fcc2e25 100644 --- a/src/ripple/module/core/functional/JobTypeData.h +++ b/src/ripple/module/core/JobTypeData.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_CORE_JOBTYPEDATA_H_INCLUDED #define RIPPLE_CORE_JOBTYPEDATA_H_INCLUDED -#include +#include namespace ripple { diff --git a/src/ripple/module/core/functional/JobTypeInfo.h b/src/ripple/module/core/JobTypeInfo.h similarity index 100% rename from src/ripple/module/core/functional/JobTypeInfo.h rename to src/ripple/module/core/JobTypeInfo.h diff --git a/src/ripple/module/core/functional/JobTypes.h b/src/ripple/module/core/JobTypes.h similarity index 98% rename from src/ripple/module/core/functional/JobTypes.h rename to src/ripple/module/core/JobTypes.h index 719c00c14..6a423159e 100644 --- a/src/ripple/module/core/functional/JobTypes.h +++ b/src/ripple/module/core/JobTypes.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_JOBTYPES_H_INCLUDED #define RIPPLE_JOBTYPES_H_INCLUDED -#include -#include +#include +#include #include namespace ripple diff --git a/src/ripple/module/core/functional/LoadEvent.cpp b/src/ripple/module/core/LoadEvent.cpp similarity index 100% rename from src/ripple/module/core/functional/LoadEvent.cpp rename to src/ripple/module/core/LoadEvent.cpp diff --git a/src/ripple/module/core/functional/LoadEvent.h b/src/ripple/module/core/LoadEvent.h similarity index 100% rename from src/ripple/module/core/functional/LoadEvent.h rename to src/ripple/module/core/LoadEvent.h diff --git a/src/ripple/module/core/functional/LoadFeeTrack.h b/src/ripple/module/core/LoadFeeTrack.h similarity index 100% rename from src/ripple/module/core/functional/LoadFeeTrack.h rename to src/ripple/module/core/LoadFeeTrack.h diff --git a/src/ripple/module/core/functional/LoadFeeTrackImp.cpp b/src/ripple/module/core/LoadFeeTrackImp.cpp similarity index 100% rename from src/ripple/module/core/functional/LoadFeeTrackImp.cpp rename to src/ripple/module/core/LoadFeeTrackImp.cpp diff --git a/src/ripple/module/core/functional/LoadFeeTrackImp.h b/src/ripple/module/core/LoadFeeTrackImp.h similarity index 99% rename from src/ripple/module/core/functional/LoadFeeTrackImp.h rename to src/ripple/module/core/LoadFeeTrackImp.h index feee28a69..b2014764f 100644 --- a/src/ripple/module/core/functional/LoadFeeTrackImp.h +++ b/src/ripple/module/core/LoadFeeTrackImp.h @@ -21,6 +21,7 @@ #define RIPPLE_LOADFEETRACKIMP_H_INCLUDED #include +#include namespace ripple { diff --git a/src/ripple/module/core/functional/LoadMonitor.cpp b/src/ripple/module/core/LoadMonitor.cpp similarity index 100% rename from src/ripple/module/core/functional/LoadMonitor.cpp rename to src/ripple/module/core/LoadMonitor.cpp diff --git a/src/ripple/module/core/functional/LoadMonitor.h b/src/ripple/module/core/LoadMonitor.h similarity index 97% rename from src/ripple/module/core/functional/LoadMonitor.h rename to src/ripple/module/core/LoadMonitor.h index bcf927ad1..782dcde7b 100644 --- a/src/ripple/module/core/functional/LoadMonitor.h +++ b/src/ripple/module/core/LoadMonitor.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_LOADMONITOR_H_INCLUDED #define RIPPLE_LOADMONITOR_H_INCLUDED -#include +#include namespace ripple { diff --git a/src/ripple/module/net/basics/HTTPClient.cpp b/src/ripple/module/net/basics/HTTPClient.cpp index 3721ce19c..0fef0534e 100644 --- a/src/ripple/module/net/basics/HTTPClient.cpp +++ b/src/ripple/module/net/basics/HTTPClient.cpp @@ -17,9 +17,10 @@ */ //============================================================================== -#include +#include #include #include +#include namespace ripple { diff --git a/src/ripple/module/net/basics/SNTPClient.h b/src/ripple/module/net/basics/SNTPClient.h index 451cbf465..460d303f3 100644 --- a/src/ripple/module/net/basics/SNTPClient.h +++ b/src/ripple/module/net/basics/SNTPClient.h @@ -20,6 +20,8 @@ #ifndef RIPPLE_NET_BASICS_SNTPCLIENT_H_INCLUDED #define RIPPLE_NET_BASICS_SNTPCLIENT_H_INCLUDED +#include + namespace ripple { class SNTPClient : public beast::Stoppable diff --git a/src/ripple/module/net/rpc/InfoSub.h b/src/ripple/module/net/rpc/InfoSub.h index bdd8b2656..f212d3b70 100644 --- a/src/ripple/module/net/rpc/InfoSub.h +++ b/src/ripple/module/net/rpc/InfoSub.h @@ -20,6 +20,8 @@ #ifndef RIPPLE_NET_RPC_INFOSUB_H_INCLUDED #define RIPPLE_NET_RPC_INFOSUB_H_INCLUDED +#include + namespace ripple { // Operations that clients may wish to perform against the network diff --git a/src/ripple/module/net/rpc/RPCSub.h b/src/ripple/module/net/rpc/RPCSub.h index ca62e774e..d659f10f0 100644 --- a/src/ripple/module/net/rpc/RPCSub.h +++ b/src/ripple/module/net/rpc/RPCSub.h @@ -20,6 +20,9 @@ #ifndef RIPPLE_NET_RPC_RPCSUB_H_INCLUDED #define RIPPLE_NET_RPC_RPCSUB_H_INCLUDED +#include +#include + namespace ripple { /** Subscription object for JSON RPC. */ diff --git a/src/ripple/module/rpc/RPCHandler.h b/src/ripple/module/rpc/RPCHandler.h index a368d4785..0f6f0b79d 100644 --- a/src/ripple/module/rpc/RPCHandler.h +++ b/src/ripple/module/rpc/RPCHandler.h @@ -20,6 +20,8 @@ #ifndef RIPPLE_APP_RPC_HANDLER #define RIPPLE_APP_RPC_HANDLER +#include + #include #include #include diff --git a/src/ripple/module/rpc/impl/Context.h b/src/ripple/module/rpc/impl/Context.h index e58b17380..783fce0dd 100644 --- a/src/ripple/module/rpc/impl/Context.h +++ b/src/ripple/module/rpc/impl/Context.h @@ -20,11 +20,15 @@ #ifndef RIPPLE_RPC_CONTEXT #define RIPPLE_RPC_CONTEXT +#include + namespace ripple { namespace RPC { /** The context of information needed to call an RPC. */ -struct Context { +struct Context +{ + // VFALCO NOTE Public members should not have underscores appended Json::Value params_; Resource::Charge& loadType_; NetworkOPs& netOps_; diff --git a/src/ripple/module/rpc/impl/Handler.h b/src/ripple/module/rpc/impl/Handler.h index cd2c4251c..57e90098a 100644 --- a/src/ripple/module/rpc/impl/Handler.h +++ b/src/ripple/module/rpc/impl/Handler.h @@ -20,6 +20,7 @@ #ifndef RIPPLE_RPC_HANDLER #define RIPPLE_RPC_HANDLER +#include #include namespace ripple { diff --git a/src/ripple/module/rpc/impl/RPCServerHandler.cpp b/src/ripple/module/rpc/impl/RPCServerHandler.cpp index aee146860..75b2df0ed 100644 --- a/src/ripple/module/rpc/impl/RPCServerHandler.cpp +++ b/src/ripple/module/rpc/impl/RPCServerHandler.cpp @@ -18,6 +18,8 @@ //============================================================================== #include +#include +#include #include #include #include diff --git a/src/ripple/nodestore/backend/HyperDBFactory.cpp b/src/ripple/nodestore/backend/HyperDBFactory.cpp index fb51abca7..c4d8012ba 100644 --- a/src/ripple/nodestore/backend/HyperDBFactory.cpp +++ b/src/ripple/nodestore/backend/HyperDBFactory.cpp @@ -19,7 +19,7 @@ #if RIPPLE_HYPERLEVELDB_AVAILABLE -#include +#include namespace ripple { namespace NodeStore { diff --git a/src/ripple/nodestore/backend/LevelDBFactory.cpp b/src/ripple/nodestore/backend/LevelDBFactory.cpp index 2985cb328..3005ad282 100644 --- a/src/ripple/nodestore/backend/LevelDBFactory.cpp +++ b/src/ripple/nodestore/backend/LevelDBFactory.cpp @@ -19,7 +19,7 @@ #if RIPPLE_LEVELDB_AVAILABLE -#include +#include namespace ripple { namespace NodeStore { diff --git a/src/ripple/nodestore/backend/RocksDBFactory.cpp b/src/ripple/nodestore/backend/RocksDBFactory.cpp index 4445b8b7f..9fe10c1ee 100644 --- a/src/ripple/nodestore/backend/RocksDBFactory.cpp +++ b/src/ripple/nodestore/backend/RocksDBFactory.cpp @@ -19,7 +19,7 @@ #if RIPPLE_ROCKSDB_AVAILABLE -#include +#include #include #include diff --git a/src/ripple/overlay/impl/PeerImp.h b/src/ripple/overlay/impl/PeerImp.h index 1598a9456..c8ba03ecb 100644 --- a/src/ripple/overlay/impl/PeerImp.h +++ b/src/ripple/overlay/impl/PeerImp.h @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/src/ripple/unity/app.h b/src/ripple/unity/app.h index 2627e0f69..780ccc4f9 100644 --- a/src/ripple/unity/app.h +++ b/src/ripple/unity/app.h @@ -44,7 +44,6 @@ //------------------------------------------------------------------------------ #include -#include #include #include diff --git a/src/ripple/unity/basics.cpp b/src/ripple/unity/basics.cpp index 92f0708d2..172bb9b44 100644 --- a/src/ripple/unity/basics.cpp +++ b/src/ripple/unity/basics.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ripple/unity/core.cpp b/src/ripple/unity/core.cpp index c505cea85..3c14af918 100644 --- a/src/ripple/unity/core.cpp +++ b/src/ripple/unity/core.cpp @@ -19,8 +19,6 @@ #include -#include - #include #include #include @@ -31,11 +29,11 @@ #include #include // for HTTPClient -#include -#include // private -#include -#include -#include +#include +#include // private +#include +#include +#include -#include -#include +#include +#include diff --git a/src/ripple/unity/core.h b/src/ripple/unity/core.h deleted file mode 100644 index c2d9e09ec..000000000 --- a/src/ripple/unity/core.h +++ /dev/null @@ -1,40 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_CORE_H_INCLUDED -#define RIPPLE_CORE_H_INCLUDED - -#include -#include - -#include // for Config -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include - -#endif diff --git a/src/ripple/unity/net.h b/src/ripple/unity/net.h index ddb915947..d79c27b41 100644 --- a/src/ripple/unity/net.h +++ b/src/ripple/unity/net.h @@ -28,7 +28,6 @@ #include #include -#include #include #include diff --git a/src/ripple/unity/testoverlay.h b/src/ripple/unity/testoverlay.h index f7ffcb83b..3b27cbf74 100644 --- a/src/ripple/unity/testoverlay.h +++ b/src/ripple/unity/testoverlay.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_TESTOVERLAY_H_INCLUDED #define RIPPLE_TESTOVERLAY_H_INCLUDED -#include - #include +#include +#include /** Provides a template based peer to peer network simulator.