]> git.sesse.net Git - cubemap/blobdiff - parse.h
Move stopping into ServerPool.
[cubemap] / parse.h
diff --git a/parse.h b/parse.h
index 83c5d2a8998dff2832b879b78db04c4467608696..3cfa09119458efbdd2d182bd09381e1111f8191c 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -22,7 +22,32 @@ std::vector<std::string> split_lines(const std::string &str);
 // Parse the configuration file.
 std::vector<ConfigLine> parse_config(const std::string &filename);
 
+enum ParameterType {
+       PARAMETER_OPTIONAL,
+       PARAMATER_MANDATORY,
+};
+
+std::string fetch_config_string(const std::vector<ConfigLine> &config, const std::string &keyword,
+                                ParameterType parameter_type, const std::string &default_value = "");
+
 // Note: Limits are inclusive.
-int fetch_config_int(const std::vector<ConfigLine> &config, const std::string &keyword, int min_limit, int max_limit);
+int fetch_config_int(const std::vector<ConfigLine> &config, const std::string &keyword,
+                     int min_limit, int max_limit,
+                     ParameterType parameter_type, int default_value = -1);
+
+// Add the new data to an existing string, looking for \r\n\r\n
+// (typical of HTTP requests and/or responses). Will return one
+// of the given statuses.
+//
+// Note that if you give too much data in new_data_size, you could
+// get an RP_OUT_OF_SPACE even if you expected RP_EXTRA_DATA.
+// Be careful about how large reads you give in.
+enum RequestParseStatus {
+       RP_OUT_OF_SPACE,       // If larger than 16 kB.
+       RP_NOT_FINISHED_YET,   // Did not get \r\n\r\n yet. 
+       RP_EXTRA_DATA,         // Got \r\n\r\n, but there was extra data behind it.
+       RP_FINISHED,           // Ended exactly in \r\n\r\n.
+};
+RequestParseStatus wait_for_double_newline(std::string *existing_data, const char *new_data, size_t new_data_size);
 
 #endif  // !defined(_PARSE_H)