Fixed a few problems, added a debugging configuration variable
[theodwalha.git] / source / configuration.cpp
blobfc0d85f7abac79ac0a32cca6cc5c4de6d31c5594
1 #include <ail/configuration.hpp>
2 #include <theodwalha/configuration.hpp>
4 uword backlog;
5 ushort http_server_port;
6 std::size_t read_buffer_size;
7 std::size_t maximal_extended_buffer_size;
8 std::size_t maximal_request_size;
9 std::string temporary_file_directory;
10 ulong temporary_file_expiration;
11 uword temporary_file_name_length;
12 uword keep_alive_timeout;
13 uword keep_alive_max;
14 std::string module_directory;
15 bool debugging;
17 bool parse_configuration_file(std::string const & path)
19 ail::configuration configuration;
20 if(!configuration.load(path))
22 std::cout << "Failed to load configuration file from \"" << path << "\"" << std::endl;
23 return false;
26 try
28 backlog = configuration.number<uword>("backlog");
29 http_server_port = configuration.number<ushort>("http_server_port");
30 read_buffer_size = configuration.number<std::size_t>("read_buffer_size");
31 maximal_extended_buffer_size = configuration.number<std::size_t>("maximal_extended_buffer_size");
32 maximal_request_size = configuration.number<std::size_t>("maximal_request_size");
33 temporary_file_directory = configuration.string("temporary_file_directory");
34 temporary_file_expiration = configuration.number<ulong>("temporary_file_expiration");
35 temporary_file_name_length = configuration.number<uword>("temporary_file_name_length");
36 keep_alive_timeout = configuration.number<uword>("keep_alive_timeout");
37 keep_alive_max = configuration.number<uword>("keep_alive_max");
38 module_directory = configuration.string("module_directory");
39 debugging = configuration.boolean("debugging", false);
41 catch(ail::exception & exception)
43 std::cout << "Error in configuration file: " << exception.get_message() << std::endl;
44 return false;
47 return true;