Mercurial > hg > nginx
annotate src/imap/ngx_imap_core_module.c @ 804:472cd9768ac2
now the "listen" directives use ngx_parse_url()
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 24 Oct 2006 13:06:55 +0000 |
parents | 887d8dec72dc |
children | da9c1521319d |
rev | line source |
---|---|
521 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #include <ngx_config.h> | |
8 #include <ngx_core.h> | |
9 #include <ngx_event.h> | |
10 #include <ngx_imap.h> | |
11 | |
12 | |
13 static void *ngx_imap_core_create_main_conf(ngx_conf_t *cf); | |
14 static void *ngx_imap_core_create_srv_conf(ngx_conf_t *cf); | |
15 static char *ngx_imap_core_merge_srv_conf(ngx_conf_t *cf, void *parent, | |
16 void *child); | |
17 static char *ngx_imap_core_server(ngx_conf_t *cf, ngx_command_t *cmd, | |
18 void *conf); | |
19 static char *ngx_imap_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, | |
20 void *conf); | |
527 | 21 static char *ngx_imap_core_capability(ngx_conf_t *cf, ngx_command_t *cmd, |
22 void *conf); | |
521 | 23 |
24 | |
25 static ngx_conf_enum_t ngx_imap_core_procotol[] = { | |
26 { ngx_string("pop3"), NGX_IMAP_POP3_PROTOCOL }, | |
27 { ngx_string("imap"), NGX_IMAP_IMAP_PROTOCOL }, | |
28 { ngx_null_string, 0 } | |
29 }; | |
30 | |
31 | |
527 | 32 static ngx_str_t ngx_pop3_default_capabilities[] = { |
33 ngx_string("TOP"), | |
34 ngx_string("USER"), | |
35 ngx_string("UIDL"), | |
36 ngx_null_string | |
37 }; | |
38 | |
39 | |
40 static ngx_str_t ngx_imap_default_capabilities[] = { | |
41 ngx_string("IMAP4"), | |
42 ngx_string("IMAP4rev1"), | |
43 ngx_string("UIDPLUS"), | |
44 ngx_null_string | |
45 }; | |
46 | |
47 | |
800 | 48 static ngx_conf_bitmask_t ngx_imap_auth_methods[] = { |
49 { ngx_string("plain"), NGX_IMAP_AUTH_PLAIN_ENABLED }, | |
50 { ngx_string("apop"), NGX_IMAP_AUTH_APOP_ENABLED }, | |
51 { ngx_null_string, 0 } | |
52 }; | |
53 | |
54 | |
521 | 55 static ngx_command_t ngx_imap_core_commands[] = { |
56 | |
57 { ngx_string("server"), | |
58 NGX_IMAP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS, | |
59 ngx_imap_core_server, | |
60 0, | |
61 0, | |
62 NULL }, | |
63 | |
64 { ngx_string("listen"), | |
641 | 65 NGX_IMAP_SRV_CONF|NGX_CONF_TAKE12, |
521 | 66 ngx_imap_core_listen, |
67 0, | |
68 0, | |
69 NULL }, | |
70 | |
71 { ngx_string("protocol"), | |
72 NGX_IMAP_SRV_CONF|NGX_CONF_TAKE1, | |
73 ngx_conf_set_enum_slot, | |
74 NGX_IMAP_SRV_CONF_OFFSET, | |
75 offsetof(ngx_imap_core_srv_conf_t, protocol), | |
76 &ngx_imap_core_procotol }, | |
77 | |
78 { ngx_string("imap_client_buffer"), | |
79 NGX_IMAP_MAIN_CONF|NGX_IMAP_SRV_CONF|NGX_CONF_TAKE1, | |
80 ngx_conf_set_size_slot, | |
81 NGX_IMAP_SRV_CONF_OFFSET, | |
82 offsetof(ngx_imap_core_srv_conf_t, imap_client_buffer_size), | |
83 NULL }, | |
84 | |
587 | 85 { ngx_string("so_keepalive"), |
86 NGX_IMAP_MAIN_CONF|NGX_IMAP_SRV_CONF|NGX_CONF_FLAG, | |
87 ngx_conf_set_flag_slot, | |
88 NGX_IMAP_SRV_CONF_OFFSET, | |
89 offsetof(ngx_imap_core_srv_conf_t, so_keepalive), | |
90 NULL }, | |
91 | |
521 | 92 { ngx_string("timeout"), |
93 NGX_IMAP_MAIN_CONF|NGX_IMAP_SRV_CONF|NGX_CONF_TAKE1, | |
94 ngx_conf_set_msec_slot, | |
95 NGX_IMAP_SRV_CONF_OFFSET, | |
96 offsetof(ngx_imap_core_srv_conf_t, timeout), | |
97 NULL }, | |
98 | |
527 | 99 { ngx_string("pop3_capabilities"), |
100 NGX_IMAP_MAIN_CONF|NGX_IMAP_SRV_CONF|NGX_CONF_1MORE, | |
101 ngx_imap_core_capability, | |
102 NGX_IMAP_SRV_CONF_OFFSET, | |
103 offsetof(ngx_imap_core_srv_conf_t, pop3_capabilities), | |
104 NULL }, | |
105 | |
106 { ngx_string("imap_capabilities"), | |
107 NGX_IMAP_MAIN_CONF|NGX_IMAP_SRV_CONF|NGX_CONF_1MORE, | |
108 ngx_imap_core_capability, | |
109 NGX_IMAP_SRV_CONF_OFFSET, | |
110 offsetof(ngx_imap_core_srv_conf_t, imap_capabilities), | |
111 NULL }, | |
112 | |
800 | 113 { ngx_string("server_name"), |
114 NGX_IMAP_MAIN_CONF|NGX_IMAP_SRV_CONF|NGX_CONF_TAKE1, | |
115 ngx_conf_set_str_slot, | |
116 NGX_IMAP_SRV_CONF_OFFSET, | |
117 offsetof(ngx_imap_core_srv_conf_t, server_name), | |
118 NULL }, | |
119 | |
120 { ngx_string("auth"), | |
121 NGX_IMAP_MAIN_CONF|NGX_IMAP_SRV_CONF|NGX_CONF_1MORE, | |
122 ngx_conf_set_bitmask_slot, | |
123 NGX_IMAP_SRV_CONF_OFFSET, | |
124 offsetof(ngx_imap_core_srv_conf_t, auth_methods), | |
125 &ngx_imap_auth_methods }, | |
126 | |
521 | 127 ngx_null_command |
128 }; | |
129 | |
130 | |
131 static ngx_imap_module_t ngx_imap_core_module_ctx = { | |
132 ngx_imap_core_create_main_conf, /* create main configuration */ | |
133 NULL, /* init main configuration */ | |
134 | |
135 ngx_imap_core_create_srv_conf, /* create server configuration */ | |
136 ngx_imap_core_merge_srv_conf /* merge server configuration */ | |
137 }; | |
138 | |
139 | |
140 ngx_module_t ngx_imap_core_module = { | |
141 NGX_MODULE_V1, | |
142 &ngx_imap_core_module_ctx, /* module context */ | |
143 ngx_imap_core_commands, /* module directives */ | |
144 NGX_IMAP_MODULE, /* module type */ | |
541 | 145 NULL, /* init master */ |
521 | 146 NULL, /* init module */ |
541 | 147 NULL, /* init process */ |
148 NULL, /* init thread */ | |
149 NULL, /* exit thread */ | |
150 NULL, /* exit process */ | |
151 NULL, /* exit master */ | |
152 NGX_MODULE_V1_PADDING | |
521 | 153 }; |
154 | |
155 | |
156 static void * | |
157 ngx_imap_core_create_main_conf(ngx_conf_t *cf) | |
577 | 158 { |
521 | 159 ngx_imap_core_main_conf_t *cmcf; |
160 | |
161 cmcf = ngx_pcalloc(cf->pool, sizeof(ngx_imap_core_main_conf_t)); | |
162 if (cmcf == NULL) { | |
163 return NGX_CONF_ERROR; | |
164 } | |
165 | |
166 if (ngx_array_init(&cmcf->servers, cf->pool, 4, | |
641 | 167 sizeof(ngx_imap_core_srv_conf_t *)) |
168 != NGX_OK) | |
169 { | |
170 return NGX_CONF_ERROR; | |
171 } | |
172 | |
173 if (ngx_array_init(&cmcf->listen, cf->pool, 4, sizeof(ngx_imap_listen_t)) | |
174 != NGX_OK) | |
521 | 175 { |
176 return NGX_CONF_ERROR; | |
177 } | |
178 | |
179 return cmcf; | |
180 } | |
181 | |
182 | |
183 static void * | |
184 ngx_imap_core_create_srv_conf(ngx_conf_t *cf) | |
577 | 185 { |
521 | 186 ngx_imap_core_srv_conf_t *cscf; |
577 | 187 |
521 | 188 cscf = ngx_pcalloc(cf->pool, sizeof(ngx_imap_core_srv_conf_t)); |
189 if (cscf == NULL) { | |
527 | 190 return NULL; |
521 | 191 } |
192 | |
193 cscf->imap_client_buffer_size = NGX_CONF_UNSET_SIZE; | |
587 | 194 cscf->protocol = NGX_CONF_UNSET_UINT; |
521 | 195 cscf->timeout = NGX_CONF_UNSET_MSEC; |
587 | 196 cscf->so_keepalive = NGX_CONF_UNSET; |
521 | 197 |
527 | 198 if (ngx_array_init(&cscf->pop3_capabilities, cf->pool, 4, sizeof(ngx_str_t)) |
199 != NGX_OK) | |
200 { | |
201 return NULL; | |
202 } | |
203 | |
204 if (ngx_array_init(&cscf->imap_capabilities, cf->pool, 4, sizeof(ngx_str_t)) | |
205 != NGX_OK) | |
206 { | |
207 return NULL; | |
208 } | |
209 | |
521 | 210 return cscf; |
211 } | |
212 | |
213 | |
214 static char * | |
215 ngx_imap_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) | |
216 { | |
217 ngx_imap_core_srv_conf_t *prev = parent; | |
218 ngx_imap_core_srv_conf_t *conf = child; | |
219 | |
583 | 220 u_char *p; |
527 | 221 size_t size; |
222 ngx_str_t *c, *d; | |
223 ngx_uint_t i; | |
224 | |
521 | 225 ngx_conf_merge_size_value(conf->imap_client_buffer_size, |
226 prev->imap_client_buffer_size, | |
227 (size_t) ngx_pagesize); | |
228 ngx_conf_merge_msec_value(conf->timeout, prev->timeout, 60000); | |
663 | 229 ngx_conf_merge_uint_value(conf->protocol, prev->protocol, |
521 | 230 NGX_IMAP_IMAP_PROTOCOL); |
587 | 231 ngx_conf_merge_value(conf->so_keepalive, prev->so_keepalive, 0); |
521 | 232 |
527 | 233 |
800 | 234 ngx_conf_merge_bitmask_value(conf->auth_methods, prev->auth_methods, |
235 (NGX_CONF_BITMASK_SET|NGX_IMAP_AUTH_PLAIN_ENABLED)); | |
236 | |
237 | |
238 ngx_conf_merge_str_value(conf->server_name, prev->server_name, ""); | |
239 | |
240 if (conf->server_name.len == 0) { | |
241 conf->server_name.data = ngx_palloc(cf->pool, NGX_MAXHOSTNAMELEN); | |
242 if (conf->server_name.data == NULL) { | |
243 return NGX_CONF_ERROR; | |
244 } | |
245 | |
246 if (gethostname((char *) conf->server_name.data, NGX_MAXHOSTNAMELEN) | |
247 == -1) | |
248 { | |
249 ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno, | |
250 "gethostname() failed"); | |
251 return NGX_CONF_ERROR; | |
252 } | |
253 | |
254 conf->server_name.len = ngx_strlen(conf->server_name.data); | |
255 } | |
256 | |
257 | |
527 | 258 if (conf->pop3_capabilities.nelts == 0) { |
259 conf->pop3_capabilities = prev->pop3_capabilities; | |
260 } | |
261 | |
262 if (conf->pop3_capabilities.nelts == 0) { | |
263 | |
264 for (d = ngx_pop3_default_capabilities; d->len; d++) { | |
265 c = ngx_array_push(&conf->pop3_capabilities); | |
266 if (c == NULL) { | |
267 return NGX_CONF_ERROR; | |
268 } | |
269 | |
270 *c = *d; | |
271 } | |
272 } | |
273 | |
274 size = sizeof("+OK Capability list follows" CRLF) - 1 | |
275 + sizeof("." CRLF) - 1; | |
276 | |
277 c = conf->pop3_capabilities.elts; | |
278 for (i = 0; i < conf->pop3_capabilities.nelts; i++) { | |
279 size += c[i].len + sizeof(CRLF) - 1; | |
280 } | |
281 | |
583 | 282 p = ngx_palloc(cf->pool, size); |
283 if (p == NULL) { | |
527 | 284 return NGX_CONF_ERROR; |
285 } | |
286 | |
583 | 287 conf->pop3_capability.len = size; |
288 conf->pop3_capability.data = p; | |
289 | |
290 p = ngx_cpymem(p, "+OK Capability list follows" CRLF, | |
291 sizeof("+OK Capability list follows" CRLF) - 1); | |
527 | 292 |
293 for (i = 0; i < conf->pop3_capabilities.nelts; i++) { | |
583 | 294 p = ngx_cpymem(p, c[i].data, c[i].len); |
295 *p++ = CR; *p++ = LF; | |
527 | 296 } |
297 | |
583 | 298 *p++ = '.'; *p++ = CR; *p = LF; |
299 | |
300 | |
301 size += sizeof("STLS" CRLF) - 1; | |
527 | 302 |
583 | 303 p = ngx_palloc(cf->pool, size); |
304 if (p == NULL) { | |
305 return NGX_CONF_ERROR; | |
306 } | |
307 | |
308 conf->pop3_starttls_capability.len = size; | |
309 conf->pop3_starttls_capability.data = p; | |
310 | |
311 p = ngx_cpymem(p, conf->pop3_capability.data, | |
312 conf->pop3_capability.len - (sizeof("." CRLF) - 1)); | |
313 | |
314 p = ngx_cpymem(p, "STLS" CRLF, sizeof("STLS" CRLF) - 1); | |
315 *p++ = '.'; *p++ = CR; *p = LF; | |
527 | 316 |
317 | |
318 if (conf->imap_capabilities.nelts == 0) { | |
319 conf->imap_capabilities = prev->imap_capabilities; | |
320 } | |
321 | |
322 if (conf->imap_capabilities.nelts == 0) { | |
323 | |
324 for (d = ngx_imap_default_capabilities; d->len; d++) { | |
325 c = ngx_array_push(&conf->imap_capabilities); | |
326 if (c == NULL) { | |
327 return NGX_CONF_ERROR; | |
328 } | |
329 | |
330 *c = *d; | |
331 } | |
332 } | |
333 | |
334 size = sizeof("* CAPABILITY") - 1 + sizeof(CRLF) - 1; | |
335 | |
336 c = conf->imap_capabilities.elts; | |
337 for (i = 0; i < conf->imap_capabilities.nelts; i++) { | |
338 size += 1 + c[i].len; | |
339 } | |
340 | |
583 | 341 p = ngx_palloc(cf->pool, size); |
342 if (p == NULL) { | |
343 return NGX_CONF_ERROR; | |
344 } | |
345 | |
346 conf->imap_capability.len = size; | |
347 conf->imap_capability.data = p; | |
348 | |
349 p = ngx_cpymem(p, "* CAPABILITY", sizeof("* CAPABILITY") - 1); | |
350 | |
351 for (i = 0; i < conf->imap_capabilities.nelts; i++) { | |
352 *p++ = ' '; | |
353 p = ngx_cpymem(p, c[i].data, c[i].len); | |
354 } | |
355 | |
356 *p++ = CR; *p = LF; | |
357 | |
358 | |
359 size += sizeof(" STARTTLS") - 1; | |
360 | |
361 p = ngx_palloc(cf->pool, size); | |
362 if (p == NULL) { | |
527 | 363 return NGX_CONF_ERROR; |
364 } | |
365 | |
583 | 366 conf->imap_starttls_capability.len = size; |
367 conf->imap_starttls_capability.data = p; | |
527 | 368 |
583 | 369 p = ngx_cpymem(p, conf->imap_capability.data, |
370 conf->imap_capability.len - (sizeof(CRLF) - 1)); | |
371 p = ngx_cpymem(p, " STARTTLS", sizeof(" STARTTLS") - 1); | |
372 *p++ = CR; *p = LF; | |
373 | |
374 | |
375 size += sizeof(" LOGINDISABLED") - 1; | |
376 | |
377 p = ngx_palloc(cf->pool, size); | |
378 if (p == NULL) { | |
379 return NGX_CONF_ERROR; | |
527 | 380 } |
381 | |
583 | 382 conf->imap_starttls_only_capability.len = size; |
383 conf->imap_starttls_only_capability.data = p; | |
527 | 384 |
583 | 385 p = ngx_cpymem(p, conf->imap_starttls_capability.data, |
386 conf->imap_starttls_capability.len - (sizeof(CRLF) - 1)); | |
387 p = ngx_cpymem(p, " LOGINDISABLED", sizeof(" LOGINDISABLED") - 1); | |
388 *p++ = CR; *p = LF; | |
389 | |
527 | 390 |
521 | 391 return NGX_CONF_OK; |
392 } | |
393 | |
394 | |
395 static char * | |
396 ngx_imap_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
397 { | |
398 char *rv; | |
399 void *mconf; | |
400 ngx_uint_t m; | |
401 ngx_conf_t pcf; | |
402 ngx_imap_module_t *module; | |
403 ngx_imap_conf_ctx_t *ctx, *imap_ctx; | |
404 ngx_imap_core_srv_conf_t *cscf, **cscfp; | |
405 ngx_imap_core_main_conf_t *cmcf; | |
406 | |
407 | |
408 ctx = ngx_pcalloc(cf->pool, sizeof(ngx_imap_conf_ctx_t)); | |
409 if (ctx == NULL) { | |
410 return NGX_CONF_ERROR; | |
411 } | |
412 | |
413 imap_ctx = cf->ctx; | |
414 ctx->main_conf = imap_ctx->main_conf; | |
577 | 415 |
521 | 416 /* the server{}'s srv_conf */ |
417 | |
418 ctx->srv_conf = ngx_pcalloc(cf->pool, sizeof(void *) * ngx_imap_max_module); | |
419 if (ctx->srv_conf == NULL) { | |
420 return NGX_CONF_ERROR; | |
421 } | |
422 | |
423 for (m = 0; ngx_modules[m]; m++) { | |
424 if (ngx_modules[m]->type != NGX_IMAP_MODULE) { | |
425 continue; | |
426 } | |
427 | |
428 module = ngx_modules[m]->ctx; | |
429 | |
430 if (module->create_srv_conf) { | |
431 mconf = module->create_srv_conf(cf); | |
432 if (mconf == NULL) { | |
433 return NGX_CONF_ERROR; | |
434 } | |
435 | |
436 ctx->srv_conf[ngx_modules[m]->ctx_index] = mconf; | |
437 } | |
438 } | |
439 | |
440 /* the server configuration context */ | |
441 | |
442 cscf = ctx->srv_conf[ngx_imap_core_module.ctx_index]; | |
443 cscf->ctx = ctx; | |
444 | |
445 cmcf = ctx->main_conf[ngx_imap_core_module.ctx_index]; | |
446 | |
447 cscfp = ngx_array_push(&cmcf->servers); | |
448 if (cscfp == NULL) { | |
449 return NGX_CONF_ERROR; | |
450 } | |
451 | |
452 *cscfp = cscf; | |
453 | |
454 | |
455 /* parse inside server{} */ | |
456 | |
457 pcf = *cf; | |
458 cf->ctx = ctx; | |
459 cf->cmd_type = NGX_IMAP_SRV_CONF; | |
460 | |
461 rv = ngx_conf_parse(cf, NULL); | |
462 | |
463 *cf = pcf; | |
464 | |
465 return rv; | |
466 } | |
467 | |
468 | |
469 /* AF_INET only */ | |
470 | |
471 static char * | |
472 ngx_imap_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
473 { | |
641 | 474 ngx_str_t *value; |
804
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
475 ngx_url_t u; |
641 | 476 ngx_uint_t i; |
477 ngx_imap_listen_t *imls; | |
478 ngx_imap_core_main_conf_t *cmcf; | |
521 | 479 |
480 value = cf->args->elts; | |
481 | |
804
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
482 ngx_memzero(&u, sizeof(ngx_url_t)); |
521 | 483 |
804
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
484 u.url = value[1]; |
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
485 u.listen = 1; |
619 | 486 |
804
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
487 if (ngx_parse_url(cf, &u) != NGX_OK) { |
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
488 if (u.err) { |
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
489 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
490 "%s in \"%V\" of the \"listen\" directive", |
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
491 u.err, &u.url); |
521 | 492 } |
493 | |
804
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
494 return NGX_CONF_ERROR; |
521 | 495 } |
496 | |
641 | 497 cmcf = ngx_imap_conf_get_module_main_conf(cf, ngx_imap_core_module); |
521 | 498 |
641 | 499 imls = cmcf->listen.elts; |
500 | |
501 for (i = 0; i < cmcf->listen.nelts; i++) { | |
502 | |
804
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
503 if (imls[i].addr != u.addr.in_addr || imls[i].port != u.portn) { |
641 | 504 continue; |
505 } | |
506 | |
507 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
804
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
508 "duplicate \"%V\" address and port pair", &u.url); |
577 | 509 return NGX_CONF_ERROR; |
521 | 510 } |
511 | |
641 | 512 imls = ngx_array_push(&cmcf->listen); |
513 if (imls == NULL) { | |
514 return NGX_CONF_ERROR; | |
515 } | |
563 | 516 |
641 | 517 ngx_memzero(imls, sizeof(ngx_imap_listen_t)); |
518 | |
804
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
519 imls->addr = u.addr.in_addr; |
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
520 imls->port = u.portn; |
641 | 521 imls->family = AF_INET; |
522 imls->ctx = cf->ctx; | |
521 | 523 |
641 | 524 if (cf->args->nelts == 2) { |
525 return NGX_CONF_OK; | |
526 } | |
521 | 527 |
641 | 528 if (ngx_strcmp(value[2].data, "bind") == 0) { |
529 imls->bind = 1; | |
530 return NGX_CONF_OK; | |
531 } | |
521 | 532 |
641 | 533 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
534 "the invalid \"%V\" parameter", &value[2]); | |
535 return NGX_CONF_ERROR; | |
521 | 536 } |
527 | 537 |
538 | |
539 static char * | |
540 ngx_imap_core_capability(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
541 { | |
542 char *p = conf; | |
543 | |
544 ngx_str_t *c, *value; | |
545 ngx_uint_t i; | |
546 ngx_array_t *a; | |
547 | |
548 a = (ngx_array_t *) (p + cmd->offset); | |
549 | |
550 value = cf->args->elts; | |
551 | |
552 for (i = 1; i < cf->args->nelts; i++) { | |
553 c = ngx_array_push(a); | |
554 if (c == NULL) { | |
555 return NGX_CONF_ERROR; | |
556 } | |
557 | |
558 *c = value[i]; | |
559 } | |
560 | |
561 return NGX_CONF_OK; | |
562 } |