changeset 292:a472bfb778b3

nginx-0.0.3-2004-03-17-00:26:01 import
author Igor Sysoev <igor@sysoev.ru>
date Tue, 16 Mar 2004 21:26:01 +0000
parents 117ccc7c4055
children ec3c049681fd
files src/core/ngx_conf_file.h src/core/ngx_file.c src/core/ngx_file.h src/core/ngx_string.h src/http/modules/ngx_http_chunked_filter.c src/http/modules/ngx_http_gzip_filter.c src/http/modules/ngx_http_index_handler.c src/http/modules/ngx_http_range_filter.c src/http/modules/proxy/ngx_http_proxy_handler.c src/http/modules/proxy/ngx_http_proxy_handler.h src/http/modules/proxy/ngx_http_proxy_upstream.c src/http/ngx_http.h src/http/ngx_http_log_handler.c src/http/ngx_http_request_body.c src/http/ngx_http_special_response.c src/os/unix/ngx_os.h src/os/win32/ngx_files.c src/os/win32/ngx_files.h src/os/win32/ngx_os.h src/os/win32/ngx_win32_config.h src/os/win32/ngx_wsarecv.c src/os/win32/ngx_wsarecv_chain.c src/os/win32/ngx_wsasend_chain.c
diffstat 23 files changed, 134 insertions(+), 149 deletions(-) [+]
line wrap: on
line diff
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -212,7 +212,7 @@ char *ngx_conf_check_num_bounds(ngx_conf
             conf.data = prev.data;                                           \
         } else {                                                             \
             conf.len = sizeof(default) - 1;                                  \
-            conf.data = default;                                             \
+            conf.data = (u_char *) default;                                  \
         }                                                                    \
     }
 
