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_HTTP_VARIABLES_H_INCLUDED_
0009 #define _NGX_HTTP_VARIABLES_H_INCLUDED_
0010 
0011 
0012 #include <ngx_config.h>
0013 #include <ngx_core.h>
0014 #include <ngx_http.h>
0015 
0016 
0017 typedef ngx_variable_value_t  ngx_http_variable_value_t;
0018 
0019 #define ngx_http_variable(v)     { sizeof(v) - 1, 1, 0, 0, 0, (u_char *) v }
0020 
0021 typedef struct ngx_http_variable_s  ngx_http_variable_t;
0022 
0023 typedef void (*ngx_http_set_variable_pt) (ngx_http_request_t *r,
0024     ngx_http_variable_value_t *v, uintptr_t data);
0025 typedef ngx_int_t (*ngx_http_get_variable_pt) (ngx_http_request_t *r,
0026     ngx_http_variable_value_t *v, uintptr_t data);
0027 
0028 
0029 #define NGX_HTTP_VAR_CHANGEABLE   1
0030 #define NGX_HTTP_VAR_NOCACHEABLE  2
0031 #define NGX_HTTP_VAR_INDEXED      4
0032 #define NGX_HTTP_VAR_NOHASH       8
0033 #define NGX_HTTP_VAR_WEAK         16
0034 #define NGX_HTTP_VAR_PREFIX       32
0035 
0036 
0037 struct ngx_http_variable_s {
0038     ngx_str_t                     name;   /* must be first to build the hash */
0039     ngx_http_set_variable_pt      set_handler;
0040     ngx_http_get_variable_pt      get_handler;
0041     uintptr_t                     data;
0042     ngx_uint_t                    flags;
0043     ngx_uint_t                    index;
0044 };
0045 
0046 
0047 ngx_http_variable_t *ngx_http_add_variable(ngx_conf_t *cf, ngx_str_t *name,
0048     ngx_uint_t flags);
0049 ngx_int_t ngx_http_get_variable_index(ngx_conf_t *cf, ngx_str_t *name);
0050 ngx_http_variable_value_t *ngx_http_get_indexed_variable(ngx_http_request_t *r,
0051     ngx_uint_t index);
0052 ngx_http_variable_value_t *ngx_http_get_flushed_variable(ngx_http_request_t *r,
0053     ngx_uint_t index);
0054 
0055 ngx_http_variable_value_t *ngx_http_get_variable(ngx_http_request_t *r,
0056     ngx_str_t *name, ngx_uint_t key);
0057 
0058 ngx_int_t ngx_http_variable_unknown_header(ngx_http_variable_value_t *v,
0059     ngx_str_t *var, ngx_list_part_t *part, size_t prefix);
0060 
0061 
0062 #if (NGX_PCRE)
0063 
0064 typedef struct {
0065     ngx_uint_t                    capture;
0066     ngx_int_t                     index;
0067 } ngx_http_regex_variable_t;
0068 
0069 
0070 typedef struct {
0071     ngx_regex_t                  *regex;
0072     ngx_uint_t                    ncaptures;
0073     ngx_http_regex_variable_t    *variables;
0074     ngx_uint_t                    nvariables;
0075     ngx_str_t                     name;
0076 } ngx_http_regex_t;
0077 
0078 
0079 typedef struct {
0080     ngx_http_regex_t             *regex;
0081     void                         *value;
0082 } ngx_http_map_regex_t;
0083 
0084 
0085 ngx_http_regex_t *ngx_http_regex_compile(ngx_conf_t *cf,
0086     ngx_regex_compile_t *rc);
0087 ngx_int_t ngx_http_regex_exec(ngx_http_request_t *r, ngx_http_regex_t *re,
0088     ngx_str_t *s);
0089 
0090 #endif
0091 
0092 
0093 typedef struct {
0094     ngx_hash_combined_t           hash;
0095 #if (NGX_PCRE)
0096     ngx_http_map_regex_t         *regex;
0097     ngx_uint_t                    nregex;
0098 #endif
0099 } ngx_http_map_t;
0100 
0101 
0102 void *ngx_http_map_find(ngx_http_request_t *r, ngx_http_map_t *map,
0103     ngx_str_t *match);
0104 
0105 
0106 ngx_int_t ngx_http_variables_add_core_vars(ngx_conf_t *cf);
0107 ngx_int_t ngx_http_variables_init_vars(ngx_conf_t *cf);
0108 
0109 
0110 extern ngx_http_variable_value_t  ngx_http_variable_null_value;
0111 extern ngx_http_variable_value_t  ngx_http_variable_true_value;
0112 
0113 
0114 #endif /* _NGX_HTTP_VARIABLES_H_INCLUDED_ */