http.h
author Tero Marttila <terom@fixme.fi>
Sat, 30 Aug 2008 19:13:15 +0300
changeset 49 10c7dce1a043
parent 27 1e79b4cc8f1b
permissions -rw-r--r--
autogenerate the memcache_test help output, and pipeline memcache requests
/*
 * 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_UINT16,    // hqa_addr is an `unsigned short int`
    QARG_UINT32,    // hqa_addr is an `unsigned int`
    QARG_UINT64,    // hqa_addr is an `unsigned long long int`

    QARG_END,       // last item in the qarg_spec
};

#define QARG_OPTIONAL 0x00
#define QARG_REQUIRED 0x01

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 specified in the request
    void                *hqa_addr;

    // flags
    int                  hqa_flags;
};

/*
 * 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 */