Forwarding change
[mistral.git] / parser.h
blobd5152813f8254f49271a14cc40f03cace730ad20
1 /**
2 * Copyright (c) 2005 Zed A. Shaw
3 * You can redistribute it and/or modify it under the same terms as Ruby.
4 */
6 #ifndef http11_parser_h
7 #define http11_parser_h
9 #include <sys/types.h>
11 #if defined(_WIN32)
12 #include <stddef.h>
13 #endif
15 enum { MONGREL_CONTENT_LENGTH
16 , MONGREL_CONTENT_TYPE
17 , MONGREL_FRAGMENT
18 , MONGREL_HTTP_VERSION
19 , MONGREL_QUERY_STRING
20 , MONGREL_REQUEST_PATH
21 , MONGREL_REQUEST_METHOD
22 , MONGREL_REQUEST_URI
25 typedef void (*field_cb)(void *data, const char *field, size_t flen, const char *value, size_t vlen);
26 typedef void (*element_cb)(void *data, int type, const char *at, size_t length);
28 typedef struct http_parser {
29 int cs;
30 int overflow_error;
31 size_t body_start;
32 size_t content_length;
33 size_t nread;
34 size_t mark;
35 size_t field_start;
36 size_t field_len;
37 size_t query_start;
39 void *data;
41 field_cb http_field;
42 element_cb on_element;
43 } http_parser;
45 void http_parser_init(http_parser *parser);
46 int http_parser_finish(http_parser *parser);
47 size_t http_parser_execute(http_parser *parser, const char *data, size_t len, size_t off);
48 int http_parser_has_error(http_parser *parser);
49 int http_parser_is_finished(http_parser *parser);
51 #define http_parser_nread(parser) (parser)->nread
53 #endif