comparison src/http/ngx_http_config.c @ 32:d45effe5854c

nginx-0.0.1-2002-12-19-10:08:55 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 19 Dec 2002 07:08:55 +0000
parents c2d9ef3ebb6d
children 59e7c7f30d49
comparison
equal deleted inserted replaced
31:d1ebcc555037 32:d45effe5854c
1 1
2 #include <ngx_config.h> 2 #include <ngx_config.h>
3 #include <ngx_core.h> 3 #include <ngx_core.h>
4 #include <ngx_config_command.h> 4 #include <ngx_config_file.h>
5 #include <ngx_http.h> 5 #include <ngx_http.h>
6 #include <ngx_http_write_filter.h> 6 #include <ngx_http_write_filter.h>
7 #include <ngx_http_output_filter.h> 7 #include <ngx_http_output_filter.h>
8 #include <ngx_http_index_handler.h> 8 #include <ngx_http_index_handler.h>
9 9
15 /* STUB: gobal srv and loc conf */ 15 /* STUB: gobal srv and loc conf */
16 void **ngx_srv_conf; 16 void **ngx_srv_conf;
17 void **ngx_loc_conf; 17 void **ngx_loc_conf;
18 18
19 #if 0 19 #if 0
20 void *ngx_http_block(ngx_conf_t *cf) 20 int ngx_http_block(ngx_conf_t *cf)
21 { 21 {
22 ngx_http_conf_ctx_t *ctx; 22 ngx_http_conf_ctx_t *ctx;
23 23
24 ngx_test_null(ctx, 24 ngx_test_null(ctx,
25 ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)), 25 ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)),
26 NGX_ERROR); 26 NGX_ERROR);
27 27
28 #if 0
28 /* null server config */ 29 /* null server config */
29 ngx_test_null(ctx->srv_conf, 30 ngx_test_null(ctx->srv_conf,
30 ngx_pcalloc(cf->pool, sizeof(void *) * ngx_max_module), 31 ngx_pcalloc(cf->pool, sizeof(void *) * ngx_max_module),
31 NGX_ERROR); 32 NGX_ERROR);
33 #endif
32 34
33 /* null location config */ 35 /* null location config */
34 ngx_test_null(ctx->loc_conf, 36 ngx_test_null(ctx->loc_conf,
35 ngx_pcalloc(cf->pool, sizeof(void *) * ngx_max_module), 37 ngx_pcalloc(cf->pool, sizeof(void *) * ngx_max_module),
36 NGX_ERROR); 38 NGX_ERROR);
37 39
38 for (i = 0; modules[i]; i++) { 40 for (i = 0; modules[i]; i++) {
41 #if 0
39 if (modules[i]->create_srv_conf) 42 if (modules[i]->create_srv_conf)
40 ngx_test_null(ctx->srv_conf[i], 43 ngx_test_null(ctx->srv_conf[i],
41 modules[i]->create_srv_conf(cf->pool), 44 modules[i]->create_srv_conf(cf->pool),
42 NGX_ERROR); 45 NGX_ERROR);
46 #endif
43 47
44 if (modules[i]->create_loc_conf) 48 if (modules[i]->create_loc_conf)
45 ngx_test_null(ctx->loc_conf[i], 49 ngx_test_null(ctx->loc_conf[i],
46 modules[i]->create_loc_conf(cf->pool), 50 modules[i]->create_loc_conf(cf->pool),
47 NGX_ERROR); 51 NGX_ERROR);
49 53
50 cf->ctx = ctx; 54 cf->ctx = ctx;
51 return ngx_conf_parse(cf); 55 return ngx_conf_parse(cf);
52 } 56 }
53 57
54 void *ngx_server_block(ngx_conf_t *cf) 58 int ngx_server_block(ngx_conf_t *cf)
55 { 59 {
56 ngx_http_conf_ctx_t *ctx, *prev; 60 ngx_http_conf_ctx_t *ctx, *prev;
57 ngx_http_core_loc_conf_t *loc_conf;
58 61
59 ngx_test_null(ctx, 62 ngx_test_null(ctx,
60 ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)), 63 ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)),
61 NGX_ERROR); 64 NGX_ERROR);
62 65
86 prev = cf->ctx; 89 prev = cf->ctx;
87 cf->ctx = ctx; 90 cf->ctx = ctx;
88 rc = ngx_conf_parse(cf); 91 rc = ngx_conf_parse(cf);
89 cf->ctx = prev; 92 cf->ctx = prev;
90 93
91 if (loc == NULL) 94 if (loc == NGX_ERROR)
92 return NULL; 95 return NGX_ERROR;
93 96
94 for (i = 0; modules[i]; i++) { 97 for (i = 0; modules[i]; i++) {
98 #if 0
95 if (modules[i]->merge_srv_conf) 99 if (modules[i]->merge_srv_conf)
96 if (modules[i]->merge_srv_conf(cf->pool, 100 if (modules[i]->merge_srv_conf(cf->pool,
97 prev->srv_conf, ctx->srv_conf) 101 prev->srv_conf, ctx->srv_conf)
98 == NGX_ERROR) 102 == NGX_ERROR)
99 return NGX_ERROR; 103 return NGX_ERROR;
104 #endif
105
106 if (modules[i]->init_srv_conf)
107 if (modules[i]->init_srv_conf(cf->pool, ctx->srv_conf) == NGX_ERROR)
108 return NGX_ERROR;
100 109
101 if (modules[i]->merge_loc_conf) 110 if (modules[i]->merge_loc_conf)
102 if (modules[i]->merge_loc_conf(cf->pool, 111 if (modules[i]->merge_loc_conf(cf->pool,
103 prev->loc_conf, ctx->loc_conf) 112 prev->loc_conf, ctx->loc_conf)
104 == NGX_ERROR) 113 == NGX_ERROR)
105 return NGX_ERROR; 114 return NGX_ERROR;
106 } 115
107 116 for (array) {
108 return (void *) 1; 117 if (modules[i]->merge_loc_conf(cf->pool,
109 } 118 ctx->loc_conf, loc->loc_conf)
110 119 == NGX_ERROR)
111 void *ngx_location_block(ngx_conf_t *cf) 120 return NGX_ERROR;
112 { 121 }
113 122 }
114 ngx_test_null(ctx, 123 }
115 ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)), 124
125 return NGX_OK;
126 }
127
128 int ngx_location_block(ngx_conf_t *cf)
129 {
130 ngx_http_conf_ctx_t *ctx, *prev;
131
132 ngx_test_null(ctx, ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)),
116 NGX_ERROR); 133 NGX_ERROR);
117 134
118 ctx->srv_conf = cf->ctx->srv_conf; 135 ctx->srv_conf = cf->ctx->srv_conf;
119 136
120 ngx_test_null(ctx->loc_conf, 137 ngx_test_null(ctx->loc_conf,