diff --git a/include/Swiften/TLS/Schannel/SchannelServerContext.cpp b/include/Swiften/TLS/Schannel/SchannelServerContext.cpp index 40ccd6e22f4b317e0c0d818c384bf54191858921..96c090b55f3c39f0c325ba24aaf734313319b780 100644 --- a/include/Swiften/TLS/Schannel/SchannelServerContext.cpp +++ b/include/Swiften/TLS/Schannel/SchannelServerContext.cpp @@ -60,7 +60,7 @@ void SchannelServerContext::connect() { if (m_my_cert_store == NULL) { - m_my_cert_store = CertOpenSystemStore(0, m_cert_store_name.c_str()); + m_my_cert_store = CertOpenSystemStoreA(0, m_cert_store_name.c_str()); if (!m_my_cert_store) { ///// printf( "**** Error 0x%x returned by CertOpenSystemStore\n", GetLastError() ); diff --git a/include/transport/config.h b/include/transport/config.h index 4ced7c987d1a66bccc3504c77c7e636bc76a2e84..dd76bc7be81a0c43f77075b863bb76b75d83ebfc 100644 --- a/include/transport/config.h +++ b/include/transport/config.h @@ -35,6 +35,9 @@ #define CONFIG_LIST(PTR, KEY) (*PTR)[KEY].as >() #define CONFIG_VECTOR(PTR, KEY) ((*PTR).hasKey(KEY) ? (*PTR)[KEY].as >() : std::vector()) +#define CONFIG_STRING_DEFAULTED(PTR, KEY, DEF) ((*PTR).hasKey(KEY) ? (*PTR)[KEY].as() : DEF) +#define CONFIG_BOOL_DEFAULTED(PTR, KEY, DEF) ((*PTR).hasKey(KEY) ? (*PTR)[KEY].as() : DEF) + namespace Transport { @@ -49,6 +52,9 @@ typedef boost::program_options::variables_map Variables; /// class documentation to get a list of all relevant variables for that class. class Config { public: + typedef std::map SectionValuesCont; + typedef std::map UnregisteredCont; + /// Constructor. Config(int argc = 0, char **argv = NULL) : m_argc(argc), m_argv(argv) {} @@ -91,6 +97,10 @@ class Config { return m_unregistered[key]; } + SectionValuesCont getSectionValues(const std::string& sectionName); + + std::string getCommandLineArgs() const; + /// Returns path to config file from which data were loaded. const std::string &getConfigFile() { return m_file; } diff --git a/src/config.cpp b/src/config.cpp index fe40a26952fabf64f23aca13549c16cc4ac667aa..a5f670b289469c80cae71a746a4fbfbac92462f6 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -31,6 +31,7 @@ #include "iostream" #include "boost/version.hpp" +#include "boost/algorithm/string.hpp" #define BOOST_MAJOR_VERSION BOOST_VERSION / 100000 #define BOOST_MINOR_VERSION BOOST_VERSION / 100 % 1000 @@ -249,4 +250,32 @@ bool Config::reload() { return load(m_file); } +Config::SectionValuesCont Config::getSectionValues(const std::string& sectionName) { + SectionValuesCont sectionValues; + + std::string sectionSearchString = sectionName + "."; + BOOST_FOREACH (const Variables::value_type & varItem, m_variables) { + if (boost::istarts_with(varItem.first, sectionSearchString)) + sectionValues[varItem.first] = varItem.second; + } + + BOOST_FOREACH (const UnregisteredCont::value_type & varItem, m_unregistered) { + if (boost::istarts_with(varItem.first, sectionSearchString)) + sectionValues[varItem.first] = varItem.second; + } + + return sectionValues; +} + +std::string Config::getCommandLineArgs() const { + std::ostringstream commandLineArgs; + + // Return the command-line arguments that were passed to us originally (but remove the initial .exe part) + for (int i = 1; i < m_argc; ++i) { + commandLineArgs << "\"" << m_argv[i] << "\" "; + } + + return commandLineArgs.str(); +} + }