nginx-0.0.10-2004-09-07-19:29:22 import
diff --git a/auto/make b/auto/make
index 8aefe00..f8dc80f 100644
--- a/auto/make
+++ b/auto/make
@@ -1,7 +1,8 @@
 
 mkdir -p $OBJS/src/core $OBJS/src/event $OBJS/src/event/modules \
          $OBJS/src/os/unix $OBJS/src/os/win32 \
-         $OBJS/src/http $OBJS/src/http/modules $OBJS/src/http/modules/proxy
+         $OBJS/src/http $OBJS/src/http/modules $OBJS/src/http/modules/proxy \
+         $OBJS/src/imap
 
 
 echo "CC = $CC"                                                   > $MAKEFILE
@@ -18,13 +19,15 @@
     echo                                                          >> $MAKEFILE
 fi
 
-all_inc="$CORE_INCS $OBJS $HTTP_INCS"
+all_inc="$CORE_INCS $OBJS $HTTP_INCS $IMAP_INCS"
 all_inc=`echo " $all_inc" | sed -e "s/ \([^ ]\)/ $INCOPT\1/g"`
 all_inc=`echo $all_inc | sed -e "s/\//$DIRSEP/g"`
 
 echo "ALL_INCS = $all_inc"                                        >> $MAKEFILE
 echo                                                              >> $MAKEFILE
 
+all_srcs="$CORE_SRCS"
+
 
 # CORE_DEPS
 
@@ -60,38 +63,84 @@
 echo                                                              >> $MAKEFILE
 
 
-# HTTP_DEPS
+if [ $HTTP = YES ]; then
 
-if [ $MAKE_SL = YES ]; then
-    echo $ngx_n "HTTP_DEPS =" $ngx_c                              >> $MAKEFILE
-else
-    echo "HTTP_DEPS = \\"                                         >> $MAKEFILE
-fi
+    all_srcs="$all_srcs $HTTP_SRCS"
 
-for dep in $HTTP_DEPS
-do
-    dep=`echo $dep | sed -e "s/\//$DIRSEP/g"`
+    # HTTP_DEPS
 
     if [ $MAKE_SL = YES ]; then
-        echo $ngx_n " $dep" $ngx_c                                >> $MAKEFILE
+        echo $ngx_n "HTTP_DEPS =" $ngx_c                          >> $MAKEFILE
     else
-        echo "	$dep \\"                                          >> $MAKEFILE
+        echo "HTTP_DEPS = \\"                                     >> $MAKEFILE
     fi
-done
-echo                                                              >> $MAKEFILE
 
+    for dep in $HTTP_DEPS
+    do
+        dep=`echo $dep | sed -e "s/\//$DIRSEP/g"`
 
-# HTTP_INCS
-
-if [ $MAKE_SL = YES ]; then
+        if [ $MAKE_SL = YES ]; then
+            echo $ngx_n " $dep" $ngx_c                            >> $MAKEFILE
+        else
+            echo "	$dep \\"                                  >> $MAKEFILE
+        fi
+    done
     echo                                                          >> $MAKEFILE
+
+
+    # HTTP_INCS
+
+    if [ $MAKE_SL = YES ]; then
+        echo                                                      >> $MAKEFILE
+    fi
+
+    inc="$HTTP_INCS $OBJS"
+    inc=`echo " $inc" | sed -e "s/ \([^ ]\)/ $INCOPT\1/g" -e "s/\//$DIRSEP/g"`
+
+    echo "HTTP_INCS = $inc"                                       >> $MAKEFILE
+    echo                                                          >> $MAKEFILE
+
 fi
 
-inc="$HTTP_INCS $OBJS"
-inc=`echo " $inc" | sed -e "s/ \([^ ]\)/ $INCOPT\1/g" -e "s/\//$DIRSEP/g"`
 
