Lines Matching refs:parser
9 #include "http-parser.h"
74 void http_parser_init(struct http_parser *parser,
77 i_zero(parser);
78 parser->begin = data;
79 parser->cur = data;
80 parser->end = data + size;
83 void http_parse_ows(struct http_parser *parser)
86 if (parser->cur >= parser->end)
88 while (parser->cur < parser->end &&
89 (parser->cur[0] == ' ' || parser->cur[0] == '\t')) {
90 parser->cur++;
94 int http_parser_skip_token(struct http_parser *parser)
98 if (parser->cur >= parser->end || !http_char_is_token(*parser->cur))
100 parser->cur++;
102 while (parser->cur < parser->end && http_char_is_token(*parser->cur))
103 parser->cur++;
107 int http_parse_token(struct http_parser *parser, const char **token_r)
109 const unsigned char *first = parser->cur;
112 if ((ret=http_parser_skip_token(parser)) <= 0)
114 *token_r = t_strndup(first, parser->cur - first);
118 int http_parse_token_list_next(struct http_parser *parser,
133 if (http_parse_token(parser, token_r) > 0)
135 http_parse_ows(parser);
136 if (parser->cur >= parser->end || parser->cur[0] != ',')
138 parser->cur++;
139 http_parse_ows(parser);
145 int http_parse_quoted_string(struct http_parser *parser, const char **str_r)
158 if (parser->cur >= parser->end || parser->cur[0] != '"')
160 parser->cur++;
168 first = parser->cur;
169 while (parser->cur < parser->end && http_char_is_qdtext(*parser->cur))
170 parser->cur++;
172 if (parser->cur >= parser->end)
175 str_append_n(str, first, parser->cur - first);
178 if (*parser->cur == '"') {
179 parser->cur++;
183 } else if (*parser->cur == '\\') {
184 parser->cur++;
186 if (parser->cur >= parser->end || !http_char_is_text(*parser->cur))
188 str_append_c(str, *parser->cur);
189 parser->cur++;
200 int http_parse_token_or_qstring(struct http_parser *parser,
203 if (parser->cur >= parser->end)
205 if (parser->cur[0] == '"')
206 return http_parse_quoted_string(parser, word_r);
207 return http_parse_token(parser, word_r);