Back to home page

Nginx displayed by LXR

Source navigation ]
Diff markup ]
Identifier search ]
general search ]
 
 
Version: nginx-1.13.12 ]​[ nginx-1.12.2 ]​

0001 
0002 /*
0003  * Copyright (C) Igor Sysoev
0004  * Copyright (C) Nginx, Inc.
0005  */
0006 
0007 
0008 #ifndef _NGX_CONF_FILE_H_INCLUDED_
0009 #define _NGX_CONF_FILE_H_INCLUDED_
0010 
0011 
0012 #include <ngx_config.h>
0013 #include <ngx_core.h>
0014 
0015 
0016 /*
0017  *        AAAA  number of arguments
0018  *      FF      command flags
0019  *    TT        command type, i.e. HTTP "location" or "server" command
0020  */
0021 
0022 #define NGX_CONF_NOARGS      0x00000001
0023 #define NGX_CONF_TAKE1       0x00000002
0024 #define NGX_CONF_TAKE2       0x00000004
0025 #define NGX_CONF_TAKE3       0x00000008
0026 #define NGX_CONF_TAKE4       0x00000010
0027 #define NGX_CONF_TAKE5       0x00000020
0028 #define NGX_CONF_TAKE6       0x00000040
0029 #define NGX_CONF_TAKE7       0x00000080
0030 
0031 #define NGX_CONF_MAX_ARGS    8
0032 
0033 #define NGX_CONF_TAKE12      (NGX_CONF_TAKE1|NGX_CONF_TAKE2)
0034 #define NGX_CONF_TAKE13      (NGX_CONF_TAKE1|NGX_CONF_TAKE3)
0035 
0036 #define NGX_CONF_TAKE23      (NGX_CONF_TAKE2|NGX_CONF_TAKE3)
0037 
0038 #define NGX_CONF_TAKE123     (NGX_CONF_TAKE1|NGX_CONF_TAKE2|NGX_CONF_TAKE3)
0039 #define NGX_CONF_TAKE1234    (NGX_CONF_TAKE1|NGX_CONF_TAKE2|NGX_CONF_TAKE3   \
0040                               |NGX_CONF_TAKE4)
0041 
0042 #define NGX_CONF_ARGS_NUMBER 0x000000ff
0043 #define NGX_CONF_BLOCK       0x00000100
0044 #define NGX_CONF_FLAG        0x00000200
0045 #define NGX_CONF_ANY         0x00000400
0046 #define NGX_CONF_1MORE       0x00000800
0047 #define NGX_CONF_2MORE       0x00001000
0048 
0049 #define NGX_DIRECT_CONF      0x00010000
0050 
0051 #define NGX_MAIN_CONF        0x01000000
0052 #define NGX_ANY_CONF         0x1F000000
0053 
0054 
0055 
0056 #define NGX_CONF_UNSET       -1
0057 #define NGX_CONF_UNSET_UINT  (ngx_uint_t) -1
0058 #define NGX_CONF_UNSET_PTR   (void *) -1
0059 #define NGX_CONF_UNSET_SIZE  (size_t) -1
0060 #define NGX_CONF_UNSET_MSEC  (ngx_msec_t) -1
0061 
0062 
0063 #define NGX_CONF_OK          NULL
0064 #define NGX_CONF_ERROR       (void *) -1
0065 
0066 #define NGX_CONF_BLOCK_START 1
0067 #define NGX_CONF_BLOCK_DONE  2
0068 #define NGX_CONF_FILE_DONE   3
0069 
0070 #define NGX_CORE_MODULE      0x45524F43  /* "CORE" */
0071 #define NGX_CONF_MODULE      0x464E4F43  /* "CONF" */
0072 
0073 
0074 #define NGX_MAX_CONF_ERRSTR  1024
0075 
0076 
0077 struct ngx_command_s {
0078     ngx_str_t             name;
0079     ngx_uint_t            type;
0080     char               *(*set)(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
0081     ngx_uint_t            conf;
0082     ngx_uint_t            offset;
0083     void                 *post;
0084 };
0085 
0086 #define ngx_null_command  { ngx_null_string, 0, NULL, 0, 0, NULL }
0087 
0088 
0089 struct ngx_open_file_s {
0090     ngx_fd_t              fd;
0091     ngx_str_t             name;
0092 
0093     void                (*flush)(ngx_open_file_t *file, ngx_log_t *log);
0094     void                 *data;
0095 };
0096 
0097 
0098 typedef struct {
0099     ngx_file_t            file;
0100     ngx_buf_t            *buffer;
0101     ngx_buf_t            *dump;
0102     ngx_uint_t            line;
0103 } ngx_conf_file_t;
0104 
0105 
0106 typedef struct {
0107     ngx_str_t             name;
0108     ngx_buf_t            *buffer;
0109 } ngx_conf_dump_t;
0110 
0111 
0112 typedef char *(*ngx_conf_handler_pt)(ngx_conf_t *cf,
0113     ngx_command_t *dummy, void *conf);
0114 
0115 
0116 struct ngx_conf_s {
0117     char                 *name;
0118     ngx_array_t          *args;
0119 
0120     ngx_cycle_t          *cycle;
0121     ngx_pool_t           *pool;
0122     ngx_pool_t           *temp_pool;
0123     ngx_conf_file_t      *conf_file;
0124     ngx_log_t            *log;
0125 
0126     void                 *ctx;
0127     ngx_uint_t            module_type;
0128     ngx_uint_t            cmd_type;
0129 
0130     ngx_conf_handler_pt   handler;
0131     void                 *handler_conf;
0132 };
0133 
0134 
0135 typedef char *(*ngx_conf_post_handler_pt) (ngx_conf_t *cf,
0136     void *data, void *conf);
0137 
0138 typedef struct {
0139     ngx_conf_post_handler_pt  post_handler;
0140 } ngx_conf_post_t;
0141 
0142 
0143 typedef struct {
0144     ngx_conf_post_handler_pt  post_handler;
0145     char                     *old_name;
0146     char                     *new_name;
0147 } ngx_conf_deprecated_t;
0148 
0149 
0150 typedef struct {
0151     ngx_conf_post_handler_pt  post_handler;
0152     ngx_int_t                 low;
0153     ngx_int_t                 high;
0154 } ngx_conf_num_bounds_t;
0155 
0156 
0157 typedef struct {
0158     ngx_str_t                 name;
0159     ngx_uint_t                value;
0160 } ngx_conf_enum_t;
0161 
0162 
0163 #define NGX_CONF_BITMASK_SET  1
0164 
0165 typedef struct {
0166     ngx_str_t                 name;
0167     ngx_uint_t                mask;
0168 } ngx_conf_bitmask_t;
0169 
0170 
0171 
0172 char * ngx_conf_deprecated(ngx_conf_t *cf, void *post, void *data);
0173 char *ngx_conf_check_num_bounds(ngx_conf_t *cf, void *post, void *data);
0174 
0175 
0176 #define ngx_get_conf(conf_ctx, module)  conf_ctx[module.index]
0177 
0178 
0179 
0180 #define ngx_conf_init_value(conf, default)                                   \
0181     if (conf == NGX_CONF_UNSET) {                                            \
0182         conf = default;                                                      \
0183     }
0184 
0185 #define ngx_conf_init_ptr_value(conf, default)                               \
0186     if (conf == NGX_CONF_UNSET_PTR) {                                        \
0187         conf = default;                                                      \
0188     }
0189 
0190 #define ngx_conf_init_uint_value(conf, default)                              \
0191     if (conf == NGX_CONF_UNSET_UINT) {                                       \
0192         conf = default;                                                      \
0193     }
0194 
0195 #define ngx_conf_init_size_value(conf, default)                              \
0196     if (conf == NGX_CONF_UNSET_SIZE) {                                       \
0197         conf = default;                                                      \
0198     }
0199 
0200 #define ngx_conf_init_msec_value(conf, default)                              \
0201     if (conf == NGX_CONF_UNSET_MSEC) {                                       \
0202         conf = default;                                                      \
0203     }
0204 
0205 #define ngx_conf_merge_value(conf, prev, default)                            \
0206     if (conf == NGX_CONF_UNSET) {                                            \
0207         conf = (prev == NGX_CONF_UNSET) ? default : prev;                    \
0208     }
0209 
0210 #define ngx_conf_merge_ptr_value(conf, prev, default)                        \
0211     if (conf == NGX_CONF_UNSET_PTR) {                                        \
0212         conf = (prev == NGX_CONF_UNSET_PTR) ? default : prev;                \
0213     }
0214 
0215 #define ngx_conf_merge_uint_value(conf, prev, default)                       \
0216     if (conf == NGX_CONF_UNSET_UINT) {                                       \
0217         conf = (prev == NGX_CONF_UNSET_UINT) ? default : prev;               \
0218     }
0219 
0220 #define ngx_conf_merge_msec_value(conf, prev, default)                       \
0221     if (conf == NGX_CONF_UNSET_MSEC) {                                       \
0222         conf = (prev == NGX_CONF_UNSET_MSEC) ? default : prev;               \
0223     }
0224 
0225 #define ngx_conf_merge_sec_value(conf, prev, default)                        \
0226     if (conf == NGX_CONF_UNSET) {                                            \
0227         conf = (prev == NGX_CONF_UNSET) ? default : prev;                    \
0228     }
0229 
0230 #define ngx_conf_merge_size_value(conf, prev, default)                       \
0231     if (conf == NGX_CONF_UNSET_SIZE) {                                       \
0232         conf = (prev == NGX_CONF_UNSET_SIZE) ? default : prev;               \
0233     }
0234 
0235 #define ngx_conf_merge_off_value(conf, prev, default)                        \
0236     if (conf == NGX_CONF_UNSET) {                                            \
0237         conf = (prev == NGX_CONF_UNSET) ? default : prev;                    \
0238     }
0239 
0240 #define ngx_conf_merge_str_value(conf, prev, default)                        \
0241     if (conf.data == NULL) {                                                 \
0242         if (prev.data) {                                                     \
0243             conf.len = prev.len;                                             \
0244             conf.data = prev.data;                                           \
0245         } else {                                                             \
0246             conf.len = sizeof(default) - 1;                                  \
0247             conf.data = (u_char *) default;                                  \
0248         }                                                                    \
0249     }
0250 
0251 #define ngx_conf_merge_bufs_value(conf, prev, default_num, default_size)     \
0252     if (conf.num == 0) {                                                     \
0253         if (prev.num) {                                                      \
0254             conf.num = prev.num;                                             \
0255             conf.size = prev.size;                                           \
0256         } else {                                                             \
0257             conf.num = default_num;                                          \
0258             conf.size = default_size;                                        \
0259         }                                                                    \
0260     }
0261 
0262 #define ngx_conf_merge_bitmask_value(conf, prev, default)                    \
0263     if (conf == 0) {                                                         \
0264         conf = (prev == 0) ? default : prev;                                 \
0265     }
0266 
0267 
0268 char *ngx_conf_param(ngx_conf_t *cf);
0269 char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename);
0270 char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
0271 
0272 
0273 ngx_int_t ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name,
0274     ngx_uint_t conf_prefix);
0275 ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name);
0276 void ngx_cdecl ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf,
0277     ngx_err_t err, const char *fmt, ...);
0278 
0279 
0280 char *ngx_conf_set_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
0281 char *ngx_conf_set_str_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
0282 char *ngx_conf_set_str_array_slot(ngx_conf_t *cf, ngx_command_t *cmd,
0283     void *conf);
0284 char *ngx_conf_set_keyval_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
0285 char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
0286 char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
0287 char *ngx_conf_set_off_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
0288 char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
0289 char *ngx_conf_set_sec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
0290 char *ngx_conf_set_bufs_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
0291 char *ngx_conf_set_enum_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
0292 char *ngx_conf_set_bitmask_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
0293 
0294 
0295 #endif /* _NGX_CONF_FILE_H_INCLUDED_ */