nginx-0.0.2-2004-03-16-10:10:12 import
diff --git a/src/core/nginx.c b/src/core/nginx.c
index d4dedbc..a19695c 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -5,36 +5,6 @@
 #include <nginx.h>
 
 
-#if 0
-
-typedef struct {
-     ngx_flag_t  daemon;
-     ngx_flag_t  master;
-     ngx_flag_t  worker_reopen;
-     uid_t       user;
-     gid_t       group;
-     ngx_str_t   pid;
-     ngx_str_t   newpid;
-} ngx_core_conf_t;
-
-
-typedef struct {
-     ngx_file_t    pid;
-     char         *name;
-     int           argc;
-     char *const  *argv;
-} ngx_master_ctx_t;
-
-
-static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx);
-static void ngx_master_exit(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx);
-static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data);
-#if (NGX_THREADS)
-static int ngx_worker_thread_cycle(void *data);
-#endif
-
-#endif
-
 static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle);
 static ngx_int_t ngx_getopt(ngx_master_ctx_t *ctx, ngx_cycle_t *cycle);
 static ngx_int_t ngx_core_module_init(ngx_cycle_t *cycle);
@@ -112,7 +82,7 @@
     ngx_master_ctx_t   ctx;
 #if !(WIN32)
     size_t             len;
-    char               pid[/* STUB */ 10];
+    u_char             pid[/* STUB */ 10];
 #endif
 
 #if __FreeBSD__
@@ -220,7 +190,7 @@
                    NGINX_NEW_PID_EXT, sizeof(NGINX_NEW_PID_EXT));
     }
 
-    len = ngx_snprintf(pid, /* STUB */ 10, PID_T_FMT, ngx_getpid());
+    len = ngx_snprintf((char *) pid, /* STUB */ 10, PID_T_FMT, ngx_getpid());
     ngx_memzero(&ctx.pid, sizeof(ngx_file_t));
     ctx.pid.name = ngx_inherited ? ccf->newpid : ccf->pid;
     ctx.name = ccf->pid.data;
@@ -253,11 +223,11 @@
 
 static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle)
 {
-    char                *p, *v, *inherited;
+    u_char              *p, *v, *inherited;
     ngx_socket_t         s;
     ngx_listening_t     *ls;
 
-    inherited = getenv(NGINX_VAR);
+    inherited = (u_char *) getenv(NGINX_VAR);
 
     if (inherited == NULL) {
         return NGX_OK;
@@ -280,11 +250,11 @@
                 break;
             }
 
-        v = p + 1;
+            v = p + 1;
 
-        if (!(ls = ngx_push_array(&cycle->listening))) {
+            if (!(ls = ngx_push_array(&cycle->listening))) {
                 return NGX_ERROR;
-        }
+            }
 
             ls->fd = s;
         }
@@ -299,7 +269,7 @@
 ngx_pid_t ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv)
 {
     char             *env[2], *var, *p;
-    ngx_int_t         i;
+    ngx_uint_t        i;
     ngx_pid_t         pid;
     ngx_exec_ctx_t    ctx;
     ngx_listening_t  *ls;
@@ -312,7 +282,7 @@
                             + cycle->listening.nelts * (NGX_INT32_LEN + 1) + 2,
                     cycle->log);
 
