Mercurial > hg > nginx-quic
annotate src/imap/ngx_imap.c @ 533:d6e48c08d718 release-0.1.41
nginx-0.1.41-RELEASE import
*) Bugfix: if the variable was used in the configuration file, then it
can not be used in SSI.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 19 Aug 2005 08:54:17 +0000 |
parents | 6f00349b98e5 |
children | b09ee85d0ac8 |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
5 |
413
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_event.h> |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
10 #include <ngx_imap.h> |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
11 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
12 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
13 static char *ngx_imap_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
413
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
14 |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
15 |
521 | 16 ngx_uint_t ngx_imap_max_module; |
17 | |
18 | |
413
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
19 static ngx_command_t ngx_imap_commands[] = { |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
20 |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
21 { ngx_string("imap"), |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
22 NGX_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS, |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
23 ngx_imap_block, |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
24 0, |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
25 0, |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
26 NULL }, |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
27 |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
28 ngx_null_command |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
29 }; |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
30 |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
31 |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
32 static ngx_core_module_t ngx_imap_module_ctx = { |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
33 ngx_string("imap"), |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
34 NULL, |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
35 NULL |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
36 }; |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
37 |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
38 |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
39 ngx_module_t ngx_imap_module = { |
509 | 40 NGX_MODULE_V1, |
413
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
41 &ngx_imap_module_ctx, /* module context */ |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
42 ngx_imap_commands, /* module directives */ |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
43 NGX_CORE_MODULE, /* module type */ |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
44 NULL, /* init module */ |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
45 NULL /* init process */ |
413
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
46 }; |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
47 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
48 |
521 | 49 static char * |
50 ngx_imap_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
51 { |
521 | 52 char *rv; |
53 ngx_uint_t m, mi, s; | |
54 ngx_conf_t pcf; | |
55 ngx_imap_module_t *module; | |
56 ngx_imap_conf_ctx_t *ctx; | |
57 ngx_imap_core_srv_conf_t **cscfp; | |
58 ngx_imap_core_main_conf_t *cmcf; | |
59 | |
60 /* the main imap context */ | |
61 | |
62 ctx = ngx_pcalloc(cf->pool, sizeof(ngx_imap_conf_ctx_t)); | |
63 if (ctx == NULL) { | |
64 return NGX_CONF_ERROR; | |
65 } | |
66 | |
67 *(ngx_imap_conf_ctx_t **) conf = ctx; | |
68 | |
69 /* count the number of the http modules and set up their indices */ | |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
70 |
521 | 71 ngx_imap_max_module = 0; |
72 for (m = 0; ngx_modules[m]; m++) { | |
73 if (ngx_modules[m]->type != NGX_IMAP_MODULE) { | |
74 continue; | |
75 } | |
76 | |
77 ngx_modules[m]->ctx_index = ngx_imap_max_module++; | |
78 } | |
79 | |
80 | |
81 /* the imap main_conf context, it is the same in the all imap contexts */ | |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
82 |
521 | 83 ctx->main_conf = ngx_pcalloc(cf->pool, |
84 sizeof(void *) * ngx_imap_max_module); | |
85 if (ctx->main_conf == NULL) { | |
86 return NGX_CONF_ERROR; | |
87 } | |
88 | |
89 | |
90 /* | |
91 * the imap null srv_conf context, it is used to merge | |
92 * the server{}s' srv_conf's | |
93 */ | |
94 | |
95 ctx->srv_conf = ngx_pcalloc(cf->pool, sizeof(void *) * ngx_imap_max_module); | |
96 if (ctx->srv_conf == NULL) { | |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
97 return NGX_CONF_ERROR; |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
98 } |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
99 |
521 | 100 |
101 /* | |
102 * create the main_conf's, the null srv_conf's, and the null loc_conf's | |
103 * of the all imap modules | |
104 */ | |
105 | |
106 for (m = 0; ngx_modules[m]; m++) { | |
107 if (ngx_modules[m]->type != NGX_IMAP_MODULE) { | |
108 continue; | |
109 } | |
110 | |
111 module = ngx_modules[m]->ctx; | |
112 mi = ngx_modules[m]->ctx_index; | |
113 | |
114 if (module->create_main_conf) { | |
115 ctx->main_conf[mi] = module->create_main_conf(cf); | |
116 if (ctx->main_conf[mi] == NULL) { | |
117 return NGX_CONF_ERROR; | |
118 } | |
119 } | |
120 | |
121 if (module->create_srv_conf) { | |
122 ctx->srv_conf[mi] = module->create_srv_conf(cf); | |
123 if (ctx->srv_conf[mi] == NULL) { | |
124 return NGX_CONF_ERROR; | |
125 } | |
126 } | |
127 } | |
128 | |
129 | |
130 /* parse inside the imap{} block */ | |
131 | |
132 pcf = *cf; | |
133 cf->ctx = ctx; | |
134 | |
135 cf->module_type = NGX_IMAP_MODULE; | |
136 cf->cmd_type = NGX_IMAP_MAIN_CONF; | |
137 rv = ngx_conf_parse(cf, NULL); | |
138 | |
139 if (rv != NGX_CONF_OK) { | |
140 *cf = pcf; | |
141 return rv; | |
142 } | |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
143 |
521 | 144 |
145 /* init imap{} main_conf's, merge the server{}s' srv_conf's */ | |
146 | |
147 cmcf = ctx->main_conf[ngx_imap_core_module.ctx_index]; | |
148 cscfp = cmcf->servers.elts; | |
149 | |
150 for (m = 0; ngx_modules[m]; m++) { | |
151 if (ngx_modules[m]->type != NGX_IMAP_MODULE) { | |
152 continue; | |
153 } | |
154 | |
155 module = ngx_modules[m]->ctx; | |
156 mi = ngx_modules[m]->ctx_index; | |
157 | |
158 /* init imap{} main_conf's */ | |
159 | |
160 if (module->init_main_conf) { | |
161 rv = module->init_main_conf(cf, ctx->main_conf[mi]); | |
162 if (rv != NGX_CONF_OK) { | |
163 *cf = pcf; | |
164 return rv; | |
165 } | |
166 } | |
167 | |
168 for (s = 0; s < cmcf->servers.nelts; s++) { | |
169 | |
170 /* merge the server{}s' srv_conf's */ | |
171 | |
172 if (module->merge_srv_conf) { | |
173 rv = module->merge_srv_conf(cf, | |
174 ctx->srv_conf[mi], | |
175 cscfp[s]->ctx->srv_conf[mi]); | |
176 if (rv != NGX_CONF_OK) { | |
177 *cf = pcf; | |
178 return rv; | |
179 } | |
180 } | |
181 } | |
182 } | |
183 | |
184 /* imap{}'s cf->ctx was needed while the configuration merging */ | |
185 | |
186 *cf = pcf; | |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
187 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
188 return NGX_CONF_OK; |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
189 } |