3 * Copyright (C) Igor Sysoev
7 #ifndef _NGX_HTTP_CONF_FILE_H_INCLUDED_
8 #define _NGX_HTTP_CONF_FILE_H_INCLUDED_
11 #include <ngx_config.h>
16 * AAAA number of agruments
18 * TT command type, i.e. HTTP "location" or "server" command
21 #define NGX_CONF_NOARGS 0x00000001
22 #define NGX_CONF_TAKE1 0x00000002
23 #define NGX_CONF_TAKE2 0x00000004
24 #define NGX_CONF_TAKE3 0x00000008
25 #define NGX_CONF_TAKE4 0x00000010
26 #define NGX_CONF_TAKE5 0x00000020
27 #define NGX_CONF_TAKE6 0x00000040
28 #define NGX_CONF_TAKE7 0x00000080
30 #define NGX_CONF_MAX_ARGS 8
32 #define NGX_CONF_TAKE12 (NGX_CONF_TAKE1|NGX_CONF_TAKE2)
33 #define NGX_CONF_TAKE13 (NGX_CONF_TAKE1|NGX_CONF_TAKE3)
35 #define NGX_CONF_TAKE23 (NGX_CONF_TAKE2|NGX_CONF_TAKE3)
37 #define NGX_CONF_TAKE123 (NGX_CONF_TAKE1|NGX_CONF_TAKE2|NGX_CONF_TAKE3)
38 #define NGX_CONF_TAKE1234 (NGX_CONF_TAKE1|NGX_CONF_TAKE2|NGX_CONF_TAKE3 \
41 #define NGX_CONF_ARGS_NUMBER 0x000000ff
42 #define NGX_CONF_BLOCK 0x00000100
43 #define NGX_CONF_FLAG 0x00000200
44 #define NGX_CONF_ANY 0x00000400
45 #define NGX_CONF_1MORE 0x00000800
46 #define NGX_CONF_2MORE 0x00001000
47 #define NGX_CONF_MULTI 0x00002000
49 #define NGX_DIRECT_CONF 0x00010000
51 #define NGX_MAIN_CONF 0x01000000
52 #define NGX_ANY_CONF 0x0F000000
56 #define NGX_CONF_UNSET -1
57 #define NGX_CONF_UNSET_UINT (ngx_uint_t) -1
58 #define NGX_CONF_UNSET_PTR (void *) -1
59 #define NGX_CONF_UNSET_SIZE (size_t) -1
60 #define NGX_CONF_UNSET_MSEC (ngx_msec_t) -1
63 #define NGX_CONF_OK NULL
64 #define NGX_CONF_ERROR (void *) -1
66 #define NGX_CONF_BLOCK_START 1
67 #define NGX_CONF_BLOCK_DONE 2
68 #define NGX_CONF_FILE_DONE 3
70 #define NGX_CORE_MODULE 0x45524F43 /* "CORE" */
71 #define NGX_CONF_MODULE 0x464E4F43 /* "CONF" */
74 #define NGX_MAX_CONF_ERRSTR 1024
77 struct ngx_command_s {
80 char *(*set)(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
86 #define ngx_null_command { ngx_null_string, 0, NULL, 0, 0, NULL }
89 struct ngx_open_file_s {
98 /* e.g. append mode, error_log */
100 /* e.g. reopen db file */
101 ngx_uint_t (*handler)(void *data, ngx_open_file_t *file);
107 #define NGX_MODULE_V1 0, 0, 0, 0, 0, 0, 1
108 #define NGX_MODULE_V1_PADDING 0, 0, 0, 0, 0, 0, 0, 0
110 struct ngx_module_s {
111 ngx_uint_t ctx_index;
122 ngx_command_t *commands;
125 ngx_int_t (*init_master)(ngx_log_t *log);
127 ngx_int_t (*init_module)(ngx_cycle_t *cycle);
129 ngx_int_t (*init_process)(ngx_cycle_t *cycle);
130 ngx_int_t (*init_thread)(ngx_cycle_t *cycle);
131 void (*exit_thread)(ngx_cycle_t *cycle);
132 void (*exit_process)(ngx_cycle_t *cycle);
134 void (*exit_master)(ngx_cycle_t *cycle);
136 uintptr_t spare_hook0;
137 uintptr_t spare_hook1;
138 uintptr_t spare_hook2;
139 uintptr_t spare_hook3;
140 uintptr_t spare_hook4;
141 uintptr_t spare_hook5;
142 uintptr_t spare_hook6;
143 uintptr_t spare_hook7;
149 void *(*create_conf)(ngx_cycle_t *cycle);
150 char *(*init_conf)(ngx_cycle_t *cycle, void *conf);
161 typedef char *(*ngx_conf_handler_pt)(ngx_conf_t *cf,
162 ngx_command_t *dummy, void *conf);
171 ngx_pool_t *temp_pool;
172 ngx_conf_file_t *conf_file;
176 ngx_uint_t module_type;
179 ngx_conf_handler_pt handler;
184 typedef char *(*ngx_conf_post_handler_pt) (ngx_conf_t *cf,
185 void *data, void *conf);
188 ngx_conf_post_handler_pt post_handler;
193 ngx_conf_post_handler_pt post_handler;
196 } ngx_conf_deprecated_t;
200 ngx_conf_post_handler_pt post_handler;
203 } ngx_conf_num_bounds_t;
212 #define NGX_CONF_BITMASK_SET 1
217 } ngx_conf_bitmask_t;
221 char * ngx_conf_deprecated(ngx_conf_t *cf, void *post, void *data);
222 char *ngx_conf_check_num_bounds(ngx_conf_t *cf, void *post, void *data);
225 #define ngx_get_conf(conf_ctx, module) conf_ctx[module.index]
229 #define ngx_conf_init_value(conf, default) \
230 if (conf == NGX_CONF_UNSET) { \
234 #define ngx_conf_init_ptr_value(conf, default) \
235 if (conf == NGX_CONF_UNSET_PTR) { \
239 #define ngx_conf_init_uint_value(conf, default) \
240 if (conf == NGX_CONF_UNSET_UINT) { \
244 #define ngx_conf_init_size_value(conf, default) \
245 if (conf == NGX_CONF_UNSET_SIZE) { \
249 #define ngx_conf_init_msec_value(conf, default) \
250 if (conf == NGX_CONF_UNSET_MSEC) { \
254 #define ngx_conf_merge_value(conf, prev, default) \
255 if (conf == NGX_CONF_UNSET) { \
256 conf = (prev == NGX_CONF_UNSET) ? default : prev; \
259 #define ngx_conf_merge_ptr_value(conf, prev, default) \
260 if (conf == NGX_CONF_UNSET_PTR) { \
261 conf = (prev == NGX_CONF_UNSET_PTR) ? default : prev; \
264 #define ngx_conf_merge_uint_value(conf, prev, default) \
265 if (conf == NGX_CONF_UNSET_UINT) { \
266 conf = (prev == NGX_CONF_UNSET_UINT) ? default : prev; \
269 #define ngx_conf_merge_msec_value(conf, prev, default) \
270 if (conf == NGX_CONF_UNSET_MSEC) { \
271 conf = (prev == NGX_CONF_UNSET_MSEC) ? default : prev; \
274 #define ngx_conf_merge_sec_value(conf, prev, default) \
275 if (conf == NGX_CONF_UNSET) { \
276 conf = (prev == NGX_CONF_UNSET) ? default : prev; \
279 #define ngx_conf_merge_size_value(conf, prev, default) \
280 if (conf == NGX_CONF_UNSET_SIZE) { \
281 conf = (prev == NGX_CONF_UNSET_SIZE) ? default : prev; \
284 #define ngx_conf_merge_off_value(conf, prev, default) \
285 if (conf == NGX_CONF_UNSET) { \
286 conf = (prev == NGX_CONF_UNSET) ? default : prev; \
289 #define ngx_conf_merge_str_value(conf, prev, default) \
290 if (conf.data == NULL) { \
292 conf.len = prev.len; \
293 conf.data = prev.data; \
295 conf.len = sizeof(default) - 1; \
296 conf.data = (u_char *) default; \
300 #define ngx_conf_merge_bufs_value(conf, prev, default_num, default_size) \
301 if (conf.num == 0) { \
303 conf.num = prev.num; \
304 conf.size = prev.size; \
306 conf.num = default_num; \
307 conf.size = default_size; \
311 #define ngx_conf_merge_bitmask_value(conf, prev, default) \
313 conf = (prev == 0) ? default : prev; \
317 char *ngx_conf_param(ngx_conf_t *cf);
318 char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename);
321 ngx_int_t ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name,
322 ngx_uint_t conf_prefix);
323 ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name);
324 void ngx_cdecl ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf,
325 ngx_err_t err, char *fmt, ...);
328 char *ngx_conf_set_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
329 char *ngx_conf_set_str_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
330 char *ngx_conf_set_str_array_slot(ngx_conf_t *cf, ngx_command_t *cmd,
332 char *ngx_conf_set_keyval_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
333 char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
334 char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
335 char *ngx_conf_set_off_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
336 char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
337 char *ngx_conf_set_sec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
338 char *ngx_conf_set_bufs_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
339 char *ngx_conf_set_enum_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
340 char *ngx_conf_set_bitmask_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
343 extern ngx_uint_t ngx_max_module;
344 extern ngx_module_t *ngx_modules[];
347 #endif /* _NGX_HTTP_CONF_FILE_H_INCLUDED_ */