~ubuntu-branches/ubuntu/wily/dovecot/wily

« back to all changes in this revision

Viewing changes to src/lib-http/http-parser.h

  • Committer: Package Import Robot
  • Author(s): Jaldhar H. Vyas
  • Date: 2013-09-09 00:57:32 UTC
  • mfrom: (1.13.11)
  • mto: (4.8.5 experimental) (1.16.1)
  • mto: This revision was merged to the branch mainline in revision 97.
  • Revision ID: package-import@ubuntu.com-20130909005732-dn1eell8srqbhh0e
Tags: upstream-2.2.5
ImportĀ upstreamĀ versionĀ 2.2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef HTTP_PARSER_H
 
2
#define HTTP_PARSER_H
 
3
 
 
4
/*
 
5
 * Character definitions
 
6
 */
 
7
 
 
8
extern const unsigned char _http_token_char_mask;
 
9
extern const unsigned char _http_value_char_mask;
 
10
extern const unsigned char _http_text_char_mask;
 
11
extern const unsigned char _http_qdtext_char_mask;
 
12
extern const unsigned char _http_ctext_char_mask;
 
13
 
 
14
extern const unsigned char _http_char_lookup[256];
 
15
 
 
16
static inline bool http_char_is_token(unsigned char ch) {
 
17
        return (_http_char_lookup[ch] & _http_token_char_mask) != 0;
 
18
}
 
19
 
 
20
static inline bool http_char_is_value(unsigned char ch) {
 
21
        return (_http_char_lookup[ch] & _http_value_char_mask) != 0;
 
22
}
 
23
 
 
24
static inline bool http_char_is_text(unsigned char ch) {
 
25
        return (_http_char_lookup[ch] & _http_text_char_mask) != 0;
 
26
}
 
27
 
 
28
static inline bool http_char_is_qdtext(unsigned char ch) {
 
29
        return (_http_char_lookup[ch] & _http_qdtext_char_mask) != 0;
 
30
}
 
31
 
 
32
static inline bool http_char_is_ctext(unsigned char ch) {
 
33
        return (_http_char_lookup[ch] & _http_ctext_char_mask) != 0;
 
34
}
 
35
 
 
36
/*
 
37
 * HTTP value parsing
 
38
 */
 
39
 
 
40
struct http_parser {
 
41
        const unsigned char *begin, *cur, *end;
 
42
};
 
43
 
 
44
void http_parser_init(struct http_parser *parser,
 
45
                        const unsigned char *data, size_t size);
 
46
 
 
47
void http_parse_ows(struct http_parser *parser);
 
48
 
 
49
int http_parse_token(struct http_parser *parser, const char **token_r);
 
50
int http_parse_token_list_next(struct http_parser *parser,
 
51
        const char **token_r);
 
52
 
 
53
#endif