comparison src/stream/ngx_stream_script.h @ 6607:c70b7f4537e1

Stream: variables and script. This is a port of corresponding http code with unrelated features excluded.
author Vladimir Homutov <vl@nginx.com>
date Mon, 04 Jul 2016 16:37:36 +0300
parents
children 0125b151c9a5
comparison
equal deleted inserted replaced
6606:2f41d383c9c7 6607:c70b7f4537e1
1
2 /*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Nginx, Inc.
5 */
6
7
8 #ifndef _NGX_STREAM_SCRIPT_H_INCLUDED_
9 #define _NGX_STREAM_SCRIPT_H_INCLUDED_
10
11
12 #include <ngx_config.h>
13 #include <ngx_core.h>
14 #include <ngx_stream.h>
15
16
17 typedef struct {
18 u_char *ip;
19 u_char *pos;
20 ngx_stream_variable_value_t *sp;
21
22 ngx_str_t buf;
23 ngx_str_t line;
24
25 unsigned flushed:1;
26 unsigned skip:1;
27
28 ngx_stream_session_t *session;
29 } ngx_stream_script_engine_t;
30
31
32 typedef struct {
33 ngx_conf_t *cf;
34 ngx_str_t *source;
35
36 ngx_array_t **flushes;
37 ngx_array_t **lengths;
38 ngx_array_t **values;
39
40 ngx_uint_t variables;
41 ngx_uint_t ncaptures;
42 ngx_uint_t size;
43
44 void *main;
45
46 unsigned complete_lengths:1;
47 unsigned complete_values:1;
48 unsigned zero:1;
49 unsigned conf_prefix:1;
50 unsigned root_prefix:1;
51 } ngx_stream_script_compile_t;
52
53
54 typedef struct {
55 ngx_str_t value;
56 ngx_uint_t *flushes;
57 void *lengths;
58 void *values;
59 } ngx_stream_complex_value_t;
60
61
62 typedef struct {
63 ngx_conf_t *cf;
64 ngx_str_t *value;
65 ngx_stream_complex_value_t *complex_value;
66
67 unsigned zero:1;
68 unsigned conf_prefix:1;
69 unsigned root_prefix:1;
70 } ngx_stream_compile_complex_value_t;
71
72
73 typedef void (*ngx_stream_script_code_pt) (ngx_stream_script_engine_t *e);
74 typedef size_t (*ngx_stream_script_len_code_pt) (ngx_stream_script_engine_t *e);
75
76
77 typedef struct {
78 ngx_stream_script_code_pt code;
79 uintptr_t len;
80 } ngx_stream_script_copy_code_t;
81
82
83 typedef struct {
84 ngx_stream_script_code_pt code;
85 uintptr_t index;
86 } ngx_stream_script_var_code_t;
87
88
89 typedef struct {
90 ngx_stream_script_code_pt code;
91 uintptr_t n;
92 } ngx_stream_script_copy_capture_code_t;
93
94
95 typedef struct {
96 ngx_stream_script_code_pt code;
97 uintptr_t conf_prefix;
98 } ngx_stream_script_full_name_code_t;
99
100
101 void ngx_stream_script_flush_complex_value(ngx_stream_session_t *s,
102 ngx_stream_complex_value_t *val);
103 ngx_int_t ngx_stream_complex_value(ngx_stream_session_t *s,
104 ngx_stream_complex_value_t *val, ngx_str_t *value);
105 ngx_int_t ngx_stream_compile_complex_value(
106 ngx_stream_compile_complex_value_t *ccv);
107 char *ngx_stream_set_complex_value_slot(ngx_conf_t *cf, ngx_command_t *cmd,
108 void *conf);
109
110
111 ngx_uint_t ngx_stream_script_variables_count(ngx_str_t *value);
112 ngx_int_t ngx_stream_script_compile(ngx_stream_script_compile_t *sc);
113
114 void *ngx_stream_script_add_code(ngx_array_t *codes, size_t size, void *code);
115
116 size_t ngx_stream_script_copy_len_code(ngx_stream_script_engine_t *e);
117 void ngx_stream_script_copy_code(ngx_stream_script_engine_t *e);
118 size_t ngx_stream_script_copy_var_len_code(ngx_stream_script_engine_t *e);
119 void ngx_stream_script_copy_var_code(ngx_stream_script_engine_t *e);
120 size_t ngx_stream_script_copy_capture_len_code(ngx_stream_script_engine_t *e);
121 void ngx_stream_script_copy_capture_code(ngx_stream_script_engine_t *e);
122
123 #endif /* _NGX_STREAM_SCRIPT_H_INCLUDED_ */