http.h
author Tero Marttila <terom@fixme.fi>
Wed, 27 Aug 2008 21:30:32 +0300
changeset 41 540737bf6bac
parent 27 1e79b4cc8f1b
permissions -rw-r--r--
sending requests, and partial support for receiving -- incomplete, not tested
10
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
/*
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
 * The HTTP interface code
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
 */
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
#ifndef HTTP_H
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     6
#define HTTP_H
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
#include <event2/http.h>
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     9
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    10
enum http_qarg_type {
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    11
    QARG_INVALID,   // hqa_addr is NULL, abort parsing
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    12
    QARG_INT,       // hqa_addr is a `signed long int`
27
1e79b4cc8f1b support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    13
    QARG_UINT16,    // hqa_addr is an `unsigned short int`
1e79b4cc8f1b support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    14
    QARG_UINT32,    // hqa_addr is an `unsigned int`
1e79b4cc8f1b support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    15
    QARG_UINT64,    // hqa_addr is an `unsigned long long int`
10
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    16
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    17
    QARG_END,       // last item in the qarg_spec
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    18
};
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    19
27
1e79b4cc8f1b support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    20
#define QARG_OPTIONAL 0x00
1e79b4cc8f1b support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    21
#define QARG_REQUIRED 0x01
1e79b4cc8f1b support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    22
10
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    23
struct http_qarg {
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    24
    // the key to look for
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    25
    const char          *hqa_key;
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    26
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    27
    // the type of value
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    28
    enum http_qarg_type  hqa_type;
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    29
27
1e79b4cc8f1b support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    30
    // where to store the value, left unchanged if not specified in the request
10
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    31
    void                *hqa_addr;
27
1e79b4cc8f1b support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    32
1e79b4cc8f1b support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    33
    // flags
1e79b4cc8f1b support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    34
    int                  hqa_flags;
10
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    35
};
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    36
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    37
/*
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    38
 * Parse the query args in the given evhttp_request according to the given http_arg specification.
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    39
 *
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    40
 * Returns zero if all matching fields were succesfully parsed, nonzero if any field was invalid
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    41
 */
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    42
int http_qarg_parse (struct evhttp_request *request, struct http_qarg *qarg_spec);
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    43
9daa832ab9c4 separate http query argument parsing into a new http module, and clean up unused headers from web_main.c
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    44
#endif /* HTTP_H */