summaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2003-10-24 06:53:41 +0000
committerIgor Sysoev <igor@sysoev.ru>2003-10-24 06:53:41 +0000
commit12b4b00784bbc3cd934e2f2bbee79679684629e3 (patch)
tree602dfdcdc4fe5b21c17366eacfae63efcb03770e /src/core
parent8556e6da41e80772cb9710e4309d9ad44a7b360e (diff)
downloadnginx-12b4b00784bbc3cd934e2f2bbee79679684629e3.tar.gz
nginx-12b4b00784bbc3cd934e2f2bbee79679684629e3.tar.bz2
nginx-0.0.1-2003-10-24-10:53:41 import
Diffstat (limited to 'src/core')
-rw-r--r--src/core/ngx_conf_file.c53
-rw-r--r--src/core/ngx_conf_file.h54
2 files changed, 52 insertions, 55 deletions
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index 99ed1cb1b..e9e931525 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -596,8 +596,9 @@ char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
char *p = conf;
- int *np;
- ngx_str_t *value;
+ int *np;
+ ngx_str_t *value;
+ ngx_conf_post_t *post;
np = (int *) (p + cmd->offset);
@@ -612,8 +613,9 @@ char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return "invalid number";
}
- if (cmd->bounds) {
- return cmd->bounds->check(cf, cmd->bounds, np);
+ if (cmd->post) {
+ post = cmd->post;
+ return post->post_handler(cf, post, np);
}
return NGX_CONF_OK;
@@ -624,8 +626,9 @@ char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
char *p = conf;
- int *np;
- ngx_str_t *value;
+ int *np;
+ ngx_str_t *value;
+ ngx_conf_post_t *post;
np = (int *) (p + cmd->offset);
@@ -640,8 +643,9 @@ char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return "invalid value";
}
- if (cmd->bounds) {
- return cmd->bounds->check(cf, cmd->bounds, np);
+ if (cmd->post) {
+ post = cmd->post;
+ return post->post_handler(cf, post, np);
}
return NGX_CONF_OK;
@@ -652,10 +656,9 @@ char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
char *p = conf;
- int size, total, len, scale, *np;
- u_int max, i;
- char last, *start;
- ngx_str_t *value;
+ int *np;
+ ngx_str_t *value;
+ ngx_conf_post_t *post;
np = (int *) (p + cmd->offset);
@@ -674,8 +677,9 @@ char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return "value must be less than 597 hours";
}
- if (cmd->bounds) {
- return cmd->bounds->check(cf, cmd->bounds, np);
+ if (cmd->post) {
+ post = cmd->post;
+ return post->post_handler(cf, post, np);
}
return NGX_CONF_OK;
@@ -686,10 +690,9 @@ char *ngx_conf_set_sec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
char *p = conf;
- int size, total, len, scale, *np;
- u_int max, i;
- char last, *start;
- ngx_str_t *value;
+ int *np;
+ ngx_str_t *value;
+ ngx_conf_post_t *post;
np = (int *) (p + cmd->offset);
@@ -708,8 +711,9 @@ char *ngx_conf_set_sec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return "value must be less than 68 years";
}
- if (cmd->bounds) {
- return cmd->bounds->check(cf, cmd->bounds, np);
+ if (cmd->post) {
+ post = cmd->post;
+ return post->post_handler(cf, post, np);
}
return NGX_CONF_OK;
@@ -751,14 +755,13 @@ char *ngx_conf_unsupported(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}
-char *ngx_conf_check_num_bounds(ngx_conf_t *cf, ngx_conf_bounds_t *bounds,
- void *conf)
+char *ngx_conf_check_num_bounds(ngx_conf_t *cf, void *post, void *data)
{
- int *num = conf;
+ ngx_conf_num_bounds_t *bounds = post;
+ int *np = data;
- if (*num >= bounds->type.num.low && *num <= bounds->type.num.high) {
+ if (*np >= bounds->low && (u_int) *np <= (u_int) bounds->high) {
return NGX_CONF_OK;
-
}
return "invalid value";
diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h
index c40e40ec9..c132d07ac 100644
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -51,34 +51,13 @@
#define NGX_CONF_MODULE 0x464E4F43 /* "CONF" */
-typedef struct ngx_conf_bounds_s ngx_conf_bounds_t;
-
-struct ngx_conf_bounds_s {
- char *(*check)(ngx_conf_t *cf, ngx_conf_bounds_t *bounds, void *conf);
-
- union {
- struct {
- int low;
- int high;
- } num;
-
- struct num {
- int low_num;
- int high_num;
- int low_size;
- int high_size;
- } bufs;
- } type;
-};
-
-
struct ngx_command_s {
- ngx_str_t name;
- int type;
- char *(*set)(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
- int conf;
- int offset;
- ngx_conf_bounds_t *bounds;
+ ngx_str_t name;
+ int type;
+ char *(*set)(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
+ int conf;
+ int offset;
+ void *post;
};
#define ngx_null_command { ngx_null_string, 0, NULL, 0, 0, NULL }
@@ -156,6 +135,24 @@ struct ngx_conf_s {
};
+typedef char *(*ngx_conf_post_handler_pt) (ngx_conf_t *cf,
+ void *data, void *conf);
+
+typedef struct {
+ ngx_conf_post_handler_pt post_handler;
+} ngx_conf_post_t;
+
+
+typedef struct {
+ ngx_conf_post_handler_pt post_handler;
+ int low;
+ int high;
+} ngx_conf_num_bounds_t;
+
+
+char *ngx_conf_check_num_bounds(ngx_conf_t *cf, void *post, void *data);
+
+
#define ngx_get_conf(conf_ctx, module) conf_ctx[module.index]
@@ -240,9 +237,6 @@ char *ngx_conf_set_bufs_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
char *ngx_conf_set_core_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
-char *ngx_conf_check_num_bounds(ngx_conf_t *cf, ngx_conf_bounds_t *bounds,
- void *conf);
-
extern ngx_module_t *ngx_modules[];
extern ngx_cycle_t *ngx_cycle;