blob: 1c89655d8d7d417fe13859f9eae4cc6b099d539f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
#include "configurationparser.h"
#include "configuration.h"
ConfigurationParser::ConfigurationParser(std::string filename)
{
this->filename = filename;
reload();
}
void ConfigurationParser::reload()
throw(ConfigurationParserException)
{
try {
readFile(this->filename.c_str());
} catch(libconfig::FileIOException) {
throw ConfigurationParserException("Could not read config file: File does not exist.");
} catch(libconfig::ParseException &e) {
char lineno[32];
sprintf(lineno, "%d", e.getLine());
throw ConfigurationParserException(std::string("Error when parsing the config file in line ")
+ lineno + ": " + e.getError());
}
try {
int p = lookup("server_port");
Conf::server_port = p;
} catch( ... ) {
}
try {
std::string u = lookup("server_user");
Conf::server_user = u;
} catch( ... ) {
}
try {
std::string g = lookup("server_group");
Conf::server_group = g;
} catch( ... ) {
}
try {
std::string a = lookup("journal_commit_addr");
Conf::journal_commit_addr = a;
} catch( ... ) {
}
try {
int p = lookup("journal_commit_port");
Conf::journal_commit_port = p;
} catch( ... ) {
}
try {
int t = lookup("db_max_ttl");
Conf::db_max_ttl = t;
} catch( ... ) {
}
try {
int t = lookup("pentominos_max_ttl");
Conf::pentominos_max_ttl = t;
} catch( ... ) {
}
try {
std::string a = lookup("pentominos_addr");
Conf::pentominos_addr = a;
} catch( ... ) {
}
try {
int p = lookup("pentominos_port");
Conf::pentominos_port = p;
} catch( ... ) {
}
try {
std::string a = lookup("database_addr");
Conf::database_addr = a;
} catch( ... ) {
}
try {
std::string u = lookup("database_user");
Conf::database_user = u;
} catch( ... ) {
}
try {
std::string p = lookup("database_passwd");
Conf::database_passwd = p;
} catch( ... ) {
}
try {
std::string p = lookup("xml_basedir");
Conf::xml_basedir = p;
} catch( ... ) {
}
}
|