Back to home page

Nginx displayed by LXR

Source navigation ]
Diff markup ]
Identifier search ]
general search ]
 
 
Version: nginx-1.13.12 ]​[ nginx-1.12.2 ]​

0001 
0002 /*
0003  * Copyright (C) Igor Sysoev
0004  * Copyright (C) Nginx, Inc.
0005  */
0006 
0007 
0008 #ifndef _NGX_STREAM_VARIABLES_H_INCLUDED_
0009 #define _NGX_STREAM_VARIABLES_H_INCLUDED_
0010 
0011 
0012 #include <ngx_config.h>
0013 #include <ngx_core.h>
0014 #include <ngx_stream.h>
0015 
0016 
0017 typedef ngx_variable_value_t  ngx_stream_variable_value_t;
0018 
0019 #define ngx_stream_variable(v)     { sizeof(v) - 1, 1, 0, 0, 0, (u_char *) v }
0020 
0021 typedef struct ngx_stream_variable_s  ngx_stream_variable_t;
0022 
0023 typedef void (*ngx_stream_set_variable_pt) (ngx_stream_session_t *s,
0024     ngx_stream_variable_value_t *v, uintptr_t data);
0025 typedef ngx_int_t (*ngx_stream_get_variable_pt) (ngx_stream_session_t *s,
0026     ngx_stream_variable_value_t *v, uintptr_t data);
0027 
0028 
0029 #define NGX_STREAM_VAR_CHANGEABLE   1
0030 #define NGX_STREAM_VAR_NOCACHEABLE  2
0031 #define NGX_STREAM_VAR_INDEXED      4
0032 #define NGX_STREAM_VAR_NOHASH       8
0033 #define NGX_STREAM_VAR_WEAK         16
0034 #define NGX_STREAM_VAR_PREFIX       32
0035 
0036 
0037 struct ngx_stream_variable_s {
0038     ngx_str_t                     name;   /* must be first to build the hash */
0039     ngx_stream_set_variable_pt    set_handler;
0040     ngx_stream_get_variable_pt    get_handler;
0041     uintptr_t                     data;
0042     ngx_uint_t                    flags;
0043     ngx_uint_t                    index;
0044 };
0045 
0046 
0047 ngx_stream_variable_t *ngx_stream_add_variable(ngx_conf_t *cf, ngx_str_t *name,
0048     ngx_uint_t flags);
0049 ngx_int_t ngx_stream_get_variable_index(ngx_conf_t *cf, ngx_str_t *name);
0050 ngx_stream_variable_value_t *ngx_stream_get_indexed_variable(
0051     ngx_stream_session_t *s, ngx_uint_t index);
0052 ngx_stream_variable_value_t *ngx_stream_get_flushed_variable(
0053     ngx_stream_session_t *s, ngx_uint_t index);
0054 
0055 ngx_stream_variable_value_t *ngx_stream_get_variable(ngx_stream_session_t *s,
0056     ngx_str_t *name, ngx_uint_t key);
0057 
0058 
0059 #if (NGX_PCRE)
0060 
0061 typedef struct {
0062     ngx_uint_t                    capture;
0063     ngx_int_t                     index;
0064 } ngx_stream_regex_variable_t;
0065 
0066 
0067 typedef struct {
0068     ngx_regex_t                  *regex;
0069     ngx_uint_t                    ncaptures;
0070     ngx_stream_regex_variable_t  *variables;
0071     ngx_uint_t                    nvariables;
0072     ngx_str_t                     name;
0073 } ngx_stream_regex_t;
0074 
0075 
0076 typedef struct {
0077     ngx_stream_regex_t           *regex;
0078     void                         *value;
0079 } ngx_stream_map_regex_t;
0080 
0081 
0082 ngx_stream_regex_t *ngx_stream_regex_compile(ngx_conf_t *cf,
0083     ngx_regex_compile_t *rc);
0084 ngx_int_t ngx_stream_regex_exec(ngx_stream_session_t *s, ngx_stream_regex_t *re,
0085     ngx_str_t *str);
0086 
0087 #endif
0088 
0089 
0090 typedef struct {
0091     ngx_hash_combined_t           hash;
0092 #if (NGX_PCRE)
0093     ngx_stream_map_regex_t       *regex;
0094     ngx_uint_t                    nregex;
0095 #endif
0096 } ngx_stream_map_t;
0097 
0098 
0099 void *ngx_stream_map_find(ngx_stream_session_t *s, ngx_stream_map_t *map,
0100     ngx_str_t *match);
0101 
0102 
0103 ngx_int_t ngx_stream_variables_add_core_vars(ngx_conf_t *cf);
0104 ngx_int_t ngx_stream_variables_init_vars(ngx_conf_t *cf);
0105 
0106 
0107 extern ngx_stream_variable_value_t  ngx_stream_variable_null_value;
0108 extern ngx_stream_variable_value_t  ngx_stream_variable_true_value;
0109 
0110 
0111 #endif /* _NGX_STREAM_VARIABLES_H_INCLUDED_ */