Mercurial > hg > nginx
diff src/core/ngx_conf_file.c @ 156:afc333135a6b
nginx-0.0.1-2003-10-23-10:13:16 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 23 Oct 2003 06:13:16 +0000 |
parents | 46eb23d9471d |
children | 70b36c805682 |
line wrap: on
line diff
--- a/src/core/ngx_conf_file.c Wed Oct 22 16:38:26 2003 +0000 +++ b/src/core/ngx_conf_file.c Thu Oct 23 06:13:16 2003 +0000 @@ -546,6 +546,7 @@ int flag; ngx_str_t *value; + if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) { return "is duplicate"; } @@ -596,23 +597,25 @@ { char *p = conf; - int num, len; + int *np; ngx_str_t *value; - if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) { + + np = (int *) (p + cmd->offset); + + if (*np != NGX_CONF_UNSET) { return "is duplicate"; } value = (ngx_str_t *) cf->args->elts; - - len = value[1].len; - - num = ngx_atoi(value[1].data, len); - if (num == NGX_ERROR) { + *np = ngx_atoi(value[1].data, value[1].len); + if (*np == NGX_ERROR) { return "invalid number"; } - *(int *) (p + cmd->offset) = num; + if (cmd->bounds) { + return cmd->bounds->check(cf, cmd->bounds, np); + } return NGX_CONF_OK; } @@ -622,11 +625,14 @@ { char *p = conf; - int size, len, scale; + int size, len, scale, *np; char last; ngx_str_t *value; - if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) { + + np = (int *) (p + cmd->offset); + + if (*np != NGX_CONF_UNSET) { return "is duplicate"; } @@ -658,8 +664,11 @@ } size *= scale; + *np = size; - *(int *) (p + cmd->offset) = size; + if (cmd->bounds) { + return cmd->bounds->check(cf, cmd->bounds, np); + } return NGX_CONF_OK; } @@ -669,12 +678,15 @@ { char *p = conf; - int size, total, len, scale; + int size, total, len, scale, *np; u_int max, i; char last, *start; ngx_str_t *value; - if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) { + + np = (int *) (p + cmd->offset); + + if (*np != NGX_CONF_UNSET) { return "is duplicate"; } @@ -756,7 +768,11 @@ start = &value[1].data[i + 1]; } - *(int *) (p + cmd->offset) = total; + *np = total; + + if (cmd->bounds) { + return cmd->bounds->check(cf, cmd->bounds, np); + } return NGX_CONF_OK; } @@ -766,12 +782,15 @@ { char *p = conf; - int size, total, len, scale; + int size, total, len, scale, *np; u_int max, i; char last, *start; ngx_str_t *value; - if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) { + + np = (int *) (p + cmd->offset); + + if (*np != NGX_CONF_UNSET) { return "is duplicate"; } @@ -865,7 +884,11 @@ start = &value[1].data[i + 1]; } - *(int *) (p + cmd->offset) = total; + *np = total; + + if (cmd->bounds) { + return cmd->bounds->check(cf, cmd->bounds, np); + } return NGX_CONF_OK; } @@ -929,3 +952,17 @@ { return "unsupported on this platform"; } + + +char *ngx_conf_check_num_bounds(ngx_conf_t *cf, ngx_conf_bounds_t *bounds, + void *conf) +{ + int *num = conf; + + if (*num >= bounds->type.num.low && *num <= bounds->type.num.high) { + return NGX_CONF_OK; + + } + + return "invalid value"; +}