3 * Copyright (C) Igor Sysoev
7 #include <ngx_config.h>
12 ngx_parse_size(ngx_str_t *line)
20 unit = line->data[len - 1];
39 size = ngx_atosz(line->data, len);
40 if (size == NGX_ERROR) {
51 ngx_parse_offset(ngx_str_t *line)
59 unit = line->data[len - 1];
77 scale = 1024 * 1024 * 1024;
84 offset = ngx_atoof(line->data, len);
85 if (offset == NGX_ERROR) {
96 ngx_parse_time(ngx_str_t *line, ngx_uint_t sec)
99 ngx_int_t value, total, scale;
100 ngx_uint_t max, valid;
117 step = sec ? st_start : st_month;
118 scale = sec ? 1 : 1000;
121 last = p + line->len;
125 if (*p >= '0' && *p <= '9') {
126 value = value * 10 + (*p++ - '0');
134 if (step > st_start) {
139 scale = 60 * 60 * 24 * 365;
143 if (step > st_year) {
148 scale = 60 * 60 * 24 * 30;
152 if (step > st_month) {
157 scale = 60 * 60 * 24 * 7;
161 if (step > st_week) {
166 scale = 60 * 60 * 24;
180 if (sec || step > st_sec) {
190 if (step > st_hour) {
220 if (step != st_msec && !sec) {
225 if ((ngx_uint_t) value > max) {
229 total += value * scale;
231 if ((ngx_uint_t) total > 2147483647) {
236 scale = sec ? 1 : 1000;
238 while (p < last && *p == ' ') {
244 return total + value * scale;