src/http/ngx_http_script.h - nginx-1.7.10

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.     ngx_http_variable_value_t  *sp;

  14.     ngx_str_t                   buf;
  15.     ngx_str_t                   line;

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

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

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


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

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

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

  36.     void                       *main;

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

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


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


  52. typedef struct {
  53.     ngx_conf_t                 *cf;
  54.     ngx_str_t                  *value;
  55.     ngx_http_complex_value_t   *complex_value;

  56.     unsigned                    zero:1;
  57.     unsigned                    conf_prefix:1;
  58.     unsigned                    root_prefix:1;
  59. } ngx_http_compile_complex_value_t;


  60. typedef void (*ngx_http_script_code_pt) (ngx_http_script_engine_t *e);
  61. typedef size_t (*ngx_http_script_len_code_pt) (ngx_http_script_engine_t *e);


  62. typedef struct {
  63.     ngx_http_script_code_pt     code;
  64.     uintptr_t                   len;
  65. } ngx_http_script_copy_code_t;


  66. typedef struct {
  67.     ngx_http_script_code_pt     code;
  68.     uintptr_t                   index;
  69. } ngx_http_script_var_code_t;


  70. typedef struct {
  71.     ngx_http_script_code_pt     code;
  72.     ngx_http_set_variable_pt    handler;
  73.     uintptr_t                   data;
  74. } ngx_http_script_var_handler_code_t;


  75. typedef struct {
  76.     ngx_http_script_code_pt     code;
  77.     uintptr_t                   n;
  78. } ngx_http_script_copy_capture_code_t;


  79. #if (NGX_PCRE)

  80. typedef struct {
  81.     ngx_http_script_code_pt     code;
  82.     ngx_http_regex_t           *regex;
  83.     ngx_array_t                *lengths;
  84.     uintptr_t                   size;
  85.     uintptr_t                   status;
  86.     uintptr_t                   next;

  87.     uintptr_t                   test:1;
  88.     uintptr_t                   negative_test:1;
  89.     uintptr_t                   uri:1;
  90.     uintptr_t                   args:1;

  91.     /* add the r->args to the new arguments */
  92.     uintptr_t                   add_args:1;

  93.     uintptr_t                   redirect:1;
  94.     uintptr_t                   break_cycle:1;

  95.     ngx_str_t                   name;
  96. } ngx_http_script_regex_code_t;


  97. typedef struct {
  98.     ngx_http_script_code_pt     code;

  99.     uintptr_t                   uri:1;
  100.     uintptr_t                   args:1;

  101.     /* add the r->args to the new arguments */
  102.     uintptr_t                   add_args:1;

  103.     uintptr_t                   redirect:1;
  104. } ngx_http_script_regex_end_code_t;

  105. #endif


  106. typedef struct {
  107.     ngx_http_script_code_pt     code;
  108.     uintptr_t                   conf_prefix;
  109. } ngx_http_script_full_name_code_t;


  110. typedef struct {
  111.     ngx_http_script_code_pt     code;
  112.     uintptr_t                   status;
  113.     ngx_http_complex_value_t    text;
  114. } ngx_http_script_return_code_t;


  115. typedef enum {
  116.     ngx_http_script_file_plain = 0,
  117.     ngx_http_script_file_not_plain,
  118.     ngx_http_script_file_dir,
  119.     ngx_http_script_file_not_dir,
  120.     ngx_http_script_file_exists,
  121.     ngx_http_script_file_not_exists,
  122.     ngx_http_script_file_exec,
  123.     ngx_http_script_file_not_exec
  124. } ngx_http_script_file_op_e;


  125. typedef struct {
  126.     ngx_http_script_code_pt     code;
  127.     uintptr_t                   op;
  128. } ngx_http_script_file_code_t;


  129. typedef struct {
  130.     ngx_http_script_code_pt     code;
  131.     uintptr_t                   next;
  132.     void                      **loc_conf;
  133. } ngx_http_script_if_code_t;


  134. typedef struct {
  135.     ngx_http_script_code_pt     code;
  136.     ngx_array_t                *lengths;
  137. } ngx_http_script_complex_value_code_t;


  138. typedef struct {
  139.     ngx_http_script_code_pt     code;
  140.     uintptr_t                   value;
  141.     uintptr_t                   text_len;
  142.     uintptr_t                   text_data;
  143. } ngx_http_script_value_code_t;


  144. void ngx_http_script_flush_complex_value(ngx_http_request_t *r,
  145.     ngx_http_complex_value_t *val);
  146. ngx_int_t ngx_http_complex_value(ngx_http_request_t *r,
  147.     ngx_http_complex_value_t *val, ngx_str_t *value);
  148. ngx_int_t ngx_http_compile_complex_value(ngx_http_compile_complex_value_t *ccv);
  149. char *ngx_http_set_complex_value_slot(ngx_conf_t *cf, ngx_command_t *cmd,
  150.     void *conf);


  151. ngx_int_t ngx_http_test_predicates(ngx_http_request_t *r,
  152.     ngx_array_t *predicates);
  153. char *ngx_http_set_predicate_slot(ngx_conf_t *cf, ngx_command_t *cmd,
  154.     void *conf);

  155. ngx_uint_t ngx_http_script_variables_count(ngx_str_t *value);
  156. ngx_int_t ngx_http_script_compile(ngx_http_script_compile_t *sc);
  157. u_char *ngx_http_script_run(ngx_http_request_t *r, ngx_str_t *value,
  158.     void *code_lengths, size_t reserved, void *code_values);
  159. void ngx_http_script_flush_no_cacheable_variables(ngx_http_request_t *r,
  160.     ngx_array_t *indices);

  161. void *ngx_http_script_start_code(ngx_pool_t *pool, ngx_array_t **codes,
  162.     size_t size);
  163. void *ngx_http_script_add_code(ngx_array_t *codes, size_t size, void *code);

  164. size_t ngx_http_script_copy_len_code(ngx_http_script_engine_t *e);
  165. void ngx_http_script_copy_code(ngx_http_script_engine_t *e);
  166. size_t ngx_http_script_copy_var_len_code(ngx_http_script_engine_t *e);
  167. void ngx_http_script_copy_var_code(ngx_http_script_engine_t *e);
  168. size_t ngx_http_script_copy_capture_len_code(ngx_http_script_engine_t *e);
  169. void ngx_http_script_copy_capture_code(ngx_http_script_engine_t *e);
  170. size_t ngx_http_script_mark_args_code(ngx_http_script_engine_t *e);
  171. void ngx_http_script_start_args_code(ngx_http_script_engine_t *e);
  172. #if (NGX_PCRE)
  173. void ngx_http_script_regex_start_code(ngx_http_script_engine_t *e);
  174. void ngx_http_script_regex_end_code(ngx_http_script_engine_t *e);
  175. #endif
  176. void ngx_http_script_return_code(ngx_http_script_engine_t *e);
  177. void ngx_http_script_break_code(ngx_http_script_engine_t *e);
  178. void ngx_http_script_if_code(ngx_http_script_engine_t *e);
  179. void ngx_http_script_equal_code(ngx_http_script_engine_t *e);
  180. void ngx_http_script_not_equal_code(ngx_http_script_engine_t *e);
  181. void ngx_http_script_file_code(ngx_http_script_engine_t *e);
  182. void ngx_http_script_complex_value_code(ngx_http_script_engine_t *e);
  183. void ngx_http_script_value_code(ngx_http_script_engine_t *e);
  184. void ngx_http_script_set_var_code(ngx_http_script_engine_t *e);
  185. void ngx_http_script_var_set_handler_code(ngx_http_script_engine_t *e);
  186. void ngx_http_script_var_code(ngx_http_script_engine_t *e);
  187. void ngx_http_script_nop_code(ngx_http_script_engine_t *e);


  188. #endif /* _NGX_HTTP_SCRIPT_H_INCLUDED_ */