aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/nginx.c4
-rw-r--r--src/core/ngx_conf_file.c55
-rw-r--r--src/core/ngx_conf_file.h38
-rw-r--r--src/core/ngx_connection.h5
-rw-r--r--src/core/ngx_modules.c6
5 files changed, 67 insertions, 41 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c
index 70ff149cf..c2fdc87ba 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -87,7 +87,7 @@ int main(int argc, char *const *argv)
conf.ctx = ngx_conf_ctx;
conf.pool = ngx_pool;
conf.log = &ngx_log;
- conf.module_type = NGX_CORE_MODULE_TYPE;
+ conf.module_type = NGX_CORE_MODULE;
conf.cmd_type = NGX_MAIN_CONF;
conf_file.len = sizeof("nginx.conf") - 1;
@@ -121,7 +121,7 @@ int main(int argc, char *const *argv)
/* STUB */
ngx_worker(&ngx_log);
- }
+ }
return 0;
}
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index 28068d4fe..527cbdfe0 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -6,6 +6,9 @@
#include <ngx_conf_file.h>
+char ngx_conf_errstr[MAX_CONF_ERRSTR];
+
+
static int argument_number[] = {
NGX_CONF_NOARGS,
NGX_CONF_TAKE1,
@@ -17,7 +20,7 @@ static int ngx_conf_read_token(ngx_conf_t *cf);
char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename)
{
- int i, rc, found;
+ int m, rc, found;
char *rv;
void *conf, **confp;
ngx_str_t *name;
@@ -32,7 +35,6 @@ char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename)
fd = ngx_open_file(filename->data, NGX_FILE_RDONLY);
if (fd == NGX_INVALID_FILE) {
ngx_log_error(NGX_LOG_EMERG, cf->log, ngx_errno,
- "ngx_conf_file: "
ngx_open_file_n " %s failed", filename->data);
return NGX_CONF_ERROR;
}
@@ -44,7 +46,6 @@ char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename)
if (ngx_stat_fd(fd, &cf->conf_file->file.info) == -1) {
ngx_log_error(NGX_LOG_EMERG, cf->log, ngx_errno,
- "ngx_conf_file: "
ngx_stat_fd_n " %s failed", filename->data);
}
@@ -101,17 +102,17 @@ ngx_log_debug(cf->log, "token %d" _ rc);
name = (ngx_str_t *) cf->args->elts;
found = 0;
- for (i = 0; !found && ngx_modules[i]; i++) {
+ for (m = 0; !found && ngx_modules[m]; m++) {
/* look up the directive in the appropriate modules */
- if (ngx_modules[i]->type != NGX_CONF_MODULE_TYPE
- && ngx_modules[i]->type != cf->module_type)
+ if (ngx_modules[m]->type != NGX_CONF_MODULE
+ && ngx_modules[m]->type != cf->module_type)
{
continue;
}
- cmd = ngx_modules[i]->commands;
+ cmd = ngx_modules[m]->commands;
if (cmd == NULL) {
continue;
}
@@ -160,14 +161,14 @@ ngx_log_debug(cf->log, "command '%s'" _ cmd->name.data);
conf = NULL;
- if (cf->module_type == NGX_CORE_MODULE_TYPE) {
- conf = &(((void **) cf->ctx)[ngx_modules[i]->index]);
+ if (cf->module_type == NGX_CORE_MODULE) {
+ conf = &(((void **) cf->ctx)[ngx_modules[m]->index]);
} else if (cf->ctx) {
confp = *(void **) ((char *) cf->ctx + cmd->conf);
if (confp) {
- conf = confp[*(int *)(ngx_modules[i]->ctx)];
+ conf = confp[ngx_modules[m]->ctx_index];
}
}
@@ -185,11 +186,19 @@ ngx_log_debug(cf->log, "rv: %d" _ rv);
return NGX_CONF_ERROR;
} else {
- ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
- "%s %s in %s:%d",
- name->data, rv,
- cf->conf_file->file.name.data,
- cf->conf_file->line);
+ if (rv == ngx_conf_errstr) {
+ ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
+ "%s in %s:%d",
+ rv,
+ cf->conf_file->file.name.data,
+ cf->conf_file->line);
+ } else {
+ ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
+ "%s %s in %s:%d",
+ name->data, rv,
+ cf->conf_file->file.name.data,
+ cf->conf_file->line);
+ }
return NGX_CONF_ERROR;
}
@@ -430,7 +439,7 @@ ngx_log_debug(cf->log, "FOUND %d:'%s'" _ word->len _ word->data);
}
-char *ngx_conf_set_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
+char *ngx_conf_set_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
int flag;
ngx_str_t *value;
@@ -457,13 +466,13 @@ char *ngx_conf_set_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
}
-char *ngx_conf_set_str_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
+char *ngx_conf_set_str_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
ngx_str_t *field, *value;
field = (ngx_str_t *) (conf + cmd->offset);
- if (field->len > 0) {
+ if (field->data) {
return "is duplicate";
}
@@ -476,7 +485,7 @@ char *ngx_conf_set_str_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
}
-char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
+char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
int num, len;
ngx_str_t *value;
@@ -500,7 +509,7 @@ char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
}
-char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
+char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
int size, len, scale;
char last;
@@ -545,7 +554,7 @@ char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
}
-char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
+char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
int size, total, len, scale;
u_int max, i;
@@ -640,7 +649,7 @@ char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
}
-char *ngx_conf_set_sec_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
+char *ngx_conf_set_sec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
int size, total, len, scale;
u_int max, i;
@@ -747,7 +756,7 @@ char *ngx_conf_set_sec_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
}
-char *ngx_conf_unsupported(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
+char *ngx_conf_unsupported(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
return "unsupported on this platform";
}
diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h
index 40b976316..3624d5df0 100644
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -40,9 +40,14 @@
#define NGX_CONF_BLOCK_DONE 1
#define NGX_CONF_FILE_DONE 2
+#define NGX_MODULE 0, 0
-#define NGX_CORE_MODULE_TYPE 0x45524F43 /* "CORE" */
-#define NGX_CONF_MODULE_TYPE 0x464E4F43 /* "CONF" */
+#define NGX_CORE_MODULE 0x45524F43 /* "CORE" */
+#define NGX_CONF_MODULE 0x464E4F43 /* "CONF" */
+
+
+#define MAX_CONF_ERRSTR 256
+extern char ngx_conf_errstr[MAX_CONF_ERRSTR];
typedef struct ngx_conf_s ngx_conf_t;
@@ -52,16 +57,18 @@ typedef struct ngx_command_s ngx_command_t;
struct ngx_command_s {
ngx_str_t name;
int type;
- char *(*set)(ngx_conf_t *cf, ngx_command_t *cmd, char *conf);
+ char *(*set)(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
int conf;
int offset;
void *bounds;
};
+#define ngx_null_command {ngx_null_string, 0, NULL, 0, 0, NULL}
typedef struct {
- void *ctx;
+ int ctx_index;
int index;
+ void *ctx;
ngx_command_t *commands;
int type;
int (*init_module)(ngx_pool_t *p);
@@ -129,6 +136,17 @@ struct ngx_conf_s {
conf = (prev == (size_t) NGX_CONF_UNSET) ? default : prev; \
}
+#define ngx_conf_merge_str_value(conf, prev, default) \
+ if (conf.len == 0) { \
+ if (prev.len) { \
+ conf.len = prev.len; \
+ conf.data = prev.data; \
+ } else { \
+ conf.len = sizeof(default) - 1; \
+ conf.data = default; \
+ } \
+ }
+
#define addressof(addr) ((int) &addr)
@@ -136,12 +154,12 @@ struct ngx_conf_s {
char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename);
-char *ngx_conf_set_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf);
-char *ngx_conf_set_str_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf);
-char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf);
-char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf);
-char *ngx_conf_set_msec_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);
+char *ngx_conf_set_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
+char *ngx_conf_set_str_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
+char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
+char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
+char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
+char *ngx_conf_set_time_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
extern ngx_module_t *ngx_modules[];
diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h
index 02108426c..59bf33307 100644
--- a/src/core/ngx_connection.h
+++ b/src/core/ngx_connection.h
@@ -10,9 +10,9 @@
#include <ngx_hunk.h>
#include <ngx_array.h>
#include <ngx_string.h>
-#endif
#include <ngx_server.h>
+#endif
#if 0
typedef struct ngx_connection_s ngx_connection_t;
@@ -35,7 +35,7 @@ struct ngx_connection_s {
void (*handler)(ngx_connection_t *c);
void *ctx;
- ngx_server_t *servers;
+ void *servers;
ngx_log_t *log;
@@ -114,7 +114,6 @@ ngx_chain_t *ngx_write_chain(ngx_connection_t *c, ngx_chain_t *in, off_t flush);
/* TODO: move it to OS specific file */
#if (__FreeBSD__)
-ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in);
ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in);
#endif
diff --git a/src/core/ngx_modules.c b/src/core/ngx_modules.c
index cf5458c5a..8f57db399 100644
--- a/src/core/ngx_modules.c
+++ b/src/core/ngx_modules.c
@@ -30,6 +30,7 @@ extern ngx_module_t ngx_http_output_filter_module;
extern ngx_module_t ngx_http_header_filter_module;
extern ngx_module_t ngx_http_index_module;
+extern ngx_module_t ngx_http_static_module;
extern ngx_module_t ngx_http_proxy_module;
@@ -68,9 +69,8 @@ ngx_module_t *ngx_modules[] = {
/* &ngx_http_ssi_filter_module, */
&ngx_http_index_module,
-/*
- &ngx_http_proxy_module,
-*/
+ /* &ngx_http_static_module, */
+ /* &ngx_http_proxy_module, */
NULL
};