1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 #ifndef LOCATION_H
30 #define LOCATION_H
31
32 #include <cx/string.h>
33 #include <cx/hash_map.h>
34 #include <regex.h>
35 #include "../public/nsapi.h"
36 #include "../config/serverconfig.h"
37 #include "config.h"
38 #include "../util/strreplace.h"
39 #include "../webdav/webdav.h"
40
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 #define WS_LOCATION_NMATCH 16
47
48 typedef struct WSLocation WSLocation;
49 typedef struct WSLocationConfig WSLocationConfig;
50
51 typedef enum WSLocationMatch {
52 WS_LOCATION_MATCH_EXACT =
0,
53 WS_LOCATION_MATCH_PREFIX,
54 WS_LOCATION_MATCH_CS_REGEX,
55 WS_LOCATION_MATCH_CI_REGEX
56 } WSLocationMatch;
57
58 struct WSLocationConfig {
59
60
61
62 regmatch_t match[
WS_LOCATION_NMATCH];
63
64
65
66
67 WSBool set_dirindex;
68
69
70
71
72 WSBool dirindex;
73
74
75
76
77 WSBool set_forcetls;
78
79
80
81
82 WSBool forcetls;
83
84
85
86
87 cxmutstr name;
88
89
90
91
92 cxmutstr vfs;
93
94
95
96
97 cxmutstr docroot;
98
99
100
101
102
103
104 StringTemplate *redirect;
105
106
107
108
109 regex_t redirect_match;
110
111
112
113
114 int redirect_status;
115
116
117
118
119
120
121 WebdavRepository *dav;
122
123
124
125
126
127 CxList *acls;
128 };
129
130 struct WSLocation {
131 WSLocationMatch match;
132 cxmutstr match_string;
133 regex_t regex;
134
135
136
137
138 WSLocationConfig config;
139
140
141
142
143 CxList *rewrite;
144
145
146
147
148
149
150
151 CxMap *ext_config;
152
153 WSLocation *children_begin;
154 WSLocation *children_end;
155 WSLocation *prev;
156 WSLocation *next;
157 };
158
159 WSLocation* cfg_location_get(ServerConfiguration *cfg, ConfigNode *obj);
160
161 int location_apply_config(WSLocationConfig *target, WSLocation *loc);
162 int location_match(WSLocation *loc, cxstring uri,
regmatch_t *match);
163 WSLocationConfig* location_match_and_get_config(
pool_handle_t *pool, Request *rq, cxstring uri, WSLocation *loc);
164 WSLocationConfig* cfg_location_match(Session *sn, Request *rq);
165
166 #ifdef __cplusplus
167 }
168 #endif
169
170 #endif
171
172