ngx_stream_script.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * Copyright (C) Igor Sysoev
  3. * Copyright (C) Nginx, Inc.
  4. */
  5. #ifndef _NGX_STREAM_SCRIPT_H_INCLUDED_
  6. #define _NGX_STREAM_SCRIPT_H_INCLUDED_
  7. #include <ngx_config.h>
  8. #include <ngx_core.h>
  9. #include <ngx_stream.h>
  10. typedef struct {
  11. u_char *ip;
  12. u_char *pos;
  13. ngx_stream_variable_value_t *sp;
  14. ngx_str_t buf;
  15. ngx_str_t line;
  16. unsigned flushed:1;
  17. unsigned skip:1;
  18. ngx_stream_session_t *session;
  19. } ngx_stream_script_engine_t;
  20. typedef struct {
  21. ngx_conf_t *cf;
  22. ngx_str_t *source;
  23. ngx_array_t **flushes;
  24. ngx_array_t **lengths;
  25. ngx_array_t **values;
  26. ngx_uint_t variables;
  27. ngx_uint_t ncaptures;
  28. ngx_uint_t size;
  29. void *main;
  30. unsigned complete_lengths:1;
  31. unsigned complete_values:1;
  32. unsigned zero:1;
  33. unsigned conf_prefix:1;
  34. unsigned root_prefix:1;
  35. } ngx_stream_script_compile_t;
  36. typedef struct {
  37. ngx_str_t value;
  38. ngx_uint_t *flushes;
  39. void *lengths;
  40. void *values;
  41. union {
  42. size_t size;
  43. } u;
  44. } ngx_stream_complex_value_t;
  45. typedef struct {
  46. ngx_conf_t *cf;
  47. ngx_str_t *value;
  48. ngx_stream_complex_value_t *complex_value;
  49. unsigned zero:1;
  50. unsigned conf_prefix:1;
  51. unsigned root_prefix:1;
  52. } ngx_stream_compile_complex_value_t;
  53. typedef void (*ngx_stream_script_code_pt) (ngx_stream_script_engine_t *e);
  54. typedef size_t (*ngx_stream_script_len_code_pt) (ngx_stream_script_engine_t *e);
  55. typedef struct {
  56. ngx_stream_script_code_pt code;
  57. uintptr_t len;
  58. } ngx_stream_script_copy_code_t;
  59. typedef struct {
  60. ngx_stream_script_code_pt code;
  61. uintptr_t index;
  62. } ngx_stream_script_var_code_t;
  63. typedef struct {
  64. ngx_stream_script_code_pt code;
  65. uintptr_t n;
  66. } ngx_stream_script_copy_capture_code_t;
  67. typedef struct {
  68. ngx_stream_script_code_pt code;
  69. uintptr_t conf_prefix;
  70. } ngx_stream_script_full_name_code_t;
  71. void ngx_stream_script_flush_complex_value(ngx_stream_session_t *s,
  72. ngx_stream_complex_value_t *val);
  73. ngx_int_t ngx_stream_complex_value(ngx_stream_session_t *s,
  74. ngx_stream_complex_value_t *val, ngx_str_t *value);
  75. size_t ngx_stream_complex_value_size(ngx_stream_session_t *s,
  76. ngx_stream_complex_value_t *val, size_t default_value);
  77. ngx_int_t ngx_stream_compile_complex_value(
  78. ngx_stream_compile_complex_value_t *ccv);
  79. char *ngx_stream_set_complex_value_slot(ngx_conf_t *cf, ngx_command_t *cmd,
  80. void *conf);
  81. char *ngx_stream_set_complex_value_zero_slot(ngx_conf_t *cf, ngx_command_t *cmd,
  82. void *conf);
  83. char *ngx_stream_set_complex_value_size_slot(ngx_conf_t *cf, ngx_command_t *cmd,
  84. void *conf);
  85. ngx_uint_t ngx_stream_script_variables_count(ngx_str_t *value);
  86. ngx_int_t ngx_stream_script_compile(ngx_stream_script_compile_t *sc);
  87. u_char *ngx_stream_script_run(ngx_stream_session_t *s, ngx_str_t *value,
  88. void *code_lengths, size_t reserved, void *code_values);
  89. void ngx_stream_script_flush_no_cacheable_variables(ngx_stream_session_t *s,
  90. ngx_array_t *indices);
  91. void *ngx_stream_script_add_code(ngx_array_t *codes, size_t size, void *code);
  92. size_t ngx_stream_script_copy_len_code(ngx_stream_script_engine_t *e);
  93. void ngx_stream_script_copy_code(ngx_stream_script_engine_t *e);
  94. size_t ngx_stream_script_copy_var_len_code(ngx_stream_script_engine_t *e);
  95. void ngx_stream_script_copy_var_code(ngx_stream_script_engine_t *e);
  96. size_t ngx_stream_script_copy_capture_len_code(ngx_stream_script_engine_t *e);
  97. void ngx_stream_script_copy_capture_code(ngx_stream_script_engine_t *e);
  98. #endif /* _NGX_STREAM_SCRIPT_H_INCLUDED_ */