http.h
changeset 10 9daa832ab9c4
child 27 1e79b4cc8f1b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/http.h	Fri Jun 06 16:05:26 2008 +0300
@@ -0,0 +1,36 @@
+/*
+ * The HTTP interface code
+ */
+
+#ifndef HTTP_H
+#define HTTP_H
+
+#include <event2/http.h>
+
+enum http_qarg_type {
+    QARG_INVALID,   // hqa_addr is NULL, abort parsing
+    QARG_INT,       // hqa_addr is a `signed long int`
+    QARG_UINT,      // hqa_addr is an `unsigned long int`
+
+    QARG_END,       // last item in the qarg_spec
+};
+
+struct http_qarg {
+    // the key to look for
+    const char          *hqa_key;
+
+    // the type of value
+    enum http_qarg_type  hqa_type;
+
+    // where to store the value, left unchanged if not found
+    void                *hqa_addr;
+};
+
+/*
+ * Parse the query args in the given evhttp_request according to the given http_arg specification.
+ *
+ * Returns zero if all matching fields were succesfully parsed, nonzero if any field was invalid
+ */
+int http_qarg_parse (struct evhttp_request *request, struct http_qarg *qarg_spec);
+
+#endif /* HTTP_H */