--- a/src/core/ngx_file.c
+++ b/src/core/ngx_file.c
@@ -57,25 +57,11 @@ int ngx_create_temp_file(ngx_file_t *fil
         ngx_create_hashed_filename(file, path);
 
 #if 0
-#if (WIN32)
-        file->fd = CreateFile(file->name.data,
-                        GENERIC_READ|GENERIC_WRITE,
-                        FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
-                        NULL,
-                        CREATE_NEW,
-                        persistent ? 0:
-                            FILE_ATTRIBUTE_TEMPORARY|FILE_FLAG_DELETE_ON_CLOSE,
-                        NULL);
+        file->fd = ngx_open_tempfile(file->name.data, persistent);
 #else
-        file->fd = open(file->name.data, O_CREAT|O_EXCL|O_WRONLY, 0600);
-#endif
+        file->fd = ngx_open_tempfile(file->name.data, 1);
 #endif
 
-#if 0
-        file->fd = ngx_open_tempfile(file->name.data, persistent);
-#endif
-        file->fd = ngx_open_tempfile(file->name.data, 1);
-
         ngx_log_debug1(NGX_LOG_DEBUG_CORE, file->log, 0,
                        "temp fd:%d", file->fd);
 
--- a/src/core/ngx_file.h
+++ b/src/core/ngx_file.h
@@ -61,7 +61,7 @@ char *ngx_conf_set_path_slot(ngx_conf_t 
         if (prev == NULL) {                                                  \
             ngx_test_null(conf, ngx_palloc(pool, sizeof(ngx_path_t)), NULL); \
             conf->name.len = sizeof(path) - 1;                               \
-            conf->name.data = path;                                          \
+            conf->name.data = (u_char *) path;                               \
             conf->level[0] = l1;                                             \
             conf->level[1] = l2;                                             \
             conf->level[2] = l3;                                             \
--- a/src/core/ngx_string.h
+++ b/src/core/ngx_string.h
@@ -18,8 +18,10 @@ typedef struct {
 
 #if (WIN32)
 
-#define ngx_strncasecmp           strnicmp
-#define ngx_strcasecmp            stricmp
+#define ngx_strncasecmp(s1, s2, n)                                           \
+                          strnicmp((const char *) s1, (const char *) s2, n)
+#define ngx_strcasecmp(s1, s2)                                               \
+                          stricmp((const char *) s1, (const char *) s2)
 
 #define ngx_snprintf              _snprintf
 #define ngx_vsnprintf             _vsnprintf
--- a/src/http/modules/ngx_http_chunked_filter.c
+++ b/src/http/modules/ngx_http_chunked_filter.c
@@ -101,12 +101,12 @@ static int ngx_http_chunked_body_filter(
     if (cl->hunk->type & NGX_HUNK_LAST) {
         cl->hunk->type &= ~NGX_HUNK_LAST;
         h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_MEMORY|NGX_HUNK_LAST;
-        h->pos = CRLF "0" CRLF CRLF;
+        h->pos = (u_char *) CRLF "0" CRLF CRLF;
         h->last = h->pos + 7;
 
     } else {
         h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_MEMORY;
-        h->pos = CRLF;
+        h->pos = (u_char *) CRLF;
         h->last = h->pos + 2;
     }
 
--- a/src/http/modules/ngx_http_gzip_filter.c
+++ b/src/http/modules/ngx_http_gzip_filter.c
@@ -217,9 +217,9 @@ static int ngx_http_gzip_header_filter(n
     }
 
     r->headers_out.content_encoding->key.len = sizeof("Content-Encoding") - 1;
-    r->headers_out.content_encoding->key.data = "Content-Encoding";
+    r->headers_out.content_encoding->key.data = (u_char *) "Content-Encoding";
     r->headers_out.content_encoding->value.len = sizeof("gzip") - 1;
-    r->headers_out.content_encoding->value.data = "gzip";
+    r->headers_out.content_encoding->value.data = (u_char *) "gzip";
 
     ctx->length = r->headers_out.content_length_n;
     r->headers_out.content_length_n = -1;
--- a/src/http/modules/ngx_http_index_handler.c
+++ b/src/http/modules/ngx_http_index_handler.c
@@ -21,7 +21,7 @@ typedef struct {
 } ngx_http_index_ctx_t;
 
 
-#define NGX_HTTP_DEFAULT_INDEX   "index.html"
+#define NGX_HTTP_DEFAULT_INDEX   (u_char *) "index.html"
 
 
 static ngx_int_t ngx_http_index_test_dir(ngx_http_request_t *r,
--- a/src/http/modules/ngx_http_range_filter.c
+++ b/src/http/modules/ngx_http_range_filter.c
@@ -108,9 +108,9 @@ static ngx_int_t ngx_http_range_header_f
         }
 
         r->headers_out.accept_ranges->key.len = sizeof("Accept-Ranges") - 1;
-        r->headers_out.accept_ranges->key.data = "Accept-Ranges";
+        r->headers_out.accept_ranges->key.data = (u_char *) "Accept-Ranges";
         r->headers_out.accept_ranges->value.len = sizeof("bytes") - 1;
-        r->headers_out.accept_ranges->value.data = "bytes";
+        r->headers_out.accept_ranges->value.data = (u_char *) "bytes";
 
         return ngx_http_next_header_filter(r);
     }
@@ -230,7 +230,7 @@ static ngx_int_t ngx_http_range_header_f
         }
 
         r->headers_out.content_range->key.len = sizeof("Content-Range") - 1;
-        r->headers_out.content_range->key.data = "Content-Range";
+        r->headers_out.content_range->key.data = (u_char *) "Content-Range";
 
         ngx_test_null(r->headers_out.content_range->value.data,
                       ngx_palloc(r->pool, 8 + 20 + 1),
@@ -261,7 +261,7 @@ static ngx_int_t ngx_http_range_header_f
             }
 
             r->headers_out.content_range->key.len = sizeof("Content-Range") - 1;
-            r->headers_out.content_range->key.data = "Content-Range";
+            r->headers_out.content_range->key.data = (u_char *) "Content-Range";
 
             ngx_test_null(r->headers_out.content_range->value.data,
                           ngx_palloc(r->pool, 6 + 20 + 1 + 20 + 1 + 20 + 1),
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -1073,7 +1073,7 @@ static char *ngx_http_proxy_parse_upstre
                 u->default_port = 1;
                 u->port = htons(80);
                 u->port_text.len = 2;
-                u->port_text.data = "80";
+                u->port_text.data = (u_char *) "80";
                 return NULL;
             }
 
@@ -1097,14 +1097,14 @@ static char *ngx_http_proxy_parse_upstre
 
     u->host_header.len = i;
 
-    u->uri.data = "/";
+    u->uri.data = (u_char *) "/";
     u->uri.len = 1;
 
     if (u->port_text.data == NULL) {
         u->default_port = 1;
         u->port = htons(80);
         u->port_text.len = 2;
-        u->port_text.data = "80";
+        u->port_text.data = (u_char *) "80";
         return NULL;
     }
 
--- a/src/http/modules/proxy/ngx_http_proxy_handler.h
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.h
@@ -184,7 +184,13 @@ struct ngx_http_proxy_ctx_s {
     ngx_http_proxy_state_t       *state;
     ngx_array_t                   states;    /* of ngx_http_proxy_state_t */
 
-    u_char                       *action;
+    /*
+     * we declare "action" as "char *" because the actions are usually
+     * the static strings and in the "u_char *" case we have to override
+     * all the time their types
+     */
+
+    char                         *action;
     ngx_http_log_ctx_t           *saved_ctx;
     ngx_log_handler_pt            saved_handler;
 };
--- a/src/http/modules/proxy/ngx_http_proxy_upstream.c
+++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c
@@ -305,7 +305,7 @@ static void ngx_http_proxy_init_upstream
     ngx_http_request_t        *r;
     ngx_output_chain_ctx_t    *output;
     ngx_chain_writer_ctx_t    *writer;
-    ngx_http_proxy_log_ctx_t  *lctx;
+    ngx_http_proxy_log_ctx_t  *ctx;
 
     r = p->request;
 
@@ -345,17 +345,17 @@ static void ngx_http_proxy_init_upstream
 
     r->request_hunks = cl;
 
-    if (!(lctx = ngx_pcalloc(r->pool, sizeof(ngx_http_proxy_log_ctx_t)))) {
+    if (!(ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_proxy_log_ctx_t)))) {
         ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
         return;
     }
-    lctx->connection = r->connection->number;
-    lctx->proxy = p;
+    ctx->connection = r->connection->number;
+    ctx->proxy = p;
 
     p->upstream->peer.log = r->connection->log;
     p->saved_ctx = r->connection->log->data;
     p->saved_handler = r->connection->log->handler;
-    r->connection->log->data = lctx;
+    r->connection->log->data = ctx;
     r->connection->log->handler = ngx_http_proxy_log_error;
     p->action = "connecting to upstream";
 
@@ -378,7 +378,6 @@ static void ngx_http_proxy_init_upstream
     }
 
     output->output_ctx = writer;
-
     writer->pool = r->pool;
 
     if (p->lcf->busy_lock && !p->busy_locked) {
@@ -393,6 +392,7 @@ static void ngx_http_proxy_reinit_upstre
 {
     ngx_chain_t             *cl;
     ngx_output_chain_ctx_t  *output;
+    ngx_chain_writer_ctx_t  *writer;
 
     output = p->upstream->output_chain_ctx;
 
@@ -402,7 +402,7 @@ static void ngx_http_proxy_reinit_upstre
         cl->hunk->pos = cl->hunk->start;
     }
 
-    /* reinit ngx_output_chain() context */
+    /* reinit the ngx_output_chain() context */
 
     output->hunk = NULL;
     output->in = NULL;
@@ -488,6 +488,7 @@ static void ngx_http_proxy_connect(ngx_h
     ngx_connection_t        *c;
     ngx_http_request_t      *r;
     ngx_output_chain_ctx_t  *output;
+    ngx_chain_writer_ctx_t  *writer;
 
     p->action = "connecting to upstream";
 
@@ -517,14 +518,18 @@ static void ngx_http_proxy_connect(ngx_h
     c->pool = r->pool;
     c->read->log = c->write->log = c->log = r->connection->log;
 
+    /* init or reinit the ngx_output_chain() and ngx_chain_writer() contexts */
+
     output = p->upstream->output_chain_ctx;
+    writer = output->output_ctx;
+    writer->out = NULL;
+    writer->last = &writer->out;
+    writer->connection = c;
 
     if (p->upstream->peer.tries > 1 && p->request_sent) {
         ngx_http_proxy_reinit_upstream(p);
     }
 
-    /* init or reinit ngx_output_chain() context */
-
     if (r->request_body_hunk) {
         if (!(output->free = ngx_alloc_chain_link(r->pool))) {
             ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
@@ -563,9 +568,8 @@ static void ngx_http_proxy_connect(ngx_h
 
 static void ngx_http_proxy_send_request(ngx_http_proxy_ctx_t *p)
 {
-    int                      rc;
-    ngx_connection_t        *c;
-    ngx_chain_writer_ctx_t  *writer;
+    int                rc;
+    ngx_connection_t  *c;
 
     c = p->upstream->peer.connection;
 
@@ -586,11 +590,6 @@ static void ngx_http_proxy_send_request(
 
     p->action = "sending request to upstream";
 
-    writer = p->upstream->output_chain_ctx->output_ctx;
-    writer->out = NULL;
-    writer->last = &writer->out;
-    writer->connection = c;
-
     rc = ngx_output_chain(p->upstream->output_chain_ctx,
                           p->request_sent ? NULL : p->request->request_hunks);
 
--- a/src/http/ngx_http.h
+++ b/src/http/ngx_http.h
@@ -23,7 +23,14 @@ typedef struct ngx_http_cleanup_s  ngx_h
 
 typedef struct {
     u_int     connection;
-    u_char   *action;
+
+    /*
+     * we declare "action" as "char *" because the actions are usually
+     * the static strings and in the "u_char *" case we have to override
+     * all the time their types
+     */
+
+    char     *action;
     u_char   *client;
     u_char   *url;
 } ngx_http_log_ctx_t;
--- a/src/http/ngx_http_log_handler.c
+++ b/src/http/ngx_http_log_handler.c
@@ -597,7 +597,7 @@ static void *ngx_http_log_create_main_co
     }
 
     value->len = sizeof("combined") - 1;
-    value->data = "combined";
+    value->data = (u_char *) "combined";
 
     if (!(value = ngx_push_array(cf->args))) {
         return NGX_CONF_ERROR;
@@ -699,7 +699,7 @@ static char *ngx_http_log_set_log(ngx_co
         name = value[2];
     } else {
         name.len = sizeof("combined") - 1;
-        name.data = "combined";
+        name.data = (u_char *) "combined";
     }
 
     fmt = lmcf->formats.elts;
--- a/src/http/ngx_http_request_body.c
+++ b/src/http/ngx_http_request_body.c
@@ -83,55 +83,65 @@ static void ngx_http_read_client_request
     c = rev->data;
     r = c->data;
 
-    if (r->request_body_hunk->end - r->request_body_hunk->last == 0) {
-        n = ngx_write_chain_to_temp_file(r->temp_file,
+    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
+                   "http read client request body");
+
+    for ( ;; ) {
+        if (r->request_body_hunk->last == r->request_body_hunk->end) {
+            n = ngx_write_chain_to_temp_file(r->temp_file,
                                r->request_hunks->next ? r->request_hunks->next:
                                                         r->request_hunks);
-        /* TODO: n == 0 or not complete and level event */
+
+            /* TODO: n == 0 or not complete and level event */
+
+            if (n == NGX_ERROR) {
+                ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
+                return;
+            }
+
+            r->temp_file->offset += n;
+
+            r->request_body_hunk->pos = r->request_body_hunk->start;
+            r->request_body_hunk->last = r->request_body_hunk->start;
+        }
 
-        if (n == NGX_ERROR) {
-            ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
+        size = r->request_body_hunk->end - r->request_body_hunk->last;
+
+        if (size > r->request_body_len) {
+            size = r->request_body_len;
+        }
+
+        n = ngx_recv(c, r->request_body_hunk->last, size);
+
+        if (n == NGX_AGAIN) {
+            clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+            ngx_add_timer(rev, clcf->client_body_timeout);
+
+            if (ngx_handle_read_event(rev, 0) == NGX_ERROR) {
+                ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
+            }
+
             return;
         }
 
-        r->temp_file->offset += n;
-
-        r->request_body_hunk->pos = r->request_body_hunk->start;
-        r->request_body_hunk->last = r->request_body_hunk->start;
-    }
-
-    size = r->request_body_hunk->end - r->request_body_hunk->last;
-
-    if (size > r->request_body_len) {
-        size = r->request_body_len;
-    }
-
-    n = ngx_recv(c, r->request_body_hunk->last, size);
-
-    if (n == NGX_AGAIN) {
-        clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
-        ngx_add_timer(rev, clcf->client_body_timeout);
-
-        if (ngx_handle_read_event(rev, 0) == NGX_ERROR) {
-            ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
+        if (n == 0) {
+            ngx_log_error(NGX_LOG_INFO, c->log, 0,
+                          "client closed prematurely connection");
         }
 
-        return;
-    }
-
-    if (n == 0) {
-        ngx_log_error(NGX_LOG_INFO, c->log, 0,
-                      "client closed prematurely connection");
-    }
+        if (n == 0 || n == NGX_ERROR) {
+            ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
+            return;
+        }
 
-    if (n == 0 || n == NGX_ERROR) {
-        ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
-        return;
+        r->request_body_hunk->last += n;
+        r->request_body_len -= n;
+
+        if (r->request_body_hunk->last < r->request_body_hunk->end) {
+            break;
+        }
     }
 
-    r->request_body_hunk->last += n;
-    r->request_body_len -= n;
-
     if (r->request_body_len) {
         return;
     }
@@ -142,6 +152,7 @@ static void ngx_http_read_client_request
         n = ngx_write_chain_to_temp_file(r->temp_file,
                                r->request_hunks->next ? r->request_hunks->next:
                                                         r->request_hunks);
+
         /* TODO: n == 0 or not complete and level event */
 
         if (n == NGX_ERROR) {
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -248,9 +248,9 @@ int ngx_http_special_response_handler(ng
         }
 
         r->headers_out.content_type->key.len = sizeof("Content-Type") - 1;
-        r->headers_out.content_type->key.data = "Content-Type";
+        r->headers_out.content_type->key.data = (u_char *) "Content-Type";
         r->headers_out.content_type->value.len = sizeof("text/html") - 1;
-        r->headers_out.content_type->value.data = "text/html";
+        r->headers_out.content_type->value.data = (u_char *) "text/html";
 
     } else {
         r->headers_out.content_length_n = -1;
--- a/src/os/unix/ngx_os.h
+++ b/src/os/unix/ngx_os.h
@@ -49,24 +49,6 @@ extern int          ngx_max_sockets;
 extern int          ngx_inherited_nonblocking;
 
 
-#if 0
-
-extern ngx_int_t    ngx_process;
-extern ngx_pid_t    ngx_new_binary;
-
-extern ngx_int_t    ngx_inherited;
-extern ngx_int_t    ngx_reap;
-extern ngx_int_t    ngx_timer;
-extern ngx_int_t    ngx_quit;
-extern ngx_int_t    ngx_terminate;
-extern ngx_int_t    ngx_noaccept;
-extern ngx_int_t    ngx_reconfigure;
-extern ngx_int_t    ngx_reopen;
-extern ngx_int_t    ngx_change_binary;
-
-#endif
-
-
 #ifdef __FreeBSD__
 #include <ngx_freebsd.h>
 #endif
--- a/src/os/win32/ngx_files.c
+++ b/src/os/win32/ngx_files.c
@@ -132,7 +132,7 @@ ssize_t ngx_write_file(ngx_file_t *file,
 ssize_t ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl,
                                 off_t offset, ngx_pool_t *pool)
 {
-    char     *buf, *prev;
+    u_char   *buf, *prev;
     size_t    size;
     ssize_t   total, n;
 
@@ -169,7 +169,7 @@ int ngx_win32_rename_file(ngx_str_t *fro
 {
     int         rc, collision;
     u_int       num;
-    char       *name;
+    u_char     *name;
 
     if (!(name = ngx_palloc(pool, to->len + 1 + 10 + 1 + sizeof("DELETE")))) {
         return NGX_ERROR;
@@ -184,10 +184,10 @@ int ngx_win32_rename_file(ngx_str_t *fro
     do {
         num = ngx_next_temp_number(collision);
 
-        ngx_snprintf(name + to->len, 1 + 10 + 1 + sizeof("DELETE"),
+        ngx_snprintf((char *) name + to->len, 1 + 10 + 1 + sizeof("DELETE"),
                      ".%010u.DELETE", num);
 
-        if (MoveFile(to->data, name) == 0) {
+        if (MoveFile((const char *) to->data, (const char *) name) == 0) {
             collision = 1;
             ngx_log_error(NGX_LOG_ERR, pool->log, ngx_errno,
                           "MoveFile() failed");
@@ -195,7 +195,7 @@ int ngx_win32_rename_file(ngx_str_t *fro
 
     } while (collision);
 
-    if (MoveFile(from->data, to->data) == 0) {
+    if (MoveFile((const char *) from->data, (const char *) to->data) == 0) {
         rc = NGX_ERROR;
 
     } else {
@@ -203,7 +203,7 @@ int ngx_win32_rename_file(ngx_str_t *fro
     }
 
     if (ngx_win32_version >= NGX_WIN_NT) {
-        if (DeleteFile(name) == 0) {
+        if (DeleteFile((const char *) name) == 0) {
             ngx_log_error(NGX_LOG_ERR, pool->log, ngx_errno,
                           "DeleteFile() failed");
         }
@@ -247,11 +247,11 @@ int ngx_file_info(char *file, ngx_file_i
 #endif
 
 
-int ngx_file_info(char *file, ngx_file_info_t *sb)
+int ngx_file_info(u_char *file, ngx_file_info_t *sb)
 {
     /* Win95 */
 
-    sb->dwFileAttributes = GetFileAttributes(file);
+    sb->dwFileAttributes = GetFileAttributes((const char *) file);
 
     if (sb->dwFileAttributes == INVALID_FILE_ATTRIBUTES) {
         return NGX_ERROR;
@@ -265,7 +265,7 @@ int ngx_open_dir(ngx_str_t *name, ngx_di
 {
     ngx_cpystrn(name->data + name->len, NGX_DIR_MASK, NGX_DIR_MASK_LEN + 1);
 
-    dir->dir = FindFirstFile(name->data, &dir->fd);
+    dir->dir = FindFirstFile((const char *) name->data, &dir->fd);
     
     if (dir->dir == INVALID_HANDLE_VALUE) {
         return NGX_ERROR; 
--- a/src/os/win32/ngx_files.h
+++ b/src/os/win32/ngx_files.h
@@ -59,7 +59,7 @@ int ngx_file_append_mode(ngx_fd_t fd);
 #define ngx_close_file_n            "CloseHandle()"
 
 
-#define ngx_delete_file             DeleteFile
+#define ngx_delete_file(name)       DeleteFile((const char *) name)
 #define ngx_delete_file_n           "DeleteFile()"
 
 
@@ -68,7 +68,7 @@ int ngx_file_append_mode(ngx_fd_t fd);
 int ngx_win32_rename_file(ngx_str_t *from, ngx_str_t *to, ngx_pool_t *pool);
 
 
-int ngx_file_info(char *filename, ngx_file_info_t *fi);
+int ngx_file_info(u_char *filename, ngx_file_info_t *fi);
 #define ngx_file_info_n             "GetFileAttributesEx()"
 
 
@@ -94,7 +94,7 @@ int ngx_file_info(char *filename, ngx_fi
                                           - 116444736000000000) / 10000000)
 
 
-#define NGX_DIR_MASK                "/*"
+#define NGX_DIR_MASK                (u_char *) "/*"
 #define NGX_DIR_MASK_LEN            2
 
 
@@ -110,11 +110,11 @@ int ngx_read_dir(ngx_dir_t *dir);
 #define ngx_close_dir_n             "FindClose()"
 
 
-#define ngx_create_dir(name)        CreateDirectory(name, NULL)
+#define ngx_create_dir(name)        CreateDirectory((const char *) name, NULL)
 #define ngx_create_dir_n            "CreateDirectory()"
 
 
-#define ngx_delete_dir              RemoveDirectory
+#define ngx_delete_dir(name)        RemoveDirectory((const char *) name)
 #define ngx_delete_dir_n            "RemoveDirectory()"
 
 
--- a/src/os/win32/ngx_os.h
+++ b/src/os/win32/ngx_os.h
@@ -23,9 +23,9 @@
 
 
 typedef struct {
-    ssize_t       (*recv)(ngx_connection_t *c, char *buf, size_t size);
+    ssize_t       (*recv)(ngx_connection_t *c, u_char *buf, size_t size);
     ssize_t       (*recv_chain)(ngx_connection_t *c, ngx_chain_t *in);
-    ssize_t       (*send)(ngx_connection_t *c, char *buf, size_t size);
+    ssize_t       (*send)(ngx_connection_t *c, u_char *buf, size_t size);
     ngx_chain_t  *(*send_chain)(ngx_connection_t *c, ngx_chain_t *in);
     int             flags;
 } ngx_os_io_t;
@@ -33,8 +33,8 @@ typedef struct {
 
 int ngx_os_init(ngx_log_t *log);
 
-ssize_t ngx_wsarecv(ngx_connection_t *c, char *buf, size_t size);
-ssize_t ngx_overlapped_wsarecv(ngx_connection_t *c, char *buf, size_t size);
+ssize_t ngx_wsarecv(ngx_connection_t *c, u_char *buf, size_t size);
+ssize_t ngx_overlapped_wsarecv(ngx_connection_t *c, u_char *buf, size_t size);
 ssize_t ngx_wsarecv_chain(ngx_connection_t *c, ngx_chain_t *chain);
 ngx_chain_t *ngx_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in);
 ngx_chain_t *ngx_overlapped_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in);
@@ -46,15 +46,6 @@ extern int          ngx_inherited_nonblo
 extern int          ngx_win32_version;
 
 
-extern ngx_int_t    ngx_process;
-
-extern ngx_int_t    ngx_quit;
-extern ngx_int_t    ngx_terminate;
-
-extern ngx_int_t    ngx_reconfigure;
-extern ngx_int_t    ngx_reopen;
-
-
 
 #endif /* _NGX_OS_H_INCLUDED_ */
 
--- a/src/os/win32/ngx_win32_config.h
+++ b/src/os/win32/ngx_win32_config.h
@@ -27,6 +27,7 @@
 #ifdef _MSC_VER
 #pragma warning(default:4201)
 
+
 /* disable some "-W4" level warnings */
 
 #pragma warning(disable:4054)
@@ -49,7 +50,7 @@
 #include <ngx_auto_config.h>
 
 
-#define ngx_inline   __inline
+#define ngx_inlie         __inline
 
 
 #ifdef _MSC_VER
--- a/src/os/win32/ngx_wsarecv.c
+++ b/src/os/win32/ngx_wsarecv.c
@@ -4,7 +4,7 @@
 #include <ngx_event.h>
 
 
-ssize_t ngx_wsarecv(ngx_connection_t *c, char *buf, size_t size)
+ssize_t ngx_wsarecv(ngx_connection_t *c, u_char *buf, size_t size)
 {
     int           rc;
     u_long        bytes, flags;
@@ -12,7 +12,7 @@ ssize_t ngx_wsarecv(ngx_connection_t *c,
     ngx_err_t     err;
     ngx_event_t  *rev;
 
-    wsabuf[0].buf = buf;
+    wsabuf[0].buf = (char *) buf;
     wsabuf[0].len = size;
     flags = 0;
     bytes = 0;
@@ -52,7 +52,7 @@ ssize_t ngx_wsarecv(ngx_connection_t *c,
 }
 
 
-ssize_t ngx_overlapped_wsarecv(ngx_connection_t *c, char *buf, size_t size)
+ssize_t ngx_overlapped_wsarecv(ngx_connection_t *c, u_char *buf, size_t size)
 {
     int               rc;
     u_long            bytes, flags;
@@ -95,7 +95,7 @@ ssize_t ngx_overlapped_wsarecv(ngx_conne
 
     ovlp = (LPWSAOVERLAPPED) &rev->ovlp;
     ngx_memzero(ovlp, sizeof(WSAOVERLAPPED));
-    wsabuf[0].buf = buf;
+    wsabuf[0].buf = (char *) buf;
     wsabuf[0].len = size;
     flags = 0;
     bytes = 0;
--- a/src/os/win32/ngx_wsarecv_chain.c
+++ b/src/os/win32/ngx_wsarecv_chain.c
@@ -7,7 +7,7 @@
 ssize_t ngx_wsarecv_chain(ngx_connection_t *c, ngx_chain_t *chain)
 {
     int           rc;
-    char         *prev;
+    u_char       *prev;
     u_long        bytes, flags;
     size_t        size;
     WSABUF       *wsabuf;
@@ -31,7 +31,7 @@ ssize_t ngx_wsarecv_chain(ngx_connection
 
         } else {
             ngx_test_null(wsabuf, ngx_push_array(&io), NGX_ERROR);
-            wsabuf->buf = chain->hunk->last;
+            wsabuf->buf = (char *) chain->hunk->last;
             wsabuf->len = chain->hunk->end - chain->hunk->last;
         }
 
--- a/src/os/win32/ngx_wsasend_chain.c
+++ b/src/os/win32/ngx_wsasend_chain.c
@@ -7,7 +7,7 @@
 ngx_chain_t *ngx_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in)
 {
     int           rc;
-    char         *prev;
+    u_char       *prev;
     size_t        size;
     u_long        sent;
     LPWSABUF      wsabuf;
@@ -42,7 +42,7 @@ ngx_chain_t *ngx_wsasend_chain(ngx_conne
 
         } else {
             ngx_test_null(wsabuf, ngx_push_array(&wsabufs), NGX_CHAIN_ERROR);
-            wsabuf->buf = cl->hunk->pos;
+            wsabuf->buf = (char *) cl->hunk->pos;
             wsabuf->len = cl->hunk->last - cl->hunk->pos;
             prev = cl->hunk->last;
         }
@@ -102,7 +102,7 @@ ngx_chain_t *ngx_wsasend_chain(ngx_conne
 ngx_chain_t *ngx_overlapped_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in)
 {
     int               rc;
-    char             *prev;
+    u_char           *prev;
     size_t            size;
     u_long            sent;
     LPWSABUF          wsabuf;
@@ -143,7 +143,7 @@ ngx_chain_t *ngx_overlapped_wsasend_chai
             } else {
                 ngx_test_null(wsabuf, ngx_push_array(&wsabufs),
                               NGX_CHAIN_ERROR);
-                wsabuf->buf = cl->hunk->pos;
+                wsabuf->buf = (char *) cl->hunk->pos;
                 wsabuf->len = cl->hunk->last - cl->hunk->pos;
                 prev = cl->hunk->last;
             }