Mercurial > hg > nginx-vendor-0-6
comparison src/core/ngx_conf_file.h @ 0:f0b350454894 NGINX_0_1_0
nginx 0.1.0
*) The first public version.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 04 Oct 2004 00:00:00 +0400 |
parents | |
children | cc9f381affaa |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0b350454894 |
---|---|
1 | |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #ifndef _NGX_HTTP_CONF_FILE_H_INCLUDED_ | |
8 #define _NGX_HTTP_CONF_FILE_H_INCLUDED_ | |
9 | |
10 | |
11 #include <ngx_config.h> | |
12 #include <ngx_core.h> | |
13 | |
14 | |
15 /* | |
16 * AAAA number of agruments | |
17 * FF command flags | |
18 * TT command type, i.e. HTTP "location" or "server" command | |
19 */ | |
20 | |
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 | |
29 | |
30 #define NGX_CONF_TAKE12 (NGX_CONF_TAKE1|NGX_CONF_TAKE2) | |
31 #define NGX_CONF_TAKE13 (NGX_CONF_TAKE1|NGX_CONF_TAKE3) | |
32 | |
33 #define NGX_CONF_TAKE23 (NGX_CONF_TAKE2|NGX_CONF_TAKE3) | |
34 | |
35 #define NGX_CONF_TAKE1234 (NGX_CONF_TAKE1|NGX_CONF_TAKE2|NGX_CONF_TAKE3 \ | |
36 |NGX_CONF_TAKE4) | |
37 | |
38 #define NGX_CONF_ARGS_NUMBER 0x000000ff | |
39 #define NGX_CONF_BLOCK 0x00000100 | |
40 #define NGX_CONF_FLAG 0x00000200 | |
41 #define NGX_CONF_ANY 0x00000400 | |
42 #define NGX_CONF_1MORE 0x00000800 | |
43 #define NGX_CONF_2MORE 0x00001000 | |
44 | |
45 #define NGX_DIRECT_CONF 0x00010000 | |
46 | |
47 #define NGX_MAIN_CONF 0x01000000 | |
48 #define NGX_ANY_CONF 0x0F000000 | |
49 | |
50 | |
51 | |
52 #define NGX_CONF_UNSET -1 | |
53 #define NGX_CONF_UNSET_UINT (ngx_uint_t) -1 | |
54 #define NGX_CONF_UNSET_PTR (void *) -1 | |
55 #define NGX_CONF_UNSET_SIZE (size_t) -1 | |
56 #define NGX_CONF_UNSET_MSEC (ngx_msec_t) -1 | |
57 | |
58 | |
59 #define NGX_CONF_OK NULL | |
60 #define NGX_CONF_ERROR (void *) -1 | |
61 | |
62 #define NGX_CONF_BLOCK_DONE 1 | |
63 #define NGX_CONF_FILE_DONE 2 | |
64 | |
65 #define NGX_MODULE 0, 0 | |
66 | |
67 #define NGX_CORE_MODULE 0x45524F43 /* "CORE" */ | |
68 #define NGX_CONF_MODULE 0x464E4F43 /* "CONF" */ | |
69 | |
70 | |
71 #define NGX_MAX_CONF_ERRSTR 256 | |
72 | |
73 | |
74 struct ngx_command_s { | |
75 ngx_str_t name; | |
76 int type; | |
77 char *(*set)(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | |
78 int conf; | |
79 int offset; | |
80 void *post; | |
81 }; | |
82 | |
83 #define ngx_null_command { ngx_null_string, 0, NULL, 0, 0, NULL } | |
84 | |
85 | |
86 struct ngx_open_file_s { | |
87 ngx_fd_t fd; | |
88 ngx_str_t name; | |
89 #if 0 | |
90 /* e.g. append mode, error_log */ | |
91 int flags; | |
92 /* e.g. reopen db file */ | |
93 int (*handler)(void *data, ngx_open_file_t *file); | |
94 void *data; | |
95 #endif | |
96 }; | |
97 | |
98 | |
99 struct ngx_module_s { | |
100 ngx_uint_t ctx_index; | |
101 ngx_uint_t index; | |
102 void *ctx; | |
103 ngx_command_t *commands; | |
104 ngx_uint_t type; | |
105 ngx_int_t (*init_module)(ngx_cycle_t *cycle); | |
106 ngx_int_t (*init_process)(ngx_cycle_t *cycle); | |
107 #if 0 | |
108 ngx_int_t (*init_thread)(ngx_cycle_t *cycle); | |
109 #endif | |
110 }; | |
111 | |
112 | |
113 typedef struct { | |
114 ngx_str_t name; | |
115 void *(*create_conf)(ngx_cycle_t *cycle); | |
116 char *(*init_conf)(ngx_cycle_t *cycle, void *conf); | |
117 } ngx_core_module_t; | |
118 | |
119 | |
120 typedef struct { | |
121 ngx_file_t file; | |
122 ngx_buf_t *buffer; | |
123 ngx_uint_t line; | |
124 } ngx_conf_file_t; | |
125 | |
126 | |
127 typedef char *(*ngx_conf_handler_pt)(ngx_conf_t *cf, | |
128 ngx_command_t *dummy, void *conf); | |
129 | |
130 | |
131 struct ngx_conf_s { | |
132 char *name; | |
133 ngx_array_t *args; | |
134 | |
135 ngx_cycle_t *cycle; | |
136 ngx_pool_t *pool; | |
137 ngx_conf_file_t *conf_file; | |
138 ngx_log_t *log; | |
139 | |
140 void *ctx; | |
141 ngx_uint_t module_type; | |
142 ngx_uint_t cmd_type; | |
143 | |
144 ngx_conf_handler_pt handler; | |
145 char *handler_conf; | |
146 }; | |
147 | |
148 | |
149 typedef char *(*ngx_conf_post_handler_pt) (ngx_conf_t *cf, | |
150 void *data, void *conf); | |
151 | |
152 typedef struct { | |
153 ngx_conf_post_handler_pt post_handler; | |
154 } ngx_conf_post_t; | |
155 | |
156 | |
157 typedef struct { | |
158 ngx_conf_post_handler_pt post_handler; | |
159 int low; | |
160 int high; | |
161 } ngx_conf_num_bounds_t; | |
162 | |
163 | |
164 typedef struct { | |
165 ngx_str_t name; | |
166 ngx_uint_t value; | |
167 } ngx_conf_enum_t; | |
168 | |
169 | |
170 #define NGX_CONF_BITMASK_SET 1 | |
171 | |
172 typedef struct { | |
173 ngx_str_t name; | |
174 ngx_uint_t mask; | |
175 } ngx_conf_bitmask_t; | |
176 | |
177 | |
178 char *ngx_conf_check_num_bounds(ngx_conf_t *cf, void *post, void *data); | |
179 | |
180 | |
181 #define ngx_get_conf(conf_ctx, module) conf_ctx[module.index] | |
182 | |
183 | |
184 | |
185 #define ngx_conf_init_value(conf, default) \ | |
186 if (conf == NGX_CONF_UNSET) { \ | |
187 conf = default; \ | |
188 } | |
189 | |
190 #define ngx_conf_init_ptr_value(conf, default) \ | |
191 if (conf == NGX_CONF_UNSET_PTR) { \ | |
192 conf = default; \ | |
193 } | |
194 | |
195 #define ngx_conf_init_unsigned_value(conf, default) \ | |
196 if (conf == (unsigned) NGX_CONF_UNSET) { \ | |
197 conf = default; \ | |
198 } | |
199 | |
200 #define ngx_conf_init_size_value(conf, default) \ | |
201 if (conf == NGX_CONF_UNSET_SIZE) { \ | |
202 conf = default; \ | |
203 } | |
204 | |
205 #define ngx_conf_init_msec_value(conf, default) \ | |
206 if (conf == NGX_CONF_UNSET_MSEC) { \ | |
207 conf = default; \ | |
208 } | |
209 | |
210 #define ngx_conf_merge_value(conf, prev, default) \ | |
211 if (conf == NGX_CONF_UNSET) { \ | |
212 conf = (prev == NGX_CONF_UNSET) ? default : prev; \ | |
213 } | |
214 | |
215 #define ngx_conf_merge_ptr_value(conf, prev, default) \ | |
216 if (conf == NULL) { \ | |
217 conf = (prev == NULL) ? default : prev; \ | |
218 } | |
219 | |
220 #define ngx_conf_merge_unsigned_value(conf, prev, default) \ | |
221 if (conf == NGX_CONF_UNSET_UINT) { \ | |
222 conf = (prev == NGX_CONF_UNSET_UINT) ? default : prev; \ | |
223 } | |
224 | |
225 #define ngx_conf_merge_msec_value(conf, prev, default) \ | |
226 if (conf == NGX_CONF_UNSET_MSEC) { \ | |
227 conf = (prev == NGX_CONF_UNSET_MSEC) ? default : prev; \ | |
228 } | |
229 | |
230 #define ngx_conf_merge_sec_value(conf, prev, default) \ | |
231 if (conf == NGX_CONF_UNSET) { \ | |
232 conf = (prev == NGX_CONF_UNSET) ? default : prev; \ | |
233 } | |
234 | |
235 #define ngx_conf_merge_size_value(conf, prev, default) \ | |
236 if (conf == NGX_CONF_UNSET_SIZE) { \ | |
237 conf = (prev == NGX_CONF_UNSET_SIZE) ? default : prev; \ | |
238 } | |
239 | |
240 #define ngx_conf_merge_str_value(conf, prev, default) \ | |
241 if (conf.len == 0) { \ | |
242 if (prev.len) { \ | |
243 conf.len = prev.len; \ | |
244 conf.data = prev.data; \ | |
245 } else { \ | |
246 conf.len = sizeof(default) - 1; \ | |
247 conf.data = (u_char *) default; \ | |
248 } \ | |
249 } | |
250 | |
251 #define ngx_conf_merge_bufs_value(conf, prev, default_num, default_size) \ | |
252 if (conf.num == 0) { \ | |
253 if (prev.num) { \ | |
254 conf.num = prev.num; \ | |
255 conf.size = prev.size; \ | |
256 } else { \ | |
257 conf.num = default_num; \ | |
258 conf.size = default_size; \ | |
259 } \ | |
260 } | |
261 | |
262 #define ngx_conf_merge_bitmask_value(conf, prev, default) \ | |
263 if (conf == 0) { \ | |
264 conf = (prev == 0) ? default : prev; \ | |
265 } | |
266 | |
267 | |
268 #define addressof(addr) ((int) &addr) | |
269 | |
270 | |
271 char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename); | |
272 | |
273 | |
274 ngx_int_t ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name); | |
275 ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name); | |
276 void ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf, ngx_err_t err, | |
277 char *fmt, ...); | |
278 | |
279 | |
280 char *ngx_conf_set_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | |
281 char *ngx_conf_set_str_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | |
282 char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | |
283 char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | |
284 char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | |
285 char *ngx_conf_set_sec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | |
286 char *ngx_conf_set_bufs_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | |
287 char *ngx_conf_set_enum_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | |
288 char *ngx_conf_set_bitmask_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | |
289 | |
290 | |
291 extern ngx_uint_t ngx_max_module; | |
292 extern ngx_module_t *ngx_modules[]; | |
293 | |
294 | |
295 #endif /* _NGX_HTTP_CONF_FILE_H_INCLUDED_ */ |