Main file.
[bpdyndnsd] / src / main.cpp
1
2 #ifdef HAVE_CONFIG_H
3 #include <config.h>
4 #endif
5
6 #define VERSION     0
7 #define REVISION    1
8 #define RELEASE     0
9
10 #include <iostream>
11 #include <list>
12 #include <string>
13
14 #include <boost/foreach.hpp>
15
16 #include "updater.cpp"
17 #include "config.cpp"
18
19 #include "service.cpp"
20
21 #include "dhs.cpp"
22 #include "ods.cpp"
23
24 using namespace std;
25
26 /**
27  * @brief the main part.
28  * @param argc number of arguments
29  * @param argv command line arguments
30  * @return exit code for the process.
31  */
32 int main(int argc, char *argv[])
33 {
34     // Initialize Config class and get the command line parameters
35     Config * config = new Config;
36     int ret_val = config->parse_cmd_line(argc,argv);
37     if(ret_val == 1)
38     {
39         // usage
40         config->print_usage();
41         return 0;
42     }
43     else if(ret_val == 2)
44     {
45         // version
46         ostringstream version_string;
47         version_string << VERSION << "." << REVISION << "." << RELEASE;
48         config->print_version(version_string.str());
49         return 0;
50     }
51
52     string config_path = "/home/bjoern/bpdyndnsd";  // TODO: standard config path should be /etc/bpdyndnsd if not specified other on command line
53     ret_val = config->load_config_from_files(config_path);
54     if(ret_val == 3)
55     {
56         cout << "See manpage for config file structure." << endl;
57     }
58     else if(ret_val == 4)
59     {
60         return 0;
61     }
62
63     // initialize Updater
64     Updater * updater = new Updater(config);
65     updater->update_services();
66
67     return 0;
68 }