src/server/safs/nametrans.c

Sat, 31 Oct 2015 15:01:07 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 31 Oct 2015 15:01:07 +0100
changeset 106
b122f34ddc80
parent 97
09fbefc0e6a9
child 116
d7a186cf87f6
permissions
-rw-r--r--

added minimal ssl support

14
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
44
3da1f7b6847f added some error messages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 14
diff changeset
4 * Copyright 2013 Olaf Wintermann. All rights reserved.
14
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include "nametrans.h"
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30
77
f1cff81e425a some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
31 #include "../daemon/log.h"
14
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 #include "../util/pblock.h"
96
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
33 #include "../util/util.h"
14
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35 /*
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 * assign_name
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 *
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38 * Assigns the name specified by the name parameter if the uri has the
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 * specified prefix.
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 *
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 * pblock parameter:
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 * name object name
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 * from optional uri prefix
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 */
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 int assign_name(pblock *pb, Session *sn, Request *rq) {
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 /* TODO: expression instead of simple prefix */
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 char *name = pblock_findkeyval(pb_key_name, pb);
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 char *from = pblock_findkeyval(pb_key_from, pb);
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 if(!name) {
77
f1cff81e425a some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
52 log_ereport(LOG_MISCONFIG, "assign-name: missing name parameter");
14
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 protocol_status(sn, rq, 500, NULL);
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 return REQ_ABORTED;
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 }
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 if(from) {
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 char *uri = pblock_findkeyval(pb_key_uri, rq->reqpb);
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 char c;
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 int i = 0;
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 while((c = from[i]) != 0) {
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 if(c != uri[i]) {
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 return REQ_NOACTION;
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64 }
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 i++;
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 }
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 }
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68
77
f1cff81e425a some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
69 // add object to rq->vars
14
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 pblock_kvinsert(pb_key_name, name, strlen(name), rq->vars);
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 return REQ_NOACTION;
b8bf95b39952 New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 }
96
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
74
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
75 /*
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
76 * document_root
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
77 *
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
78 * Specifies the document root directory.
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
79 *
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
80 * pblock parameter:
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
81 * root path to document root
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
82 */
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
83 int document_root(pblock *pb, Session *sn, Request *rq) {
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
84 char *root = pblock_findkeyval(pb_key_root, pb);
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
85 if(!root) {
97
09fbefc0e6a9 added ldap group support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 96
diff changeset
86 log_ereport(LOG_MISCONFIG, "document-root: missing root parameter");
96
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
87 protocol_status(sn, rq, 500, NULL);
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
88 return REQ_ABORTED;
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
89 }
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
90
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
91 sstr_t root_str = sstr(root);
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
92 sstr_t uri_str = sstr(pblock_findkeyval(pb_key_uri, rq->reqpb));
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
93 util_add_ppath(root_str, uri_str, rq->vars);
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
94
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
95 return REQ_PROCEED;
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
96 }
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
97
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
98 /*
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
99 * pfx2dir
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
100 *
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
101 * ...
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
102 *
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
103 * pblock parameter:
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
104 * from prefix
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
105 * dir file system directory
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
106 * name (optional) object name
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
107 *
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
108 */
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
109 int pfx2dir(pblock *pb, Session *sn, Request *rq) {
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
110 char *from = pblock_findkeyval(pb_key_from, pb);
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
111 char *dir = pblock_findkeyval(pb_key_dir, pb);
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
112 char *name = pblock_findkeyval(pb_key_name, pb);
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
113
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
114 if(!from || !dir) {
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
115 if(!from && dir) {
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
116 log_ereport(LOG_MISCONFIG, "pfx2dir: missing from parameter");
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
117 } else if(!dir && from) {
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
118 log_ereport(LOG_MISCONFIG, "pfx2dir: missing dir parameter");
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
119 } else {
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
120 log_ereport(
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
121 LOG_MISCONFIG,
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
122 "pfx2dir: missing from and dir parameter");
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
123 }
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
124 protocol_status(sn, rq, 500, NULL);
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
125 return REQ_ABORTED;
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
126 }
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
127
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
128 // check prefix
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
129 char *uri = pblock_findkeyval(pb_key_uri, rq->reqpb);
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
130 char fc;
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
131 char uc;
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
132 int i = 0;
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
133 while((fc = from[i]) != 0) {
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
134 uc = uri[i];
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
135 if(fc != uc) {
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
136 return REQ_NOACTION;
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
137 }
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
138 i++;
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
139 }
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
140
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
141 // url has the specified prefix
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
142
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
143 uri = uri + i;
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
144 if(uri[0] == '/') {
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
145 uri++;
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
146 }
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
147 sstr_t ppath = util_path_append(sn->pool, dir, uri);
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
148 pblock_kvinsert(
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
149 pb_key_ppath,
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
150 ppath.ptr,
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
151 ppath.length,
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
152 rq->vars);
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
153
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
154 if(name) {
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
155 // add object to rq->vars
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
156 pblock_kvinsert(pb_key_name, name, strlen(name), rq->vars);
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
157 }
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
158
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
159 return REQ_PROCEED;
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
160 }
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
161
0185b13bf41f added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 77
diff changeset
162

mercurial