src/http/ngx_http_script.h - nginx-1.31.4 nginx/ @ 8d9666701

Data types defined

Macros defined

Source code


  1. /*
  2. * Copyright (C) Igor Sysoev
  3. * Copyright (C) Nginx, Inc.
  4. */


  5. #ifndef _NGX_HTTP_SCRIPT_H_INCLUDED_
  6. #define _NGX_HTTP_SCRIPT_H_INCLUDED_


  7. #include <ngx_config.h>
  8. #include <ngx_core.h>
  9. #include <ngx_http.h>


  10. typedef struct {
  11.     u_char                     *ip;
  12.     u_char                     *pos;
  13.     u_char                     *end;
  14.     ngx_http_variable_value_t  *sp;

  15.     ngx_str_t                   buf;
  16.     ngx_str_t                   line;

  17.     /* the start of the rewritten arguments */
  18.     u_char                     *args;

  19.     unsigned                    flushed:1;
  20.     unsigned                    skip:1;
  21.     unsigned                    quote:1;
  22.     unsigned                    is_args:1;
  23.     unsigned                    log:1;

  24.     ngx_int_t                   status;
  25.     ngx_http_request_t         *request;
  26. } ngx_http_script_engine_t;


  27. typedef struct {
  28.     ngx_conf_t                 *cf;
  29.     ngx_str_t                  *source;

  30.     ngx_array_t               **flushes;
  31.     ngx_array_t               **lengths;
  32.     ngx_array_t               **values;

  33.     ngx_uint_t                  variables;
  34.     ngx_uint_t                  ncaptures;
  35.     ngx_uint_t                  captures_mask;
  36.     ngx_uint_t                  size;

  37.     void                       *main;

  38.     unsigned                    compile_args:1;
  39.     unsigned                    complete_lengths:1;
  40.     unsigned                    complete_values:1;
  41.     unsigned                    zero:1;
  42.     unsigned                    conf_prefix:1;
  43.     unsigned                    root_prefix:1;

  44.     unsigned                    dup_capture:1;
  45.     unsigned                    args:1;
  46. } ngx_http_script_compile_t;


  47. typedef struct {
  48.     ngx_str_t                   value;
  49.     ngx_uint_t                 *flushes;
  50.     void                       *lengths;
  51.     void                       *values;

  52.     union {
  53.         size_t                  size;
  54.     } u;
  55. } ngx_http_complex_value_t;


  56. typedef struct {
  57.     ngx_conf_t                 *cf;
  58.     ngx_str_t                  *value;
  59.     ngx_http_complex_value_t   *complex_value;

  60.     unsigned                    zero:1;
  61.     unsigned                    conf_prefix:1;
  62.     unsigned                    root_prefix:1;
  63. } ngx_http_compile_complex_value_t;


  64. typedef void (*ngx_http_script_code_pt) (ngx_http_script_engine_t *e);
  65. typedef size_t (*ngx_http_script_len_code_pt) (ngx_http_script_engine_t *e);


  66. typedef struct {
  67.     ngx_http_script_code_pt     code;
  68.     uintptr_t                   len;
  69. } ngx_http_script_copy_code_t;


  70. typedef struct {
  71.     ngx_http_script_code_pt     code;
  72.     uintptr_t                   index;
  73. } ngx_http_script_var_code_t;


  74. typedef struct {
  75.     ngx_http_script_code_pt     code;
  76.     ngx_http_set_variable_pt    handler;
  77.     uintptr_t                   data;
  78. } ngx_http_script_var_handler_code_t;


  79. typedef struct {
  80.     ngx_http_script_code_pt     code;
  81.     uintptr_t                   n;
  82. } ngx_http_script_copy_capture_code_t;


  83. #if (NGX_PCRE)

  84. typedef struct {
  85.     ngx_http_script_code_pt     code;
  86.     ngx_http_regex_t           *regex;
  87.     ngx_array_t                *lengths;
  88.     uintptr_t                   size;
  89.     uintptr_t                   status;
  90.     uintptr_t                   next;

  91.     unsigned                    test:1;
  92.     unsigned                    negative_test:1;
  93.     unsigned                    uri:1;
  94.     unsigned                    args:1;

  95.     /* add the r->args to the new arguments */
  96.     unsigned                    add_args:1;

  97.     unsigned                    redirect:1;
  98.     unsigned                    break_cycle:1;

  99.     ngx_str_t                   name;
  100. } ngx_http_script_regex_code_t;


  101. typedef struct {
  102.     ngx_http_script_code_pt     code;

  103.     unsigned                    uri:1;
  104.     unsigned                    args:1;

  105.     /* add the r->args to the new arguments */
  106.     unsigned                    add_args:1;

  107.     unsigned                    redirect:1;
  108. } ngx_http_script_regex_end_code_t;

  109. #endif


  110. typedef struct {
  111.     ngx_http_script_code_pt     code;
  112.     uintptr_t                   conf_prefix;
  113. } ngx_http_script_full_name_code_t;


  114. typedef struct {
  115.     ngx_http_script_code_pt     code;
  116.     uintptr_t                   status;
  117.     ngx_http_complex_value_t    text;
  118. } ngx_http_script_return_code_t;


  119. typedef enum {
  120.     ngx_http_script_file_plain = 0,
  121.     ngx_http_script_file_not_plain,
  122.     ngx_http_script_file_dir,
  123.     ngx_http_script_file_not_dir,
  124.     ngx_http_script_file_exists,
  125.     ngx_http_script_file_not_exists,
  126.     ngx_http_script_file_exec,
  127.     ngx_http_script_file_not_exec
  128. } ngx_http_script_file_op_e;


  129. typedef struct {
  130.     ngx_http_script_code_pt     code;
  131.     uintptr_t                   op;
  132. } ngx_http_script_file_code_t;


  133. typedef struct {
  134.     ngx_http_script_code_pt     code;
  135.     uintptr_t                   next;
  136.     void                      **loc_conf;
  137. } ngx_http_script_if_code_t;


  138. typedef struct {
  139.     ngx_http_script_code_pt     code;
  140.     ngx_array_t                *lengths;
  141. } ngx_http_script_complex_value_code_t;


  142. typedef struct {
  143.     ngx_http_script_code_pt     code;
  144. } ngx_http_script_complex_value_end_code_t;


  145. typedef struct {
  146.     ngx_http_script_code_pt     code;
  147.     uintptr_t                   value;
  148.     uintptr_t                   text_len;
  149.     uintptr_t                   text_data;
  150. } ngx_http_script_value_code_t;


  151. void ngx_http_script_flush_complex_value(ngx_http_request_t *r,
  152.     ngx_http_complex_value_t *val);
  153. ngx_int_t ngx_http_complex_value(ngx_http_request_t *r,
  154.     ngx_http_complex_value_t *val, ngx_str_t *value);
  155. size_t ngx_http_complex_value_size(ngx_http_request_t *r,
  156.     ngx_http_complex_value_t *val, size_t default_value);
  157. ngx_int_t ngx_http_compile_complex_value(ngx_http_compile_complex_value_t *ccv);
  158. char *ngx_http_set_complex_value_slot(ngx_conf_t *cf, ngx_command_t *cmd,
  159.     void *conf);
  160. char *ngx_http_set_complex_value_zero_slot(ngx_conf_t *cf, ngx_command_t *cmd,
  161.     void *conf);
  162. char *ngx_http_set_complex_value_size_slot(ngx_conf_t *cf, ngx_command_t *cmd,
  163.     void *conf);


  164. ngx_int_t ngx_http_test_predicates(ngx_http_request_t *r,
  165.     ngx_array_t *predicates);
  166. ngx_int_t ngx_http_test_required_predicates(ngx_http_request_t *r,
  167.     ngx_array_t *predicates);
  168. char *ngx_http_set_predicate_slot(ngx_conf_t *cf, ngx_command_t *cmd,
  169.     void *conf);

  170. ngx_uint_t ngx_http_script_variables_count(ngx_str_t *value);
  171. ngx_int_t ngx_http_script_compile(ngx_http_script_compile_t *sc);
  172. u_char *ngx_http_script_run(ngx_http_request_t *r, ngx_str_t *value,
  173.     void *code_lengths, size_t reserved, void *code_values);
  174. void ngx_http_script_flush_no_cacheable_variables(ngx_http_request_t *r,
  175.     ngx_array_t *indices);

  176. void *ngx_http_script_start_code(ngx_pool_t *pool, ngx_array_t **codes,
  177.     size_t size);
  178. void *ngx_http_script_add_code(ngx_array_t *codes, size_t size, void *code);

  179. ngx_int_t ngx_http_script_check_length(ngx_http_script_engine_t *e,
  180.     size_t len);

  181. size_t ngx_http_script_copy_len_code(ngx_http_script_engine_t *e);
  182. void ngx_http_script_copy_code(ngx_http_script_engine_t *e);
  183. size_t ngx_http_script_copy_var_len_code(ngx_http_script_engine_t *e);
  184. void ngx_http_script_copy_var_code(ngx_http_script_engine_t *e);
  185. size_t ngx_http_script_copy_capture_len_code(ngx_http_script_engine_t *e);
  186. void ngx_http_script_copy_capture_code(ngx_http_script_engine_t *e);
  187. size_t ngx_http_script_mark_args_code(ngx_http_script_engine_t *e);
  188. void ngx_http_script_start_args_code(ngx_http_script_engine_t *e);
  189. #if (NGX_PCRE)
  190. void ngx_http_script_regex_start_code(ngx_http_script_engine_t *e);
  191. void ngx_http_script_regex_end_code(ngx_http_script_engine_t *e);
  192. #endif
  193. void ngx_http_script_return_code(ngx_http_script_engine_t *e);
  194. void ngx_http_script_break_code(ngx_http_script_engine_t *e);
  195. void ngx_http_script_if_code(ngx_http_script_engine_t *e);
  196. void ngx_http_script_equal_code(ngx_http_script_engine_t *e);
  197. void ngx_http_script_not_equal_code(ngx_http_script_engine_t *e);
  198. void ngx_http_script_file_code(ngx_http_script_engine_t *e);
  199. void ngx_http_script_complex_value_code(ngx_http_script_engine_t *e);
  200. void ngx_http_script_complex_value_end_code(ngx_http_script_engine_t *e);
  201. void ngx_http_script_value_code(ngx_http_script_engine_t *e);
  202. void ngx_http_script_set_var_code(ngx_http_script_engine_t *e);
  203. void ngx_http_script_var_set_handler_code(ngx_http_script_engine_t *e);
  204. void ngx_http_script_var_code(ngx_http_script_engine_t *e);
  205. void ngx_http_script_nop_code(ngx_http_script_engine_t *e);


  206. #endif /* _NGX_HTTP_SCRIPT_H_INCLUDED_ */