Back to home page

Nginx displayed by LXR

Source navigation ]
Diff markup ]
Identifier search ]
general search ]
 
 
Version: nginx-1.15.11 ]​[ nginx-1.14.2 ]​

0001 
0002 /*
0003  * Copyright (C) Igor Sysoev
0004  * Copyright (C) Nginx, Inc.
0005  */
0006 
0007 
0008 #ifndef _NGX_HTTP_SCRIPT_H_INCLUDED_
0009 #define _NGX_HTTP_SCRIPT_H_INCLUDED_
0010 
0011 
0012 #include <ngx_config.h>
0013 #include <ngx_core.h>
0014 #include <ngx_http.h>
0015 
0016 
0017 typedef struct {
0018     u_char                     *ip;
0019     u_char                     *pos;
0020     ngx_http_variable_value_t  *sp;
0021 
0022     ngx_str_t                   buf;
0023     ngx_str_t                   line;
0024 
0025     /* the start of the rewritten arguments */
0026     u_char                     *args;
0027 
0028     unsigned                    flushed:1;
0029     unsigned                    skip:1;
0030     unsigned                    quote:1;
0031     unsigned                    is_args:1;
0032     unsigned                    log:1;
0033 
0034     ngx_int_t                   status;
0035     ngx_http_request_t         *request;
0036 } ngx_http_script_engine_t;
0037 
0038 
0039 typedef struct {
0040     ngx_conf_t                 *cf;
0041     ngx_str_t                  *source;
0042 
0043     ngx_array_t               **flushes;
0044     ngx_array_t               **lengths;
0045     ngx_array_t               **values;
0046 
0047     ngx_uint_t                  variables;
0048     ngx_uint_t                  ncaptures;
0049     ngx_uint_t                  captures_mask;
0050     ngx_uint_t                  size;
0051 
0052     void                       *main;
0053 
0054     unsigned                    compile_args:1;
0055     unsigned                    complete_lengths:1;
0056     unsigned                    complete_values:1;
0057     unsigned                    zero:1;
0058     unsigned                    conf_prefix:1;
0059     unsigned                    root_prefix:1;
0060 
0061     unsigned                    dup_capture:1;
0062     unsigned                    args:1;
0063 } ngx_http_script_compile_t;
0064 
0065 
0066 typedef struct {
0067     ngx_str_t                   value;
0068     ngx_uint_t                 *flushes;
0069     void                       *lengths;
0070     void                       *values;
0071 } ngx_http_complex_value_t;
0072 
0073 
0074 typedef struct {
0075     ngx_conf_t                 *cf;
0076     ngx_str_t                  *value;
0077     ngx_http_complex_value_t   *complex_value;
0078 
0079     unsigned                    zero:1;
0080     unsigned                    conf_prefix:1;
0081     unsigned                    root_prefix:1;
0082 } ngx_http_compile_complex_value_t;
0083 
0084 
0085 typedef void (*ngx_http_script_code_pt) (ngx_http_script_engine_t *e);
0086 typedef size_t (*ngx_http_script_len_code_pt) (ngx_http_script_engine_t *e);
0087 
0088 
0089 typedef struct {
0090     ngx_http_script_code_pt     code;
0091     uintptr_t                   len;
0092 } ngx_http_script_copy_code_t;
0093 
0094 
0095 typedef struct {
0096     ngx_http_script_code_pt     code;
0097     uintptr_t                   index;
0098 } ngx_http_script_var_code_t;
0099 
0100 
0101 typedef struct {
0102     ngx_http_script_code_pt     code;
0103     ngx_http_set_variable_pt    handler;
0104     uintptr_t                   data;
0105 } ngx_http_script_var_handler_code_t;
0106 
0107 
0108 typedef struct {
0109     ngx_http_script_code_pt     code;
0110     uintptr_t                   n;
0111 } ngx_http_script_copy_capture_code_t;
0112 
0113 
0114 #if (NGX_PCRE)
0115 
0116 typedef struct {
0117     ngx_http_script_code_pt     code;
0118     ngx_http_regex_t           *regex;
0119     ngx_array_t                *lengths;
0120     uintptr_t                   size;
0121     uintptr_t                   status;
0122     uintptr_t                   next;
0123 
0124     unsigned                    test:1;
0125     unsigned                    negative_test:1;
0126     unsigned                    uri:1;
0127     unsigned                    args:1;
0128 
0129     /* add the r->args to the new arguments */
0130     unsigned                    add_args:1;
0131 
0132     unsigned                    redirect:1;
0133     unsigned                    break_cycle:1;
0134 
0135     ngx_str_t                   name;
0136 } ngx_http_script_regex_code_t;
0137 
0138 
0139 typedef struct {
0140     ngx_http_script_code_pt     code;
0141 
0142     unsigned                    uri:1;
0143     unsigned                    args:1;
0144 
0145     /* add the r->args to the new arguments */
0146     unsigned                    add_args:1;
0147 
0148     unsigned                    redirect:1;
0149 } ngx_http_script_regex_end_code_t;
0150 
0151 #endif
0152 
0153 
0154 typedef struct {
0155     ngx_http_script_code_pt     code;
0156     uintptr_t                   conf_prefix;
0157 } ngx_http_script_full_name_code_t;
0158 
0159 
0160 typedef struct {
0161     ngx_http_script_code_pt     code;
0162     uintptr_t                   status;
0163     ngx_http_complex_value_t    text;
0164 } ngx_http_script_return_code_t;
0165 
0166 
0167 typedef enum {
0168     ngx_http_script_file_plain = 0,
0169     ngx_http_script_file_not_plain,
0170     ngx_http_script_file_dir,
0171     ngx_http_script_file_not_dir,
0172     ngx_http_script_file_exists,
0173     ngx_http_script_file_not_exists,
0174     ngx_http_script_file_exec,
0175     ngx_http_script_file_not_exec
0176 } ngx_http_script_file_op_e;
0177 
0178 
0179 typedef struct {
0180     ngx_http_script_code_pt     code;
0181     uintptr_t                   op;
0182 } ngx_http_script_file_code_t;
0183 
0184 
0185 typedef struct {
0186     ngx_http_script_code_pt     code;
0187     uintptr_t                   next;
0188     void                      **loc_conf;
0189 } ngx_http_script_if_code_t;
0190 
0191 
0192 typedef struct {
0193     ngx_http_script_code_pt     code;
0194     ngx_array_t                *lengths;
0195 } ngx_http_script_complex_value_code_t;
0196 
0197 
0198 typedef struct {
0199     ngx_http_script_code_pt     code;
0200     uintptr_t                   value;
0201     uintptr_t                   text_len;
0202     uintptr_t                   text_data;
0203 } ngx_http_script_value_code_t;
0204 
0205 
0206 void ngx_http_script_flush_complex_value(ngx_http_request_t *r,
0207     ngx_http_complex_value_t *val);
0208 ngx_int_t ngx_http_complex_value(ngx_http_request_t *r,
0209     ngx_http_complex_value_t *val, ngx_str_t *value);
0210 ngx_int_t ngx_http_compile_complex_value(ngx_http_compile_complex_value_t *ccv);
0211 char *ngx_http_set_complex_value_slot(ngx_conf_t *cf, ngx_command_t *cmd,
0212     void *conf);
0213 
0214 
0215 ngx_int_t ngx_http_test_predicates(ngx_http_request_t *r,
0216     ngx_array_t *predicates);
0217 ngx_int_t ngx_http_test_required_predicates(ngx_http_request_t *r,
0218     ngx_array_t *predicates);
0219 char *ngx_http_set_predicate_slot(ngx_conf_t *cf, ngx_command_t *cmd,
0220     void *conf);
0221 
0222 ngx_uint_t ngx_http_script_variables_count(ngx_str_t *value);
0223 ngx_int_t ngx_http_script_compile(ngx_http_script_compile_t *sc);
0224 u_char *ngx_http_script_run(ngx_http_request_t *r, ngx_str_t *value,
0225     void *code_lengths, size_t reserved, void *code_values);
0226 void ngx_http_script_flush_no_cacheable_variables(ngx_http_request_t *r,
0227     ngx_array_t *indices);
0228 
0229 void *ngx_http_script_start_code(ngx_pool_t *pool, ngx_array_t **codes,
0230     size_t size);
0231 void *ngx_http_script_add_code(ngx_array_t *codes, size_t size, void *code);
0232 
0233 size_t ngx_http_script_copy_len_code(ngx_http_script_engine_t *e);
0234 void ngx_http_script_copy_code(ngx_http_script_engine_t *e);
0235 size_t ngx_http_script_copy_var_len_code(ngx_http_script_engine_t *e);
0236 void ngx_http_script_copy_var_code(ngx_http_script_engine_t *e);
0237 size_t ngx_http_script_copy_capture_len_code(ngx_http_script_engine_t *e);
0238 void ngx_http_script_copy_capture_code(ngx_http_script_engine_t *e);
0239 size_t ngx_http_script_mark_args_code(ngx_http_script_engine_t *e);
0240 void ngx_http_script_start_args_code(ngx_http_script_engine_t *e);
0241 #if (NGX_PCRE)
0242 void ngx_http_script_regex_start_code(ngx_http_script_engine_t *e);
0243 void ngx_http_script_regex_end_code(ngx_http_script_engine_t *e);
0244 #endif
0245 void ngx_http_script_return_code(ngx_http_script_engine_t *e);
0246 void ngx_http_script_break_code(ngx_http_script_engine_t *e);
0247 void ngx_http_script_if_code(ngx_http_script_engine_t *e);
0248 void ngx_http_script_equal_code(ngx_http_script_engine_t *e);
0249 void ngx_http_script_not_equal_code(ngx_http_script_engine_t *e);
0250 void ngx_http_script_file_code(ngx_http_script_engine_t *e);
0251 void ngx_http_script_complex_value_code(ngx_http_script_engine_t *e);
0252 void ngx_http_script_value_code(ngx_http_script_engine_t *e);
0253 void ngx_http_script_set_var_code(ngx_http_script_engine_t *e);
0254 void ngx_http_script_var_set_handler_code(ngx_http_script_engine_t *e);
0255 void ngx_http_script_var_code(ngx_http_script_engine_t *e);
0256 void ngx_http_script_nop_code(ngx_http_script_engine_t *e);
0257 
0258 
0259 #endif /* _NGX_HTTP_SCRIPT_H_INCLUDED_ */