Mon, 06 May 2013 14:54:40 +0200
improved logging
1 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
3 | * | |
4 | * Copyright 2008 Sun Microsystems, Inc. All rights reserved. | |
5 | * | |
6 | * THE BSD LICENSE | |
7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions are met: | |
10 | * | |
11 | * Redistributions of source code must retain the above copyright notice, this | |
12 | * list of conditions and the following disclaimer. | |
13 | * Redistributions in binary form must reproduce the above copyright notice, | |
14 | * this list of conditions and the following disclaimer in the documentation | |
15 | * and/or other materials provided with the distribution. | |
16 | * | |
17 | * Neither the name of the nor the names of its contributors may be | |
18 | * used to endorse or promote products derived from this software without | |
19 | * specific prior written permission. | |
20 | * | |
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER | |
25 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
27 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | |
28 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | |
30 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
31 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | |
33 | ||
34 | /* | |
35 | * util.c: A hodge podge of utility functions and standard functions which | |
36 | * are unavailable on certain systems | |
37 | * | |
38 | * Rob McCool | |
39 | */ | |
40 | ||
41 | #ifdef XP_UNIX | |
42 | #include <sys/types.h> | |
43 | #include <sys/wait.h> | |
44 | #include <stdlib.h> | |
45 | #include <unistd.h> | |
46 | #include <limits.h> | |
47 | #include "prthread.h" | |
48 | #endif /* XP_UNIX */ | |
49 | ||
50 | ||
24
1a7853a4257e
removed some NSPR dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
51 | //include "nspr.h" |
56
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
52 | #include <errno.h> |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
53 | |
24
1a7853a4257e
removed some NSPR dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
54 | #include "../daemon/netsite.h" |
14
b8bf95b39952
New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
55 | #include "../public/nsapi.h" |
1 | 56 | |
57 | #include "util.h" | |
58 | ||
59 | /* | |
60 | NSAPI_PUBLIC int util_getboolean(const char *v, int def) { | |
61 | if(v[0] == 'T' || v[0] == 't') { | |
62 | return 1; | |
63 | } | |
64 | if(v[0] == 'F' || v[0] == 'f') { | |
65 | return 0; | |
66 | } | |
67 | return def; | |
68 | } | |
69 | */ | |
70 | ||
71 | NSAPI_PUBLIC int INTutil_getboolean(const char *v, int def) { | |
72 | if(v[0] == 'T' || v[0] == 't') { | |
73 | return 1; | |
74 | } | |
75 | if(v[0] == 'F' || v[0] == 'f') { | |
76 | return 0; | |
77 | } | |
78 | return def; | |
79 | } | |
80 | ||
81 | ||
82 | /* ------------------------------ util_itoa ------------------------------- */ | |
83 | /* | |
84 | NSAPI_PUBLIC int util_itoa(int i, char *a) | |
85 | { | |
86 | int len = util_i64toa(i, a); | |
87 | ||
88 | PR_ASSERT(len < UTIL_ITOA_SIZE); | |
89 | ||
90 | return len; | |
91 | } | |
92 | */ | |
93 | NSAPI_PUBLIC int INTutil_itoa(int i, char *a) { | |
94 | return INTutil_i64toa(i, a); | |
95 | } | |
96 | ||
97 | ||
98 | /* ----------------------------- util_i64toa ------------------------------ */ | |
99 | ||
100 | /* | |
101 | * Assumption: Reversing the digits will be faster in the general case | |
102 | * than doing a log10 or some nasty trick to find the # of digits. | |
103 | */ | |
104 | ||
24
1a7853a4257e
removed some NSPR dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
105 | NSAPI_PUBLIC int INTutil_i64toa(int64_t i, char *a) |
1 | 106 | { |
107 | register int x, y, p; | |
108 | register char c; | |
109 | int negative; | |
110 | ||
111 | negative = 0; | |
112 | if(i < 0) { | |
113 | *a++ = '-'; | |
114 | negative = 1; | |
115 | i = -i; | |
116 | } | |
117 | p = 0; | |
118 | while(i > 9) { | |
119 | a[p++] = (i%10) + '0'; | |
120 | i /= 10; | |
121 | } | |
122 | a[p++] = i + '0'; | |
123 | ||
124 | if(p > 1) { | |
125 | for(x = 0, y = p - 1; x < y; ++x, --y) { | |
126 | c = a[x]; | |
127 | a[x] = a[y]; | |
128 | a[y] = c; | |
129 | } | |
130 | } | |
131 | a[p] = '\0'; | |
132 | ||
133 | //PR_ASSERT(p + negative < UTIL_I64TOA_SIZE); | |
134 | ||
135 | return p + negative; | |
136 | } | |
47
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
137 | |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
138 | |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
139 | |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
140 | #ifndef XP_WIN32 |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
141 | NSAPI_PUBLIC struct passwd * |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
142 | util_getpwnam(const char *name, struct passwd *result, char *buffer, |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
143 | int buflen) |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
144 | { |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
145 | struct passwd *rv; |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
146 | |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
147 | #if defined(AIX) || defined(LINUX) || defined(HPUX) |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
148 | errno = getpwnam_r(name, result, buffer, buflen, &rv); |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
149 | if (errno != 0) |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
150 | rv = NULL; |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
151 | #else |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
152 | rv = getpwnam_r(name, result, buffer, buflen); |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
153 | #endif |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
154 | |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
155 | return rv; |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
156 | } |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
157 | #endif |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
158 | |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
159 | |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
160 | #ifndef XP_WIN32 |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
161 | NSAPI_PUBLIC struct passwd * |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
162 | util_getpwuid(uid_t uid, struct passwd *result, char *buffer, int buflen) |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
163 | { |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
164 | struct passwd *rv; |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
165 | |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
166 | #if defined(AIX) || defined(LINUX) || defined(HPUX) |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
167 | errno = getpwuid_r(uid, result, buffer, buflen, &rv); |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
168 | if (errno != 0) |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
169 | rv = NULL; |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
170 | #else |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
171 | rv = getpwuid_r(uid, result, buffer, buflen); |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
172 | #endif |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
173 | |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
174 | return rv; |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
175 | } |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
176 | #endif |
56
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
177 | |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
178 | |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
179 | NSAPI_PUBLIC int util_errno2status(int errno_value) { |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
180 | switch(errno_value) { |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
181 | case 0: { |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
182 | return 200; |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
183 | } |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
184 | case EACCES: { |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
185 | return 403; |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
186 | } |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
187 | case ENOENT: { |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
188 | return 404; |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
189 | break; |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
190 | } |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
191 | } |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
192 | return 500; |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
47
diff
changeset
|
193 | } |
58
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
194 | |
59
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
195 | NSAPI_PUBLIC int util_uri_unescape_strict(char *s) |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
196 | { |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
197 | char *t, *u, t1, t2; |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
198 | int rv = 1; |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
199 | |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
200 | for(t = s, u = s; *t; ++t, ++u) { |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
201 | if (*t == '%') { |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
202 | t1 = t[1] & 0xdf; /* [a-f] -> [A-F] */ |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
203 | if ((t1 < 'A' || t1 > 'F') && (t[1] < '0' || t[1] > '9')) |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
204 | rv = 0; |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
205 | |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
206 | t2 = t[2] & 0xdf; /* [a-f] -> [A-F] */ |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
207 | if ((t2 < 'A' || t2 > 'F') && (t[2] < '0' || t[2] > '9')) |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
208 | rv = 0; |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
209 | |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
210 | *u = ((t[1] >= 'A' ? ((t[1] & 0xdf) - 'A')+10 : (t[1] - '0'))*16) + |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
211 | (t[2] >= 'A' ? ((t[2] & 0xdf) - 'A')+10 : (t[2] - '0')); |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
212 | t += 2; |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
213 | } |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
214 | else if (u != t) |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
215 | *u = *t; |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
216 | } |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
217 | *u = *t; |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
218 | |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
219 | return rv; |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
220 | } |
58
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
221 | |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
222 | NSAPI_PUBLIC |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
223 | sstr_t util_path_append(pool_handle_t *pool, char *path, char *ch) { |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
224 | sstr_t parent = sstr(path); |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
225 | sstr_t child = sstr(ch); |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
226 | sstr_t newstr; |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
227 | sstr_t s; |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
228 | |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
229 | s.length = 0; |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
230 | s.ptr = NULL; |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
231 | newstr.length = parent.length + child.length; |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
232 | if(parent.ptr[parent.length - 1] != '/') { |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
233 | s = sstrn("/", 1); |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
234 | newstr.length++; |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
235 | } |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
236 | |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
237 | newstr.ptr = pool_malloc(pool, newstr.length + 1); |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
238 | if(!newstr.ptr) { |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
239 | // TODO: error |
59
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
240 | newstr.length = 0; |
58
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
241 | return newstr; |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
242 | } |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
243 | if(s.length == 1) { |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
244 | newstr = sstrncat(3, newstr, parent, s, child); |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
245 | } else { |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
246 | newstr = sstrncat(2, newstr, parent, child); |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
247 | } |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
248 | newstr.ptr[newstr.length] = '\0'; |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
249 | |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
250 | return newstr; |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
56
diff
changeset
|
251 | } |