summaryrefslogtreecommitdiffhomepage
path: root/src/http/ngx_http_parse_time.c
blob: 3e730a61a34296efcd48ffedbb90db38ee6956ce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

time_t ngx_http_parse_time()
{
    enum {
        sw_start = 0,
    } state;

    state = sw_start;

    while () {
        switch (state) {

        case sw_start:
            if (ch == ' ') {
                ansi = 1;
                state = sw_month;

            } else if (ch == ',')
                state = sw_day_first_digit;

            break;

        case sw_day_first_digit:
            if (ch == ' ')
                break;

            if (ch >= '0' && ch <= '9') {
                day = ch - '0';
                state = sw_day;
                break;

            }

            return NGX_ERROR;

        case sw_day:
            if (ansi && ch == ' ') {
                state = sw_hour_first_digit;
                break;
            }

            if (ch >= '0' && ch <= '9') {
                day = ch - '0';
                state = ansi ? sw_space_before_hour : sw_before_month;
                break;
            }

            return NGX_ERROR;

        case sw_before_month:
            if (ch == ' ') {
                rfc822 = 1;
            }

            if (ch == '-') {
                rfc850 = 1;
            }

        case sw_space_before_hour:


        }
    }
}