-echo "HTTP_INCS = $inc"                                           >> $MAKEFILE
-echo                                                              >> $MAKEFILE
+if [ $IMAP = YES ]; then
+
+    all_srcs="$all_srcs $IMAP_SRCS"
+
+    # IMAP_DEPS
+
+    if [ $MAKE_SL = YES ]; then
+        echo $ngx_n "IMAP_DEPS =" $ngx_c                          >> $MAKEFILE
+    else
+        echo "IMAP_DEPS = \\"                                     >> $MAKEFILE
+    fi
+
+    for dep in $IMAP_DEPS
+    do
+        dep=`echo $dep | sed -e "s/\//$DIRSEP/g"`
+
+        if [ $MAKE_SL = YES ]; then
+            echo $ngx_n " $dep" $ngx_c                            >> $MAKEFILE
+        else
+            echo "	$dep \\"                                  >> $MAKEFILE
+        fi
+    done
+    echo                                                          >> $MAKEFILE
+
+
+    # IMAP_INCS
+
+    if [ $MAKE_SL = YES ]; then
+        echo                                                      >> $MAKEFILE
+    fi
+
+    inc="$IMAP_INCS $OBJS"
+    inc=`echo " $inc" | sed -e "s/ \([^ ]\)/ $INCOPT\1/g" -e "s/\//$DIRSEP/g"`
+
+    echo "IMAP_INCS = $inc"                                       >> $MAKEFILE
+    echo                                                          >> $MAKEFILE
+
+fi
 
 
 # nginx
@@ -105,7 +154,7 @@
 
 # nginx deps
 
-for src in $CORE_SRCS $HTTP_SRCS
+for src in $all_srcs
 do
     obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/" -e "s/\.S\$/.$OBJEXT/"`
     obj=`echo $OBJS/$obj | sed -e "s/\//$DIRSEP/g"`
@@ -142,7 +191,7 @@
 
 # nginx build sources
 
-for src in $CORE_SRCS $HTTP_SRCS
+for src in $all_srcs
 do
     obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/" -e "s/\.S\$/.$OBJEXT/"`
     obj=`echo $OBJS/$obj | sed -e "s/\//$DIRSEP/g"`
@@ -223,33 +272,72 @@
 
 # http sources
 
-deps="\$(CORE_DEPS) \$(HTTP_DEPS)"
+if [ $HTTP = YES ]; then
 
-if [ $PCH != NO ]; then
-    args="\$(CFLAGS) $USEPCH \$(ALL_INCS)"
-else
-    args="\$(CFLAGS) $USEPCH \$(CORE_INCS) \$(HTTP_INCS)"
+    deps="\$(CORE_DEPS) \$(HTTP_DEPS)"
+
+    if [ $PCH != NO ]; then
+        args="\$(CFLAGS) $USEPCH \$(ALL_INCS)"
+    else
+        args="\$(CFLAGS) $USEPCH \$(CORE_INCS) \$(HTTP_INCS)"
+    fi
+
+    for src in $HTTP_SRCS
+    do
+        obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/"`
+        obj=`echo $OBJS/$obj | sed -e "s/\//$DIRSEP/g"`
+        src=`echo $src | sed -e "s/\//$DIRSEP/g"`
+
+        if [ $MAKE_SL = YES ]; then
+            echo "$obj: $src $deps"                               >> $MAKEFILE
+            echo "	\$(CC) $COMPOPT $args $OBJOUT$obj $src"   >> $MAKEFILE
+            echo                                                  >> $MAKEFILE
+        else
+            echo "$obj: \\"                                       >> $MAKEFILE
+            echo "	$src $deps"                               >> $MAKEFILE
+            echo "	\$(CC) $COMPOPT $args \\"                 >> $MAKEFILE
+            echo "		$OBJOUT$obj \\"                   >> $MAKEFILE
+            echo "		$src"                             >> $MAKEFILE
+            echo                                                  >> $MAKEFILE
+        fi
+    done
+
 fi
 
-for src in $HTTP_SRCS
-do
-    obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/"`
-    obj=`echo $OBJS/$obj | sed -e "s/\//$DIRSEP/g"`
-    src=`echo $src | sed -e "s/\//$DIRSEP/g"`
 
