2 // C++ Implementation: config
7 // Author: Bjoern Sikora <bjoern.sikora@intra2net.com>, (C) 2009
9 // Copyright: See COPYING file that comes with this distribution
16 // define valid command line parameters
17 opt_desc_cmd = new po::options_description("Command line options");
19 opt_desc_cmd->add_options()
20 ("help,?","Show help.")
21 ("version,v","Show version.")
22 ("protocol,q",po::value<string>(),"Set the service protocol type.")
23 ("host,h",po::value<string>(),"Set the hostname to update.")
24 ("login,l",po::value<string>(),"Set the login.")
25 ("password,p",po::value<string>(),"Set the password.")
28 // define valid config file parameters
29 opt_desc_conf = new po::options_description("Config file options");
31 opt_desc_conf->add_options()
32 ("help,?","Show help.")
33 ("version,v","Show version.")
43 int Config::parse_cmd_line(int argc, char *argv[])
48 po::store(po::parse_command_line(argc, argv, *opt_desc_cmd), vm);
53 else if(vm.count("version"))
56 if(vm.count("protocol") && vm.count("host") && vm.count("login") && vm.count("password"))
58 // get the cmd parameter values for protocol host login and password
59 string protocol = vm["protocol"].as<string>();
60 string host = vm["host"].as<string>();
61 string login = vm["login"].as<string>();
62 string password = vm["password"].as<string>();
64 //TODO: convert all options to lowercase
66 // create Service object
69 Service * service = new DHS(host,login,password);
70 this->services.push_back(service);
72 else if(protocol == "ods")
74 Service * service = new ODS(host,login,password);
75 this->services.push_back(service);
80 cout << "Not all needed options set!\n" << endl;
84 catch(boost::program_options::unknown_option e)
86 cout << "Unknown option set." << endl;
92 void Config::print_usage()
94 cout << "Usage: bpdyndnsd [Command line options]" << "\n" << endl;
95 cout << *opt_desc_cmd << endl;
98 void Config::print_version(string version)
100 cout << "Bullet proof dynamic dns daemon.\nbpdyndnsd " << version << endl;
103 void Config::load_config_file(string filename)
108 list<Service*> Config::get_services()
110 return this->services;