Lines Matching refs:parser
92 http_date_parse_sp(struct http_date_parser *parser)
94 if (parser->cur >= parser->end)
96 if (parser->cur[0] != ' ')
98 parser->cur++;
103 http_date_parse_number(struct http_date_parser *parser,
108 if (parser->cur >= parser->end || !i_isdigit(parser->cur[0]))
111 *number_r = parser->cur[0] - '0';
112 parser->cur++;
115 if (parser->cur >= parser->end || !i_isdigit(parser->cur[0]))
117 *number_r = ((*number_r) * 10) + parser->cur[0] - '0';
118 parser->cur++;
124 http_date_parse_word(struct http_date_parser *parser,
130 if (parser->cur >= parser->end || !i_isalpha(parser->cur[0]))
134 str_append_c(word, parser->cur[0]);
135 parser->cur++;
138 if (parser->cur >= parser->end || !i_isalpha(parser->cur[0]))
140 str_append_c(word, parser->cur[0]);
141 parser->cur++;
144 if (parser->cur < parser->end && i_isalpha(parser->cur[0]))
151 http_date_parse_year(struct http_date_parser *parser)
154 if (http_date_parse_number(parser, 4, &parser->tm.tm_year) <= 0)
156 if (parser->tm.tm_year < 1900)
158 parser->tm.tm_year -= 1900;
163 http_date_parse_month(struct http_date_parser *parser)
168 if (http_date_parse_word(parser, 3, &month) <= 0 || str_len(month) != 3)
179 parser->tm.tm_mon = i;
184 http_date_parse_day(struct http_date_parser *parser)
187 if (http_date_parse_number(parser, 2, &parser->tm.tm_mday) <= 0)
193 http_date_parse_time_of_day(struct http_date_parser *parser)
203 if (http_date_parse_number(parser, 2, &parser->tm.tm_hour) <= 0)
207 if (parser->cur >= parser->end || parser->cur[0] != ':')
209 parser->cur++;
212 if (http_date_parse_number(parser, 2, &parser->tm.tm_min) <= 0)
216 if (parser->cur >= parser->end || parser->cur[0] != ':')
218 parser->cur++;
221 if (http_date_parse_number(parser, 2, &parser->tm.tm_sec) <= 0)
227 http_date_parse_time_gmt(struct http_date_parser *parser)
235 if (http_date_parse_sp(parser) <= 0)
237 if (http_date_parse_time_of_day(parser) <= 0)
241 if (http_date_parse_sp(parser) <= 0)
243 if (http_date_parse_word(parser, 3, &gmt) <= 0 ||
250 http_date_parse_format_imf_fixdate(struct http_date_parser *parser)
264 if (http_date_parse_sp(parser) <= 0)
266 if (http_date_parse_day(parser) <= 0)
270 if (http_date_parse_sp(parser) <= 0)
272 if (http_date_parse_month(parser) <= 0)
276 if (http_date_parse_sp(parser) <= 0)
278 if (http_date_parse_year(parser) <= 0)
282 return http_date_parse_time_gmt(parser);
286 http_date_parse_format_rfc850(struct http_date_parser *parser)
297 if (parser->cur >= parser->end || parser->cur[0] != ',')
299 parser->cur++;
300 if (http_date_parse_sp(parser) <= 0)
304 if (http_date_parse_day(parser) <= 0)
308 if (parser->cur >= parser->end || parser->cur[0] != '-')
310 parser->cur++;
313 if (http_date_parse_month(parser) <= 0)
317 if (parser->cur >= parser->end || parser->cur[0] != '-')
319 parser->cur++;
322 if (http_date_parse_number(parser, 2, &parser->tm.tm_year) <= 0)
324 if (parser->tm.tm_year < 70)
325 parser->tm.tm_year += 100;
328 return http_date_parse_time_gmt(parser);
332 http_date_parse_format_asctime(struct http_date_parser *parser)
345 if (http_date_parse_month(parser) <= 0)
349 if (http_date_parse_sp(parser) <= 0)
353 if ((ret=http_date_parse_sp(parser)) < 0)
356 if (http_date_parse_number(parser, 2, &parser->tm.tm_mday) <= 0)
359 if (http_date_parse_number(parser, 1, &parser->tm.tm_mday) <= 0)
364 if (http_date_parse_sp(parser) <= 0)
366 if (http_date_parse_time_of_day(parser) <= 0)
370 if (http_date_parse_sp(parser) <= 0)
373 return http_date_parse_year(parser);
377 http_date_parse_format_any(struct http_date_parser *parser)
392 if (http_date_parse_word(parser, 9, &dayname) <= 0)
404 return http_date_parse_format_rfc850(parser);
414 if (i >= 7 || parser->cur >= parser->end)
417 if (parser->cur[0] == ' ') {
419 parser->cur++;
420 return http_date_parse_format_asctime(parser);
423 if (parser->cur[0] != ',')
427 parser->cur++;
428 return http_date_parse_format_imf_fixdate(parser);
434 struct http_date_parser parser;
437 i_zero(&parser);
438 parser.cur = data;
439 parser.end = data + size;
441 if (http_date_parse_format_any(&parser) <= 0)
444 if (parser.cur != parser.end)
447 parser.tm.tm_isdst = -1;
448 timestamp = utc_mktime(&parser.tm);