Back to home page

Nginx displayed by LXR

Source navigation ]
Diff markup ]
Identifier search ]
general search ]
 
 
Version: nginx-1.15.12 ]​[ nginx-1.16.0 ]​

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 #define ngx_stream_null_variable  { ngx_null_string, NULL, NULL, 0, 0, 0 }
0047 
0048 
0049 ngx_stream_variable_t *ngx_stream_add_variable(ngx_conf_t *cf, ngx_str_t *name,
0050     ngx_uint_t flags);
0051 ngx_int_t ngx_stream_get_variable_index(ngx_conf_t *cf, ngx_str_t *name);
0052 ngx_stream_variable_value_t *ngx_stream_get_indexed_variable(
0053     ngx_stream_session_t *s, ngx_uint_t index);
0054 ngx_stream_variable_value_t *ngx_stream_get_flushed_variable(
0055     ngx_stream_session_t *s, ngx_uint_t index);
0056 
0057 ngx_stream_variable_value_t *ngx_stream_get_variable(ngx_stream_session_t *s,
0058     ngx_str_t *name, ngx_uint_t key);
0059 
0060 
0061 #if (NGX_PCRE)
0062 
0063 typedef struct {
0064     ngx_uint_t                    capture;
0065     ngx_int_t                     index;
0066 } ngx_stream_regex_variable_t;
0067 
0068 
0069 typedef struct {
0070     ngx_regex_t                  *regex;
0071     ngx_uint_t                    ncaptures;
0072     ngx_stream_regex_variable_t  *variables;
0073     ngx_uint_t                    nvariables;
0074     ngx_str_t                     name;
0075 } ngx_stream_regex_t;
0076 
0077 
0078 typedef struct {
0079     ngx_stream_regex_t           *regex;
0080     void                         *value;
0081 } ngx_stream_map_regex_t;
0082 
0083 
0084 ngx_stream_regex_t *ngx_stream_regex_compile(ngx_conf_t *cf,
0085     ngx_regex_compile_t *rc);
0086 ngx_int_t ngx_stream_regex_exec(ngx_stream_session_t *s, ngx_stream_regex_t *re,
0087     ngx_str_t *str);
0088 
0089 #endif
0090 
0091 
0092 typedef struct {
0093     ngx_hash_combined_t           hash;
0094 #if (NGX_PCRE)
0095     ngx_stream_map_regex_t       *regex;
0096     ngx_uint_t                    nregex;
0097 #endif
0098 } ngx_stream_map_t;
0099 
0100 
0101 void *ngx_stream_map_find(ngx_stream_session_t *s, ngx_stream_map_t *map,
0102     ngx_str_t *match);
0103 
0104 
0105 ngx_int_t ngx_stream_variables_add_core_vars(ngx_conf_t *cf);
0106 ngx_int_t ngx_stream_variables_init_vars(ngx_conf_t *cf);
0107 
0108 
0109 extern ngx_stream_variable_value_t  ngx_stream_variable_null_value;
0110 extern ngx_stream_variable_value_t  ngx_stream_variable_true_value;
0111 
0112 
0113 #endif /* _NGX_STREAM_VARIABLES_H_INCLUDED_ */