-    if [ $MAKE_SL = YES ]; then
-        echo "$obj: $src $deps"                                   >> $MAKEFILE
-        echo "	\$(CC) $COMPOPT $args $OBJOUT$obj $src"           >> $MAKEFILE
-        echo                                                      >> $MAKEFILE
+# imap sources
+
+if [ $IMAP = YES ]; then
+
+    deps="\$(CORE_DEPS) \$(IMAP_DEPS)"
+
+    if [ $PCH != NO ]; then
+        args="\$(CFLAGS) $USEPCH \$(ALL_INCS)"
     else
-        echo "$obj: \\"                                           >> $MAKEFILE
-        echo "	$src $deps"                                       >> $MAKEFILE
-        echo "	\$(CC) $COMPOPT $args \\"                         >> $MAKEFILE
-        echo "		$OBJOUT$obj \\"                           >> $MAKEFILE
-        echo "		$src"                                     >> $MAKEFILE
-        echo                                                      >> $MAKEFILE
+        args="\$(CFLAGS) $USEPCH \$(CORE_INCS) \$(IMAP_INCS)"
     fi
-done
+
+    for src in $IMAP_SRCS
+    do
+        obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/"`
+        obj=`echo $OBJS/$obj | sed -e "s/\//$DIRSEP/g"`
+        src=`echo $src | sed -e "s/\//$DIRSEP/g"`
+
+        if [ $MAKE_SL = YES ]; then
+            echo "$obj: $src $deps"                               >> $MAKEFILE
+            echo "	\$(CC) $COMPOPT $args $OBJOUT$obj $src"   >> $MAKEFILE
+            echo                                                  >> $MAKEFILE
+        else
+            echo "$obj: \\"                                       >> $MAKEFILE
+            echo "	$src $deps"                               >> $MAKEFILE
+            echo "	\$(CC) $COMPOPT $args \\"                 >> $MAKEFILE
+            echo "		$OBJOUT$obj \\"                   >> $MAKEFILE
+            echo "		$src"                             >> $MAKEFILE
+            echo                                                  >> $MAKEFILE
+        fi
+    done
+
+fi
 
 
 # precompiled headers
diff --git a/auto/modules b/auto/modules
index d80a05c..bfbab15 100644
--- a/auto/modules
+++ b/auto/modules
@@ -136,6 +136,12 @@
              $HTTP_NOT_MODIFIED_FILTER_MODULE"
 fi
 
+IMAP_MODULES=$IMAP_MODULE
+
+if [ $IMAP = YES ]; then
+    modules="$modules $IMAP_MODULES"
+fi
+
 
 echo "#include <ngx_config.h>"                > $NGX_MODULES_C
 echo "#include <ngx_core.h>"                  >> $NGX_MODULES_C
diff --git a/auto/options b/auto/options
index 538e6ad..18909d6 100644
--- a/auto/options
+++ b/auto/options
@@ -40,6 +40,8 @@
 HTTP_REWRITE=YES
 HTTP_PROXY=YES
 
+IMAP=NO
+
 USE_PCRE=NO
 PCRE=NONE
 PCRE_OPT=
@@ -101,6 +103,8 @@
         --without-http_rewrite_module)   HTTP_REWRITE=NO            ;;
         --without-http_proxy_module)     HTTP_PROXY=NO              ;;
 
+        --with-imap)                     IMAP=YES                   ;;
+
         --with-cc=*)                     CC="$value"                ;;
         --with-cpp=*)                    CPP="$value"               ;;
         --with-cc-opt=*)                 CC_OPT="$value"            ;;
