예제 #1
0
static int
http_date_parse_format_imf_fixdate(struct http_date_parser *parser)
{
	/*
	 IMF-fixdate  = day-name "," SP date1 SP time-of-day SP GMT
		            ; fixed length/zone/capitalization subset of the format
		            ; see Section 3.3 of [RFC5322]
	 date1        = day SP month SP year
	              ; e.g., 02 Jun 1982
	 
	 Remaining: 	 {...} SP day SP month SP year SP time-of-day SP GMT

	 */

	/* SP day */
	if (http_date_parse_sp(parser) <= 0)
		return -1;
	if (http_date_parse_day(parser) <= 0)
		return -1;

	/* SP month */
	if (http_date_parse_sp(parser) <= 0)
		return -1;
	if (http_date_parse_month(parser) <= 0)
		return -1;

	/* SP year */
	if (http_date_parse_sp(parser) <= 0)
		return -1;
	if (http_date_parse_year(parser) <= 0)
		return -1;

	/* SP time-of-day SP GMT */
	return http_date_parse_time_gmt(parser);
}
예제 #2
0
파일: http-date.c 프로젝트: bdraco/dovecot
static int
http_date_parse_format_rfc1123(struct http_date_parser *parser)
{
    /*
     rfc1123-date = day-name "," SP date1 SP time-of-day SP GMT
                    ; fixed length subset of the format defined in
                    ; Section 5.2.14 of [RFC1123]
     date1        = day SP month SP year
                    ; e.g., 02 Jun 1982

     Remaining: 	 {...} SP day SP month SP year SP time-of-day SP GMT

     */

    /* SP day */
    if (http_date_parse_sp(parser) <= 0)
        return -1;
    if (http_date_parse_day(parser) <= 0)
        return -1;

    /* SP month */
    if (http_date_parse_sp(parser) <= 0)
        return -1;
    if (http_date_parse_month(parser) <= 0)
        return -1;

    /* SP year */
    if (http_date_parse_sp(parser) <= 0)
        return -1;
    if (http_date_parse_year(parser) <= 0)
        return -1;

    /* SP time-of-day SP GMT */
    return http_date_parse_time_gmt(parser);
}
예제 #3
0
static int
http_date_parse_format_asctime(struct http_date_parser *parser)
{
	int ret;

	/*
	 asctime-date = day-name SP date3 SP time-of-day SP year
	 date3        = month SP ( 2DIGIT / ( SP 1DIGIT ))
		              ; month day (e.g., Jun  2)

	 Remaining: {...} month SP ( 2DIGIT / ( SP 1DIGIT )) SP time-of-day SP year
	*/

	/* month */
	if (http_date_parse_month(parser) <= 0)
		return -1;

	/* SP */
	if (http_date_parse_sp(parser) <= 0)
		return -1;

	/* SP 1DIGIT / 2DIGIT */
	if ((ret=http_date_parse_sp(parser)) < 0)
		return -1;
	if (ret == 0) {
		if (http_date_parse_number(parser, 2, &parser->tm.tm_mday) <= 0)
			return -1;
	} else {
		if (http_date_parse_number(parser, 1, &parser->tm.tm_mday) <= 0)
			return -1;
	}

	/* SP time-of-day */
	if (http_date_parse_sp(parser) <= 0)
		return -1;
	if (http_date_parse_time_of_day(parser) <= 0)
		return -1;

	/* SP year */
	if (http_date_parse_sp(parser) <= 0)
		return -1;

	return http_date_parse_year(parser);
}
예제 #4
0
static inline int
http_date_parse_time_gmt(struct http_date_parser *parser)
{
	string_t *gmt;

	/* Remaining: 	 {...} SP time-of-day SP GMT
	 */

	/* SP time-of-day */
	if (http_date_parse_sp(parser) <= 0)
		return -1;
	if (http_date_parse_time_of_day(parser) <= 0)
		return -1;

	/* SP GMT */
	if (http_date_parse_sp(parser) <= 0)
		return -1;
	if (http_date_parse_word(parser, 3, &gmt) <= 0 ||
		strcmp("GMT", str_c(gmt)) != 0)
		return -1;
	return 1;
}
예제 #5
0
static int
http_date_parse_format_rfc850(struct http_date_parser *parser)
{
	/* 
	 rfc850-date  = day-name-l "," SP date2 SP time-of-day SP GMT
	 date2        = day "-" month "-" 2DIGIT
		              ; day-month-year (e.g., 02-Jun-82)

	 Remaining: "," SP day "-" month "-" 2DIGIT SP time-of-day SP GMT
	 */

	/* "," SP */
	if (parser->cur >= parser->end || parser->cur[0] != ',')
		return -1;
	parser->cur++;
	if (http_date_parse_sp(parser) <= 0)
		return -1;

	/* day */
	if (http_date_parse_day(parser) <= 0)
		return -1;	

	/* "-" */
	if (parser->cur >= parser->end || parser->cur[0] != '-')
		return -1;
	parser->cur++;

	/* month */
	if (http_date_parse_month(parser) <= 0)
		return -1;	

	/* "-" */
	if (parser->cur >= parser->end || parser->cur[0] != '-')
		return -1;
	parser->cur++;

	/* 2DIGIT */
	if (http_date_parse_number(parser, 2, &parser->tm.tm_year) <= 0)
		return -1;
	if (parser->tm.tm_year < 70)
		parser->tm.tm_year += 100;

	/* SP time-of-day SP GMT */
	return http_date_parse_time_gmt(parser);
}