3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Nginx, Inc.
8 #include <ngx_config.h>
11 #define NGX_CONF_BUFFER 4096
13 static ngx_int_t
ngx_conf_handler(ngx_conf_t
*cf
, ngx_int_t last
);
14 static ngx_int_t
ngx_conf_read_token(ngx_conf_t
*cf
);
15 static ngx_int_t
ngx_conf_test_full_name(ngx_str_t
*name
);
16 static void ngx_conf_flush_files(ngx_cycle_t
*cycle
);
19 static ngx_command_t ngx_conf_commands
[] = {
21 { ngx_string("include"),
22 NGX_ANY_CONF
|NGX_CONF_TAKE1
,
32 ngx_module_t ngx_conf_module
= {
34 NULL
, /* module context */
35 ngx_conf_commands
, /* module directives */
36 NGX_CONF_MODULE
, /* module type */
37 NULL
, /* init master */
38 NULL
, /* init module */
39 NULL
, /* init process */
40 NULL
, /* init thread */
41 NULL
, /* exit thread */
42 ngx_conf_flush_files
, /* exit process */
43 NULL
, /* exit master */
48 /* The eight fixed arguments */
50 static ngx_uint_t argument_number
[] = {
63 ngx_conf_param(ngx_conf_t
*cf
)
68 ngx_conf_file_t conf_file
;
70 param
= &cf
->cycle
->conf_param
;
72 if (param
->len
== 0) {
76 ngx_memzero(&conf_file
, sizeof(ngx_conf_file_t
));
78 ngx_memzero(&b
, sizeof(ngx_buf_t
));
80 b
.start
= param
->data
;
82 b
.last
= param
->data
+ param
->len
;
86 conf_file
.file
.fd
= NGX_INVALID_FILE
;
87 conf_file
.file
.name
.data
= NULL
;
90 cf
->conf_file
= &conf_file
;
91 cf
->conf_file
->buffer
= &b
;
93 rv
= ngx_conf_parse(cf
, NULL
);
102 ngx_conf_parse(ngx_conf_t
*cf
, ngx_str_t
*filename
)
108 ngx_conf_file_t
*prev
, conf_file
;
115 #if (NGX_SUPPRESS_WARN)
116 fd
= NGX_INVALID_FILE
;
122 /* open configuration file */
124 fd
= ngx_open_file(filename
->data
, NGX_FILE_RDONLY
, NGX_FILE_OPEN
, 0);
125 if (fd
== NGX_INVALID_FILE
) {
126 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, ngx_errno
,
127 ngx_open_file_n
" \"%s\" failed",
129 return NGX_CONF_ERROR
;
132 prev
= cf
->conf_file
;
134 cf
->conf_file
= &conf_file
;
136 if (ngx_fd_info(fd
, &cf
->conf_file
->file
.info
) == NGX_FILE_ERROR
) {
137 ngx_log_error(NGX_LOG_EMERG
, cf
->log
, ngx_errno
,
138 ngx_fd_info_n
" \"%s\" failed", filename
->data
);
141 cf
->conf_file
->buffer
= &buf
;
143 buf
.start
= ngx_alloc(NGX_CONF_BUFFER
, cf
->log
);
144 if (buf
.start
== NULL
) {
149 buf
.last
= buf
.start
;
150 buf
.end
= buf
.last
+ NGX_CONF_BUFFER
;
153 cf
->conf_file
->file
.fd
= fd
;
154 cf
->conf_file
->file
.name
.len
= filename
->len
;
155 cf
->conf_file
->file
.name
.data
= filename
->data
;
156 cf
->conf_file
->file
.offset
= 0;
157 cf
->conf_file
->file
.log
= cf
->log
;
158 cf
->conf_file
->line
= 1;
162 } else if (cf
->conf_file
->file
.fd
!= NGX_INVALID_FILE
) {
172 rc
= ngx_conf_read_token(cf
);
175 * ngx_conf_read_token() may return
177 * NGX_ERROR there is error
178 * NGX_OK the token terminated by ";" was found
179 * NGX_CONF_BLOCK_START the token terminated by "{" was found
180 * NGX_CONF_BLOCK_DONE the "}" was found
181 * NGX_CONF_FILE_DONE the configuration file is done
184 if (rc
== NGX_ERROR
) {
188 if (rc
== NGX_CONF_BLOCK_DONE
) {
190 if (type
!= parse_block
) {
191 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0, "unexpected \"}\"");
198 if (rc
== NGX_CONF_FILE_DONE
) {
200 if (type
== parse_block
) {
201 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0,
202 "unexpected end of file, expecting \"}\"");
209 if (rc
== NGX_CONF_BLOCK_START
) {
211 if (type
== parse_param
) {
212 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0,
213 "block directives are not supported "
219 /* rc == NGX_OK || rc == NGX_CONF_BLOCK_START */
224 * the custom handler, i.e., that is used in the http's
225 * "types { ... }" directive
228 rv
= (*cf
->handler
)(cf
, NULL
, cf
->handler_conf
);
229 if (rv
== NGX_CONF_OK
) {
233 if (rv
== NGX_CONF_ERROR
) {
237 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0, rv
);
243 rc
= ngx_conf_handler(cf
, rc
);
245 if (rc
== NGX_ERROR
) {
257 if (cf
->conf_file
->buffer
->start
) {
258 ngx_free(cf
->conf_file
->buffer
->start
);
261 if (ngx_close_file(fd
) == NGX_FILE_ERROR
) {
262 ngx_log_error(NGX_LOG_ALERT
, cf
->log
, ngx_errno
,
263 ngx_close_file_n
" %s failed",
265 return NGX_CONF_ERROR
;
268 cf
->conf_file
= prev
;
271 if (rc
== NGX_ERROR
) {
272 return NGX_CONF_ERROR
;
280 ngx_conf_handler(ngx_conf_t
*cf
, ngx_int_t last
)
288 name
= cf
->args
->elts
;
292 for (i
= 0; ngx_modules
[i
]; i
++) {
294 cmd
= ngx_modules
[i
]->commands
;
299 for ( /* void */ ; cmd
->name
.len
; cmd
++) {
301 if (name
->len
!= cmd
->name
.len
) {
305 if (ngx_strcmp(name
->data
, cmd
->name
.data
) != 0) {
311 if (ngx_modules
[i
]->type
!= NGX_CONF_MODULE
312 && ngx_modules
[i
]->type
!= cf
->module_type
)
317 /* is the directive's location right ? */
319 if (!(cmd
->type
& cf
->cmd_type
)) {
323 if (!(cmd
->type
& NGX_CONF_BLOCK
) && last
!= NGX_OK
) {
324 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0,
325 "directive \"%s\" is not terminated by \";\"",
330 if ((cmd
->type
& NGX_CONF_BLOCK
) && last
!= NGX_CONF_BLOCK_START
) {
331 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0,
332 "directive \"%s\" has no opening \"{\"",
337 /* is the directive's argument count right ? */
339 if (!(cmd
->type
& NGX_CONF_ANY
)) {
341 if (cmd
->type
& NGX_CONF_FLAG
) {
343 if (cf
->args
->nelts
!= 2) {
347 } else if (cmd
->type
& NGX_CONF_1MORE
) {
349 if (cf
->args
->nelts
< 2) {
353 } else if (cmd
->type
& NGX_CONF_2MORE
) {
355 if (cf
->args
->nelts
< 3) {
359 } else if (cf
->args
->nelts
> NGX_CONF_MAX_ARGS
) {
363 } else if (!(cmd
->type
& argument_number
[cf
->args
->nelts
- 1]))
369 /* set up the directive's configuration context */
373 if (cmd
->type
& NGX_DIRECT_CONF
) {
374 conf
= ((void **) cf
->ctx
)[ngx_modules
[i
]->index
];
376 } else if (cmd
->type
& NGX_MAIN_CONF
) {
377 conf
= &(((void **) cf
->ctx
)[ngx_modules
[i
]->index
]);
379 } else if (cf
->ctx
) {
380 confp
= *(void **) ((char *) cf
->ctx
+ cmd
->conf
);
383 conf
= confp
[ngx_modules
[i
]->ctx_index
];
387 rv
= cmd
->set(cf
, cmd
, conf
);
389 if (rv
== NGX_CONF_OK
) {
393 if (rv
== NGX_CONF_ERROR
) {
397 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0,
398 "\"%s\" directive %s", name
->data
, rv
);
405 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0,
406 "\"%s\" directive is not allowed here", name
->data
);
411 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0,
412 "unknown directive \"%s\"", name
->data
);
418 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0,
419 "invalid number of arguments in \"%s\" directive",
427 ngx_conf_read_token(ngx_conf_t
*cf
)
429 u_char
*start
, ch
, *src
, *dst
;
433 ngx_uint_t found
, need_space
, last_space
, sharp_comment
, variable
;
434 ngx_uint_t quoted
, s_quoted
, d_quoted
, start_line
;
448 b
= cf
->conf_file
->buffer
;
450 start_line
= cf
->conf_file
->line
;
452 file_size
= ngx_file_size(&cf
->conf_file
->file
.info
);
456 if (b
->pos
>= b
->last
) {
458 if (cf
->conf_file
->file
.offset
>= file_size
) {
460 if (cf
->args
->nelts
> 0 || !last_space
) {
462 if (cf
->conf_file
->file
.fd
== NGX_INVALID_FILE
) {
463 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0,
464 "unexpected end of parameter, "
469 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0,
470 "unexpected end of file, "
471 "expecting \";\" or \"}\"");
475 return NGX_CONF_FILE_DONE
;
478 len
= b
->pos
- start
;
480 if (len
== NGX_CONF_BUFFER
) {
481 cf
->conf_file
->line
= start_line
;
486 } else if (s_quoted
) {
490 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0,
491 "too long parameter \"%*s...\" started",
496 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0,
497 "too long parameter, probably "
498 "missing terminating \"%c\" character", ch
);
503 ngx_memmove(b
->start
, start
, len
);
506 size
= (ssize_t
) (file_size
- cf
->conf_file
->file
.offset
);
508 if (size
> b
->end
- (b
->start
+ len
)) {
509 size
= b
->end
- (b
->start
+ len
);
512 n
= ngx_read_file(&cf
->conf_file
->file
, b
->start
+ len
, size
,
513 cf
->conf_file
->file
.offset
);
515 if (n
== NGX_ERROR
) {
520 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0,
521 ngx_read_file_n
" returned "
522 "only %z bytes instead of %z",
527 b
->pos
= b
->start
+ len
;
528 b
->last
= b
->pos
+ n
;
535 cf
->conf_file
->line
++;
552 if (ch
== ' ' || ch
== '\t' || ch
== CR
|| ch
== LF
) {
563 return NGX_CONF_BLOCK_START
;
571 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0,
572 "unexpected \"%c\"", ch
);
578 if (ch
== ' ' || ch
== '\t' || ch
== CR
|| ch
== LF
) {
583 start_line
= cf
->conf_file
->line
;
589 if (cf
->args
->nelts
== 0) {
590 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0,
591 "unexpected \"%c\"", ch
);
596 return NGX_CONF_BLOCK_START
;
602 if (cf
->args
->nelts
!= 0) {
603 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0,
608 return NGX_CONF_BLOCK_DONE
;
636 if (ch
== '{' && variable
) {
659 } else if (s_quoted
) {
666 } else if (ch
== ' ' || ch
== '\t' || ch
== CR
|| ch
== LF
667 || ch
== ';' || ch
== '{')
674 word
= ngx_array_push(cf
->args
);
679 word
->data
= ngx_pnalloc(cf
->pool
, b
->pos
- start
+ 1);
680 if (word
->data
== NULL
) {
684 for (dst
= word
->data
, src
= start
, len
= 0;
723 return NGX_CONF_BLOCK_START
;
734 ngx_conf_include(ngx_conf_t
*cf
, ngx_command_t
*cmd
, void *conf
)
738 ngx_str_t
*value
, file
, name
;
741 value
= cf
->args
->elts
;
744 ngx_log_debug1(NGX_LOG_DEBUG_CORE
, cf
->log
, 0, "include %s", file
.data
);
746 if (ngx_conf_full_name(cf
->cycle
, &file
, 1) != NGX_OK
) {
747 return NGX_CONF_ERROR
;
750 if (strpbrk((char *) file
.data
, "*?[") == NULL
) {
752 ngx_log_debug1(NGX_LOG_DEBUG_CORE
, cf
->log
, 0, "include %s", file
.data
);
754 return ngx_conf_parse(cf
, &file
);
757 ngx_memzero(&gl
, sizeof(ngx_glob_t
));
759 gl
.pattern
= file
.data
;
763 if (ngx_open_glob(&gl
) != NGX_OK
) {
764 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, ngx_errno
,
765 ngx_open_glob_n
" \"%s\" failed", file
.data
);
766 return NGX_CONF_ERROR
;
772 n
= ngx_read_glob(&gl
, &name
);
778 file
.len
= name
.len
++;
779 file
.data
= ngx_pstrdup(cf
->pool
, &name
);
781 ngx_log_debug1(NGX_LOG_DEBUG_CORE
, cf
->log
, 0, "include %s", file
.data
);
783 rv
= ngx_conf_parse(cf
, &file
);
785 if (rv
!= NGX_CONF_OK
) {
797 ngx_conf_full_name(ngx_cycle_t
*cycle
, ngx_str_t
*name
, ngx_uint_t conf_prefix
)
800 u_char
*p
, *n
, *prefix
;
803 rc
= ngx_conf_test_full_name(name
);
810 len
= cycle
->conf_prefix
.len
;
811 prefix
= cycle
->conf_prefix
.data
;
814 len
= cycle
->prefix
.len
;
815 prefix
= cycle
->prefix
.data
;
826 n
= ngx_pnalloc(cycle
->pool
, len
+ name
->len
+ 1);
831 p
= ngx_cpymem(n
, prefix
, len
);
832 ngx_cpystrn(p
, name
->data
, name
->len
+ 1);
842 ngx_conf_test_full_name(ngx_str_t
*name
)
862 if ((c0
>= 'a' && c0
<= 'z')) {
881 if (name
->data
[0] == '/') {
892 ngx_conf_open_file(ngx_cycle_t
*cycle
, ngx_str_t
*name
)
896 ngx_list_part_t
*part
;
897 ngx_open_file_t
*file
;
899 #if (NGX_SUPPRESS_WARN)
906 if (ngx_conf_full_name(cycle
, &full
, 0) != NGX_OK
) {
910 part
= &cycle
->open_files
.part
;
913 for (i
= 0; /* void */ ; i
++) {
915 if (i
>= part
->nelts
) {
916 if (part
->next
== NULL
) {
924 if (full
.len
!= file
[i
].name
.len
) {
928 if (ngx_strcmp(full
.data
, file
[i
].name
.data
) == 0) {
934 file
= ngx_list_push(&cycle
->open_files
);
940 file
->fd
= NGX_INVALID_FILE
;
944 file
->fd
= ngx_stderr
;
956 ngx_conf_flush_files(ngx_cycle_t
*cycle
)
959 ngx_list_part_t
*part
;
960 ngx_open_file_t
*file
;
962 ngx_log_debug0(NGX_LOG_DEBUG_CORE
, cycle
->log
, 0, "flush files");
964 part
= &cycle
->open_files
.part
;
967 for (i
= 0; /* void */ ; i
++) {
969 if (i
>= part
->nelts
) {
970 if (part
->next
== NULL
) {
979 file
[i
].flush(&file
[i
], cycle
->log
);
986 ngx_conf_log_error(ngx_uint_t level
, ngx_conf_t
*cf
, ngx_err_t err
,
987 const char *fmt
, ...)
989 u_char errstr
[NGX_MAX_CONF_ERRSTR
], *p
, *last
;
992 last
= errstr
+ NGX_MAX_CONF_ERRSTR
;
995 p
= ngx_vslprintf(errstr
, last
, fmt
, args
);
999 p
= ngx_log_errno(p
, last
, err
);
1002 if (cf
->conf_file
== NULL
) {
1003 ngx_log_error(level
, cf
->log
, 0, "%*s", p
- errstr
, errstr
);
1007 if (cf
->conf_file
->file
.fd
== NGX_INVALID_FILE
) {
1008 ngx_log_error(level
, cf
->log
, 0, "%*s in command line",
1009 p
- errstr
, errstr
);
1013 ngx_log_error(level
, cf
->log
, 0, "%*s in %s:%ui",
1015 cf
->conf_file
->file
.name
.data
, cf
->conf_file
->line
);
1020 ngx_conf_set_flag_slot(ngx_conf_t
*cf
, ngx_command_t
*cmd
, void *conf
)
1026 ngx_conf_post_t
*post
;
1028 fp
= (ngx_flag_t
*) (p
+ cmd
->offset
);
1030 if (*fp
!= NGX_CONF_UNSET
) {
1031 return "is duplicate";
1034 value
= cf
->args
->elts
;
1036 if (ngx_strcasecmp(value
[1].data
, (u_char
*) "on") == 0) {
1039 } else if (ngx_strcasecmp(value
[1].data
, (u_char
*) "off") == 0) {
1043 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0,
1044 "invalid value \"%s\" in \"%s\" directive, "
1045 "it must be \"on\" or \"off\"",
1046 value
[1].data
, cmd
->name
.data
);
1047 return NGX_CONF_ERROR
;
1052 return post
->post_handler(cf
, post
, fp
);
1060 ngx_conf_set_str_slot(ngx_conf_t
*cf
, ngx_command_t
*cmd
, void *conf
)
1064 ngx_str_t
*field
, *value
;
1065 ngx_conf_post_t
*post
;
1067 field
= (ngx_str_t
*) (p
+ cmd
->offset
);
1070 return "is duplicate";
1073 value
= cf
->args
->elts
;
1079 return post
->post_handler(cf
, post
, field
);
1087 ngx_conf_set_str_array_slot(ngx_conf_t
*cf
, ngx_command_t
*cmd
, void *conf
)
1091 ngx_str_t
*value
, *s
;
1093 ngx_conf_post_t
*post
;
1095 a
= (ngx_array_t
**) (p
+ cmd
->offset
);
1097 if (*a
== NGX_CONF_UNSET_PTR
) {
1098 *a
= ngx_array_create(cf
->pool
, 4, sizeof(ngx_str_t
));
1100 return NGX_CONF_ERROR
;
1104 s
= ngx_array_push(*a
);
1106 return NGX_CONF_ERROR
;
1109 value
= cf
->args
->elts
;
1115 return post
->post_handler(cf
, post
, s
);
1123 ngx_conf_set_keyval_slot(ngx_conf_t
*cf
, ngx_command_t
*cmd
, void *conf
)
1130 ngx_conf_post_t
*post
;
1132 a
= (ngx_array_t
**) (p
+ cmd
->offset
);
1135 *a
= ngx_array_create(cf
->pool
, 4, sizeof(ngx_keyval_t
));
1137 return NGX_CONF_ERROR
;
1141 kv
= ngx_array_push(*a
);
1143 return NGX_CONF_ERROR
;
1146 value
= cf
->args
->elts
;
1149 kv
->value
= value
[2];
1153 return post
->post_handler(cf
, post
, kv
);
1161 ngx_conf_set_num_slot(ngx_conf_t
*cf
, ngx_command_t
*cmd
, void *conf
)
1167 ngx_conf_post_t
*post
;
1170 np
= (ngx_int_t
*) (p
+ cmd
->offset
);
1172 if (*np
!= NGX_CONF_UNSET
) {
1173 return "is duplicate";
1176 value
= cf
->args
->elts
;
1177 *np
= ngx_atoi(value
[1].data
, value
[1].len
);
1178 if (*np
== NGX_ERROR
) {
1179 return "invalid number";
1184 return post
->post_handler(cf
, post
, np
);
1192 ngx_conf_set_size_slot(ngx_conf_t
*cf
, ngx_command_t
*cmd
, void *conf
)
1198 ngx_conf_post_t
*post
;
1201 sp
= (size_t *) (p
+ cmd
->offset
);
1202 if (*sp
!= NGX_CONF_UNSET_SIZE
) {
1203 return "is duplicate";
1206 value
= cf
->args
->elts
;
1208 *sp
= ngx_parse_size(&value
[1]);
1209 if (*sp
== (size_t) NGX_ERROR
) {
1210 return "invalid value";
1215 return post
->post_handler(cf
, post
, sp
);
1223 ngx_conf_set_off_slot(ngx_conf_t
*cf
, ngx_command_t
*cmd
, void *conf
)
1229 ngx_conf_post_t
*post
;
1232 op
= (off_t
*) (p
+ cmd
->offset
);
1233 if (*op
!= NGX_CONF_UNSET
) {
1234 return "is duplicate";
1237 value
= cf
->args
->elts
;
1239 *op
= ngx_parse_offset(&value
[1]);
1240 if (*op
== (off_t
) NGX_ERROR
) {
1241 return "invalid value";
1246 return post
->post_handler(cf
, post
, op
);
1254 ngx_conf_set_msec_slot(ngx_conf_t
*cf
, ngx_command_t
*cmd
, void *conf
)
1260 ngx_conf_post_t
*post
;
1263 msp
= (ngx_msec_t
*) (p
+ cmd
->offset
);
1264 if (*msp
!= NGX_CONF_UNSET_MSEC
) {
1265 return "is duplicate";
1268 value
= cf
->args
->elts
;
1270 *msp
= ngx_parse_time(&value
[1], 0);
1271 if (*msp
== (ngx_msec_t
) NGX_ERROR
) {
1272 return "invalid value";
1277 return post
->post_handler(cf
, post
, msp
);
1285 ngx_conf_set_sec_slot(ngx_conf_t
*cf
, ngx_command_t
*cmd
, void *conf
)
1291 ngx_conf_post_t
*post
;
1294 sp
= (time_t *) (p
+ cmd
->offset
);
1295 if (*sp
!= NGX_CONF_UNSET
) {
1296 return "is duplicate";
1299 value
= cf
->args
->elts
;
1301 *sp
= ngx_parse_time(&value
[1], 1);
1302 if (*sp
== (time_t) NGX_ERROR
) {
1303 return "invalid value";
1308 return post
->post_handler(cf
, post
, sp
);
1316 ngx_conf_set_bufs_slot(ngx_conf_t
*cf
, ngx_command_t
*cmd
, void *conf
)
1324 bufs
= (ngx_bufs_t
*) (p
+ cmd
->offset
);
1326 return "is duplicate";
1329 value
= cf
->args
->elts
;
1331 bufs
->num
= ngx_atoi(value
[1].data
, value
[1].len
);
1332 if (bufs
->num
== NGX_ERROR
|| bufs
->num
== 0) {
1333 return "invalid value";
1336 bufs
->size
= ngx_parse_size(&value
[2]);
1337 if (bufs
->size
== (size_t) NGX_ERROR
|| bufs
->size
== 0) {
1338 return "invalid value";
1346 ngx_conf_set_enum_slot(ngx_conf_t
*cf
, ngx_command_t
*cmd
, void *conf
)
1354 np
= (ngx_uint_t
*) (p
+ cmd
->offset
);
1356 if (*np
!= NGX_CONF_UNSET_UINT
) {
1357 return "is duplicate";
1360 value
= cf
->args
->elts
;
1363 for (i
= 0; e
[i
].name
.len
!= 0; i
++) {
1364 if (e
[i
].name
.len
!= value
[1].len
1365 || ngx_strcasecmp(e
[i
].name
.data
, value
[1].data
) != 0)
1375 ngx_conf_log_error(NGX_LOG_WARN
, cf
, 0,
1376 "invalid value \"%s\"", value
[1].data
);
1378 return NGX_CONF_ERROR
;
1383 ngx_conf_set_bitmask_slot(ngx_conf_t
*cf
, ngx_command_t
*cmd
, void *conf
)
1387 ngx_uint_t
*np
, i
, m
;
1389 ngx_conf_bitmask_t
*mask
;
1392 np
= (ngx_uint_t
*) (p
+ cmd
->offset
);
1393 value
= cf
->args
->elts
;
1396 for (i
= 1; i
< cf
->args
->nelts
; i
++) {
1397 for (m
= 0; mask
[m
].name
.len
!= 0; m
++) {
1399 if (mask
[m
].name
.len
!= value
[i
].len
1400 || ngx_strcasecmp(mask
[m
].name
.data
, value
[i
].data
) != 0)
1405 if (*np
& mask
[m
].mask
) {
1406 ngx_conf_log_error(NGX_LOG_WARN
, cf
, 0,
1407 "duplicate value \"%s\"", value
[i
].data
);
1410 *np
|= mask
[m
].mask
;
1416 if (mask
[m
].name
.len
== 0) {
1417 ngx_conf_log_error(NGX_LOG_WARN
, cf
, 0,
1418 "invalid value \"%s\"", value
[i
].data
);
1420 return NGX_CONF_ERROR
;
1431 ngx_conf_unsupported(ngx_conf_t
*cf
, ngx_command_t
*cmd
, void *conf
)
1433 return "unsupported on this platform";
1440 ngx_conf_deprecated(ngx_conf_t
*cf
, void *post
, void *data
)
1442 ngx_conf_deprecated_t
*d
= post
;
1444 ngx_conf_log_error(NGX_LOG_WARN
, cf
, 0,
1445 "the \"%s\" directive is deprecated, "
1446 "use the \"%s\" directive instead",
1447 d
->old_name
, d
->new_name
);
1454 ngx_conf_check_num_bounds(ngx_conf_t
*cf
, void *post
, void *data
)
1456 ngx_conf_num_bounds_t
*bounds
= post
;
1457 ngx_int_t
*np
= data
;
1459 if (bounds
->high
== -1) {
1460 if (*np
>= bounds
->low
) {
1464 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0,
1465 "value must be equal to or greater than %i",
1468 return NGX_CONF_ERROR
;
1471 if (*np
>= bounds
->low
&& *np
<= bounds
->high
) {
1475 ngx_conf_log_error(NGX_LOG_EMERG
, cf
, 0,
1476 "value must be between %i and %i",
1477 bounds
->low
, bounds
->high
);
1479 return NGX_CONF_ERROR
;