diff --git a/auto/sources b/auto/sources
index f35b445..60ce872 100644
--- a/auto/sources
+++ b/auto/sources
@@ -4,46 +4,46 @@
 CORE_INCS="src/core"
 
 CORE_DEPS="src/core/nginx.h \
-            src/core/ngx_config.h \
-            src/core/ngx_core.h \
-            src/core/ngx_log.h \
-            src/core/ngx_palloc.h \
-            src/core/ngx_array.h \
-            src/core/ngx_list.h \
-            src/core/ngx_table.h \
-            src/core/ngx_buf.h \
-            src/core/ngx_string.h \
-            src/core/ngx_parse.h \
-            src/core/ngx_inet.h \
-            src/core/ngx_file.h \
-            src/core/ngx_crc.h \
-            src/core/ngx_rbtree.h \
-            src/core/ngx_radix_tree.h \
-            src/core/ngx_times.h \
-            src/core/ngx_connection.h \
-            src/core/ngx_cycle.h \
-            src/core/ngx_conf_file.h \
-            src/core/ngx_garbage_collector.h"
+           src/core/ngx_config.h \
+           src/core/ngx_core.h \
+           src/core/ngx_log.h \
+           src/core/ngx_palloc.h \
+           src/core/ngx_array.h \
+           src/core/ngx_list.h \
+           src/core/ngx_table.h \
+           src/core/ngx_buf.h \
+           src/core/ngx_string.h \
+           src/core/ngx_parse.h \
+           src/core/ngx_inet.h \
+           src/core/ngx_file.h \
+           src/core/ngx_crc.h \
+           src/core/ngx_rbtree.h \
+           src/core/ngx_radix_tree.h \
+           src/core/ngx_times.h \
+           src/core/ngx_connection.h \
+           src/core/ngx_cycle.h \
+           src/core/ngx_conf_file.h \
+           src/core/ngx_garbage_collector.h"
 
 CORE_SRCS="src/core/nginx.c \
-            src/core/ngx_log.c \
-            src/core/ngx_palloc.c \
-            src/core/ngx_array.c \
-            src/core/ngx_list.c \
-            src/core/ngx_buf.c \
-            src/core/ngx_output_chain.c \
-            src/core/ngx_string.c \
-            src/core/ngx_parse.c \
-            src/core/ngx_inet.c \
-            src/core/ngx_file.c \
-            src/core/ngx_rbtree.c \
-            src/core/ngx_radix_tree.c \
-            src/core/ngx_times.c \
-            src/core/ngx_connection.c \
-            src/core/ngx_cycle.c \
-            src/core/ngx_spinlock.c \
-            src/core/ngx_conf_file.c \
-            src/core/ngx_garbage_collector.c"
+           src/core/ngx_log.c \
+           src/core/ngx_palloc.c \
+           src/core/ngx_array.c \
+           src/core/ngx_list.c \
+           src/core/ngx_buf.c \
+           src/core/ngx_output_chain.c \
+           src/core/ngx_string.c \
+           src/core/ngx_parse.c \
+           src/core/ngx_inet.c \
+           src/core/ngx_file.c \
+           src/core/ngx_rbtree.c \
+           src/core/ngx_radix_tree.c \
+           src/core/ngx_times.c \
+           src/core/ngx_connection.c \
+           src/core/ngx_cycle.c \
+           src/core/ngx_spinlock.c \
+           src/core/ngx_conf_file.c \
+           src/core/ngx_garbage_collector.c"
 
 
 REGEX_DEPS=src/core/ngx_regex.h
@@ -128,6 +128,7 @@
             src/os/unix/ngx_socket.c \
             src/os/unix/ngx_recv.c \
             src/os/unix/ngx_readv_chain.c \
+            src/os/unix/ngx_send.c \
             src/os/unix/ngx_writev_chain.c \
             src/os/unix/ngx_channel.c \
             src/os/unix/ngx_shared.c \
@@ -191,8 +192,8 @@
 
 
 HTTP_MODULES="ngx_http_module \
-            ngx_http_core_module \
-            ngx_http_log_module"
+              ngx_http_core_module \
+              ngx_http_log_module"
 
 HTTP_FILE_CACHE_MODULE=ngx_http_cache_module
 
