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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 #include "pblock.h"
46 #include "plist_pvt.h"
47 #include "plist.h"
48 #include "util.h"
49 #include "pool.h"
50 #include "systhr.h"
51
52 #define MALLOC_POOL_HANDLE (thread_malloc_key != -
1 ? (
pool_handle_t *)systhread_getdata(thread_malloc_key) : getThreadMallocPool())
53
54 static int thread_malloc_key = -
1;
55 static int _pblock_str2pblock(
const char* str, pblock* pb, PRBool lowerCase);
56
57 static pool_handle_t *getThreadMallocPool()
58 {
59 pool_handle_t *thread_malloc_pool =
0;
60
61 thread_malloc_key = getThreadMallocKey();
62 if (thread_malloc_key != -
1) {
63 thread_malloc_pool = (
pool_handle_t *)systhread_getdata(thread_malloc_key);
64 }
65
66 return thread_malloc_pool;
67 }
68
69
70
71
72
73
74
75
76 typedef struct pb_key pb_key;
77 struct pb_key {
78 const char *name;
79 int namelen;
80 unsigned int hashval;
81 int sizendx;
82 int hashndx;
83 };
84
85 #define PB_KEY_LIST_BUCKET_COUNT 0x7f
86
87 struct pb_key_list_bucket {
88 pb_key **elements;
89 unsigned size;
90 };
91
92 struct pb_key_list {
93 struct pb_key_list_bucket buckets[
PB_KEY_LIST_BUCKET_COUNT +
1];
94 };
95
96 static void _pb_key_list_insert(
struct pb_key_list *hashList,
unsigned int hashval, pb_key* element) {
97 struct pb_key_list_bucket *bucket = &hashList->buckets[hashval &
PB_KEY_LIST_BUCKET_COUNT];
98 size_t idx = bucket->size;
99 bucket->size++;
100 bucket->elements = realloc(bucket->elements,
sizeof(pb_key*) * bucket->size);
101 if (bucket->elements ==
NULL) abort();
102 bucket->elements[idx] = element;
103 }
104
105 static struct pb_key_list _pbKeys;
106
107 static const pb_key *_create_key(
const char *name)
108 {
109
110 pb_key *key = malloc(
sizeof(pb_key));
111 if (key ==
NULL) abort();
112 key->name =
STRDUP(name);
113 key->namelen = strlen(name);
114 key->hashval = PListHash(name);
115 key->sizendx =
0;
116 key->hashndx = key->hashval %
PLSIZENDX(
0);
117
118
119 _pb_key_list_insert(&_pbKeys, key->hashval, key);
120
121 return key;
122 }
123
124 const pb_key *pb_key_accept;
125 const pb_key *pb_key_accept_charset;
126 const pb_key *pb_key_accept_encoding;
127 const pb_key *pb_key_accept_language;
128 const pb_key *pb_key_accept_ranges;
129 const pb_key *pb_key_actual_route;
130 const pb_key *pb_key_age;
131 const pb_key *pb_key_always_allow_chunked;
132 const pb_key *pb_key_always_use_keep_alive;
133 const pb_key *pb_key_auth_cert;
134 const pb_key *pb_key_auth_expiring;
135 const pb_key *pb_key_auth_group;
136 const pb_key *pb_key_auth_type;
137 const pb_key *pb_key_auth_user;
138 const pb_key *pb_key_authorization;
139 const pb_key *pb_key_browser;
140 const pb_key *pb_key_c2p_cl;
141 const pb_key *pb_key_c2p_hl;
142 const pb_key *pb_key_cache_info;
143 const pb_key *pb_key_charset;
144 const pb_key *pb_key_check_http_server;
145 const pb_key *pb_key_ChunkedRequestBufferSize;
146 const pb_key *pb_key_ChunkedRequestTimeout;
147 const pb_key *pb_key_cipher;
148 const pb_key *pb_key_clf_request;
149 const pb_key *pb_key_cli_status;
150 const pb_key *pb_key_client_cert_nickname;
151 const pb_key *pb_key_client_ip;
152 const pb_key *pb_key_close;
153 const pb_key *pb_key_connect_timeout;
154 const pb_key *pb_key_connection;
155 const pb_key *pb_key_cont;
156 const pb_key *pb_key_content_encoding;
157 const pb_key *pb_key_content_language;
158 const pb_key *pb_key_content_length;
159 const pb_key *pb_key_content_location;
160 const pb_key *pb_key_content_md5;
161 const pb_key *pb_key_content_range;
162 const pb_key *pb_key_content_type;
163 const pb_key *pb_key_cookie;
164 const pb_key *pb_key_date;
165 const pb_key *pb_key_DATE_GMT;
166 const pb_key *pb_key_DATE_LOCAL;
167 const pb_key *pb_key_dir;
168 const pb_key *pb_key_Directive;
169 const pb_key *pb_key_dns;
170 const pb_key *pb_key_DOCUMENT_NAME;
171 const pb_key *pb_key_DOCUMENT_URI;
172 const pb_key *pb_key_domain;
173 const pb_key *pb_key_enc;
174 const pb_key *pb_key_engine;
175 const pb_key *pb_key_error_action;
176 const pb_key *pb_key_error_desc;
177 const pb_key *pb_key_error_fn;
178 const pb_key *pb_key_escape;
179 const pb_key *pb_key_escaped;
180 const pb_key *pb_key_etag;
181 const pb_key *pb_key_expect;
182 const pb_key *pb_key_expires;
183 const pb_key *pb_key_expr;
184 const pb_key *pb_key_filter;
185 const pb_key *pb_key_find_pathinfo_forward;
186 const pb_key *pb_key_flushTimer;
187 const pb_key *pb_key_fn;
188 const pb_key *pb_key_from;
189 const pb_key *pb_key_full_headers;
190 const pb_key *pb_key_hdr;
191 const pb_key *pb_key_host;
192 const pb_key *pb_key_hostname;
193 const pb_key *pb_key_if_match;
194 const pb_key *pb_key_if_modified_since;
195 const pb_key *pb_key_if_none_match;
196 const pb_key *pb_key_if_range;
197 const pb_key *pb_key_if_unmodified_since;
198 const pb_key *pb_key_ip;
199 const pb_key *pb_key_iponly;
200 const pb_key *pb_key_issuer_dn;
201 const pb_key *pb_key_jroute;
202 const pb_key *pb_key_keep_alive;
203 const pb_key *pb_key_keep_alive_timeout;
204 const pb_key *pb_key_keysize;
205 const pb_key *pb_key_lang;
206 const pb_key *pb_key_last_modified;
207 const pb_key *pb_key_level;
208 const pb_key *pb_key_location;
209 const pb_key *pb_key_lock_owner;
210 const pb_key *pb_key_magnus_charset;
211 const pb_key *pb_key_magnus_internal;
212 const pb_key *pb_key_magnus_internal_dav_src;
213 const pb_key *pb_key_magnus_internal_default_acls_only;
214 const pb_key *pb_key_magnus_internal_error_j2ee;
215 const pb_key *pb_key_magnus_internal_j2ee_nsapi;
216 const pb_key *pb_key_magnus_internal_preserve_srvhdrs;
217 const pb_key *pb_key_magnus_internal_set_request_status;
218 const pb_key *pb_key_magnus_internal_set_response_status;
219 const pb_key *pb_key_magnus_internal_webapp_errordesc;
220 const pb_key *pb_key_matched_browser;
221 const pb_key *pb_key_max_age;
222 const pb_key *pb_key_max_forwards;
223 const pb_key *pb_key_message;
224 const pb_key *pb_key_method;
225 const pb_key *pb_key_name;
226 const pb_key *pb_key_nocache;
227 const pb_key *pb_key_nostat;
228 const pb_key *pb_key_ntrans_base;
229 const pb_key *pb_key_offline_origin_addr;
230 const pb_key *pb_key_offline_proxy_addr;
231 const pb_key *pb_key_origin_addr;
232 const pb_key *pb_key_p2c_cl;
233 const pb_key *pb_key_p2c_hl;
234 const pb_key *pb_key_p2r_cl;
235 const pb_key *pb_key_p2r_hl;
236 const pb_key *pb_key_parse_timeout;
237 const pb_key *pb_key_password;
238 const pb_key *pb_key_path;
239 const pb_key *pb_key_PATH_INFO;
240 const pb_key *pb_key_path_info;
241 const pb_key *pb_key_pblock;
242 const pb_key *pb_key_poll_interval;
243 const pb_key *pb_key_pool;
244 const pb_key *pb_key_port;
245 const pb_key *pb_key_ppath;
246 const pb_key *pb_key_pragma;
247 const pb_key *pb_key_process_request_body;
248 const pb_key *pb_key_process_response_body;
249 const pb_key *pb_key_protocol;
250 const pb_key *pb_key_proxy_addr;
251 const pb_key *pb_key_proxy_agent;
252 const pb_key *pb_key_proxy_auth_cert;
253 const pb_key *pb_key_proxy_authorization;
254 const pb_key *pb_key_proxy_cipher;
255 const pb_key *pb_key_proxy_issuer_dn;
256 const pb_key *pb_key_proxy_jroute;
257 const pb_key *pb_key_proxy_keysize;
258 const pb_key *pb_key_proxy_ping;
259 const pb_key *pb_key_proxy_request;
260 const pb_key *pb_key_proxy_secret_keysize;
261 const pb_key *pb_key_proxy_ssl_id;
262 const pb_key *pb_key_proxy_user_dn;
263 const pb_key *pb_key_query;
264 const pb_key *pb_key_QUERY_STRING;
265 const pb_key *pb_key_QUERY_STRING_UNESCAPED;
266 const pb_key *pb_key_r2p_cl;
267 const pb_key *pb_key_r2p_hl;
268 const pb_key *pb_key_range;
269 const pb_key *pb_key_referer;
270 const pb_key *pb_key_reformat_request_headers;
271 const pb_key *pb_key_remote_status;
272 const pb_key *pb_key_request_jroute;
273 const pb_key *pb_key_required_rights;
274 const pb_key *pb_key_retries;
275 const pb_key *pb_key_rewrite_content_location;
276 const pb_key *pb_key_rewrite_host;
277 const pb_key *pb_key_rewrite_location;
278 const pb_key *pb_key_rewrite_set_cookie;
279 const pb_key *pb_key_root;
280 const pb_key *pb_key_route;
281 const pb_key *pb_key_route_cookie;
282 const pb_key *pb_key_route_hdr;
283 const pb_key *pb_key_route_offline;
284 const pb_key *pb_key_script_name;
285 const pb_key *pb_key_secret_keysize;
286 const pb_key *pb_key_secure;
287 const pb_key *pb_key_server;
288 const pb_key *pb_key_set_cookie;
289 const pb_key *pb_key_socks_addr;
290 const pb_key *pb_key_ssl_id;
291 const pb_key *pb_key_ssl_unclean_shutdown;
292 const pb_key *pb_key_status;
293 const pb_key *pb_key_sticky_cookie;
294 const pb_key *pb_key_sticky_param;
295 const pb_key *pb_key_suppress_request_headers;
296 const pb_key *pb_key_svr_status;
297 const pb_key *pb_key_timeout;
298 const pb_key *pb_key_to;
299 const pb_key *pb_key_transfer_encoding;
300 const pb_key *pb_key_transmit_timeout;
301 const pb_key *pb_key_tunnel_non_http_response;
302 const pb_key *pb_key_type;
303 const pb_key *pb_key_upstream_jroute;
304 const pb_key *pb_key_uri;
305 const pb_key *pb_key_url;
306 const pb_key *pb_key_url_prefix;
307 const pb_key *pb_key_UseOutputStreamSize;
308 const pb_key *pb_key_user;
309 const pb_key *pb_key_user_agent;
310 const pb_key *pb_key_user_dn;
311 const pb_key *pb_key_validate_server_cert;
312 const pb_key *pb_key_value;
313 const pb_key *pb_key_vary;
314 const pb_key *pb_key_via;
315 const pb_key *pb_key_warning;
316 const pb_key *pb_key_depth;
317 const pb_key *pb_key_if;
318 const pb_key *pb_key_vfs;
319 const pb_key *pb_key_dav;
320 const pb_key *pb_key_vfsclass;
321 const pb_key *pb_key_davclass;
322
323 NSAPI_PUBLIC void pblock_init_default_keys(
void) {
324 pb_key_accept = _create_key(
"accept");
325 pb_key_accept_charset = _create_key(
"accept-charset");
326 pb_key_accept_encoding = _create_key(
"accept-encoding");
327 pb_key_accept_language = _create_key(
"accept-language");
328 pb_key_accept_ranges = _create_key(
"accept-ranges");
329 pb_key_actual_route = _create_key(
"actual-route");
330 pb_key_age = _create_key(
"age");
331 pb_key_always_allow_chunked = _create_key(
"always-allow-chunked");
332 pb_key_always_use_keep_alive = _create_key(
"always-use-keep-alive");
333 pb_key_auth_cert = _create_key(
"auth-cert");
334 pb_key_auth_expiring = _create_key(
"auth-expiring");
335 pb_key_auth_group = _create_key(
"auth-group");
336 pb_key_auth_type = _create_key(
"auth-type");
337 pb_key_auth_user = _create_key(
"auth-user");
338 pb_key_authorization = _create_key(
"authorization");
339 pb_key_browser = _create_key(
"browser");
340 pb_key_c2p_cl = _create_key(
"c2p-cl");
341 pb_key_c2p_hl = _create_key(
"c2p-hl");
342 pb_key_cache_info = _create_key(
"cache-info");
343 pb_key_charset = _create_key(
"charset");
344 pb_key_check_http_server = _create_key(
"check-http-server");
345 pb_key_ChunkedRequestBufferSize = _create_key(
"ChunkedRequestBufferSize");
346 pb_key_ChunkedRequestTimeout = _create_key(
"ChunkedRequestTimeout");
347 pb_key_cipher = _create_key(
"cipher");
348 pb_key_clf_request = _create_key(
"clf-request");
349 pb_key_cli_status = _create_key(
"cli-status");
350 pb_key_client_cert_nickname = _create_key(
"client-cert-nickname");
351 pb_key_client_ip = _create_key(
"client-ip");
352 pb_key_close = _create_key(
"close");
353 pb_key_connect_timeout = _create_key(
"connect-timeout");
354 pb_key_connection = _create_key(
"connection");
355 pb_key_cont = _create_key(
"cont");
356 pb_key_content_encoding = _create_key(
"content-encoding");
357 pb_key_content_language = _create_key(
"content-language");
358 pb_key_content_length = _create_key(
"content-length");
359 pb_key_content_location = _create_key(
"content-location");
360 pb_key_content_md5 = _create_key(
"content-md5");
361 pb_key_content_range = _create_key(
"content-range");
362 pb_key_content_type = _create_key(
"content-type");
363 pb_key_cookie = _create_key(
"cookie");
364 pb_key_date = _create_key(
"date");
365 pb_key_DATE_GMT = _create_key(
"DATE_GMT");
366 pb_key_DATE_LOCAL = _create_key(
"DATE_LOCAL");
367 pb_key_dir = _create_key(
"dir");
368 pb_key_Directive = _create_key(
"Directive");
369 pb_key_dns = _create_key(
"dns");
370 pb_key_DOCUMENT_NAME = _create_key(
"DOCUMENT_NAME");
371 pb_key_DOCUMENT_URI = _create_key(
"DOCUMENT_URI");
372 pb_key_domain = _create_key(
"domain");
373 pb_key_enc = _create_key(
"enc");
374 pb_key_engine = _create_key(
"engine");
375 pb_key_error_action = _create_key(
"error-action");
376 pb_key_error_desc = _create_key(
"error-desc");
377 pb_key_error_fn = _create_key(
"error-fn");
378 pb_key_escape = _create_key(
"escape");
379 pb_key_escaped = _create_key(
"escaped");
380 pb_key_etag = _create_key(
"etag");
381 pb_key_expect = _create_key(
"expect");
382 pb_key_expires = _create_key(
"expires");
383 pb_key_expr = _create_key(
"expr");
384 pb_key_filter = _create_key(
"filter");
385 pb_key_find_pathinfo_forward = _create_key(
"find-pathinfo-forward");
386 pb_key_flushTimer = _create_key(
"flushTimer");
387 pb_key_fn = _create_key(
"fn");
388 pb_key_from = _create_key(
"from");
389 pb_key_full_headers = _create_key(
"full-headers");
390 pb_key_hdr = _create_key(
"hdr");
391 pb_key_host = _create_key(
"host");
392 pb_key_hostname = _create_key(
"hostname");
393 pb_key_if_match = _create_key(
"if-match");
394 pb_key_if_modified_since = _create_key(
"if-modified-since");
395 pb_key_if_none_match = _create_key(
"if-none-match");
396 pb_key_if_range = _create_key(
"if-range");
397 pb_key_if_unmodified_since = _create_key(
"if-unmodified-since");
398 pb_key_ip = _create_key(
"ip");
399 pb_key_iponly = _create_key(
"iponly");
400 pb_key_issuer_dn = _create_key(
"issuer_dn");
401 pb_key_jroute = _create_key(
"jroute");
402 pb_key_keep_alive = _create_key(
"keep-alive");
403 pb_key_keep_alive_timeout = _create_key(
"keep-alive-timeout");
404 pb_key_keysize = _create_key(
"keysize");
405 pb_key_lang = _create_key(
"lang");
406 pb_key_last_modified = _create_key(
"last-modified");
407 pb_key_level = _create_key(
"level");
408 pb_key_location = _create_key(
"location");
409 pb_key_lock_owner = _create_key(
"lock-owner");
410 pb_key_magnus_charset = _create_key(
"magnus-charset");
411 pb_key_magnus_internal = _create_key(
"magnus-internal");
412 pb_key_magnus_internal_dav_src = _create_key(
"magnus-internal/dav-src");
413 pb_key_magnus_internal_default_acls_only = _create_key(
"magnus-internal/default-acls-only");
414 pb_key_magnus_internal_error_j2ee = _create_key(
"magnus-internal/error-j2ee");
415 pb_key_magnus_internal_j2ee_nsapi = _create_key(
"magnus-internal/j2ee-nsapi");
416 pb_key_magnus_internal_preserve_srvhdrs = _create_key(
"magnus-internal/preserve-srvhdrs-after-req-restart");
417 pb_key_magnus_internal_set_request_status = _create_key(
"magnus-internal/set-request-status");
418 pb_key_magnus_internal_set_response_status = _create_key(
"magnus-internal/set-response-status");
419 pb_key_magnus_internal_webapp_errordesc = _create_key(
"magnus-internal/webapp-errordesc");
420 pb_key_matched_browser = _create_key(
"matched-browser");
421 pb_key_max_age = _create_key(
"max-age");
422 pb_key_max_forwards = _create_key(
"max-forwards");
423 pb_key_message = _create_key(
"message");
424 pb_key_method = _create_key(
"method");
425 pb_key_name = _create_key(
"name");
426 pb_key_nocache = _create_key(
"nocache");
427 pb_key_nostat = _create_key(
"nostat");
428 pb_key_ntrans_base = _create_key(
"ntrans-base");
429 pb_key_offline_origin_addr = _create_key(
"offline-origin-addr");
430 pb_key_offline_proxy_addr = _create_key(
"offline-proxy-addr");
431 pb_key_origin_addr = _create_key(
"origin-addr");
432 pb_key_p2c_cl = _create_key(
"p2c-cl");
433 pb_key_p2c_hl = _create_key(
"p2c-hl");
434 pb_key_p2r_cl = _create_key(
"p2r-cl");
435 pb_key_p2r_hl = _create_key(
"p2r-hl");
436 pb_key_parse_timeout = _create_key(
"parse-timeout");
437 pb_key_password = _create_key(
"password");
438 pb_key_path = _create_key(
"path");
439 pb_key_PATH_INFO = _create_key(
"PATH_INFO");
440 pb_key_path_info = _create_key(
"path-info");
441 pb_key_pblock = _create_key(
"pblock");
442 pb_key_poll_interval = _create_key(
"poll-interval");
443 pb_key_pool = _create_key(
"pool");
444 pb_key_port = _create_key(
"port");
445 pb_key_ppath = _create_key(
"ppath");
446 pb_key_pragma = _create_key(
"pragma");
447 pb_key_process_request_body = _create_key(
"process-request-body");
448 pb_key_process_response_body = _create_key(
"process-response-body");
449 pb_key_protocol = _create_key(
"protocol");
450 pb_key_proxy_addr = _create_key(
"proxy-addr");
451 pb_key_proxy_agent = _create_key(
"proxy-agent");
452 pb_key_proxy_auth_cert = _create_key(
"proxy-auth-cert");
453 pb_key_proxy_authorization = _create_key(
"proxy-authorization");
454 pb_key_proxy_cipher = _create_key(
"proxy-cipher");
455 pb_key_proxy_issuer_dn = _create_key(
"proxy-issuer-dn");
456 pb_key_proxy_jroute = _create_key(
"proxy-jroute");
457 pb_key_proxy_keysize = _create_key(
"proxy-keysize");
458 pb_key_proxy_ping = _create_key(
"proxy-ping");
459 pb_key_proxy_request = _create_key(
"proxy-request");
460 pb_key_proxy_secret_keysize = _create_key(
"proxy-secret-keysize");
461 pb_key_proxy_ssl_id = _create_key(
"proxy-ssl-id");
462 pb_key_proxy_user_dn = _create_key(
"proxy-user-dn");
463 pb_key_query = _create_key(
"query");
464 pb_key_QUERY_STRING = _create_key(
"QUERY_STRING");
465 pb_key_QUERY_STRING_UNESCAPED = _create_key(
"QUERY_STRING_UNESCAPED");
466 pb_key_r2p_cl = _create_key(
"r2p-cl");
467 pb_key_r2p_hl = _create_key(
"r2p-hl");
468 pb_key_range = _create_key(
"range");
469 pb_key_referer = _create_key(
"referer");
470 pb_key_reformat_request_headers = _create_key(
"reformat-request-headers");
471 pb_key_remote_status = _create_key(
"remote-status");
472 pb_key_request_jroute = _create_key(
"request-jroute");
473 pb_key_required_rights = _create_key(
"required-rights");
474 pb_key_retries = _create_key(
"retries");
475 pb_key_rewrite_content_location = _create_key(
"rewrite-content-location");
476 pb_key_rewrite_host = _create_key(
"rewrite-host");
477 pb_key_rewrite_location = _create_key(
"rewrite-location");
478 pb_key_rewrite_set_cookie = _create_key(
"rewrite-set-cookie");
479 pb_key_root = _create_key(
"root");
480 pb_key_route = _create_key(
"route");
481 pb_key_route_cookie = _create_key(
"route-cookie");
482 pb_key_route_hdr = _create_key(
"route-hdr");
483 pb_key_route_offline = _create_key(
"route-offline");
484 pb_key_script_name = _create_key(
"script-name");
485 pb_key_secret_keysize = _create_key(
"secret-keysize");
486 pb_key_secure = _create_key(
"secure");
487 pb_key_server = _create_key(
"server");
488 pb_key_set_cookie = _create_key(
"set-cookie");
489 pb_key_socks_addr = _create_key(
"socks_addr");
490 pb_key_ssl_id = _create_key(
"ssl-id");
491 pb_key_ssl_unclean_shutdown = _create_key(
"ssl-unclean-shutdown");
492 pb_key_status = _create_key(
"status");
493 pb_key_sticky_cookie = _create_key(
"sticky-cookie");
494 pb_key_sticky_param = _create_key(
"sticky-param");
495 pb_key_suppress_request_headers = _create_key(
"suppress-request-headers");
496 pb_key_svr_status = _create_key(
"svr-status");
497 pb_key_timeout = _create_key(
"timeout");
498 pb_key_to = _create_key(
"to");
499 pb_key_transfer_encoding = _create_key(
"transfer-encoding");
500 pb_key_transmit_timeout = _create_key(
"transmit-timeout");
501 pb_key_tunnel_non_http_response = _create_key(
"tunnel-non-http-response");
502 pb_key_type = _create_key(
"type");
503 pb_key_upstream_jroute = _create_key(
"upstream-jroute");
504 pb_key_uri = _create_key(
"uri");
505 pb_key_url = _create_key(
"url");
506 pb_key_url_prefix = _create_key(
"url-prefix");
507 pb_key_UseOutputStreamSize = _create_key(
"UseOutputStreamSize");
508 pb_key_user = _create_key(
"user");
509 pb_key_user_agent = _create_key(
"user-agent");
510 pb_key_user_dn = _create_key(
"user_dn");
511 pb_key_validate_server_cert = _create_key(
"validate-server-cert");
512 pb_key_value = _create_key(
"value");
513 pb_key_vary = _create_key(
"vary");
514 pb_key_via = _create_key(
"via");
515 pb_key_warning = _create_key(
"warning");
516 pb_key_depth = _create_key(
"depth");
517 pb_key_if = _create_key(
"if");
518 pb_key_vfs = _create_key(
"vfs");
519 pb_key_dav = _create_key(
"dav");
520 pb_key_vfsclass = _create_key(
"vfsclass");
521 pb_key_davclass = _create_key(
"davclass");
522 }
523
524 NSAPI_PUBLIC void pblock_free_default_keys(
void) {
525 for (
unsigned i =
0 ; i <
PB_KEY_LIST_BUCKET_COUNT ; i++) {
526 unsigned count = _pbKeys.buckets[i].size;
527 if (count >
0) {
528 pb_key **keys = _pbKeys.buckets[i].elements;
529 for (
unsigned j =
0 ; j < count ; j++) {
530 pb_key *key = keys[j];
531 if(key) {
532 free((
char*)key->name);
533 free(key);
534 }
535 }
536 free(keys);
537 }
538 }
539 }
540
541
542
543 static inline
const pb_key *_find_key(
const char *name,
unsigned int hashval)
544 {
545
546 struct pb_key_list_bucket *bucket = &_pbKeys.buckets[hashval &
PB_KEY_LIST_BUCKET_COUNT];
547 for (
unsigned i =
0 ; i < bucket->size ; i++) {
548 pb_key *key = bucket->elements[i];
549 if (key->hashval == hashval && !strcmp(key->name, name)) {
550 return key;
551 }
552 }
553 return NULL;
554 }
555
556
557
558
559 static inline
int _get_hash_index(
const PListStruct_t *pl,
const pb_key *key)
560 {
561
562 int i;
563 if (key->sizendx == pl->pl_symtab->pt_sizendx)
564 i = key->hashndx;
565 else
566 i = key->hashval %
PLSIZENDX(pl->pl_symtab->pt_sizendx);
567 return i;
568 }
569
570
571
572
573 static inline pb_param *_param_create(
pool_handle_t *pool_handle,
const char *name,
int namelen,
const char *value,
int valuelen)
574 {
575 PLValueStruct_t *ret;
576
577 ret = (
PLValueStruct_t *)pool_malloc(pool_handle,
sizeof(
PLValueStruct_t));
578
579 ret->pv_pbentry.param = &ret->pv_pbparam;
580 ret->pv_pbentry.next =
0;
581 ret->pv_next =
0;
582 ret->pv_type =
0;
583 ret->pv_mempool = pool_handle;
584
585 if (name || namelen) {
586 ret->pv_name = (
char*)pool_malloc(pool_handle, namelen +
1);
587 if (name) {
588 memcpy(ret->pv_name, name, namelen);
589 ret->pv_name[namelen] =
'\0';
590 }
else {
591 ret->pv_name[
0] =
'\0';
592 }
593 }
else {
594 ret->pv_name =
0;
595 }
596
597 if (value || valuelen) {
598 ret->pv_value = (
char*)pool_malloc(pool_handle, valuelen +
1);
599 if (value) {
600 memcpy(ret->pv_value, value, valuelen);
601 ret->pv_value[valuelen] =
'\0';
602 }
else {
603 ret->pv_value[
0] =
'\0';
604 }
605 }
else {
606 ret->pv_value =
0;
607 }
608
609 return &ret->pv_pbparam;
610 }
611
612
613
614
615 NSAPI_PUBLIC pb_param *pblock_key_param_create(pblock *pb,
const pb_key *key,
const char *value,
int valuelen)
616 {
617
618
619
620 PListStruct_t *pl =
PBTOPL(pb);
621 return _param_create(pl->pl_mempool, key->name, key->namelen, value, valuelen);
622 }
623
624
625
626
627 NSAPI_PUBLIC pb_param *pblock_param_create(pblock *pb,
const char *name,
const char *value)
628 {
629
630
631
632 PListStruct_t *pl =
PBTOPL(pb);
633 return _param_create(pl->pl_mempool, name, name ? strlen(name) :
0, value, value ? strlen(value) :
0);
634 }
635
636
637
638
639 NSAPI_PUBLIC pb_param *param_create(
const char *name,
const char *value)
640 {
641
642
643
644
645
646
647
648 return _param_create(system_pool(), name, name ? strlen(name) :
0, value, value ? strlen(value) :
0);
649 }
650
651
652
653
654 NSAPI_PUBLIC int param_free(pb_param *pp)
655 {
656 if (pp) {
657 PLValueStruct_t *pv =
PATOPV(pp);
658
659
660 if (!pv->pv_mempool) {
661 pool_free(pv->pv_mempool, pv->pv_name);
662 pool_free(pv->pv_mempool, pv->pv_value);
663 pool_free(pv->pv_mempool, pv);
664 }
665
666 return 1;
667 }
668
669 return 0;
670 }
671
672
673
674
675 NSAPI_PUBLIC pblock *pblock_create_pool(
pool_handle_t *pool_handle,
int n)
676 {
677
678 PListStruct_t *plist = (
PListStruct_t *)PListCreate(pool_handle, n,
0,
0);
679 if (!plist)
680 return NULL;
681
682 plist->pl_resvpi =
0;
683
684 return &plist->pl_pb;
685 }
686
687
688
689
690 NSAPI_PUBLIC pool_handle_t *pblock_pool(pblock *pb)
691 {
692 PListStruct_t *pl =
PBTOPL(pb);
693 return pl->pl_mempool;
694 }
695
696
697
698
699 NSAPI_PUBLIC pblock *pblock_create(
int n)
700 {
701 return pblock_create_pool(
MALLOC_POOL_HANDLE, n);
702 }
703
704
705
706
707 NSAPI_PUBLIC void pblock_free(pblock *pb)
708 {
709 PListStruct_t *pl =
PBTOPL(pb);
710 PLValueStruct_t **ppval;
711 PLValueStruct_t *pv;
712 int i;
713
714 if (!pb) {
715 return;
716 }
717
718
719
720
721 if (pl->pl_mempool || pool_enabled()) {
722 return;
723 }
724
725
726 if (pl->pl_symtab) {
727 pool_free(pl->pl_mempool, (
void *)(pl->pl_symtab));
728 }
729
730 ppval = (
PLValueStruct_t **)(pl->pl_ppval);
731
732
733 for (i =
0; i < pl->pl_initpi; ++i) {
734
735
736 pv = ppval[i];
737 if (pv) {
738
739 param_free(&pv->pv_pbparam);
740 }
741 }
742
743
744 pool_free(pl->pl_mempool, (
void *)ppval);
745
746
747 pool_free(pl->pl_mempool, (
void *)pl);
748 }
749
750
751
752
753 NSAPI_PUBLIC const pb_key *pblock_key(
const char *name)
754 {
755 if (!name)
756 return NULL;
757
758 return _find_key(name, PListHash(name));
759 }
760
761
762
763
764 NSAPI_PUBLIC void pblock_kpinsert(
const pb_key *key, pb_param *pp, pblock *pb)
765 {
766 PListStruct_t *pl =
PBTOPL(pb);
767 PLValueStruct_t *pv =
PATOPV(pp);
768
769
770
771
772 unsigned int hashval;
773 if (!key) {
774 hashval = PListHash(pv->pv_name);
775 key = _find_key(pv->pv_name, hashval);
776 }
777
778
779 int pindex = PListGetFreeIndex(pl);
780 if (pindex <
1) {
781
782 printf(
"Error - invalid property index\n");
783 return;
784 }
785
786
787 PLSymbolTable_t *pt = PListSymbolTable(pl);
788 if (!pt) {
789 printf(
"!pt\n");
790 return;
791 }
792
793
794 PLValueStruct_t **ppval = (
PLValueStruct_t **)(pl->pl_ppval);
795 pv->pv_pbkey = key;
796 pv->pv_pi = pindex;
797 ppval[pv->pv_pi -
1] = pv;
798
799
800 int i = key ? _get_hash_index(pl, key) : (hashval %
PLSIZENDX(pt->pt_sizendx));
801 pv->pv_next = pt->pt_hash[i];
802 pt->pt_hash[i] = pv;
803 pt->pt_nsyms++;
804
805
806 }
807
808
809
810
811 NSAPI_PUBLIC void pblock_pinsert(pb_param *pp, pblock *pb)
812 {
813 pblock_kpinsert(
NULL, pp, pb);
814 }
815
816
817
818
819 NSAPI_PUBLIC pb_param *pblock_nvinsert(
const char *name,
const char *value, pblock *pb)
820 {
821 pb_param *pp = pblock_param_create(pb, name, value);
822 if (pp)
823 pblock_kpinsert(
NULL, pp, pb);
824 return pp;
825 }
826
827
828
829
830 NSAPI_PUBLIC pb_param *pblock_kvinsert(
const pb_key *key,
const char *value,
int valuelen, pblock *pb)
831 {
832 pb_param *pp = pblock_key_param_create(pb, key, value, valuelen);
833 if (pp)
834 pblock_kpinsert(key, pp, pb);
835 return pp;
836 }
837
838
839
840
841 NSAPI_PUBLIC pb_param *pblock_nninsert(
const char *name,
int value, pblock *pb)
842 {
843 char num[
UTIL_ITOA_SIZE];
844
845 util_itoa(value, num);
846 return pblock_nvinsert(name, num, pb);
847 }
848
849
850
851
852 NSAPI_PUBLIC pb_param *pblock_kninsert(
const pb_key *key,
int value, pblock *pb)
853 {
854 pb_param *pp = pblock_key_param_create(pb, key,
NULL,
UTIL_ITOA_SIZE);
855 if (pp) {
856 util_itoa(value, pp->value);
857 pblock_kpinsert(key, pp, pb);
858 }
859 return pp;
860 }
861
862
863
864
865 NSAPI_PUBLIC pb_param *pblock_kllinsert(
const pb_key *key,
int64_t value, pblock *pb)
866 {
867 pb_param *pp = pblock_key_param_create(pb, key,
NULL,
UTIL_I64TOA_SIZE);
868 if (pp) {
869 util_i64toa(value, pp->value);
870 pblock_kpinsert(key, pp, pb);
871 }
872 return pp;
873 }
874
875
876
877
878 NSAPI_PUBLIC pb_param *pblock_nvlinsert(
const char *name,
int namelen,
const char *value,
int valuelen, pblock *pb)
879 {
880 PListStruct_t *pl =
PBTOPL(pb);
881
882 pb_param *pp = _param_create(pl->pl_mempool, name, namelen, value, valuelen);
883
884 if(pp) {
885 pblock_kpinsert(
NULL, pp, pb);
886 }
887
888 return pp;
889 }
890
891
892
893
894 NSAPI_PUBLIC pb_param *pblock_findkey(
const pb_key *key,
const pblock *pb)
895 {
896 PListStruct_t *pl =
PBTOPL(pb);
897
898
899 if (pl->pl_symtab) {
900 int i = _get_hash_index(pl, key);
901 PLValueStruct_t *pv;
902
903
904 for (pv = pl->pl_symtab->pt_hash[i]; pv; pv = pv->pv_next) {
905 if (pv->pv_pbkey == key)
906 return &pv->pv_pbparam;
907 }
908 }
909
910 return NULL;
911 }
912
913
914
915
916 NSAPI_PUBLIC char *pblock_findkeyval(
const pb_key *key,
const pblock *pb)
917 {
918 pb_param *pp = pblock_findkey(key, pb);
919 return pp ? pp->value :
NULL;
920 }
921
922
923
924
925 NSAPI_PUBLIC char *pblock_findval(
const char *name,
const pblock *pb)
926 {
927 void *pvalue =
0;
928
929 (
void)PListFindValue((
PList_t)(
PBTOPL(pb)), name, &pvalue,
0);
930
931 return (
char *)pvalue;
932 }
933
934
935
936
937 NSAPI_PUBLIC pb_param *pblock_fr(
const char *name, pblock *pb,
int remove)
938 {
939 PListStruct_t *pl =
PBTOPL(pb);
940 PLValueStruct_t **ppval;
941 PLValueStruct_t **pvp;
942 PLValueStruct_t *pv =
NULL;
943 int pindex;
944 int i;
945
946 if (pl->pl_symtab) {
947
948
949 i = PListHashName(pl->pl_symtab, name);
950
951
952 for (pvp = &pl->pl_symtab->pt_hash[i];
953 (pv = *pvp); pvp = &(*pvp)->pv_next) {
954
955 if (!strcmp(name, pv->pv_name)) {
956
957 if (remove) {
958
959 *pvp = pv->pv_next;
960 pl->pl_symtab->pt_nsyms--;
961
962
963 ppval = (
PLValueStruct_t **)(pl->pl_ppval);
964 pindex = pv->pv_pi;
965 ppval[pindex -
1] =
0;
966 }
967 break;
968 }
969 }
970 }
971
972 return (pv) ? &pv->pv_pbparam :
NULL;
973 }
974
975
976
977
978 NSAPI_PUBLIC pb_param *pblock_removekey(
const pb_key *key, pblock *pb)
979 {
980 PListStruct_t *pl =
PBTOPL(pb);
981 PLValueStruct_t **ppval;
982 PLValueStruct_t **pvp;
983 PLValueStruct_t *pv =
NULL;
984 int pindex;
985 int i;
986
987 if (pl->pl_symtab) {
988
989 i = _get_hash_index(pl, key);
990
991
992 for (pvp = &pl->pl_symtab->pt_hash[i]; (pv = *pvp); pvp = &pv->pv_next) {
993
994 if (pv->pv_pbkey == key) {
995
996 *pvp = pv->pv_next;
997 pl->pl_symtab->pt_nsyms--;
998
999
1000 ppval = (
PLValueStruct_t **)(pl->pl_ppval);
1001 pindex = pv->pv_pi;
1002 ppval[pindex -
1] =
0;
1003
1004 break;
1005 }
1006 }
1007 }
1008
1009 return (pv) ? &pv->pv_pbparam :
NULL;
1010 }
1011
1012
1013
1014
1015 NSAPI_PUBLIC pb_param *pblock_removeone(pblock *pb)
1016 {
1017 PListStruct_t *pl =
PBTOPL(pb);
1018
1019 if (pl && pl->pl_symtab) {
1020
1021 for (
int i =
0; i <
PLSIZENDX(pl->pl_symtab->pt_sizendx); i++) {
1022
1023 PLValueStruct_t *pv = pl->pl_symtab->pt_hash[i];
1024 if (pv) {
1025
1026 pl->pl_symtab->pt_hash[i] = pv->pv_next;
1027 pl->pl_symtab->pt_nsyms--;
1028
1029
1030 PLValueStruct_t **ppval = (
PLValueStruct_t**)pl->pl_ppval;
1031 ppval[pv->pv_pi -
1] =
0;
1032
1033 return &pv->pv_pbparam;
1034 }
1035 }
1036 }
1037
1038 return NULL;
1039 }
1040
1041
1042
1043
1044
1045 int _verify_pbstr(
const char *str)
1046 {
1047 const char *cp;
1048 const char *scp;
1049 int np;
1050 int state;
1051 int quote;
1052
1053 for(cp = str, np =
0, state =
0; *cp; ) {
1054 switch (state) {
1055 case 0:
1056
1057 while (*cp && isspace(*cp)) ++cp;
1058 if (*cp ==
'=') {
1059 return -
1;
1060 }
1061 if (*cp) state =
1;
1062 break;
1063
1064 case 1:
1065
1066 scp = cp;
1067 while (*cp && (*cp !=
'=') && !isspace(*cp)) ++cp;
1068 if (*cp ==
'=') ++cp;
1069 else cp = scp;
1070 state =
2;
1071 break;
1072
1073 case 2:
1074 quote =
0;
1075 if (*cp ==
'\"') {
1076 quote =
1;
1077 ++cp;
1078 }
1079 for (;;) {
1080 if (*cp ==
'\\') {
1081 ++cp;
1082 if (*cp ==
0) {
1083 return -
1;
1084 }
1085 }
1086 else if (*cp ==
'\"') {
1087 if (!quote) {
1088 return -
1;
1089 }
1090 ++np;
1091 ++cp;
1092 quote =
0;
1093 state =
0;
1094 break;
1095 }
1096 else if (!quote && (!*cp || isspace(*cp))) {
1097 ++np;
1098 if (*cp) ++cp;
1099 state =
0;
1100 break;
1101 }
1102 else if (*cp ==
0) {
1103 return -
1;
1104 }
1105 ++cp;
1106 }
1107 if (quote) {
1108 return -
1;
1109 }
1110 break;
1111 }
1112 }
1113
1114 return (state ==
0) ? np : -
1;
1115 }
1116
1117 NSAPI_PUBLIC int
1118 INTpblock_str2pblock_lowercasename(
const char *str, pblock *pb)
1119 {
1120 return _pblock_str2pblock(str, pb,
PR_TRUE);
1121 }
1122
1123 NSAPI_PUBLIC int pblock_str2pblock(
const char *str, pblock *pb)
1124 {
1125 return _pblock_str2pblock(str, pb,
PR_FALSE);
1126 }
1127
1128 int
1129 _pblock_str2pblock(
const char* str, pblock* pb, PRBool lowerCase)
1130 {
1131 char *cpy;
1132 char *cp;
1133 char *dp;
1134 char *pname;
1135 char *pvalue;
1136 int np;
1137 int quote;
1138 int state;
1139 char numbuf[
UTIL_ITOA_SIZE];
1140
1141 if((np = _verify_pbstr(str)) <
1)
1142 return -
1;
1143
1144 while (*str && isspace(*str)) ++str;
1145
1146 cpy =
STRDUP(str);
1147
1148 for (np =
0, cp = cpy, state =
0; *cp; ) {
1149 switch (state) {
1150
1151 case 0:
1152
1153 while (*cp && isspace(*cp)) ++cp;
1154 if (*cp) state =
1;
1155 break;
1156
1157 case 1:
1158
1159 pname = cp;
1160 while (*cp && (*cp !=
'=') && !isspace(*cp)) ++cp;
1161 if (*cp ==
'=') {
1162 *cp++ =
0;
1163 }
1164 else {
1165 cp = pname;
1166 pname = numbuf;
1167 util_itoa(np+
1, numbuf);
1168 }
1169 state =
2;
1170 break;
1171
1172 case 2:
1173 quote =
0;
1174 if (*cp ==
'\"') {
1175 quote =
1;
1176 ++cp;
1177 }
1178 for (pvalue = cp, dp = cp; ; ++cp, ++dp) {
1179 if (*cp ==
'\\') {
1180 ++cp;
1181 }
1182 else if (*cp ==
'\"') {
1183 ++np;
1184 ++cp;
1185 *dp =
0;
1186 quote =
0;
1187 state =
0;
1188 break;
1189 }
1190 else if (!quote && ((*cp ==
0) || isspace(*cp))) {
1191 ++np;
1192 if (*cp !=
0) {
1193 ++cp;
1194 }
1195 *dp =
0;
1196 state =
0;
1197 break;
1198 }
1199 if (cp != dp) *dp = *cp;
1200 }
1201 if (lowerCase ==
PR_TRUE) {
1202 for (
char* p = pname; *p; p++) {
1203 *p = tolower(*p);
1204 }
1205 }
1206 pblock_nvinsert(pname, pvalue, pb);
1207 break;
1208 }
1209 }
1210
1211 FREE(cpy);
1212
1213 return np;
1214 }
1215
1216
1217
1218
1219
1220 NSAPI_PUBLIC char *pblock_pblock2str(
const pblock *pb,
char *str)
1221 {
1222 char *s = str, *t, *u;
1223 PListStruct_t *pl =
PBTOPL(pb);
1224 PLValueStruct_t **ppval;
1225 PLValueStruct_t *pv;
1226 int i;
1227 int sl;
1228 int xlen;
1229
1230 ppval = (
PLValueStruct_t **)(pl->pl_ppval);
1231
1232
1233 for (i =
0, xlen =
0; i < pl->pl_initpi; ++i) {
1234
1235
1236 pv = ppval[i];
1237 if (pv && pv->pv_name) {
1238
1239 int ln = strlen(pv->pv_name);
1240 int lv = strlen((
char *)(pv->pv_value));
1241
1242
1243 for (t = (
char *)(pv->pv_value); *t; ++t) {
1244 if ((*t ==
'\"') || (*t ==
'\\')) ++lv;
1245 }
1246
1247
1248 xlen += (ln + lv +
4);
1249 }
1250 }
1251
1252
1253 if (!s) {
1254 s = (
char *)
MALLOC(xlen);
1255 s[
0] =
'\0';
1256 t = &s[
0];
1257 sl = xlen;
1258 }
1259 else {
1260 sl = strlen(s);
1261 t = &s[sl];
1262 sl += xlen;
1263 s = (
char *)
REALLOC(s, sl);
1264 }
1265
1266
1267 for (i =
0; i < pl->pl_initpi; ++i) {
1268
1269
1270 pv = ppval[i];
1271 if (pv && pv->pv_name) {
1272
1273 if (t != s) *t++ =
' ';
1274
1275 for (u = pv->pv_name; *u; ) *t++ = *u++;
1276
1277 *t++ =
'=';
1278 *t++ =
'\"';
1279
1280 for (u = (
char *)(pv->pv_value); *u; ) {
1281 if ((*u ==
'\\') || (*u ==
'\"')) *t++ =
'\\';
1282 *t++ = *u++;
1283 }
1284
1285 *t++ =
'\"';
1286 *t =
'\0';
1287 }
1288 }
1289
1290 return s;
1291 }
1292
1293
1294
1295
1296
1297 NSAPI_PUBLIC int pblock_copy(
const pblock *src, pblock *dst)
1298 {
1299 PListStruct_t *pl =
PBTOPL(src);
1300 PLValueStruct_t **ppval;
1301 PLValueStruct_t *pv;
1302 int rv =
0;
1303 int i;
1304
1305 ppval = (
PLValueStruct_t **)(pl->pl_ppval);
1306
1307 for (i =
0; i < pl->pl_initpi; ++i) {
1308 pv = ppval[i];
1309 if (pv) {
1310 if (pv->pv_pbkey) {
1311 if (pv->pv_pbkey != pb_key_magnus_internal) {
1312 if (!pblock_kvinsert(pv->pv_pbkey, (
char *)(pv->pv_value), strlen(pv->pv_value), dst))
1313 rv = -
1;
1314 }
1315 }
else {
1316 if (!pblock_nvinsert(pv->pv_name, (
char *)(pv->pv_value), dst))
1317 rv = -
1;
1318 }
1319 }
1320 }
1321
1322 return rv;
1323 }
1324
1325
1326
1327 NSAPI_PUBLIC pblock *pblock_dup(
const pblock *src)
1328 {
1329 pblock *dst;
1330
1331 if (!src)
1332 return NULL;
1333
1334 if ( (dst = pblock_create(src->hsize)) )
1335 pblock_copy(src, dst);
1336
1337 return dst;
1338 }
1339
1340
1341
1342
1343
1344 NSAPI_PUBLIC char **pblock_pb2env(
const pblock *pb,
char **env)
1345 {
1346 PListStruct_t *pl =
PBTOPL(pb);
1347 PLValueStruct_t **ppval;
1348 PLValueStruct_t *pv;
1349 int i;
1350 int nval;
1351 int pos;
1352
1353
1354
1355 ppval = (
PLValueStruct_t **)(pl->pl_ppval);
1356
1357 for (i =
0, nval =
0; i < pl->pl_initpi; ++i) {
1358 if (ppval[i]) ++nval;
1359 }
1360
1361 env = util_env_create(env, nval, &pos);
1362
1363 for (i =
0; i < pl->pl_initpi; ++i) {
1364 pv = ppval[i];
1365 if (pv) {
1366 env[pos++] = util_env_str(pv->pv_name, (
char *)(pv->pv_value));
1367 }
1368 }
1369 env[pos] =
NULL;
1370
1371 return env;
1372 }
1373
1374
1375
1376
1377 NSAPI_PUBLIC char * pblock_replace(
const char *name,
1378 char * new_value, pblock *pb)
1379 {
1380 PListStruct_t *pl =
PBTOPL(pb);
1381
1382
1383 pb_param *pp = pblock_find(name, pb);
1384 if (!pp)
1385 return NULL;
1386 pool_free(pl->pl_mempool, pp->value);
1387 pp->value = new_value;
1388
1389 return new_value;
1390 }
1391
1392
1393
1394
1395 NSAPI_PUBLIC void pblock_nvreplace (
const char *name,
const char *value, pblock *pb)
1396 {
1397 PListStruct_t *pl =
PBTOPL(pb);
1398
1399
1400 pb_param *pp = pblock_find(name, pb);
1401 if (pp) {
1402 pool_free(pl->pl_mempool, pp->value);
1403 pp->value = pool_strdup(pl->pl_mempool, value);
1404 }
else {
1405 pblock_nvinsert(name, value, pb);
1406 }
1407 }
1408
1409
1410
1411
1412 NSAPI_PUBLIC void pblock_kvreplace(
const pb_key *key,
const char *value,
int valuelen, pblock *pb)
1413 {
1414 PListStruct_t *pl =
PBTOPL(pb);
1415
1416
1417 pb_param *pp = pblock_findkey(key, pb);
1418 if (pp) {
1419 pool_free(pl->pl_mempool, pp->value);
1420 pp->value = (
char*)pool_malloc(pl->pl_mempool, valuelen +
1);
1421 memcpy(pp->value, value, valuelen +
1);
1422 }
else {
1423 pblock_kvinsert(key, value, valuelen, pb);
1424 }
1425 }
1426