Sat, 19 Jan 2013 21:52:21 +0100
propfind supports allprop
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" |
1a7853a4257e
removed some NSPR dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
52 | #include "../daemon/netsite.h" |
14
b8bf95b39952
New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
53 | #include "../public/nsapi.h" |
1 | 54 | |
55 | #include "util.h" | |
56 | ||
57 | /* | |
58 | NSAPI_PUBLIC int util_getboolean(const char *v, int def) { | |
59 | if(v[0] == 'T' || v[0] == 't') { | |
60 | return 1; | |
61 | } | |
62 | if(v[0] == 'F' || v[0] == 'f') { | |
63 | return 0; | |
64 | } | |
65 | return def; | |
66 | } | |
67 | */ | |
68 | ||
69 | NSAPI_PUBLIC int INTutil_getboolean(const char *v, int def) { | |
70 | if(v[0] == 'T' || v[0] == 't') { | |
71 | return 1; | |
72 | } | |
73 | if(v[0] == 'F' || v[0] == 'f') { | |
74 | return 0; | |
75 | } | |
76 | return def; | |
77 | } | |
78 | ||
79 | ||
80 | /* ------------------------------ util_itoa ------------------------------- */ | |
81 | /* | |
82 | NSAPI_PUBLIC int util_itoa(int i, char *a) | |
83 | { | |
84 | int len = util_i64toa(i, a); | |
85 | ||
86 | PR_ASSERT(len < UTIL_ITOA_SIZE); | |
87 | ||
88 | return len; | |
89 | } | |
90 | */ | |
91 | NSAPI_PUBLIC int INTutil_itoa(int i, char *a) { | |
92 | return INTutil_i64toa(i, a); | |
93 | } | |
94 | ||
95 | ||
96 | /* ----------------------------- util_i64toa ------------------------------ */ | |
97 | ||
98 | /* | |
99 | * Assumption: Reversing the digits will be faster in the general case | |
100 | * than doing a log10 or some nasty trick to find the # of digits. | |
101 | */ | |
102 | ||
24
1a7853a4257e
removed some NSPR dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
103 | NSAPI_PUBLIC int INTutil_i64toa(int64_t i, char *a) |
1 | 104 | { |
105 | register int x, y, p; | |
106 | register char c; | |
107 | int negative; | |
108 | ||
109 | negative = 0; | |
110 | if(i < 0) { | |
111 | *a++ = '-'; | |
112 | negative = 1; | |
113 | i = -i; | |
114 | } | |
115 | p = 0; | |
116 | while(i > 9) { | |
117 | a[p++] = (i%10) + '0'; | |
118 | i /= 10; | |
119 | } | |
120 | a[p++] = i + '0'; | |
121 | ||
122 | if(p > 1) { | |
123 | for(x = 0, y = p - 1; x < y; ++x, --y) { | |
124 | c = a[x]; | |
125 | a[x] = a[y]; | |
126 | a[y] = c; | |
127 | } | |
128 | } | |
129 | a[p] = '\0'; | |
130 | ||
131 | //PR_ASSERT(p + negative < UTIL_I64TOA_SIZE); | |
132 | ||
133 | return p + negative; | |
134 | } | |
47
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
135 | |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
136 | |
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 | #ifndef XP_WIN32 |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
139 | NSAPI_PUBLIC struct passwd * |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
140 | 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
|
141 | int buflen) |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
142 | { |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
143 | struct passwd *rv; |
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 | #if defined(AIX) || defined(LINUX) || defined(HPUX) |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
146 | errno = getpwnam_r(name, result, buffer, buflen, &rv); |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
147 | if (errno != 0) |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
148 | rv = NULL; |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
149 | #else |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
150 | rv = getpwnam_r(name, result, buffer, buflen); |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
151 | #endif |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
152 | |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
153 | return rv; |
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 | #endif |
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 | |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
158 | #ifndef XP_WIN32 |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
159 | NSAPI_PUBLIC struct passwd * |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
160 | 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
|
161 | { |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
162 | struct passwd *rv; |
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 | #if defined(AIX) || defined(LINUX) || defined(HPUX) |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
165 | errno = getpwuid_r(uid, result, buffer, buflen, &rv); |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
166 | if (errno != 0) |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
167 | rv = NULL; |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
168 | #else |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
169 | rv = getpwuid_r(uid, result, buffer, buflen); |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
170 | #endif |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
171 | |
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
172 | return rv; |
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 | #endif |