-    p = ngx_cpymem(var, NGINX_VAR "=", sizeof(NGINX_VAR));
+    p = (char *) ngx_cpymem(var, NGINX_VAR "=", sizeof(NGINX_VAR));
 
     ls = cycle->listening.elts;
     for (i = 0; i < cycle->listening.nelts; i++) {
@@ -347,7 +317,7 @@
         switch (ctx->argv[i][1]) {
 
         case 'c':
-            cycle->conf_file.data = ctx->argv[++i];
+            cycle->conf_file.data = (u_char *) ctx->argv[++i];
             cycle->conf_file.len = ngx_strlen(cycle->conf_file.data);
             break;
 
@@ -425,7 +395,7 @@
 
     value = (ngx_str_t *) cf->args->elts;
 
-    pwd = getpwnam(value[1].data);
+    pwd = getpwnam((const char *) value[1].data);
     if (pwd == NULL) {
         ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
                            "getpwnam(%s) failed", value[1].data);
@@ -438,7 +408,7 @@
         return NGX_CONF_OK;
     }
 
-    grp = getgrnam(value[2].data);
+    grp = getgrnam((const char *) value[2].data);
     if (grp == NULL) {
         ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
                            "getgrnam(%s) failed", value[1].data);
diff --git a/src/core/nginx.h b/src/core/nginx.h
index 8703688..436f1e8 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -3,7 +3,7 @@
 
 
 #define NGINX_VER          "nginx/0.0.2"
-#define NGINX_CONF         "nginx.conf"
+#define NGINX_CONF         (u_char *) "nginx.conf"
 #define NGINX_PID          "nginx.pid"
 #define NGINX_NEW_PID_EXT  ".newbin"
 #define NGINX_NEW_PID      NGINX_PID NGINX_NEW_PID_EXT
diff --git a/src/core/ngx_array.c b/src/core/ngx_array.c
index 8d5cec9..8ecb83f 100644
--- a/src/core/ngx_array.c
+++ b/src/core/ngx_array.c
@@ -3,7 +3,7 @@
 #include <ngx_core.h>
 
 
-ngx_array_t *ngx_create_array(ngx_pool_t *p, int n, size_t size)
+ngx_array_t *ngx_create_array(ngx_pool_t *p, ngx_uint_t n, size_t size)
 {
     ngx_array_t *a;
 
diff --git a/src/core/ngx_array.h b/src/core/ngx_array.h
index 9cef9f3..f54517f 100644
--- a/src/core/ngx_array.h
+++ b/src/core/ngx_array.h
@@ -7,15 +7,15 @@
 
 
 struct ngx_array_s {
-    void       *elts;
-    int         nelts;
-    size_t      size;
-    int         nalloc;
-    ngx_pool_t *pool;
+    void        *elts;
+    ngx_uint_t   nelts;
+    size_t       size;
+    ngx_uint_t   nalloc;
+    ngx_pool_t  *pool;
 };
 
 
-ngx_array_t *ngx_create_array(ngx_pool_t *p, int n, size_t size);
+ngx_array_t *ngx_create_array(ngx_pool_t *p, ngx_uint_t n, size_t size);
 void ngx_destroy_array(ngx_array_t *a);
 void *ngx_push_array(ngx_array_t *a);
 
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index c14a9d8..30a3e5f 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -281,7 +281,7 @@
 
 static int ngx_conf_read_token(ngx_conf_t *cf)
 {
-    char        *start, ch, *src, *dst;
+    u_char      *start, ch, *src, *dst;
     int          len;
     int          found, need_space, last_space, sharp_comment;
     int          quoted, s_quoted, d_quoted;
@@ -514,7 +514,7 @@
 
 ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
 {
-    int               i;
+    ngx_uint_t        i;
     ngx_open_file_t  *file;
 
     if (name) {
@@ -666,20 +666,20 @@
 {
     char  *p = conf;
 
-    ssize_t          *sp;
+    size_t           *sp;
     ngx_str_t        *value;
     ngx_conf_post_t  *post;
 
 
-    sp = (ssize_t *) (p + cmd->offset);
-    if (*sp != NGX_CONF_UNSET) {
+    sp = (size_t *) (p + cmd->offset);
+    if (*sp != NGX_CONF_UNSET_SIZE) {
         return "is duplicate";
     }
 
     value = (ngx_str_t *) cf->args->elts;
 
     *sp = ngx_parse_size(&value[1]);
-    if (*sp == NGX_ERROR) {
+    if (*sp == (size_t) NGX_ERROR) {
         return "invalid value";
     }
 
@@ -702,7 +702,7 @@
 
 
     msp = (ngx_msec_t *) (p + cmd->offset);
-    if (*msp != (ngx_msec_t) NGX_CONF_UNSET) {
+    if (*msp != NGX_CONF_UNSET_MSEC) {
         return "is duplicate";
     }
 
@@ -793,12 +793,12 @@
 {
     char  *p = conf;
 
-    ngx_int_t           *np, i, m;
+    ngx_uint_t          *np, i, m;
     ngx_str_t           *value;
     ngx_conf_bitmask_t  *mask;
 
 
-    np = (ngx_int_t *) (p + cmd->offset);
+    np = (ngx_uint_t *) (p + cmd->offset);
     value = (ngx_str_t *) cf->args->elts;
     mask = cmd->post;
 
diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h
index 6e81f2b..8b4aa49 100644
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -43,6 +43,8 @@
 
 
 #define NGX_CONF_UNSET       -1
+#define NGX_CONF_UNSET_SIZE  (size_t) -1
+#define NGX_CONF_UNSET_MSEC  (ngx_msec_t) -1
 
 
 #define NGX_CONF_OK          NULL
@@ -189,8 +191,8 @@
     }
 
 #define ngx_conf_merge_msec_value(conf, prev, default)                       \
-    if (conf == (ngx_msec_t) NGX_CONF_UNSET) {                               \
-        conf = (prev == (ngx_msec_t) NGX_CONF_UNSET) ? default : prev;       \
+    if (conf == NGX_CONF_UNSET_MSEC) {                                       \
+        conf = (prev == NGX_CONF_UNSET_MSEC) ? default : prev;               \
     }
 
 #define ngx_conf_merge_sec_value(conf, prev, default)                        \
@@ -199,8 +201,8 @@
     }
 
 #define ngx_conf_merge_size_value(conf, prev, default)                       \
-    if (conf == (ssize_t) NGX_CONF_UNSET) {                                  \
-        conf = (prev == (ssize_t) NGX_CONF_UNSET) ? default : prev;          \
+    if (conf == NGX_CONF_UNSET_SIZE) {                                       \
+        conf = (prev == NGX_CONF_UNSET_SIZE) ? default : prev;               \
     }
 
 #define ngx_conf_merge_str_value(conf, prev, default)                        \
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c
index 49eade1..a7c02c8 100644
--- a/src/core/ngx_connection.c
+++ b/src/core/ngx_connection.c
@@ -9,7 +9,7 @@
 
 ngx_int_t ngx_set_inherited_sockets(ngx_cycle_t *cycle)
 {
-    ngx_int_t            i;
+    ngx_uint_t           i;
     ngx_listening_t     *ls;
     struct sockaddr_in  *addr_in;
 
@@ -63,7 +63,7 @@
 
 ngx_int_t ngx_open_listening_sockets(ngx_cycle_t *cycle)
 {
-    ngx_int_t         tries, failed, reuseaddr, i;
+    ngx_uint_t        tries, failed, reuseaddr, i;
     ngx_err_t         err;
     ngx_log_t        *log;
     ngx_socket_t      s;
@@ -78,7 +78,7 @@
 
     /* TODO: tries configurable */
 
-    for (tries = /* STUB */ 1; tries; tries--) {
+    for (tries = /* STUB */ 5; tries; tries--) {
         failed = 0;
 
         /* for each listening socket */
@@ -204,7 +204,7 @@
 
 void ngx_close_listening_sockets(ngx_cycle_t *cycle)
 {
-    ngx_int_t         i;
+    ngx_uint_t        i;
     ngx_socket_t      fd;
     ngx_listening_t  *ls;
 
@@ -233,7 +233,7 @@
                           ls[i].addr_text.data);
         }
 
-        cycle->connections[fd].fd = -1;
+        cycle->connections[fd].fd = (ngx_socket_t) -1;
     }
 }
 
diff --git a/src/core/ngx_core.h b/src/core/ngx_core.h
index 57bdafc..081fc9b 100644
--- a/src/core/ngx_core.h
+++ b/src/core/ngx_core.h
@@ -56,8 +56,8 @@
 #define  NGX_ABORT      -6
 
 
-#define LF     10
-#define CR     13
+#define LF     (u_char) 10
+#define CR     (u_char) 13
 #define CRLF   "\x0d\x0a"
 
 
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index 4e61a54..be0d8f1 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -23,7 +23,7 @@
 
 ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
 {
-    ngx_int_t         i, n, failed;
+    ngx_uint_t        i, n, failed;
     ngx_log_t        *log;
     ngx_conf_t        conf;
     ngx_pool_t       *pool;
@@ -374,7 +374,7 @@
 void ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user)
 {
     ngx_fd_t          fd;
-    ngx_int_t         i;
+    ngx_uint_t        i;
     ngx_open_file_t  *file;
 
     file = cycle->open_files.elts;
@@ -412,7 +412,7 @@
         }
 #else
         if (user != (ngx_uid_t) -1) {
-            if (chown(file[i].name.data, user, -1) == -1) {
+            if (chown((const char *) file[i].name.data, user, -1) == -1) {
                 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
                               "chown \"%s\" failed", file[i].name.data);
 
@@ -461,7 +461,7 @@
 
 static void ngx_clean_old_cycles(ngx_event_t *ev)
 {
-    int            i, n, found, live;
+    ngx_uint_t     i, n, found, live;
     ngx_log_t     *log;
     ngx_cycle_t  **cycle;
 
@@ -482,7 +482,7 @@
         found = 0;
 
         for (n = 0; n < cycle[i]->connection_n; n++) {
-            if (cycle[i]->connections[n].fd != -1) {
+            if (cycle[i]->connections[n].fd != (ngx_socket_t) -1) {
                 found = 1;
 
                 ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, "live fd:%d", n);
diff --git a/src/core/ngx_cycle.h b/src/core/ngx_cycle.h
index 4d301f9..2ea229e 100644
--- a/src/core/ngx_cycle.h
+++ b/src/core/ngx_cycle.h
@@ -14,7 +14,7 @@
     ngx_array_t        open_files;
     ngx_array_t        pathes;
 
-    int                connection_n;
+    ngx_uint_t         connection_n;
     ngx_connection_t  *connections;
     ngx_event_t       *read_events;
     ngx_event_t       *write_events;
diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c
index 72d7ba7..cbb1cb2 100644
--- a/src/core/ngx_file.c
+++ b/src/core/ngx_file.c
@@ -3,8 +3,8 @@
 #include <ngx_core.h>
 
 
-static int ngx_temp_number;
-static int ngx_random;
+static ngx_uint_t ngx_temp_number;
+static ngx_uint_t ngx_random;
 
 
 int ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain)
@@ -50,8 +50,9 @@
     num = ngx_next_temp_number(0);
 
     for ( ;; ) {
-        ngx_snprintf(file->name.data + path->name.len + 1 + path->len, 11,
-                     "%010u", num);
+        ngx_snprintf((char *)
+                            (file->name.data + path->name.len + 1 + path->len),
+                     11, "%010u", num);
 
         ngx_create_hashed_filename(file, path);
 
@@ -183,7 +184,7 @@
 }
 
 
-int ngx_next_temp_number(int collision)
+ngx_uint_t ngx_next_temp_number(ngx_uint_t collision)
 {
     if (collision) {
         ngx_temp_number += ngx_random;
@@ -197,7 +198,8 @@
 {
     char  *p = conf;
 
-    int          i, n, level;
+    ngx_int_t    level;
+    ngx_uint_t   i, n;
     ngx_str_t   *value;
     ngx_path_t  *path, **pp;
 
diff --git a/src/core/ngx_file.h b/src/core/ngx_file.h
index 9042c61..6afe1d1 100644
--- a/src/core/ngx_file.h
+++ b/src/core/ngx_file.h
@@ -51,7 +51,7 @@
 int ngx_create_path(ngx_file_t *file, ngx_path_t *path);
 
 void ngx_init_temp_number();
-int ngx_next_temp_number(int collision);
+ngx_uint_t ngx_next_temp_number(ngx_uint_t collision);
 
 char *ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
 
diff --git a/src/core/ngx_garbage_collector.c b/src/core/ngx_garbage_collector.c
index 35a060b..3b67330 100644
--- a/src/core/ngx_garbage_collector.c
+++ b/src/core/ngx_garbage_collector.c
@@ -53,7 +53,7 @@
 
 void stub_init(ngx_cycle_t *cycle)
 {
-    int           i;
+    ngx_uint_t    i;
     ngx_gc_t      ctx;
     ngx_path_t  **path;
 
@@ -71,13 +71,17 @@
 static int ngx_collect_garbage(ngx_gc_t *ctx, ngx_str_t *dname, int level)
 {
     int         rc;
-    char       *last;
+    u_char     *last;
     size_t      len;
     ngx_err_t   err;
     ngx_str_t   fname, buf;
     ngx_dir_t   dir;
 
     buf.len = 0;
+#if (NGX_SUPPRESS_WARN)
+    buf.data = NULL;
+    fname.data = NULL;
+#endif
 
     ngx_log_debug2(NGX_LOG_DEBUG_CORE, ctx->log, 0,
                    "gc dir \"%s\":%d", dname->data, dname->len);
diff --git a/src/core/ngx_hunk.c b/src/core/ngx_hunk.c
index 07c3884..b448b39 100644
--- a/src/core/ngx_hunk.c
+++ b/src/core/ngx_hunk.c
@@ -31,8 +31,8 @@
 
 ngx_chain_t *ngx_create_chain_of_hunks(ngx_pool_t *pool, ngx_bufs_t *bufs)
 {
-    int           i;
-    char         *p;
+    ngx_int_t     i;
+    u_char       *p;
     ngx_hunk_t   *h;
     ngx_chain_t  *chain, *cl, **ll;
 
diff --git a/src/core/ngx_hunk.h b/src/core/ngx_hunk.h
index 7dc0f0c..ab32e45 100644
--- a/src/core/ngx_hunk.h
+++ b/src/core/ngx_hunk.h
@@ -45,14 +45,14 @@
 typedef struct ngx_hunk_s        ngx_hunk_t;
 
 struct ngx_hunk_s {
-    char            *pos;
-    char            *last;
+    u_char          *pos;
+    u_char          *last;
     off_t            file_pos;
     off_t            file_last;
 
     int              type;
-    char            *start;         /* start of hunk */
-    char            *end;           /* end of hunk */
+    u_char          *start;         /* start of hunk */
+    u_char          *end;           /* end of hunk */
     ngx_hunk_tag_t   tag;
     ngx_file_t      *file;
     ngx_hunk_t      *shadow;
@@ -69,7 +69,7 @@
 
 
 typedef struct {
-    int          num;
+    ngx_int_t    num;
     size_t       size;
 } ngx_bufs_t;
 
@@ -87,7 +87,7 @@
     unsigned                     need_in_temp;
 
     ngx_pool_t                  *pool;
-    int                          hunks;
+    ngx_int_t                    hunks;
     ngx_bufs_t                   bufs;
     ngx_hunk_tag_t               tag;
 
diff --git a/src/core/ngx_inet.c b/src/core/ngx_inet.c
index 55b8354..9f593f0 100644
--- a/src/core/ngx_inet.c
+++ b/src/core/ngx_inet.c
@@ -5,9 +5,10 @@
 
 /* AF_INET only */
 
-size_t ngx_sock_ntop(int family, struct sockaddr *addr, char *text, size_t len)
+size_t ngx_sock_ntop(int family, struct sockaddr *addr, u_char *text,
+                     size_t len)
 {
-    char                *p;
+    u_char              *p;
     struct sockaddr_in  *addr_in;
 
     if (family != AF_INET) {
@@ -15,27 +16,21 @@
     }
 
     addr_in = (struct sockaddr_in *) addr;
-    p = (char *) &addr_in->sin_addr;
+    p = (u_char *) &addr_in->sin_addr;
 
-    return ngx_snprintf(text, len > INET_ADDRSTRLEN ? INET_ADDRSTRLEN : len,
-                        "%u.%u.%u.%u",
-                        (unsigned char) p[0],
-                        (unsigned char) p[1],
-                        (unsigned char) p[2],
-                        (unsigned char) p[3]);
+    return ngx_snprintf((char *) text,
+                        len > INET_ADDRSTRLEN ? INET_ADDRSTRLEN : len,
+                        "%u.%u.%u.%u", p[0], p[1], p[2], p[3]);
 }
 
 
-size_t ngx_inet_ntop(int family, char *addr, char *text, size_t len)
+size_t ngx_inet_ntop(int family, u_char *addr, u_char *text, size_t len)
 {
     if (family != AF_INET) {
         return 0;
     }
 
-    return ngx_snprintf(text, len > INET_ADDRSTRLEN ? INET_ADDRSTRLEN : len,
-                        "%u.%u.%u.%u",
-                        (unsigned char) addr[0],
-                        (unsigned char) addr[1],
-                        (unsigned char) addr[2],
-                        (unsigned char) addr[3]);
+    return ngx_snprintf((char *) text,
+                        len > INET_ADDRSTRLEN ? INET_ADDRSTRLEN : len,
+                        "%u.%u.%u.%u", addr[0], addr[1], addr[2], addr[3]);
 }
diff --git a/src/core/ngx_inet.h b/src/core/ngx_inet.h
index 9f71444..f5f5e0d 100644
--- a/src/core/ngx_inet.h
+++ b/src/core/ngx_inet.h
@@ -2,8 +2,9 @@
 #define _NGX_INET_H_INCLUDED_
 
 
-size_t ngx_sock_ntop(int family, struct sockaddr *addr, char *text, size_t len);
-size_t ngx_inet_ntop(int family, char *addr, char *text, size_t len);
+size_t ngx_sock_ntop(int family, struct sockaddr *addr, u_char *text,
+                     size_t len);
+size_t ngx_inet_ntop(int family, u_char *addr, u_char *text, size_t len);
 
 
 #endif /* _NGX_INET_H_INCLUDED_ */
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
index 371c725..e74525e 100644
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -325,8 +325,8 @@
 
 char *ngx_set_error_log_levels(ngx_conf_t *cf, ngx_log_t *log)
 {
-    ngx_int_t   i, n, d;
-    ngx_str_t  *value;
+    ngx_uint_t   i, n, d;
+    ngx_str_t   *value;
 
     value = cf->args->elts;
 
diff --git a/src/core/ngx_parse.c b/src/core/ngx_parse.c
index 6a1f54b..9d62f70 100644
--- a/src/core/ngx_parse.c
+++ b/src/core/ngx_parse.c
@@ -3,11 +3,11 @@
 #include <ngx_core.h>
 
 
-int ngx_parse_size(ngx_str_t *line)
+ngx_int_t ngx_parse_size(ngx_str_t *line)
 {
-    int     scale, size;
-    char    last;
-    size_t  len;
+    u_char     last;
+    size_t     len;
+    ngx_int_t  scale, size;
 
     len = line->len;
     last = line->data[len - 1];
@@ -40,12 +40,12 @@
 }
 
 
-int ngx_parse_time(ngx_str_t *line, int sec)
+ngx_int_t ngx_parse_time(ngx_str_t *line, ngx_int_t sec)
 {
-    int     value, total, scale;
-    u_int   max, i;
-    size_t  len;
-    char   *start, last;
+    size_t      len;
+    u_char     *start, last;
+    ngx_int_t   value, total, scale;
+    ngx_uint_t  max, i;
     enum {
         st_start = 0,
         st_year,
diff --git a/src/core/ngx_parse.h b/src/core/ngx_parse.h
index a92eaea..630cabe 100644
--- a/src/core/ngx_parse.h
+++ b/src/core/ngx_parse.h
@@ -9,8 +9,8 @@
 #define NGX_PARSE_LARGE_TIME  -2
 
 
-int ngx_parse_size(ngx_str_t *line);
-int ngx_parse_time(ngx_str_t *line, int sec);
+ngx_int_t ngx_parse_size(ngx_str_t *line);
+ngx_int_t ngx_parse_time(ngx_str_t *line, ngx_int_t sec);
 
 
 #endif /* _NGX_PARSE_H_INCLUDED_ */
diff --git a/src/core/ngx_regex.c b/src/core/ngx_regex.c
index 167907b..1627f9f 100644
--- a/src/core/ngx_regex.c
+++ b/src/core/ngx_regex.c
@@ -27,15 +27,16 @@
 
     ngx_pcre_pool = pool;
 
-    re = pcre_compile(pattern->data, (int) options, &errstr, &erroff, NULL);
+    re = pcre_compile((const char *) pattern->data, (int) options,
+                      &errstr, &erroff, NULL);
 
     if (re == NULL) {
        if ((size_t) erroff == pattern->len) {
-           ngx_snprintf(err->data, err->len - 1,
+           ngx_snprintf((char *) err->data, err->len - 1,
                         "pcre_compile() failed: %s in \"%s\"",
                         errstr, pattern->data);
         } else {
-           ngx_snprintf(err->data, err->len - 1,
+           ngx_snprintf((char *) err->data, err->len - 1,
                         "pcre_compile() failed: %s in \"%s\" at \"%s\"",
                         errstr, pattern->data, pattern->data + erroff);
         }
@@ -50,7 +51,8 @@
 {
     int  rc;
 
-    rc = pcre_exec(re, NULL, s->data, s->len, 0, 0, matches, size);
+    rc = pcre_exec(re, NULL, (const char *) s->data, s->len, 0, 0,
+                   matches, size);
 
     if (rc == -1) {
         return NGX_DECLINED;
diff --git a/src/core/ngx_string.c b/src/core/ngx_string.c
index 87b6a09..92b4b53 100644
--- a/src/core/ngx_string.c
+++ b/src/core/ngx_string.c
@@ -3,7 +3,7 @@
 #include <ngx_core.h>
 
 
-char *ngx_cpystrn(char *dst, char *src, size_t n)
+u_char *ngx_cpystrn(u_char *dst, u_char *src, size_t n)
 {
     if (n == 0) {
         return dst;
@@ -23,7 +23,7 @@
 }
 
 
-int ngx_rstrncmp(char *s1, char *s2, size_t n)
+ngx_int_t ngx_rstrncmp(u_char *s1, u_char *s2, size_t n)
 {
     if (n == 0) {
         return 0;
@@ -33,7 +33,7 @@
 
     for ( ;; ) {
         if (s1[n] != s2[n]) {
-            return (u_char) s1[n] - (u_char) s2[n];
+            return s1[n] - s2[n];
         }
 
         if (n == 0) {
@@ -45,9 +45,9 @@
 }
 
 
-int ngx_atoi(char *line, size_t n)
+ngx_int_t ngx_atoi(u_char *line, size_t n)
 {
-    int  value;
+    ngx_int_t  value;
 
     if (n == 0) {
         return NGX_ERROR;
@@ -69,10 +69,10 @@
 }
 
 
-void ngx_md5_text(char *text, u_char *md5)
+void ngx_md5_text(u_char *text, u_char *md5)
 {
-    int          i;
-    static char  hex[] = "0123456789abcdef";
+    int            i;
+    static u_char  hex[] = "0123456789abcdef";
 
     for (i = 0; i < 16; i++) {
         *text++ = hex[md5[i] >> 4];
diff --git a/src/core/ngx_string.h b/src/core/ngx_string.h
index 158ad0f..84110b9 100644
--- a/src/core/ngx_string.h
+++ b/src/core/ngx_string.h
@@ -7,12 +7,12 @@
 
 
 typedef struct {
-    size_t  len;
-    char   *data;
+    size_t    len;
+    u_char   *data;
 } ngx_str_t;
 
 
-#define ngx_string(str)  { sizeof(str) - 1, str }
+#define ngx_string(str)  { sizeof(str) - 1, (u_char *) str }
 #define ngx_null_string  { 0, NULL }
 
 
@@ -26,8 +26,10 @@
 
 #else
 
-#define ngx_strncasecmp           strncasecmp
-#define ngx_strcasecmp            strcasecmp
+#define ngx_strncasecmp(s1, s2, n)                                           \
+                          strncasecmp((const char *) s1, (const char *) s2, n)
+#define ngx_strcasecmp(s1, s2)                                               \
+                          strcasecmp((const char *) s1, (const char *) s2)
 
 #define ngx_snprintf              snprintf
 #define ngx_vsnprintf             vsnprintf
@@ -35,13 +37,14 @@
 #endif
 
 
-#define ngx_strncmp               strncmp
+#define ngx_strncmp(s1, s2, n)                                               \
+                          strncmp((const char *) s1, (const char *) s2, n)
 
 /* msvc and icc compile strcmp() to inline loop */
-#define ngx_strcmp                strcmp
+#define ngx_strcmp(s1, s2)        strcmp((const char *) s1, (const char *) s2)
 
-#define ngx_strstr                strstr
-#define ngx_strlen                strlen
+#define ngx_strstr(s1, s2)        strstr((const char *) s1, (const char *) s2)
+#define ngx_strlen(s)             strlen((const char *) s)
 
 /*
  * msvc and icc compile memset() to inline "rep stos"
@@ -53,16 +56,16 @@
 
 /* msvc and icc compile memcpy() to inline "rep movs" */
 #define ngx_memcpy(dst, src, n)   memcpy(dst, src, n)
-#define ngx_cpymem(dst, src, n)   ((char *) memcpy(dst, src, n)) + n
+#define ngx_cpymem(dst, src, n)   ((u_char *) memcpy(dst, src, n)) + n
 
 /* msvc and icc compile memcmp() to inline loop */
 #define ngx_memcmp                memcmp
 
-char *ngx_cpystrn(char *dst, char *src, size_t n);
-int ngx_rstrncmp(char *s1, char *s2, size_t n);
-int ngx_atoi(char *line, size_t n);
+u_char *ngx_cpystrn(u_char *dst, u_char *src, size_t n);
+ngx_int_t ngx_rstrncmp(u_char *s1, u_char *s2, size_t n);
+ngx_int_t ngx_atoi(u_char *line, size_t n);
 
-void ngx_md5_text(char *text, u_char *md5);
+void ngx_md5_text(u_char *text, u_char *md5);
 
 
 #define  ngx_qsort                qsort
diff --git a/src/core/ngx_times.c b/src/core/ngx_times.c
index a9ddb82..b23fac6 100644
--- a/src/core/ngx_times.c
+++ b/src/core/ngx_times.c
@@ -15,13 +15,13 @@
 
 ngx_tm_t          ngx_cached_gmtime;
 
-static char       cached_err_log_time[] = "1970/09/28 12:00:00";
+static u_char     cached_err_log_time[] = "1970/09/28 12:00:00";
 ngx_str_t         ngx_cached_err_log_time;
 
-static char       cached_http_time[] = "Mon, 28 Sep 1970 06:00:00 GMT";
+static u_char     cached_http_time[] = "Mon, 28 Sep 1970 06:00:00 GMT";
 ngx_str_t         ngx_cached_http_time;
 
-static char       cached_http_log_time[] = "28/Sep/1970:12:00:00";
+static u_char     cached_http_log_time[] = "28/Sep/1970:12:00:00";
 ngx_str_t         ngx_cached_http_log_time;
 
 
@@ -86,7 +86,7 @@
 
     ngx_gmtime(ngx_cached_time, &ngx_cached_gmtime);
 
-    ngx_cached_http_time.len = ngx_snprintf(ngx_cached_http_time.data,
+    ngx_cached_http_time.len = ngx_snprintf((char *) ngx_cached_http_time.data,
                                        sizeof("Mon, 28 Sep 1970 06:00:00 GMT"),
                                        "%s, %02d %s %4d %02d:%02d:%02d GMT",
                                        week[ngx_cached_gmtime.ngx_tm_wday],
@@ -99,14 +99,16 @@
 
     ngx_localtime(&tm);
 
-    ngx_cached_err_log_time.len = ngx_snprintf(ngx_cached_err_log_time.data,
+    ngx_cached_err_log_time.len = ngx_snprintf((char *)
+                                       ngx_cached_err_log_time.data,
                                        sizeof("1970/09/28 12:00:00"),
                                        "%4d/%02d/%02d %02d:%02d:%02d",
                                        tm.ngx_tm_year, tm.ngx_tm_mon,
                                        tm.ngx_tm_mday, tm.ngx_tm_hour,
                                        tm.ngx_tm_min, tm.ngx_tm_sec);
 
-    ngx_cached_http_log_time.len = ngx_snprintf(ngx_cached_http_log_time.data,
+    ngx_cached_http_log_time.len = ngx_snprintf((char *)
+                                       ngx_cached_http_log_time.data,
                                        sizeof("28/Sep/1970:12:00:00"),
                                        "%02d/%s/%d:%02d:%02d:%02d",
                                        tm.ngx_tm_mday,
@@ -123,13 +125,13 @@
 }
 
 
-size_t ngx_http_time(char *buf, time_t t)
+size_t ngx_http_time(u_char *buf, time_t t)
 {
     ngx_tm_t  tm;
 
     ngx_gmtime(t, &tm);
 
-    return ngx_snprintf(buf, sizeof("Mon, 28 Sep 1970 06:00:00 GMT"),
+    return ngx_snprintf((char *) buf, sizeof("Mon, 28 Sep 1970 06:00:00 GMT"),
                                        "%s, %02d %s %4d %02d:%02d:%02d GMT",
                                        week[tm.ngx_tm_wday],
                                        tm.ngx_tm_mday,
@@ -143,7 +145,7 @@
 
 void ngx_gmtime(time_t t, ngx_tm_t *tp)
 {
-    int  sec, min, hour, mday, mon, year, wday, yday, days;
+    ngx_int_t  sec, min, hour, mday, mon, year, wday, yday, days;
 
     days = t / 86400;
 
@@ -200,11 +202,11 @@
         }
     }
 
-    tp->ngx_tm_sec = sec;
-    tp->ngx_tm_min = min;
-    tp->ngx_tm_hour = hour;
-    tp->ngx_tm_mday = mday;
-    tp->ngx_tm_mon = mon;
-    tp->ngx_tm_year = year;
-    tp->ngx_tm_wday = wday;
+    tp->ngx_tm_sec = (ngx_tm_sec_t) sec;
+    tp->ngx_tm_min = (ngx_tm_min_t) min;
+    tp->ngx_tm_hour = (ngx_tm_hour_t) hour;
+    tp->ngx_tm_mday = (ngx_tm_mday_t) mday;
+    tp->ngx_tm_mon = (ngx_tm_mon_t) mon;
+    tp->ngx_tm_year = (ngx_tm_year_t) year;
+    tp->ngx_tm_wday = (ngx_tm_wday_t) wday;
 }
diff --git a/src/core/ngx_times.h b/src/core/ngx_times.h
index 50910b1..eccbcde 100644
--- a/src/core/ngx_times.h
+++ b/src/core/ngx_times.h
@@ -11,7 +11,7 @@
 ngx_int_t ngx_time_mutex_init(ngx_log_t *log);
 #endif
 void ngx_time_update(time_t s);
-size_t ngx_http_time(char *buf, time_t t);
+size_t ngx_http_time(u_char *buf, time_t t);
 void ngx_gmtime(time_t t, ngx_tm_t *tp);
 
 #define ngx_time()   ngx_cached_time