comparison src/http/ngx_http_config.c @ 10:4f3879d9b6f6

nginx-0.0.1-2002-09-11-19:18:33 import
author Igor Sysoev <igor@sysoev.ru>
date Wed, 11 Sep 2002 15:18:33 +0000
parents
children 77c7629a2627
comparison
equal deleted inserted replaced
9:6f58641241bb 10:4f3879d9b6f6
1
2 #include <ngx_core.h>
3 #include <ngx_config_command.h>
4 #include <ngx_http.h>
5 #include <ngx_http_write_filter.h>
6 #include <ngx_http_output_filter.h>
7 #include <ngx_http_index_handler.h>
8
9
10 int ngx_max_module;
11
12 /* STUB: gobal srv and loc conf */
13 void **ngx_srv_conf;
14 void **ngx_loc_conf;
15
16
17 int ngx_http_config_modules(ngx_pool_t *pool, ngx_http_module_t **modules)
18 {
19 int i;
20
21 for (i = 0; modules[i]; i++) {
22 modules[i]->index = i;
23 }
24
25 ngx_max_module = i;
26
27 ngx_test_null(ngx_srv_conf,
28 ngx_pcalloc(pool, sizeof(void *) * ngx_max_module),
29 NGX_ERROR);
30 ngx_test_null(ngx_loc_conf,
31 ngx_pcalloc(pool, sizeof(void *) * ngx_max_module),
32 NGX_ERROR);
33
34 for (i = 0; modules[i]; i++) {
35 if (modules[i]->create_srv_conf)
36 ngx_srv_conf[i] = modules[i]->create_srv_conf(pool);
37
38 if (modules[i]->create_loc_conf)
39 ngx_loc_conf[i] = modules[i]->create_loc_conf(pool);
40 }
41 }
42
43 int ngx_http_init_modules(ngx_pool_t *pool, ngx_http_module_t **modules)
44 {
45 int i;
46
47 for (i = 0; modules[i]; i++) {
48 if (modules[i]->init_module)
49 modules[i]->init_module(pool);
50 }
51 }
52
53 int ngx_http_init_filters(ngx_pool_t *pool, ngx_http_module_t **modules)
54 {
55 int i;
56 int (*filter)(ngx_http_request_t *r, ngx_chain_t *ch);
57
58 filter = ngx_http_write_filter;
59
60 for (i = 0; modules[i]; i++) {
61 if (modules[i]->init_output_body_filter)
62 modules[i]->init_output_body_filter(&filter);
63 }
64 }
65
66
67 /* STUB */
68 ngx_http_output_filter_set_stub(ngx_pool_t *pool, ngx_http_module_t **modules)
69 {
70 int i;
71 ngx_command_t *cmd;
72
73 for (i = 0; modules[i]; i++) {
74 if (modules[i] == &ngx_http_output_filter_module) {
75 for (cmd = modules[i]->commands; cmd->name; cmd++) {
76 if (strcmp(cmd->name, "output_buffer") == 0) {
77 cmd->set(ngx_loc_conf[i], cmd->offset, "32768");
78 }
79 }
80 }
81 }
82 }
83
84 ngx_http_write_filter_set_stub(ngx_pool_t *pool, ngx_http_module_t **modules)
85 {
86 int i;
87 ngx_command_t *cmd;
88
89 for (i = 0; modules[i]; i++) {
90 if (modules[i] == &ngx_http_write_filter_module) {
91 for (cmd = modules[i]->commands; cmd->name; cmd++) {
92 if (strcmp(cmd->name, "write_buffer") == 0) {
93 cmd->set(ngx_loc_conf[i], cmd->offset, "1500");
94 }
95 }
96 }
97 }
98 }
99
100 ngx_http_index_set_stub(ngx_pool_t *pool, ngx_http_module_t **modules)
101 {
102 int i;
103 ngx_command_t *cmd;
104
105 for (i = 0; modules[i]; i++) {
106 if (modules[i] == &ngx_http_index_module) {
107 for (cmd = modules[i]->commands; cmd->name; cmd++) {
108 if (strcmp(cmd->name, "index") == 0) {
109 cmd->set(pool, ngx_loc_conf[i], "index.html");
110 }
111 }
112 }
113 }
114 }