http.h
changeset 10 9daa832ab9c4
child 27 1e79b4cc8f1b
equal deleted inserted replaced
9:fb6632e6c1bb 10:9daa832ab9c4
       
     1 /*
       
     2  * The HTTP interface code
       
     3  */
       
     4 
       
     5 #ifndef HTTP_H
       
     6 #define HTTP_H
       
     7 
       
     8 #include <event2/http.h>
       
     9 
       
    10 enum http_qarg_type {
       
    11     QARG_INVALID,   // hqa_addr is NULL, abort parsing
       
    12     QARG_INT,       // hqa_addr is a `signed long int`
       
    13     QARG_UINT,      // hqa_addr is an `unsigned long int`
       
    14 
       
    15     QARG_END,       // last item in the qarg_spec
       
    16 };
       
    17 
       
    18 struct http_qarg {
       
    19     // the key to look for
       
    20     const char          *hqa_key;
       
    21 
       
    22     // the type of value
       
    23     enum http_qarg_type  hqa_type;
       
    24 
       
    25     // where to store the value, left unchanged if not found
       
    26     void                *hqa_addr;
       
    27 };
       
    28 
       
    29 /*
       
    30  * Parse the query args in the given evhttp_request according to the given http_arg specification.
       
    31  *
       
    32  * Returns zero if all matching fields were succesfully parsed, nonzero if any field was invalid
       
    33  */
       
    34 int http_qarg_parse (struct evhttp_request *request, struct http_qarg *qarg_spec);
       
    35 
       
    36 #endif /* HTTP_H */