@@ -214,30 +215,30 @@
 HTTP_INCS="src/http src/http/modules"
 
 HTTP_DEPS="src/http/ngx_http.h \
-            src/http/ngx_http_request.h \
-            src/http/ngx_http_config.h \
-            src/http/ngx_http_core_module.h \
-            src/http/ngx_http_cache.h \
-            src/http/ngx_http_busy_lock.h \
-            src/http/ngx_http_log_handler.h"
+           src/http/ngx_http_request.h \
+           src/http/ngx_http_config.h \
+           src/http/ngx_http_core_module.h \
+           src/http/ngx_http_cache.h \
+           src/http/ngx_http_busy_lock.h \
+           src/http/ngx_http_log_handler.h"
 
 HTTP_SRCS="src/http/ngx_http.c \
-            src/http/ngx_http_core_module.c \
-            src/http/ngx_http_special_response.c \
-            src/http/ngx_http_request.c \
-            src/http/ngx_http_parse.c \
-            src/http/ngx_http_header_filter.c \
-            src/http/ngx_http_write_filter.c \
-            src/http/ngx_http_copy_filter.c \
-            src/http/ngx_http_log_handler.c \
-            src/http/ngx_http_request_body.c \
-            src/http/ngx_http_parse_time.c \
-            src/http/modules/ngx_http_static_handler.c \
-            src/http/modules/ngx_http_index_handler.c \
-            src/http/modules/ngx_http_chunked_filter.c \
-            src/http/modules/ngx_http_range_filter.c \
-            src/http/modules/ngx_http_headers_filter.c \
-            src/http/modules/ngx_http_not_modified_filter.c"
+           src/http/ngx_http_core_module.c \
+           src/http/ngx_http_special_response.c \
+           src/http/ngx_http_request.c \
+           src/http/ngx_http_parse.c \
+           src/http/ngx_http_header_filter.c \
+           src/http/ngx_http_write_filter.c \
+           src/http/ngx_http_copy_filter.c \
+           src/http/ngx_http_log_handler.c \
+           src/http/ngx_http_request_body.c \
+           src/http/ngx_http_parse_time.c \
+           src/http/modules/ngx_http_static_handler.c \
+           src/http/modules/ngx_http_index_handler.c \
+           src/http/modules/ngx_http_chunked_filter.c \
+           src/http/modules/ngx_http_range_filter.c \
+           src/http/modules/ngx_http_headers_filter.c \
+           src/http/modules/ngx_http_not_modified_filter.c"
 
 # STUB
 HTTP_SRCS="$HTTP_SRCS src/http/ngx_http_busy_lock.c"
@@ -283,9 +284,18 @@
 HTTP_PROXY_INCS="src/http/modules/proxy"
 HTTP_PROXY_DEPS=src/http/modules/proxy/ngx_http_proxy_handler.h
 HTTP_PROXY_SRCS="src/http/modules/proxy/ngx_http_proxy_handler.c \
-            src/http/modules/proxy/ngx_http_proxy_upstream.c \
-            src/http/modules/proxy/ngx_http_proxy_parse.c \
-            src/http/modules/proxy/ngx_http_proxy_header.c"
+                 src/http/modules/proxy/ngx_http_proxy_upstream.c \
+                 src/http/modules/proxy/ngx_http_proxy_parse.c \
+                 src/http/modules/proxy/ngx_http_proxy_header.c"
 
 # STUB
-#            src/http/modules/proxy/ngx_http_proxy_cache.c \
+#                 src/http/modules/proxy/ngx_http_proxy_cache.c \
+
+
+IMAP_INCS="src/imap"
+
+IMAP_DEPS="src/imap/ngx_imap.h"
+
+IMAP_MODULE=ngx_imap_module
+IMAP_SRCS="src/imap/ngx_imap.c \
+	   src/imap/ngx_imap_handler.c"
diff --git a/auto/unix b/auto/unix
index 36b9744..35b59ff 100755
--- a/auto/unix
+++ b/auto/unix
@@ -32,6 +32,8 @@
 
 ngx_type="in_addr_t"; ngx_types="uint32_t"; . auto/types/typedef
 
+ngx_type="in_port_t"; ngx_types="u_short"; . auto/types/typedef
+
 ngx_type="rlim_t"; ngx_types="int"; . auto/types/typedef
 
 . auto/types/uintptr_t