Mercurial > hg > nginx-quic
annotate src/core/ngx_parse.c @ 3572:b7c4d96cd61c stable-0.7
bump version
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 04 Jun 2010 17:38:59 +0000 |
parents | 9d2bdbda4ee3 |
children | c352c483263c |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
5 |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
563 | 11 ssize_t |
12 ngx_parse_size(ngx_str_t *line) | |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
13 { |
1971 | 14 u_char unit; |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
15 size_t len; |
563 | 16 ssize_t size; |
17 ngx_int_t scale; | |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
18 |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
19 len = line->len; |
1971 | 20 unit = line->data[len - 1]; |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
21 |
1971 | 22 switch (unit) { |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
23 case 'K': |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
24 case 'k': |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
25 len--; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
26 scale = 1024; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
27 break; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
28 |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
29 case 'M': |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
30 case 'm': |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
31 len--; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
32 scale = 1024 * 1024; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
33 break; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
34 |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
35 default: |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
36 scale = 1; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
37 } |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
38 |
563 | 39 size = ngx_atosz(line->data, len); |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
40 if (size == NGX_ERROR) { |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
41 return NGX_ERROR; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
42 } |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
43 |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
44 size *= scale; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
45 |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
46 return size; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
47 } |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
48 |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
49 |
663 | 50 off_t |
51 ngx_parse_offset(ngx_str_t *line) | |
52 { | |
1971 | 53 u_char unit; |
663 | 54 off_t offset; |
55 size_t len; | |
56 ngx_int_t scale; | |
57 | |
58 len = line->len; | |
1971 | 59 unit = line->data[len - 1]; |
663 | 60 |
1971 | 61 switch (unit) { |
663 | 62 case 'K': |
63 case 'k': | |
64 len--; | |
65 scale = 1024; | |
66 break; | |
67 | |
68 case 'M': | |
69 case 'm': | |
70 len--; | |
71 scale = 1024 * 1024; | |
72 break; | |
73 | |
74 case 'G': | |
75 case 'g': | |
76 len--; | |
77 scale = 1024 * 1024 * 1024; | |
78 break; | |
79 | |
80 default: | |
81 scale = 1; | |
82 } | |
83 | |
84 offset = ngx_atoof(line->data, len); | |
85 if (offset == NGX_ERROR) { | |
86 return NGX_ERROR; | |
87 } | |
88 | |
89 offset *= scale; | |
90 | |
91 return offset; | |
92 } | |
93 | |
94 | |
563 | 95 ngx_int_t |
1972
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
96 ngx_parse_time(ngx_str_t *line, ngx_uint_t sec) |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
97 { |
1972
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
98 u_char *p, *last; |
651 | 99 ngx_int_t value, total, scale; |
1972
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
100 ngx_uint_t max, valid; |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
101 enum { |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
102 st_start = 0, |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
103 st_year, |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
104 st_month, |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
105 st_week, |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
106 st_day, |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
107 st_hour, |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
108 st_min, |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
109 st_sec, |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
110 st_msec, |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
111 st_last |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
112 } step; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
113 |
1972
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
114 valid = 0; |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
115 value = 0; |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
116 total = 0; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
117 step = sec ? st_start : st_month; |
1972
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
118 scale = sec ? 1 : 1000; |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
119 |
1972
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
120 p = line->data; |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
121 last = p + line->len; |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
122 |
1972
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
123 while (p < last) { |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
124 |
1972
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
125 if (*p >= '0' && *p <= '9') { |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
126 value = value * 10 + (*p++ - '0'); |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
127 valid = 1; |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
128 continue; |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
129 } |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
130 |
1972
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
131 switch (*p++) { |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
132 |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
133 case 'y': |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
134 if (step > st_start) { |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
135 return NGX_ERROR; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
136 } |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
137 step = st_year; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
138 max = 68; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
139 scale = 60 * 60 * 24 * 365; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
140 break; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
141 |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
142 case 'M': |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
143 if (step > st_year) { |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
144 return NGX_ERROR; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
145 } |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
146 step = st_month; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
147 max = 828; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
148 scale = 60 * 60 * 24 * 30; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
149 break; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
150 |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
151 case 'w': |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
152 if (step > st_month) { |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
153 return NGX_ERROR; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
154 } |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
155 step = st_week; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
156 max = 3550; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
157 scale = 60 * 60 * 24 * 7; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
158 break; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
159 |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
160 case 'd': |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
161 if (step > st_week) { |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
162 return NGX_ERROR; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
163 } |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
164 step = st_day; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
165 max = 24855; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
166 scale = 60 * 60 * 24; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
167 break; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
168 |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
169 case 'h': |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
170 if (step > st_day) { |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
171 return NGX_ERROR; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
172 } |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
173 step = st_hour; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
174 max = 596523; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
175 scale = 60 * 60; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
176 break; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
177 |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
178 case 'm': |
1972
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
179 if (*p == 's') { |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
180 if (sec || step > st_sec) { |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
181 return NGX_ERROR; |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
182 } |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
183 p++; |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
184 step = st_msec; |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
185 max = 2147483647; |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
186 scale = 1; |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
187 break; |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
188 } |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
189 |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
190 if (step > st_hour) { |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
191 return NGX_ERROR; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
192 } |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
193 step = st_min; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
194 max = 35791394; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
195 scale = 60; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
196 break; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
197 |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
198 case 's': |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
199 if (step > st_min) { |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
200 return NGX_ERROR; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
201 } |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
202 step = st_sec; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
203 max = 2147483647; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
204 scale = 1; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
205 break; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
206 |
1972
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
207 case ' ': |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
208 if (step > st_min) { |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
209 return NGX_ERROR; |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
210 } |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
211 step = st_last; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
212 max = 2147483647; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
213 scale = 1; |
1972
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
214 break; |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
215 |
1972
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
216 default: |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
217 return NGX_ERROR; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
218 } |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
219 |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
220 if (step != st_msec && !sec) { |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
221 scale *= 1000; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
222 max /= 1000; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
223 } |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
224 |
1972
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
225 if ((ngx_uint_t) value > max) { |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
226 return NGX_ERROR; |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
227 } |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
228 |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
229 total += value * scale; |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
230 |
1972
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
231 if ((ngx_uint_t) total > 2147483647) { |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
232 return NGX_ERROR; |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
233 } |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
234 |
1972
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
235 value = 0; |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
236 scale = sec ? 1 : 1000; |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
237 |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
238 while (p < last && *p == ' ') { |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
239 p++; |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
240 } |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
241 } |
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
242 |
1972
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
243 if (valid) { |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
244 return total + value * scale; |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
245 } |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
246 |
9d2bdbda4ee3
allow time without spaces in ngx_parse_time()
Igor Sysoev <igor@sysoev.ru>
parents:
1971
diff
changeset
|
247 return NGX_ERROR; |
157
70b36c805682
nginx-0.0.1-2003-10-23-19:54:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
248 } |