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