nginx 1.1.11
[nginx.git] / src / http / ngx_http_variables.h
blobb0114e3006d43ac446bfb7af346d14721214661d
2 /*
3 * Copyright (C) Igor Sysoev
4 */
7 #ifndef _NGX_HTTP_VARIABLES_H_INCLUDED_
8 #define _NGX_HTTP_VARIABLES_H_INCLUDED_
11 #include <ngx_config.h>
12 #include <ngx_core.h>
13 #include <ngx_http.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;
38 uintptr_t data;
39 ngx_uint_t flags;
40 ngx_uint_t index;
44 ngx_http_variable_t *ngx_http_add_variable(ngx_conf_t *cf, ngx_str_t *name,
45 ngx_uint_t flags);
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,
48 ngx_uint_t index);
49 ngx_http_variable_value_t *ngx_http_get_flushed_variable(ngx_http_request_t *r,
50 ngx_uint_t index);
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;
62 #if (NGX_PCRE)
64 typedef struct {
65 ngx_uint_t capture;
66 ngx_int_t index;
67 } ngx_http_regex_variable_t;
70 typedef struct {
71 ngx_regex_t *regex;
72 ngx_uint_t ncaptures;
73 ngx_http_regex_variable_t *variables;
74 ngx_uint_t nvariables;
75 ngx_str_t name;
76 } ngx_http_regex_t;
79 typedef struct {
80 ngx_http_regex_t *regex;
81 void *value;
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,
88 ngx_str_t *s);
90 #endif
93 typedef struct {
94 ngx_hash_combined_t hash;
95 #if (NGX_PCRE)
96 ngx_http_map_regex_t *regex;
97 ngx_uint_t nregex;
98 #endif
99 } ngx_http_map_t;
102 void *ngx_http_map_find(ngx_http_request_t *r, ngx_http_map_t *map,
103 ngx_str_t *match);
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_ */