{
cout << "Bullet proof dynamic dns daemon.\nbpdyndnsd " << version << endl;
}
+
+/**
+ * Prints out the successful parsing of the command line options.
+ */
+void Config::print_cmd_parsed()
+{
+ cout << "Command line arguments successful parsed." << endl;
+}
+
+void Config::print_conf_loaded()
+{
+ cout << "Config files successful loaded." << endl;
+}
+
+void Config::print_unknown_conf_option()
+{
+ cout << "See manpage for config file structure." << endl;
+}
+
+void Config::print_error_opening()
+{
+ cout << "Error opening file." << endl;
+}
\ No newline at end of file
void print_version(const string&);
+ void print_cmd_parsed();
+
+ void print_conf_loaded();
+
+ void print_error_opening();
+
+ void print_unknown_conf_option();
+
list<ServicePtr> get_services();
};
*/
int main(int argc, char *argv[])
{
- // Initialize Config class and get the command line parameters
+ // initialize Config
ConfigPtr config(new Config);
- int ret_val = config->parse_cmd_line(argc,argv);
- if(ret_val == 1)
- {
- // usage
- config->print_usage();
- return 0;
- }
- else if(ret_val == 2)
- {
- // version
- ostringstream version_string;
- version_string << VERSION << "." << REVISION << "." << RELEASE;
- config->print_version(version_string.str());
- return 0;
- }
- // Load the main config and the service files
- string config_path = "/home/bjoern/bpdyndnsd"; // TODO: standard config path should be /etc/bpdyndnsd if not specified other on command line
- ret_val = config->load_config_from_files(config_path);
- if(ret_val == 3)
- {
- // unknown option
- cout << "See manpage for config file structure." << endl;
+ // initialize Updater
+ UpdaterPtr updater(new Updater(config));
+
+ if ( updater->init_config_from_cmd(argc,argv) != 0 )
return 0;
- }
- else if(ret_val == 4)
- {
- // error opening
+
+ if ( updater->init_config_from_files() != 0 )
return 0;
- }
- // initialize Updater
- UpdaterPtr updater(new Updater(config));
updater->update_services();
return 0;
/**
+ *
+ * @param argc
+ * @param argv[]
+ * @return
+ */
+const int Updater::init_config_from_cmd(int argc, char *argv[])
+{
+ // Load the command line parameters
+ int ret_val = Conf->parse_cmd_line(argc,argv);
+ if(ret_val == 1)
+ {
+ // usage
+ Conf->print_usage();
+ return ret_val;
+ }
+ else if(ret_val == 2)
+ {
+ // version
+ ostringstream version_string;
+ version_string << VERSION << "." << REVISION << "." << RELEASE;
+ Conf->print_version(version_string.str());
+ return ret_val;
+ }
+ // successful parsed
+ Conf->print_cmd_parsed();
+ return 0;
+}
+
+const int Updater::init_config_from_files()
+{
+ // Load the main config and the service files
+ string config_path = "/home/bjoern/bpdyndnsd"; // TODO: standard config path should be /etc/bpdyndnsd if not specified other on command line
+ int ret_val = Conf->load_config_from_files(config_path);
+ if(ret_val == 3)
+ {
+ // unknown option
+ Conf->print_unknown_conf_option();
+ return ret_val;
+ }
+ else if(ret_val == 4)
+ {
+ // error opening
+ Conf->print_error_opening();
+ return ret_val;
+ }
+ // successful loaded
+ Conf->print_conf_loaded();
+ return 0;
+}
+
+
+/**
* Setter for member Conf.
* @param _conf
*/
ConfigPtr get_config();
void update_services();
+
+ const int init_config_from_cmd(int, char **);
+
+ const int init_config_from_files();
};
#endif