nginx-0.0.1-2003-05-14-21:13:13 import
diff --git a/src/core/nginx.c b/src/core/nginx.c
index 7f13a74..4a22e58 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -4,6 +4,7 @@
 #include <ngx_config.h>
 
 #include <ngx_core.h>
+#include <ngx_os_init.h>
 #include <ngx_string.h>
 #include <ngx_errno.h>
 #include <ngx_time.h>
@@ -52,6 +53,10 @@
     /* STUB */
     ngx_log.log_level = NGX_LOG_DEBUG;
 
+    if (ngx_os_init(&ngx_log) == NGX_ERROR) {
+        exit(1);
+    }
+
     ngx_pool = ngx_create_pool(16 * 1024, &ngx_log);
     /* */
 
@@ -67,12 +72,6 @@
 
 #endif
 
-#if 0
-    if (ngx_os_init(&ngx_log) == NGX_ERROR) {
-        exit(1);
-    }
-#endif
-
     ngx_init_array(ngx_listening_sockets, ngx_pool, 10, sizeof(ngx_listen_t),
                    1);
 
@@ -86,7 +85,8 @@
                   ngx_create_array(ngx_pool, 10, sizeof(ngx_str_t)), 1);
     conf.pool = ngx_pool;
     conf.log = &ngx_log;
-    conf.type = NGX_CORE_MODULE_TYPE;
+    conf.module_type = NGX_CORE_MODULE_TYPE;
+    conf.cmd_type = NGX_MAIN_CONF;
 
     conf_file.len = sizeof("nginx.conf") - 1;
     conf_file.data = "nginx.conf";
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index a93922a..b8bbc52 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -76,11 +76,21 @@
 
         if (cf->handler) {
 
-            if ((*cf->handler)(cf) == NGX_CONF_ERROR) {
+            rv = (*cf->handler)(cf, NULL, cf->handler_conf);
+            if (rv == NGX_CONF_OK) {
+                continue;
+
+            } else if (rv == NGX_CONF_ERROR) {
+                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);
                 return NGX_CONF_ERROR;
             }
-
-            continue;
         }
 
         name = (ngx_str_t *) cf->args->elts;
@@ -88,7 +98,7 @@
 
         for (i = 0; !found && ngx_modules[i]; i++) {
             if (ngx_modules[i]->type != NGX_CONF_MODULE_TYPE
-                && ngx_modules[i]->type != cf->type)
+                && ngx_modules[i]->type != cf->module_type)
             {
                 continue;
             }
@@ -107,6 +117,16 @@
 ngx_log_debug(cf->log, "command '%s'" _ cmd->name.data);
 #endif
 
+                    if ((cmd->type & cf->cmd_type) == 0) {
+                        ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
+                                      "directive \"%s\" in %s:%d "
+                                      "is not allowed here",
+                                      name->data,
+                                      cf->conf_file->file.name.data,
+                                      cf->conf_file->line);
+                        return NGX_CONF_ERROR;
+                    }
+
                     if (!(cmd->type & NGX_CONF_ANY)
                         && ((cmd->type & NGX_CONF_FLAG && cf->args->nelts != 2)
                             || (!(cmd->type & NGX_CONF_FLAG)
diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h
index 5426f59..cc25dea 100644
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -12,6 +12,12 @@
 #include <ngx_array.h>
 
 
+/*
+ *      AAAA  number of agruments
+ *    TT      command flags
+ *  LL        command location
+ */
+
 #define NGX_CONF_NOARGS      1
 #define NGX_CONF_TAKE1       2
 #define NGX_CONF_TAKE2       4
@@ -20,6 +26,9 @@
 #define NGX_CONF_BLOCK       0x020000
 #define NGX_CONF_FLAG        0x040000
 
+#define NGX_MAIN_CONF        0x1000000
+
+
 
 #define NGX_CONF_UNSET       -1
 
@@ -65,17 +74,24 @@
 } ngx_conf_file_t;
 
 
+typedef char *(*ngx_conf_handler_pt)(ngx_conf_t *cf,
+                                     ngx_command_t *dummy, char *conf);
+
+
 struct ngx_conf_s {
-    char             *name;
-    ngx_array_t      *args;
+    char                 *name;
+    ngx_array_t          *args;
 
-    ngx_pool_t       *pool;
-    ngx_conf_file_t  *conf_file;
-    ngx_log_t        *log;
+    ngx_pool_t           *pool;
+    ngx_conf_file_t      *conf_file;
+    ngx_log_t            *log;
 
-    void             *ctx;
-    int               type;
-    char           *(*handler)(ngx_conf_t *cf);
+    void                 *ctx;
+    int                   module_type;
+    int                   cmd_type;
+
+    ngx_conf_handler_pt   handler;
+    char                 *handler_conf;
 };
 
 
@@ -84,6 +100,10 @@
         conf = (prev == NGX_CONF_UNSET) ? default : prev;                    \
     }
 
+#define ngx_conf_msec_merge(conf, prev, default)                             \
+    if (conf == NGX_CONF_UNSET) {                                            \
+        conf = (prev == NGX_CONF_UNSET) ? default : prev;                    \
+    }
 
 #define ngx_conf_size_merge(conf, prev, default)                             \
     if (conf == (size_t) NGX_CONF_UNSET) {                                   \