src/server/daemon/location.h

changeset 635
b85d45fd3b01
child 636
40f069ddda37
equal deleted inserted replaced
634:9728d3a2ac97 635:b85d45fd3b01
1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 2025 Olaf Wintermann. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
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 "../util/strreplace.h"
38 #include "../webdav/webdav.h"
39
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 typedef struct WSLocation WSLocation;
46 typedef struct WSLocationConfig WSLocationConfig;
47
48 typedef enum WSLocationMatch {
49 WS_LOCATION_MATCH_EXACT = 0,
50 WS_LOCATION_MATCH_PREFIX,
51 WS_LOCATION_MATCH_CS_REGEX,
52 WS_LOCATION_MATCH_CI_REGEX
53 } WSLocationMatch;
54
55 struct WSLocationConfig {
56 /*
57 * Activate dirindex setting
58 */
59 WSBool set_dirindex;
60
61 /*
62 * Enable/Disable directory index
63 */
64 WSBool dirindex;
65
66 /*
67 * Activate forcetls setting
68 */
69 WSBool set_forcetls;
70
71 /*
72 * force TLS
73 */
74 WSBool forcetls;
75
76 /*
77 * obj.conf object name
78 */
79 cxmutstr name;
80
81 /*
82 * VFS type
83 */
84 cxmutstr vfs;
85
86 /*
87 * Document root path
88 */
89 cxmutstr docroot;
90
91 /*
92 * Redirect URL
93 * Can contain references to regex capture groups (redirect match regex,
94 * if available, or the location regex)
95 */
96 StringTemplate *redirect;
97
98 /*
99 * Redirect match regex
100 */
101 regex_t redirect_match;
102
103 /*
104 * Status code for redirect response
105 */
106 int redirect_status;
107
108 /*
109 * WebDAV settings
110 * If dav is set, "webdav" is added to the obj.conf object list,
111 * unless name is also set
112 */
113 WebdavRepository *dav;
114
115 /*
116 * List of ACL names, that should be added to the request ACL list
117 * value: char*
118 */
119 CxList *acls;
120 };
121
122 struct WSLocation {
123 WSLocationMatch match;
124 cxmutstr match_string;
125 regex_t regex;
126
127 /*
128 * standard location settings
129 */
130 WSLocationConfig config;
131
132 /*
133 * extended settings
134 * key: directive name
135 * value: char*
136 */
137 CxMap *ext_config;
138
139 WSLocation *children_begin;
140 WSLocation *children_end;
141 WSLocation *prev;
142 WSLocation *next;
143 };
144
145 WSLocation* cfg_location_get(const CxAllocator *a, ConfigNode *obj);
146
147 #ifdef __cplusplus
148 }
149 #endif
150
151 #endif /* LOCATION_H */
152

mercurial