diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/nginx.c | 4 | ||||
| -rw-r--r-- | src/core/ngx_alloc.h | 4 | ||||
| -rw-r--r-- | src/core/ngx_conf_file.c | 29 | ||||
| -rw-r--r-- | src/core/ngx_conf_file.h | 3 | ||||
| -rw-r--r-- | src/core/ngx_config.h | 10 | ||||
| -rw-r--r-- | src/core/ngx_core.h | 1 | ||||
| -rw-r--r-- | src/core/ngx_file.c | 8 | ||||
| -rw-r--r-- | src/core/ngx_log.c | 2 | ||||
| -rw-r--r-- | src/core/ngx_modules.c | 3 | ||||
| -rw-r--r-- | src/core/ngx_regex.c | 71 | ||||
| -rw-r--r-- | src/core/ngx_regex.h | 23 | ||||
| -rw-r--r-- | src/core/ngx_times.c | 2 | ||||
| -rw-r--r-- | src/core/ngx_times.h | 2 |
13 files changed, 146 insertions, 16 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c index 26db6f8b7..77d1dc632 100644 --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -59,6 +59,7 @@ ngx_array_t ngx_old_cycles; static ngx_pool_t *ngx_temp_pool; static ngx_event_t ngx_cleaner_event; + /* STUB NAME */ static ngx_connection_t dumb; @@ -91,7 +92,8 @@ int main(int argc, char *const *argv) /* TODO */ ngx_max_sockets = -1; - ngx_init_time(); + ngx_time_init(); + ngx_regex_init(); log = ngx_log_init_errlog(); diff --git a/src/core/ngx_alloc.h b/src/core/ngx_alloc.h index 946361182..e64f84f4a 100644 --- a/src/core/ngx_alloc.h +++ b/src/core/ngx_alloc.h @@ -7,9 +7,9 @@ /* - * NGX_MAX_ALLOC_FROM_POOL should be (PAGE_SIZE - 1), i.e. 4095 on x86. + * NGX_MAX_ALLOC_FROM_POOL should be (NGX_PAGE_SIZE - 1), i.e. 4095 on x86. * On FreeBSD 5.x it allows to use zero copy send. - * On Windows NT it decreases number of locked pages in kernel. + * On Windows NT it decreases a number of locked pages in a kernel. */ #define NGX_MAX_ALLOC_FROM_POOL 4095 diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c index fd30216f5..868945747 100644 --- a/src/core/ngx_conf_file.c +++ b/src/core/ngx_conf_file.c @@ -3,9 +3,6 @@ #include <ngx_core.h> - -#define MAX_CONF_ERRSTR 256 - /* Ten fixed arguments */ static int argument_number[] = { @@ -471,7 +468,29 @@ ngx_log_debug(cf->log, "%d:%d:%d:%d:%d '%c'" _ len++) { if (*src == '\\') { - src++; + switch (src[1]) { + case '"': + case '\'': + case '\\': + src++; + break; + + case 't': + *dst++ = '\t'; + src += 2; + continue; + + case 'r': + *dst++ = '\r'; + src += 2; + continue; + + case 'n': + *dst++ = '\n'; + src += 2; + continue; + } + } *dst++ = *src++; } @@ -525,7 +544,7 @@ void ngx_conf_log_error(int level, ngx_conf_t *cf, ngx_err_t err, char *fmt, ...) { int len; - char errstr[MAX_CONF_ERRSTR]; + char errstr[NGX_MAX_CONF_ERRSTR]; va_list args; va_start(args, fmt); diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h index 8a473bf5a..eb5478e61 100644 --- a/src/core/ngx_conf_file.h +++ b/src/core/ngx_conf_file.h @@ -56,6 +56,9 @@ #define NGX_CONF_MODULE 0x464E4F43 /* "CONF" */ +#define NGX_MAX_CONF_ERRSTR 256 + + struct ngx_command_s { ngx_str_t name; int type; diff --git a/src/core/ngx_config.h b/src/core/ngx_config.h index 3621f8cf8..7e8c1b86d 100644 --- a/src/core/ngx_config.h +++ b/src/core/ngx_config.h @@ -2,9 +2,6 @@ #define _NGX_CONFIG_H_INCLUDED_ -#include <ngx_auto_config.h> - - #if defined __FreeBSD__ #include <ngx_freebsd_config.h> @@ -32,6 +29,13 @@ #endif +/* STUB: autoconf */ +typedef int ngx_int_t; +typedef u_int ngx_uint_t; + +#include <ngx_auto_config.h> + + #ifndef NGX_SERVER_ROOT #define NGX_SERVER_ROOT "./" #if 0 diff --git a/src/core/ngx_core.h b/src/core/ngx_core.h index 0dc45bba3..8d096fa89 100644 --- a/src/core/ngx_core.h +++ b/src/core/ngx_core.h @@ -28,6 +28,7 @@ typedef struct ngx_connection_s ngx_connection_t; #include <ngx_types.h> #include <ngx_file.h> #include <ngx_files.h> +#include <ngx_regex.h> #include <ngx_times.h> #include <ngx_inet.h> #include <ngx_conf_file.h> diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c index 4ae537894..4cbd8fc2c 100644 --- a/src/core/ngx_file.c +++ b/src/core/ngx_file.c @@ -70,7 +70,10 @@ int ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path, #endif #endif +#if 0 file->fd = ngx_open_tempfile(file->name.data, persistent); +#endif + file->fd = ngx_open_tempfile(file->name.data, 1); ngx_log_debug(file->log, "temp fd: %d" _ file->fd); @@ -225,14 +228,15 @@ char *ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return "invalid value"; } - path->len += path->level[i] + level + 1; + path->level[i] = level; + path->len += level + 1; } while (i < 3) { path->level[i++] = 0; } - path->gc_handler = cmd->post; + path->gc_handler = (ngx_gc_handler_pt) cmd->post; return NGX_CONF_OK; } diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c index a9ca9c363..627c507fc 100644 --- a/src/core/ngx_log.c +++ b/src/core/ngx_log.c @@ -89,7 +89,7 @@ void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, /* pid#tid */ len += ngx_snprintf(errstr + len, sizeof(errstr) - len - 1, - PID_FMT "#%d: ", ngx_getpid(), 0); + PID_T_FMT "#%d: ", ngx_getpid(), 0); if (log->data) { len += ngx_snprintf(errstr + len, sizeof(errstr) - len - 1, diff --git a/src/core/ngx_modules.c b/src/core/ngx_modules.c index c3159ad84..8948cdf24 100644 --- a/src/core/ngx_modules.c +++ b/src/core/ngx_modules.c @@ -28,6 +28,7 @@ extern ngx_module_t ngx_aio_module; extern ngx_module_t ngx_http_module; extern ngx_module_t ngx_http_core_module; extern ngx_module_t ngx_http_log_module; +extern ngx_module_t ngx_http_cache_module; extern ngx_module_t ngx_http_write_filter_module; extern ngx_module_t ngx_http_output_filter_module; @@ -78,6 +79,8 @@ ngx_module_t *ngx_modules[] = { &ngx_http_core_module, &ngx_http_log_module, + &ngx_http_cache_module, + &ngx_http_write_filter_module, &ngx_http_output_filter_module, &ngx_http_header_filter_module, diff --git a/src/core/ngx_regex.c b/src/core/ngx_regex.c new file mode 100644 index 000000000..377f998de --- /dev/null +++ b/src/core/ngx_regex.c @@ -0,0 +1,71 @@ + +#include <ngx_config.h> +#include <ngx_core.h> + + +static void *ngx_regex_malloc(size_t size); +static void ngx_regex_free(void *p); + + +/* THREADS: this pool should be private for each thread */ +static ngx_pool_t *ngx_pcre_pool; + + +void ngx_regex_init() +{ + pcre_malloc = ngx_regex_malloc; + pcre_free = ngx_regex_free; +} + + +ngx_regex_t *ngx_regex_compile(ngx_str_t *pattern, ngx_int_t options, + ngx_pool_t *pool, ngx_str_t *err) +{ + int erroff; + const char *errstr; + ngx_regex_t *re; + + ngx_pcre_pool = pool; + + re = pcre_compile(pattern->data, (int) options, &errstr, &erroff, NULL); + + if (re == NULL) { + if ((size_t) erroff == pattern->len) { + ngx_snprintf(err->data, err->len - 1, + "pcre_compile() failed: %s in \"%s\"", + errstr, pattern->data); + } else { + ngx_snprintf(err->data, err->len - 1, + "pcre_compile() failed: %s in \"%s\" at \"%s\"", + errstr, pattern->data, pattern->data + erroff); + } + } + + return re; +} + + +ngx_int_t ngx_regex_exec(ngx_regex_t *re, ngx_str_t *s) +{ + int rc; + + rc = pcre_exec(re, NULL, s->data, s->len, 0, 0, NULL, 0); + + if (rc == -1) { + return NGX_DECLINED; + } + + return rc; +} + + +static void *ngx_regex_malloc(size_t size) +{ + return ngx_palloc(ngx_pcre_pool, size); +} + + +static void ngx_regex_free(void *p) +{ + return; +} diff --git a/src/core/ngx_regex.h b/src/core/ngx_regex.h new file mode 100644 index 000000000..b6828cf54 --- /dev/null +++ b/src/core/ngx_regex.h @@ -0,0 +1,23 @@ +#ifndef _NGX_REGEX_H_INCLUDED_ +#define _NGX_REGEX_H_INCLUDED_ + + +#include <ngx_config.h> +#include <ngx_core.h> + +#include <pcre.h> + + +#define NGX_REGEX_CASELESS PCRE_CASELESS + +typedef pcre ngx_regex_t; + +void ngx_regex_init(); +ngx_regex_t *ngx_regex_compile(ngx_str_t *pattern, ngx_int_t options, + ngx_pool_t *pool, ngx_str_t *err); +ngx_int_t ngx_regex_exec(ngx_regex_t *re, ngx_str_t *s); + +#define ngx_regex_exec_n "pcre_exec()" + + +#endif /* _NGX_REGEX_H_INCLUDED_ */ diff --git a/src/core/ngx_times.c b/src/core/ngx_times.c index e741ebdc2..e1706baa2 100644 --- a/src/core/ngx_times.c +++ b/src/core/ngx_times.c @@ -22,7 +22,7 @@ static char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; -void ngx_init_time() +void ngx_time_init() { struct timeval tv; diff --git a/src/core/ngx_times.h b/src/core/ngx_times.h index 212fc8bf6..b765dd8e0 100644 --- a/src/core/ngx_times.h +++ b/src/core/ngx_times.h @@ -6,7 +6,7 @@ #include <ngx_core.h> -void ngx_init_time(); +void ngx_time_init(); void ngx_time_update(); size_t ngx_http_time(char *buf, time_t t); void ngx_gmtime(time_t t, ngx_tm_t *tp); |
