terom@10: /* terom@10: * The HTTP interface code terom@10: */ terom@10: terom@10: #ifndef HTTP_H terom@10: #define HTTP_H terom@10: terom@10: #include terom@10: terom@10: enum http_qarg_type { terom@10: QARG_INVALID, // hqa_addr is NULL, abort parsing terom@10: QARG_INT, // hqa_addr is a `signed long int` terom@27: QARG_UINT16, // hqa_addr is an `unsigned short int` terom@27: QARG_UINT32, // hqa_addr is an `unsigned int` terom@27: QARG_UINT64, // hqa_addr is an `unsigned long long int` terom@10: terom@10: QARG_END, // last item in the qarg_spec terom@10: }; terom@10: terom@27: #define QARG_OPTIONAL 0x00 terom@27: #define QARG_REQUIRED 0x01 terom@27: terom@10: struct http_qarg { terom@10: // the key to look for terom@10: const char *hqa_key; terom@10: terom@10: // the type of value terom@10: enum http_qarg_type hqa_type; terom@10: terom@27: // where to store the value, left unchanged if not specified in the request terom@10: void *hqa_addr; terom@27: terom@27: // flags terom@27: int hqa_flags; terom@10: }; terom@10: terom@10: /* terom@10: * Parse the query args in the given evhttp_request according to the given http_arg specification. terom@10: * terom@10: * Returns zero if all matching fields were succesfully parsed, nonzero if any field was invalid terom@10: */ terom@10: int http_qarg_parse (struct evhttp_request *request, struct http_qarg *qarg_spec); terom@10: terom@10: #endif /* HTTP_H */