http.h
author Tero Marttila <terom@fixme.fi>
Tue, 17 Jun 2008 18:15:43 +0300
changeset 21 e2916f8ebaa6
parent 10 9daa832ab9c4
child 27 1e79b4cc8f1b
permissions -rw-r--r--
fix memory alloc/free bugs, and one in render_threads where the last row was left out

committer: Tero Marttila <terom@fixme.fi>
/*
 * 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 */