]> git.sesse.net Git - cubemap/blob - config.h
Store and log connection time for inputs.
[cubemap] / config.h
1 #ifndef _CONFIG_H
2 #define _CONFIG_H
3
4 // Various routines that deal with parsing the configuration file.
5
6 #include <arpa/inet.h>
7 #include <netinet/in.h>
8 #include <stddef.h>
9 #include <string>
10 #include <vector>
11
12 struct MarkPoolConfig {
13         int from, to;
14 };
15
16 struct StreamConfig {
17         std::string url;  // As seen by the client.
18         std::string src;  // Can be empty.
19         size_t backlog_size;
20         int mark_pool;  // -1 for none.
21         enum { STREAM_ENCODING_RAW = 0, STREAM_ENCODING_METACUBE } encoding;
22 };
23
24 struct UDPStreamConfig {
25         sockaddr_in6 dst;
26         std::string src;  // Can be empty.
27         int mark_pool;  // -1 for none.
28 };
29
30 struct AcceptorConfig {
31         int port;
32 };
33
34 struct LogConfig {
35         enum { LOG_TYPE_FILE, LOG_TYPE_CONSOLE, LOG_TYPE_SYSLOG } type;
36         std::string filename;
37 };
38
39 struct Config {
40         bool daemonize;
41         int num_servers;
42         std::vector<MarkPoolConfig> mark_pools;
43         std::vector<StreamConfig> streams;
44         std::vector<UDPStreamConfig> udpstreams;
45         std::vector<AcceptorConfig> acceptors;
46         std::vector<LogConfig> log_destinations;
47
48         std::string stats_file;  // Empty means no stats file.
49         int stats_interval;
50
51         std::string input_stats_file;  // Empty means no input stats file.
52         int input_stats_interval;
53
54         std::string access_log_file;  // Empty means no accses_log file.
55 };
56
57 // Parse and validate configuration. Returns false on error.
58 // <config> is taken to be empty (uninitialized) on entry.
59 bool parse_config(const std::string &filename, Config *config);
60
61 #endif  // !defined(_CONFIG_H)