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_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 #define ngx_http_null_variable  { ngx_null_string, NULL, NULL, 0, 0, 0 }
0047 
0048 
0049 ngx_http_variable_t *ngx_http_add_variable(ngx_conf_t *cf, ngx_str_t *name,
0050     ngx_uint_t flags);
0051 ngx_int_t ngx_http_get_variable_index(ngx_conf_t *cf, ngx_str_t *name);
0052 ngx_http_variable_value_t *ngx_http_get_indexed_variable(ngx_http_request_t *r,
0053     ngx_uint_t index);
0054 ngx_http_variable_value_t *ngx_http_get_flushed_variable(ngx_http_request_t *r,
0055     ngx_uint_t index);
0056 
0057 ngx_http_variable_value_t *ngx_http_get_variable(ngx_http_request_t *r,
0058     ngx_str_t *name, ngx_uint_t key);
0059 
0060 ngx_int_t ngx_http_variable_unknown_header(ngx_http_variable_value_t *v,
0061     ngx_str_t *var, ngx_list_part_t *part, size_t prefix);
0062 
0063 
0064 #if (NGX_PCRE)
0065 
0066 typedef struct {
0067     ngx_uint_t                    capture;
0068     ngx_int_t                     index;
0069 } ngx_http_regex_variable_t;
0070 
0071 
0072 typedef struct {
0073     ngx_regex_t                  *regex;
0074     ngx_uint_t                    ncaptures;
0075     ngx_http_regex_variable_t    *variables;
0076     ngx_uint_t                    nvariables;
0077     ngx_str_t                     name;
0078 } ngx_http_regex_t;
0079 
0080 
0081 typedef struct {
0082     ngx_http_regex_t             *regex;
0083     void                         *value;
0084 } ngx_http_map_regex_t;
0085 
0086 
0087 ngx_http_regex_t *ngx_http_regex_compile(ngx_conf_t *cf,
0088     ngx_regex_compile_t *rc);
0089 ngx_int_t ngx_http_regex_exec(ngx_http_request_t *r, ngx_http_regex_t *re,
0090     ngx_str_t *s);
0091 
0092 #endif
0093 
0094 
0095 typedef struct {
0096     ngx_hash_combined_t           hash;
0097 #if (NGX_PCRE)
0098     ngx_http_map_regex_t         *regex;
0099     ngx_uint_t                    nregex;
0100 #endif
0101 } ngx_http_map_t;
0102 
0103 
0104 void *ngx_http_map_find(ngx_http_request_t *r, ngx_http_map_t *map,
0105     ngx_str_t *match);
0106 
0107 
0108 ngx_int_t ngx_http_variables_add_core_vars(ngx_conf_t *cf);
0109 ngx_int_t ngx_http_variables_init_vars(ngx_conf_t *cf);
0110 
0111 
0112 extern ngx_http_variable_value_t  ngx_http_variable_null_value;
0113 extern ngx_http_variable_value_t  ngx_http_variable_true_value;
0114 
0115 
0116 #endif /* _NGX_HTTP_VARIABLES_H_INCLUDED_ */