3 * Copyright (C) Igor Sysoev
7 #ifndef _NGX_HTTP_VARIABLES_H_INCLUDED_
8 #define _NGX_HTTP_VARIABLES_H_INCLUDED_
11 #include <ngx_config.h>
16 typedef ngx_variable_value_t ngx_http_variable_value_t
;
18 #define ngx_http_variable(v) { sizeof(v) - 1, 1, 0, 0, 0, (u_char *) v }
20 typedef struct ngx_http_variable_s ngx_http_variable_t
;
22 typedef void (*ngx_http_set_variable_pt
) (ngx_http_request_t
*r
,
23 ngx_http_variable_value_t
*v
, uintptr_t data
);
24 typedef ngx_int_t (*ngx_http_get_variable_pt
) (ngx_http_request_t
*r
,
25 ngx_http_variable_value_t
*v
, uintptr_t data
);
28 #define NGX_HTTP_VAR_CHANGEABLE 1
29 #define NGX_HTTP_VAR_NOCACHEABLE 2
30 #define NGX_HTTP_VAR_INDEXED 4
31 #define NGX_HTTP_VAR_NOHASH 8
34 struct ngx_http_variable_s
{
35 ngx_str_t name
; /* must be first to build the hash */
36 ngx_http_set_variable_pt set_handler
;
37 ngx_http_get_variable_pt get_handler
;
44 ngx_http_variable_t
*ngx_http_add_variable(ngx_conf_t
*cf
, ngx_str_t
*name
,
46 ngx_int_t
ngx_http_get_variable_index(ngx_conf_t
*cf
, ngx_str_t
*name
);
47 ngx_http_variable_value_t
*ngx_http_get_indexed_variable(ngx_http_request_t
*r
,
49 ngx_http_variable_value_t
*ngx_http_get_flushed_variable(ngx_http_request_t
*r
,
52 ngx_http_variable_value_t
*ngx_http_get_variable(ngx_http_request_t
*r
,
53 ngx_str_t
*name
, ngx_uint_t key
);
55 ngx_int_t
ngx_http_variable_unknown_header(ngx_http_variable_value_t
*v
,
56 ngx_str_t
*var
, ngx_list_part_t
*part
, size_t prefix
);
59 #define ngx_http_clear_variable(r, index) r->variables0[index].text.data = NULL;
67 } ngx_http_regex_variable_t
;
73 ngx_http_regex_variable_t
*variables
;
74 ngx_uint_t nvariables
;
80 ngx_http_regex_t
*regex
;
82 } ngx_http_map_regex_t
;
85 ngx_http_regex_t
*ngx_http_regex_compile(ngx_conf_t
*cf
,
86 ngx_regex_compile_t
*rc
);
87 ngx_int_t
ngx_http_regex_exec(ngx_http_request_t
*r
, ngx_http_regex_t
*re
,
94 ngx_hash_combined_t hash
;
96 ngx_http_map_regex_t
*regex
;
102 void *ngx_http_map_find(ngx_http_request_t
*r
, ngx_http_map_t
*map
,
106 ngx_int_t
ngx_http_variables_add_core_vars(ngx_conf_t
*cf
);
107 ngx_int_t
ngx_http_variables_init_vars(ngx_conf_t
*cf
);
110 extern ngx_http_variable_value_t ngx_http_variable_null_value
;
111 extern ngx_http_variable_value_t ngx_http_variable_true_value
;
114 #endif /* _NGX_HTTP_VARIABLES_H_INCLUDED_ */