+ // Parse input encoding.
+ map<string, string>::const_iterator src_encoding_parm_it = line.parameters.find("src_encoding");
+ if (src_encoding_parm_it == line.parameters.end() ||
+ src_encoding_parm_it->second == "metacube") {
+ udpstream.src_encoding = StreamConfig::STREAM_ENCODING_METACUBE;
+ } else if (src_encoding_parm_it->second == "raw") {
+ udpstream.src_encoding = StreamConfig::STREAM_ENCODING_RAW;
+ } else {
+ log(ERROR, "Parameter 'src_encoding' must be either 'raw' or 'metacube' (default)");
+ return false;
+ }
+
+ config->udpstreams.push_back(udpstream);
+ return true;
+}
+
+bool parse_gen204(const ConfigLine &line, Config *config)
+{
+ if (line.arguments.size() != 1) {
+ log(ERROR, "'gen204' takes exactly one argument");
+ return false;
+ }
+
+ Gen204Config gen204;
+ gen204.url = line.arguments[0];
+
+ // Parse the CORS origin, if it exists.
+ map<string, string>::const_iterator allow_origin_it = line.parameters.find("allow_origin");
+ if (allow_origin_it != line.parameters.end()) {
+ gen204.allow_origin = allow_origin_it->second;
+ }
+
+ config->pings.push_back(gen204);
+ return true;
+}
+
+bool parse_error_log(const ConfigLine &line, Config *config)
+{
+ if (line.arguments.size() != 0) {
+ log(ERROR, "'error_log' takes no arguments (only parameters type= and filename=)");
+ return false;
+ }
+
+ LogConfig log_config;
+ map<string, string>::const_iterator type_it = line.parameters.find("type");
+ if (type_it == line.parameters.end()) {
+ log(ERROR, "'error_log' has no type= parameter");
+ return false;
+ }
+
+ string type = type_it->second;
+ if (type == "file") {
+ log_config.type = LogConfig::LOG_TYPE_FILE;
+ } else if (type == "syslog") {
+ log_config.type = LogConfig::LOG_TYPE_SYSLOG;
+ } else if (type == "console") {
+ log_config.type = LogConfig::LOG_TYPE_CONSOLE;
+ } else {
+ log(ERROR, "Unknown log type '%s'", type.c_str());
+ return false;
+ }
+
+ if (log_config.type == LogConfig::LOG_TYPE_FILE) {
+ map<string, string>::const_iterator filename_it = line.parameters.find("filename");
+ if (filename_it == line.parameters.end()) {
+ log(ERROR, "error_log type 'file' with no filename= parameter");
+ return false;
+ }
+ log_config.filename = filename_it->second;
+ }
+
+ config->log_destinations.push_back(log_config);