Changeset - 47f86754eae6
[Not reviewed]
0 4 0
HanzZ - 13 years ago 2012-04-17 18:26:21
hanzz.k@gmail.com
Allow setting config file options also from command line
4 files changed with 12 insertions and 5 deletions:
0 comments (0 inline, 0 general)
include/transport/config.h
Show inline comments
 
@@ -50,7 +50,7 @@ typedef boost::program_options::variables_map Variables;
 
class Config {
 
	public:
 
		/// Constructor.
 
		Config() {}
 
		Config(int argc = 0, char **argv = NULL) : m_argc(argc), m_argv(argv) {}
 

	
 
		/// Destructor
 
		virtual ~Config() {}
 
@@ -99,6 +99,8 @@ class Config {
 
		boost::signal<void ()> onConfigReloaded;
 
	
 
	private:
 
		int m_argc;
 
		char **m_argv;
 
		Variables m_variables;
 
		std::map<std::string, std::string> m_unregistered;
 
		std::string m_file;
spectrum/src/main.cpp
Show inline comments
 
@@ -114,7 +114,7 @@ static void daemonize(const char *cwd, const char *lock_file) {
 

	
 
int main(int argc, char **argv)
 
{
 
	Config config;
 
	Config config(argc, argv);
 

	
 
	boost::program_options::variables_map vm;
 
	bool no_daemon = false;
spectrum/src/sample.cfg
Show inline comments
 
@@ -8,13 +8,13 @@ backend_host=localhost
 
pidfile=./test.pid
 
# < this option doesn't work yet
 
#backend_port=10001
 
admin_jid=admin@localhost
 
#admin_jid=admin@localhost
 
admin_password=test
 
#cert=server.pfx #patch to PKCS#12 certificate
 
#cert_password=test #password to that certificate if any
 
users_per_backend=10
 
#backend=../..//backends/libpurple/spectrum2_libpurple_backend
 
backend=../../backends/template/template_backend.py
 
backend=../..//backends/libpurple/spectrum2_libpurple_backend
 
#backend=../../backends/template/template_backend.py
 
protocol=prpl-jabber
 
#protocol=prpl-msn
 
#protocol=any
src/config.cpp
Show inline comments
 
@@ -187,6 +187,11 @@ bool Config::load(std::istream &ifs, boost::program_options::options_description
 
		}
 
	}
 

	
 
	// Load configs passed by command line
 
	if (m_argc != 0 && m_argv) {
 
		store(parse_command_line(m_argc, m_argv, opts), m_variables);
 
	}
 

	
 
	store(parsed, m_variables);
 
	notify(m_variables);
 

	
0 comments (0 inline, 0 general)