I wonder if this is ever going to work
[theodwalha.git] / theodwalha / configuration.cpp
blobd0fa033344a8a9397dd4e18eadd958cec770c40d
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;
16 bool parse_configuration_file(std::string const & path)
18 ail::configuration configuration;
19 if(!configuration.load(path))
21 std::cout << "Failed to load configuration file from \"" << path << "\"" << std::endl;
22 return false;
25 try
27 backlog = configuration.number<uword>("backlog");
28 http_server_port = configuration.number<ushort>("http_server_port");
29 read_buffer_size = configuration.number<std::size_t>("read_buffer_size");
30 maximal_extended_buffer_size = configuration.number<std::size_t>("maximal_extended_buffer_size");
31 maximal_request_size = configuration.number<std::size_t>("maximal_request_size");
32 temporary_file_directory = configuration.string("temporary_file_directory");
33 temporary_file_expiration = configuration.number<ulong>("temporary_file_expiration");
34 temporary_file_name_length = configuration.number<uword>("temporary_file_name_length");
35 keep_alive_timeout = configuration.number<uword>("keep_alive_timeout");
36 keep_alive_max = configuration.number<uword>("keep_alive_max");
37 module_directory = configuration.string("module_directory");
39 catch(ail::exception & exception)
41 std::cout << "Error in configuration file: " << exception.get_message() << std::endl;
42 return false;
45 return true;