aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/nginx.c1
-rw-r--r--src/core/ngx_config_file.c65
-rw-r--r--src/core/ngx_config_file.h23
-rw-r--r--src/core/ngx_modules.c20
-rw-r--r--src/core/ngx_string.h3
5 files changed, 61 insertions, 51 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c
index bab1fa738..17a3d10c3 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -62,7 +62,6 @@ int main(int argc, char *const *argv)
ngx_create_array(ngx_pool, 10, sizeof(ngx_str_t)), 1);
conf.pool = ngx_pool;
conf.log = &ngx_log;
- conf.modules = ngx_http_modules;
conf_file.len = sizeof("nginx.conf") - 1;
conf_file.data = "nginx.conf";
diff --git a/src/core/ngx_config_file.c b/src/core/ngx_config_file.c
index b1582d1d2..79d72183c 100644
--- a/src/core/ngx_config_file.c
+++ b/src/core/ngx_config_file.c
@@ -1,8 +1,6 @@
#include <ngx_config.h>
-
#include <ngx_core.h>
-
#include <ngx_config_file.h>
@@ -13,14 +11,13 @@ static int argument_number[] = {
};
static int ngx_conf_read_token(ngx_conf_t *cf);
-static ngx_command_t *ngx_conf_find_token(ngx_conf_t *cf,
- ngx_http_module_t **modules);
int ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename)
{
- int rc;
+ int rc, i;
char *error;
+ ngx_str_t *name;
ngx_fd_t fd;
ngx_conf_file_t *prev;
ngx_command_t *cmd;
@@ -75,7 +72,29 @@ int ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename)
continue;
}
- cmd = ngx_conf_find_token(cf);
+ name = (ngx_str_t *) cf->args->elts;
+
+ for (i = 0; ngx_modules[i]; i++) {
+ if (cf->type != ngx_modules[i]->type) {
+ continue;
+ }
+
+ cmd = ngx_modules[i]->commands;
+ if (cmd == NULL) {
+ continue;
+ }
+
+ while (cmd->name.len) {
+ if (name->len == cmd->name.len
+ && ngx_strcmp(name->data, cmd->name.data) == 0)
+ {
+ngx_log_debug(cf->log, "command '%s'" _ cmd->name.data);
+ cmd->set(cf, cmd, NULL);
+ }
+
+ cmd++;
+ }
+ }
#if 0
cmd = ngx_conf_find_token(cf);
@@ -368,59 +387,37 @@ ngx_log_debug(cf->log, "FOUND %d:'%s'" _ word->len _ word->data);
}
-static ngx_command_t *ngx_conf_find_token(ngx_conf_t *cf)
-{
- int i;
- ngx_command_t *cmd;
-
- for (i = 0; cf->modules[i]; i++) {
- cmd = cf->modules[i]->commands;
- if (cmd == NULL) {
- continue;
- }
-
- while (cmd->name) {
-
-ngx_log_debug(cf->log, "command '%s'" _ cmd->name);
-
- cmd++;
- }
-
- }
-}
-
-
-char *ngx_conf_set_size_slot(ngx_conf_t *cf, char *conf)
+char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
{
int size;
ngx_str_t *value;
value = (ngx_str_t *) cf->args->elts;
- size = atoi(value.data);
+ size = atoi(value[1].data);
if (size < 0) {
return "value must be greater or equal to zero";
}
- *(int *) (conf + cf->offset) = size;
+ *(int *) (conf + cmd->offset) = size;
return NULL;
}
-char *ngx_conf_set_time_slot(ngx_conf_t *cf, char *conf)
+char *ngx_conf_set_time_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
{
int size;
ngx_str_t *value;
value = (ngx_str_t *) cf->args->elts;
- size = atoi(value.data);
+ size = atoi(value[1].data);
if (size < 0) {
return "value must be greater or equal to zero";
}
- *(int *) (conf + offset) = size;
+ *(int *) (conf + cmd->offset) = size;
return NULL;
}
diff --git a/src/core/ngx_config_file.h b/src/core/ngx_config_file.h
index a7eb47c1d..768dc666b 100644
--- a/src/core/ngx_config_file.h
+++ b/src/core/ngx_config_file.h
@@ -16,7 +16,8 @@
#define NGX_CONF_TAKE1 2
#define NGX_CONF_TAKE2 4
-#define NGX_CONF_ITERATE 0
+#define NGX_CONF_ANY 0x10000
+#define NGX_CONF_BLOCK 0x20000
#define NGX_CONF_UNSET -1
@@ -28,13 +29,14 @@
typedef struct ngx_conf_s ngx_conf_t;
-typedef struct {
+typedef struct ngx_command_s ngx_command_t;
+struct ngx_command_s {
ngx_str_t name;
- char *(*set)(ngx_conf_t *cf);
- int offset;
- int zone;
int type;
-} ngx_command_t;
+ char *(*set)(ngx_conf_t *cf, ngx_command_t *cmd, char *conf);
+ int conf;
+ int offset;
+};
typedef struct {
@@ -60,9 +62,8 @@ struct ngx_conf_s {
ngx_conf_file_t *conf_file;
ngx_log_t *log;
- ngx_module_t *modules;
-
void *ctx;
+ int type;
int (*handler)(ngx_conf_t *cf);
};
@@ -70,7 +71,11 @@ struct ngx_conf_s {
int ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename);
-char *ngx_conf_set_size_slot(ngx_conf_t *cf);
+char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf);
+char *ngx_conf_set_time_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf);
+
+
+extern ngx_module_t *ngx_modules[];
#endif _NGX_HTTP_CONFIG_FILE_H_INCLUDED_
diff --git a/src/core/ngx_modules.c b/src/core/ngx_modules.c
index 5b814baf9..4d43349f3 100644
--- a/src/core/ngx_modules.c
+++ b/src/core/ngx_modules.c
@@ -1,15 +1,19 @@
-#include <ngx_http.h>
+#include <ngx_config_file.h>
-extern ngx_http_module_t ngx_http_header_filter_module;
-extern ngx_http_module_t ngx_http_write_filter_module;
-extern ngx_http_module_t ngx_http_output_filter_module;
+extern ngx_module_t ngx_http_header_filter_module;
-extern ngx_http_module_t ngx_http_core_module;
-extern ngx_http_module_t ngx_http_index_module;
+extern ngx_module_t ngx_http_write_filter_module;
+extern ngx_module_t ngx_http_output_filter_module;
-ngx_http_module_t *ngx_http_modules[] = {
+extern ngx_module_t ngx_http_core_module;
+extern ngx_module_t ngx_http_index_module;
+
+extern ngx_module_t ngx_http_module;
+
+
+ngx_module_t *ngx_modules[] = {
&ngx_http_header_filter_module,
@@ -19,5 +23,7 @@ ngx_http_module_t *ngx_http_modules[] = {
&ngx_http_index_module,
&ngx_http_core_module,
+ &ngx_http_module,
+
NULL
};
diff --git a/src/core/ngx_string.h b/src/core/ngx_string.h
index 3e28abb68..9ee3e5e29 100644
--- a/src/core/ngx_string.h
+++ b/src/core/ngx_string.h
@@ -19,6 +19,7 @@ typedef struct {
#define ngx_memzero ZeroMemory
#define strcasecmp stricmp
+#define ngx_strcmp strcmp
#define ngx_snprintf _snprintf
#define ngx_vsnprintf _vsnprintf
@@ -27,6 +28,8 @@ typedef struct {
#define ngx_memzero bzero
+#define ngx_strcmp strcmp
+
#define ngx_snprintf snprintf
#define ngx_vsnprintf vsnprintf