Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(829)

Side by Side Diff: nss/mozilla/security/nss/lib/libpkix/include/pkix_pl_system.h

Issue 7530005: Add all NSS files to allow using a complete NSS in the future. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:executable
+ *
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is the PKIX-C library.
15 *
16 * The Initial Developer of the Original Code is
17 * Sun Microsystems, Inc.
18 * Portions created by the Initial Developer are
19 * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
20 *
21 * Contributor(s):
22 * Sun Microsystems, Inc.
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37 /*
38 * This file defines several platform independent functions to make system
39 * calls in a portable manner.
40 *
41 */
42
43 #ifndef _PKIX_PL_SYSTEM_H
44 #define _PKIX_PL_SYSTEM_H
45
46 #include "pkixt.h"
47
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51
52 /* General
53 *
54 * Please refer to the libpkix Programmer's Guide for detailed information
55 * about how to use the libpkix library. Certain key warnings and notices from
56 * that document are repeated here for emphasis.
57 *
58 * All identifiers in this file (and all public identifiers defined in
59 * libpkix) begin with "PKIX_". Private identifiers only intended for use
60 * within the library begin with "pkix_".
61 *
62 * A function returns NULL upon success, and a PKIX_Error pointer upon failure.
63 *
64 * Unless otherwise noted, for all accessor (gettor) functions that return a
65 * PKIX_PL_Object pointer, callers should assume that this pointer refers to a
66 * shared object. Therefore, the caller should treat this shared object as
67 * read-only and should not modify this shared object. When done using the
68 * shared object, the caller should release the reference to the object by
69 * using the PKIX_PL_Object_DecRef function.
70 *
71 * While a function is executing, if its arguments (or anything referred to by
72 * its arguments) are modified, free'd, or destroyed, the function's behavior
73 * is undefined.
74 *
75 */
76
77 /*
78 * FUNCTION: PKIX_PL_Initialize
79 * DESCRIPTION:
80 *
81 * XXX If this function is really only meant to be used by PKIX_Initialize,
82 * why don't we just put it in a private header file rather than the public
83 * API. I think it may confuse users.
84 *
85 * This function should NOT be called by applications. It is only meant to
86 * be used internally. The application needs only to call PKIX_Initialize,
87 * which in turn will call this function.
88 *
89 * This function initializes data structures critical to the operation of
90 * libpkix. If initialization is not successful, an Error pointer is
91 * returned. This function should only be called once. If it is called more
92 * than once, the behavior is undefined.
93 *
94 * No PKIX_* types and functions should be used before this function is
95 * called and returns successfully.
96 *
97 * PARAMETERS:
98 * "platformInitNeeded"
99 * Boolean indicating whether platform initialization is to be called
100 * "useArenas"
101 * Boolean indicating whether allocation is to be done using arenas or
102 * individual allocation (malloc).
103 * "pPlContext"
104 * Address at which platform-specific context pointer is stored. Must be
105 * non-NULL.
106 * THREAD SAFETY:
107 * Not Thread Safe
108 *
109 * This function assumes that no other thread is calling this function while
110 * it is executing.
111 * RETURNS:
112 * Returns NULL if the function succeeds.
113 * Returns a Fatal Error if the function fails in an unrecoverable way.
114 */
115 PKIX_Error *
116 PKIX_PL_Initialize(
117 PKIX_Boolean platformInitNeeded,
118 PKIX_Boolean useArenas,
119 void **pPlContext);
120
121 /*
122 * FUNCTION: PKIX_PL_Shutdown
123 * DESCRIPTION:
124 *
125 * XXX If this function is really only meant to be used by PKIX_Shutdown,
126 * why don't we just put it in a private header file rather than the public
127 * API. I think it may confuse users.
128 *
129 * This function should NOT be called by applications. It is only meant to
130 * be used internally. The application needs only to call PKIX_Shutdown,
131 * which in turn will call this function.
132 *
133 * This function deallocates any memory used by the Portability Layer (PL)
134 * component of the libpkix library and shuts down any ongoing operations.
135 * This function should only be called once. If it is called more than once,
136 * the behavior is undefined.
137 *
138 * No PKIX_* types and functions should be used after this function is called
139 * and returns successfully.
140 *
141 * PARAMETERS:
142 * "platformInitNeeded"
143 * Boolean value of whether PKIX initialized NSS: PKIX_TRUE if we
144 * called nssInit, PKIX_FALSE otherwise
145 * "plContext"
146 * Platform-specific context pointer.
147 * THREAD SAFETY:
148 * Not Thread Safe
149 *
150 * This function makes use of global variables and should only be called once.
151 * RETURNS:
152 * Returns NULL if the function succeeds.
153 * Returns a Fatal Error if the function fails in an unrecoverable way.
154 */
155 PKIX_Error *
156 PKIX_PL_Shutdown(void *plContext);
157
158 /* standard memory management operations (not reference-counted) */
159
160 /*
161 * FUNCTION: PKIX_PL_Malloc
162 * DESCRIPTION:
163 *
164 * Allocates a block of "size" bytes. The bytes are not initialized. A
165 * pointer to the newly allocated memory will be stored at "pMemory". The
166 * memory allocated by PKIX_PL_Malloc() may only be freed by PKIX_PL_Free().
167 * If "size" equals zero, this function stores NULL at "pMemory".
168 *
169 * PARAMETERS:
170 * "size"
171 * Number of bytes to allocate.
172 * "pMemory"
173 * Address where newly allocated pointer will be stored. Must be non-NULL.
174 * "plContext"
175 * Platform-specific context pointer.
176 * THREAD SAFETY:
177 * Thread safety depends on underlying thread safety of platform used by PL.
178 * RETURNS:
179 * Returns NULL if the function succeeds.
180 * Returns a Fatal Error if the function fails in an unrecoverable way.
181 */
182 PKIX_Error *
183 PKIX_PL_Malloc(
184 PKIX_UInt32 size,
185 void **pMemory,
186 void *plContext);
187
188 /*
189 * FUNCTION: PKIX_PL_Calloc
190 * DESCRIPTION:
191 *
192 * Allocates memory for an array of "nElem" elements, with each element
193 * requiring "elSize" bytes, and with all the bits initialized to zero. A
194 * pointer to the newly allocated memory will be stored at "pMemory". The
195 * memory allocated by PKIX_PL_Calloc() may only be freed by PKIX_PL_Free().
196 * If "nElem" equals zero or "elSize" equals zero, this function stores NULL
197 * at "pMemory".
198 *
199 * PARAMETERS:
200 * "nElem"
201 * Number of elements needed.
202 * "elSize"
203 * Number of bytes needed per element.
204 * "pMemory"
205 * Address where newly allocated pointer will be stored. Must be non-NULL.
206 * "plContext"
207 * Platform-specific context pointer.
208 * THREAD SAFETY:
209 * Thread safety depends on underlying thread safety of platform used by PL.
210 * RETURNS:
211 * Returns NULL if the function succeeds.
212 * Returns a Fatal Error if the function fails in an unrecoverable way.
213 */
214 PKIX_Error *
215 PKIX_PL_Calloc(
216 PKIX_UInt32 nElem,
217 PKIX_UInt32 elSize,
218 void **pMemory,
219 void *plContext);
220
221 /*
222 * FUNCTION: PKIX_PL_Realloc
223 * DESCRIPTION:
224 *
225 * Resizes an existing block of memory (pointed to by "ptr") to "size" bytes.
226 * Stores a pointer to the resized memory at "pNewPtr". The "ptr" must
227 * originate from either PKIX_PL_Malloc(), PKIX_PL_Realloc(), or
228 * PKIX_PL_Calloc(). If "ptr" is NULL, this function behaves as if
229 * PKIX_PL_Malloc were called. If "ptr" is not NULL and "size" equals zero,
230 * the memory pointed to by "ptr" is deallocated and this function stores
231 * NULL at "pPtr".
232 *
233 * PARAMETERS:
234 * "ptr"
235 * A pointer to an existing block of memory.
236 * "size"
237 * New size in bytes.
238 * "pPtr"
239 * Address where newly allocated pointer will be stored. Must be non-NULL.
240 * "plContext"
241 * Platform-specific context pointer.
242 * THREAD SAFETY:
243 * Thread safety depends on underlying thread safety of platform used by PL.
244 * RETURNS:
245 * Returns NULL if the function succeeds.
246 * Returns a Fatal Error if the function fails in an unrecoverable way.
247 */
248 PKIX_Error *
249 PKIX_PL_Realloc(
250 void *ptr,
251 PKIX_UInt32 size,
252 void **pNewPtr,
253 void *plContext);
254
255 /*
256 * FUNCTION: PKIX_PL_Free
257 * DESCRIPTION:
258 *
259 * Frees a block of memory pointed to by "ptr". This value must originate with
260 * either PKIX_PL_Malloc(), PKIX_PL_Calloc, or PKIX_PL_Realloc(). If "ptr" is
261 * NULL, the function has no effect.
262 *
263 * PARAMETERS:
264 * "ptr"
265 * A pointer to an existing block of memory.
266 * "plContext"
267 * Platform-specific context pointer.
268 * THREAD SAFETY:
269 * Thread safety depends on underlying thread safety of platform used by PL.
270 * RETURNS:
271 * Returns NULL always.
272 */
273 PKIX_Error *
274 PKIX_PL_Free(
275 void *ptr,
276 void *plContext);
277
278 /* Callback Types
279 *
280 * The next few typedefs define function pointer types for the standard
281 * functions associated with every object type. See the Implementation
282 * Guidelines or the comments below for more information.
283 */
284
285 /*
286 * TYPE: PKIX_PL_DestructorCallback
287 * DESCRIPTION:
288 *
289 * This callback function destroys (or DecRef's) any pointers contained in
290 * the user data for the Object pointed to by "object" before the Object is
291 * destroyed.
292 *
293 * PARAMETERS:
294 * "object"
295 * Address of Object to destroy. Must be non-NULL.
296 * "plContext"
297 * Platform-specific context pointer.
298 * THREAD SAFETY:
299 * Thread Safe
300 *
301 * Multiple threads must be able to safely call this function without
302 * worrying about conflicts (as long as they're not operating on the same
303 * object and nobody else is performing an operation on the object at the
304 * same time). Both of these conditions should be guaranteed by the fact that
305 * the object's ref count was reduced to 0 in a lock that's still held when
306 * this callback is called.
307 * RETURNS:
308 * Returns NULL if the function succeeds.
309 * Returns an error if the function fails in a non-fatal way.
310 * Returns a Fatal Error if the function fails in an unrecoverable way.
311 */
312 typedef PKIX_Error *
313 (*PKIX_PL_DestructorCallback)(
314 PKIX_PL_Object *object,
315 void *plContext);
316
317 /*
318 * TYPE: PKIX_PL_EqualsCallback
319 * DESCRIPTION:
320 *
321 * This callback function compares the Object pointed to by "firstObject" with
322 * the Object pointed to by "secondObject" for equality and stores the result
323 * at "pResult" (PKIX_TRUE if equal; PKIX_FALSE if not).
324 *
325 * PARAMETERS:
326 * "firstObject"
327 * Address of first object to compare. Must be non-NULL.
328 * "secondObject"
329 * Address of second object to compare. Must be non-NULL.
330 * "pResult"
331 * Address where Boolean will be stored. Must be non-NULL.
332 * "plContext"
333 * Platform-specific context pointer.
334 * THREAD SAFETY:
335 * Thread Safe
336 *
337 * Multiple threads must be able to safely call this function without
338 * worrying about conflicts, even if they're operating on the same objects.
339 * RETURNS:
340 * Returns NULL if the function succeeds.
341 * Returns an error if the function fails in a non-fatal way.
342 * Returns a Fatal Error if the function fails in an unrecoverable way.
343 */
344 typedef PKIX_Error *
345 (*PKIX_PL_EqualsCallback)(
346 PKIX_PL_Object *firstObject,
347 PKIX_PL_Object *secondObject,
348 PKIX_Boolean *pResult,
349 void *plContext);
350
351 /*
352 * TYPE: PKIX_PL_HashcodeCallback
353 * DESCRIPTION:
354 *
355 * This callback function computes the hashcode of the Object pointed to by
356 * "object" and stores the result at "pValue".
357 *
358 * PARAMETERS:
359 * "object"
360 * Address of Object whose hashcode is desired. Must be non-NULL.
361 * "pValue"
362 * Address where PKIX_UInt32 will be stored. Must be non-NULL.
363 * "plContext"
364 * Platform-specific context pointer.
365 * THREAD SAFETY:
366 * Thread Safe
367 *
368 * Multiple threads must be able to safely call this function without
369 * worrying about conflicts, even if they're operating on the same object.
370 * RETURNS:
371 * Returns NULL if the function succeeds.
372 * Returns an error if the function fails in a non-fatal way.
373 * Returns a Fatal Error if the function fails in an unrecoverable way.
374 */
375 typedef PKIX_Error *
376 (*PKIX_PL_HashcodeCallback)(
377 PKIX_PL_Object *object,
378 PKIX_UInt32 *pValue,
379 void *plContext);
380
381 /*
382 * TYPE: PKIX_PL_ToStringCallback
383 * DESCRIPTION:
384 *
385 * This callback function converts the Object pointed to by "object" to a
386 * string representation and stores the result at "pString".
387 *
388 * PARAMETERS:
389 * "object"
390 * Object to get a string representation from. Must be non-NULL.
391 * "pString"
392 * Address where object pointer will be stored. Must be non-NULL.
393 * "plContext"
394 * Platform-specific context pointer.
395 * THREAD SAFETY:
396 * Thread Safe
397 *
398 * Multiple threads must be able to safely call this function without
399 * worrying about conflicts, even if they're operating on the same object.
400 * RETURNS:
401 * Returns NULL if the function succeeds.
402 * Returns an error if the function fails in a non-fatal way.
403 * Returns a Fatal Error if the function fails in an unrecoverable way.
404 */
405 typedef PKIX_Error *
406 (*PKIX_PL_ToStringCallback)(
407 PKIX_PL_Object *object,
408 PKIX_PL_String **pString,
409 void *plContext);
410
411 /*
412 * TYPE: PKIX_PL_ComparatorCallback
413 * DESCRIPTION:
414 *
415 * This callback function determines how the Object pointed to by
416 * "firstObject" compares to the Object pointed to by "secondObject" and
417 * stores the result at "pResult".
418 *
419 * Result is less than 0 if firstObject < secondObject
420 * Result equals 0 if firstObject = secondObject
421 * Result is greater than 0 if firstObject > secondObject
422 *
423 * PARAMETERS:
424 * "firstObject"
425 * Address of the first Object to compare. Must be non-NULL.
426 * "secondObject"
427 * Address of the second Object to compare. Must be non-NULL.
428 * "pResult"
429 * Address where PKIX_Int32 will be stored. Must be non-NULL.
430 * "plContext"
431 * Platform-specific context pointer.
432 * THREAD SAFETY:
433 * Thread Safe
434 *
435 * Multiple threads must be able to safely call this function without
436 * worrying about conflicts, even if they're operating on the same objects.
437 * RETURNS:
438 * Returns NULL if the function succeeds.
439 * Returns an error if the function fails in a non-fatal way.
440 * Returns a Fatal Error if the function fails in an unrecoverable way.
441 */
442 typedef PKIX_Error *
443 (*PKIX_PL_ComparatorCallback)(
444 PKIX_PL_Object *firstObject,
445 PKIX_PL_Object *secondObject,
446 PKIX_Int32 *pResult,
447 void *plContext);
448
449 /*
450 * TYPE: PKIX_PL_DuplicateCallback
451 * DESCRIPTION:
452 *
453 * This callback function creates a copy of the Object pointed to by "object"
454 * and stores it at "pNewObject". Changes to the copy will not affect the
455 * original and vice versa.
456 *
457 * Note that if "object" is immutable, the Duplicate callback function simply
458 * needs to increment the reference count on "object" and return a reference
459 * to "object".
460 *
461 * PARAMETERS:
462 * "object"
463 * Address of the object to be copied. Must be non-NULL.
464 * "pNewObject"
465 * Address where object pointer will be stored. Must be non-NULL.
466 * "plContext"
467 * Platform-specific context pointer.
468 * THREAD SAFETY:
469 * Thread Safe
470 *
471 * Multiple threads must be able to safely call this function without
472 * worrying about conflicts, even if they're operating on the same object.
473 * RETURNS:
474 * Returns NULL if the function succeeds.
475 * Returns an error if the function fails in a non-fatal way.
476 * Returns a Fatal Error if the function fails in an unrecoverable way.
477 */
478 typedef PKIX_Error *
479 (*PKIX_PL_DuplicateCallback)(
480 PKIX_PL_Object *object,
481 PKIX_PL_Object **pNewObject,
482 void *plContext);
483
484 /* reference-counted objects */
485
486 /*
487 * FUNCTION: PKIX_PL_Object_Alloc
488 * DESCRIPTION:
489 *
490 * Allocates a new Object of type "type" with "size" bytes and stores the
491 * resulting pointer at "pObject". The reference count of the newly
492 * allocated object will be initialized to 1. To improve performance, each
493 * object maintains a small cache for the results of Hashcode and ToString.
494 * Mutable objects should call InvalidateCache whenever changes are made to
495 * the object's state (after creation). If an error occurs during allocation,
496 * "pObject" will be set to NULL. If "size" equals zero, this function creates
497 * an Object with a reference count of 1, and places a pointer to unallocated
498 * memory at "pMemory".
499 *
500 * PARAMETERS:
501 * "type"
502 * The type code of this object. See pkixt.h for codes. The type code
503 * must be previously registered with PKIX_PL_Object_RegisterType().
504 * "size"
505 * The number of bytes needed for this object.
506 * "pMemory"
507 * Address where object pointer will be stored. Must be non-NULL.
508 * "plContext"
509 * Platform-specific context pointer.
510 * THREAD SAFETY:
511 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
512 * RETURNS:
513 * Returns NULL if the function succeeds.
514 * Returns a Fatal Error if the function fails in an unrecoverable way.
515 */
516 PKIX_Error *
517 PKIX_PL_Object_Alloc(
518 PKIX_TYPENUM type,
519 PKIX_UInt32 size,
520 PKIX_PL_Object **pObject,
521 void *plContext);
522
523 /*
524 * FUNCTION: PKIX_PL_Object_IsTypeRegistered
525 * DESCRIPTION:
526 *
527 * Checks whether "type" has been registered by a previous call to
528 * PKIX_PL_Object_RegisterType() and stores the Boolean result at "pBool".
529 * This function will typically only be called by constructors for specific
530 * types.
531 *
532 * PARAMETERS:
533 * "type"
534 * The type code to check if valid.
535 * "pBool"
536 * Address where Boolean will be stored. Must be non-NULL.
537 * "plContext"
538 * Platform-specific context pointer.
539 * THREAD SAFETY:
540 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
541 * RETURNS:
542 * Returns NULL if the function succeeds.
543 * Returns a Fatal Error if the function fails in an unrecoverable way.
544 */
545 PKIX_Error *
546 PKIX_PL_Object_IsTypeRegistered(
547 PKIX_UInt32 type,
548 PKIX_Boolean *pBool,
549 void *plContext);
550
551 #ifdef PKIX_USER_OBJECT_TYPE
552 /*
553 * FUNCTION: PKIX_PL_Object_RegisterType
554 * DESCRIPTION:
555 *
556 * Registers a new Object with type value "type" and associates it with a set
557 * of functions ("destructor", "equalsFunction", "hashcodeFunction",
558 * "toStringFunction", "comparator", "duplicateFunction"). The new type value
559 * is also associated with a string pointed to by "description", which is used
560 * by the default ToStringCallback. This function may only be called with a
561 * particular "type" value once. If "destructor", "equalsFunction",
562 * "hashcodeFunction", or "toStringFunction" are NULL, default functions will
563 * be registered. However, if "comparator" and "duplicateFunction" are NULL,
564 * no functions will be registered and calls to PKIX_PL_Object_Compare and
565 * PKIX_PL_Object_Duplicate will result in an error.
566 *
567 * PARAMETERS:
568 * "type"
569 * The type code.
570 * "description"
571 * The string used by the default ToStringCallback. Default used if NULL.
572 * "destructor"
573 * The DestructorCallback function to be set. Default used if NULL.
574 * "equalsFunction"
575 * The EqualsCallback function to be set. Default used if NULL.
576 * "hashcodeFunction"
577 * The HashcodeCallback function to be set. Default used if NULL.
578 * "toStringFunction"
579 * The ToStringCallback function to be set. Default used if NULL.
580 * "comparator"
581 * The ComparatorCallback function to be set. None set if NULL. If no
582 * callback function is set in this field, calls to
583 * PKIX_PL_Object_Compare() will result in an error.
584 * "duplicateFunction"
585 * The DuplicateCallback function to be set. None set if NULL. If no
586 * callback function is set in this field, calls to
587 * PKIX_PL_Object_Duplicate() will result in an error.
588 * "plContext"
589 * Platform-specific context pointer.
590 * THREAD SAFETY:
591 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
592 * RETURNS:
593 * Returns NULL if the function succeeds.
594 * Returns an Object Error if "type" is already registered.
595 * Returns a Fatal Error if the function fails in an unrecoverable way.
596 */
597 PKIX_Error *
598 PKIX_PL_Object_RegisterType(
599 PKIX_UInt32 type,
600 char *description,
601 PKIX_PL_DestructorCallback destructor,
602 PKIX_PL_EqualsCallback equalsFunction,
603 PKIX_PL_HashcodeCallback hashcodeFunction,
604 PKIX_PL_ToStringCallback toStringFunction,
605 PKIX_PL_ComparatorCallback comparator,
606 PKIX_PL_DuplicateCallback duplicateFunction,
607 void *plContext);
608
609 #endif
610 /*
611 * FUNCTION: PKIX_PL_Object_InvalidateCache
612 * DESCRIPTION:
613 *
614 * Invalidates the cache of the Object pointed to by "object". The cache
615 * contains results of Hashcode and ToString. This function should be used by
616 * mutable objects whenever changes are made to the Object's state (after
617 * creation).
618 *
619 * For example, if ToString is called on a mutable Object, the result will be
620 * computed, cached, and returned. If the Object's state does not change, a
621 * subsequent call to ToString will recognize that the relevant result is
622 * cached and will simply return the result (without calling the Object's
623 * ToStringCallback to recompute it). However, when the Object's state
624 * changes, the cache needs to be invalidated in order to force a subsequent
625 * call to ToString to recompute the result.
626 *
627 * PARAMETERS:
628 * "object"
629 * Address of Object whose cache is to be invalidated. Must be non-NULL.
630 * "plContext"
631 * Platform-specific context pointer.
632 *
633 * THREAD SAFETY
634 * Thread Safe - Object Type Table is locked during modification.
635 *
636 * Multiple threads can safely call this function without worrying about
637 * conflicts, even if they're operating on the same object.
638 * RETURNS:
639 * Returns NULL if the function succeeds.
640 * Returns a Fatal Error if the function fails in an unrecoverable way.
641 */
642 PKIX_Error *
643 PKIX_PL_Object_InvalidateCache(
644 PKIX_PL_Object *object,
645 void *plContext);
646
647 /*
648 * FUNCTION: PKIX_PL_Object_IncRef
649 * DESCRIPTION:
650 *
651 * Increments the reference count of the Object pointed to by "object".
652 *
653 * PARAMETERS:
654 * "object"
655 * Address of Object whose reference count is to be incremented.
656 * Must be non-NULL.
657 * "plContext"
658 * Platform-specific context pointer.
659 * THREAD SAFETY:
660 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
661 * RETURNS:
662 * Returns NULL if the function succeeds.
663 * Returns a Fatal Error if the function fails in an unrecoverable way.
664 */
665 PKIX_Error *
666 PKIX_PL_Object_IncRef(
667 PKIX_PL_Object *object,
668 void *plContext);
669
670 /*
671 * FUNCTION: PKIX_PL_Object_DecRef
672 * DESCRIPTION:
673 *
674 * Decrements the reference count of the Object pointed to by "object". If the
675 * resulting reference count is zero, the destructor (if any) registered for
676 * the Object's type (by PKIX_PL_RegisterType) will be called and then the
677 * Object will be destroyed.
678 *
679 * PARAMETERS:
680 * "object"
681 * Address of Object whose reference count is to be decremented.
682 * Must be non-NULL.
683 * "plContext"
684 * Platform-specific context pointer.
685 * THREAD SAFETY:
686 * If destructor is not called, multiple threads can safely call this function
687 * without worrying about conflicts, even if they're operating on the same
688 * object. If destructor is called, thread safety depends on the callback
689 * defined by PKIX_PL_RegisterType().
690 * RETURNS:
691 * Returns NULL if the function succeeds.
692 * Returns a Fatal Error if the function fails in an unrecoverable way.
693 */
694 PKIX_Error *
695 PKIX_PL_Object_DecRef(
696 PKIX_PL_Object *object,
697 void *plContext);
698
699 /*
700 * FUNCTION: PKIX_PL_Object_Equals
701 * DESCRIPTION:
702 *
703 * Compares the Object pointed to by "firstObject" with the Object pointed to
704 * by "secondObject" for equality using the callback function registered for
705 * "firstObject"'s type, and stores the Boolean result at "pResult". While
706 * typical callbacks will return PKIX_FALSE if the objects are of different
707 * types, other callbacks may be capable of comparing objects of different
708 * types [which may correctly result in cases where Equals(first, second)
709 * differs from Equals(second, first)].
710 *
711 * PARAMETERS:
712 * "firstObject"
713 * Address of the first Object to compare. Must be non-NULL.
714 * The EqualsCallback for this Object will be called.
715 * "secondObject"
716 * Address of the second Object to compare. Must be non-NULL.
717 * "pResult"
718 * Address where Boolean will be stored. Must be non-NULL.
719 * "plContext"
720 * Platform-specific context pointer.
721 * THREAD SAFETY:
722 * Thread safety depends on the callback defined by PKIX_PL_RegisterType().
723 * RETURNS:
724 * Returns NULL if the function succeeds.
725 * Returns an Object Error if the function fails in a non-fatal way.
726 * Returns a Fatal Error if the function fails in an unrecoverable way.
727 */
728 PKIX_Error *
729 PKIX_PL_Object_Equals(
730 PKIX_PL_Object *firstObject,
731 PKIX_PL_Object *secondObject,
732 PKIX_Boolean *pResult,
733 void *plContext);
734
735 /*
736 * FUNCTION: PKIX_PL_Object_Hashcode
737 * DESCRIPTION:
738 *
739 * Computes a hashcode of the Object pointed to by "object" using the
740 * callback registered for "object"'s type and stores it at "pValue". Two
741 * objects which are equal should have the same hashcode. Once a call to
742 * Hashcode has been made, the results are cached and subsequent calls to
743 * Hashcode will return the cached value. For mutable objects, an
744 * InvalidateCache function is provided, which should be called whenever
745 * changes are made to the object's state (after creation).
746 *
747 * PARAMETERS:
748 * "object"
749 * Address of the Object whose hashcode is desired. Must be non-NULL.
750 * The HashcodeCallback for this object will be called.
751 * "pValue"
752 * Address where PKIX_Int32 will be stored. Must be non-NULL.
753 * "plContext"
754 * Platform-specific context pointer.
755 *
756 * THREAD SAFETY:
757 * Thread safety depends on the callback defined by PKIX_PL_RegisterType().
758 * RETURNS:
759 * Returns NULL if the function succeeds.
760 * Returns an Object Error if the function fails in a non-fatal way.
761 * Returns a Fatal Error if the function fails in an unrecoverable way.
762 */
763 PKIX_Error *
764 PKIX_PL_Object_Hashcode(
765 PKIX_PL_Object *object,
766 PKIX_UInt32 *pValue,
767 void *plContext);
768
769 /*
770 * FUNCTION: PKIX_PL_Object_ToString
771 * DESCRIPTION:
772 *
773 * Creates a string representation of the Object pointed to by "object" using
774 * the callback registered for "object"'s type and stores it at "pString".
775 * Once a call to ToString has been made, the results are cached and
776 * subsequent calls to ToString will return the cached value. For mutable
777 * objects, an InvalidateCache function is provided, which should be called
778 * whenever changes are made to the object's state (after creation).
779 *
780 * PARAMETERS:
781 * "object"
782 * Address of Object whose string representation is desired.
783 * Must be non-NULL. The ToStringCallback for this object will be called.
784 * "pString"
785 * Address where object pointer will be stored. Must be non-NULL.
786 * "plContext"
787 * Platform-specific context pointer.
788 * THREAD SAFETY:
789 * Thread safety depends on the callback defined by PKIX_PL_RegisterType().
790 * RETURNS:
791 * Returns NULL if the function succeeds.
792 * Returns an Object Error if the function fails in a non-fatal way.
793 * Returns a Fatal Error if the function fails in an unrecoverable way.
794 */
795 PKIX_Error *
796 PKIX_PL_Object_ToString(
797 PKIX_PL_Object *object,
798 PKIX_PL_String **pString,
799 void *plContext);
800
801 /*
802 * FUNCTION: PKIX_PL_Object_Compare
803 * DESCRIPTION:
804 *
805 * Compares the Object pointed to by "firstObject" and the Object pointed to
806 * by "secondObject" using the comparator registered for "firstObject"'s type
807 * and stores the result at "pResult". Different types may be compared. This
808 * may correctly result in cases where Compare(first, second) is not the
809 * opposite of Compare(second, first). The PKIX_Int32 value stored at
810 * "pResult" will be:
811 * Less than 0 if "firstObject" < "secondObject"
812 * Equals to 0 if "firstObject" = "secondObject"
813 * Greater than 0 if "firstObject" > "secondObject"
814 *
815 * PARAMETERS:
816 * "firstObject"
817 * Address of first Object to compare. Must be non-NULL.
818 * The ComparatorCallback for this object will be called.
819 * "secondObject"
820 * Address of second object to compare. Must be non-NULL.
821 * "pResult
822 * Address where PKIX_Int32 will be stored. Must be non-NULL.
823 * "plContext"
824 * Platform-specific context pointer.
825 * THREAD SAFETY:
826 * Thread safety depends on the comparator defined by PKIX_PL_RegisterType().
827 * RETURNS:
828 * Returns NULL if the function succeeds.
829 * Returns an Object Error if the function fails in a non-fatal way.
830 * Returns a Fatal Error if the function fails in an unrecoverable way.
831 */
832 PKIX_Error *
833 PKIX_PL_Object_Compare(
834 PKIX_PL_Object *firstObject,
835 PKIX_PL_Object *secondObject,
836 PKIX_Int32 *pResult,
837 void *plContext);
838
839 /*
840 * FUNCTION: PKIX_PL_Object_Duplicate
841 * DESCRIPTION:
842 *
843 * Creates a duplicate copy of the Object pointed to by "object" using the
844 * callback registered for "object"'s type and stores the copy at
845 * "pNewObject". Changes to the new object will not affect the original and
846 * vice versa.
847 *
848 * Note that if "object" is immutable, the Duplicate callback function simply
849 * needs to increment the reference count on "object" and return a reference
850 * to "object".
851 *
852 * PARAMETERS:
853 * "object"
854 * Address of Object to be duplicated. Must be non-NULL.
855 * The DuplicateCallback for this Object will be called.
856 * "pNewObject"
857 * Address where object pointer will be stored. Must be non-NULL.
858 * "plContext"
859 * Platform-specific context pointer.
860 * THREAD SAFETY:
861 * Thread safety depends on the callback defined by PKIX_PL_RegisterType().
862 * RETURNS:
863 * Returns NULL if the function succeeds.
864 * Returns an Object Error if the function fails in a non-fatal way.
865 * Returns a Fatal Error if the function fails in an unrecoverable way.
866 */
867 PKIX_Error *
868 PKIX_PL_Object_Duplicate(
869 PKIX_PL_Object *object,
870 PKIX_PL_Object **pNewObject,
871 void *plContext);
872
873 /*
874 * FUNCTION: PKIX_PL_Object_GetType
875 * DESCRIPTION:
876 *
877 * Retrieves the type code of the Object pointed to by "object" and stores it
878 * at "pType". See pkixt.h for type codes.
879 *
880 * PARAMETERS:
881 * "object"
882 * Address of Object whose type is desired. Must be non-NULL.
883 * "pType"
884 * Address where PKIX_UInt32 will be stored. Must be non-NULL.
885 * "plContext"
886 * Platform-specific context pointer.
887 * THREAD SAFETY:
888 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
889 * RETURNS:
890 * Returns NULL if the function succeeds.
891 * Returns a Fatal Error if the function fails in an unrecoverable way.
892 */
893 PKIX_Error *
894 PKIX_PL_Object_GetType(
895 PKIX_PL_Object *object,
896 PKIX_UInt32 *pType,
897 void *plContext);
898
899 /*
900 * FUNCTION: PKIX_PL_Object_Lock
901 * DESCRIPTION:
902 *
903 * Locks the Mutex associated with the Object pointed to by "object". When an
904 * object is created, it is associated with an object-specific Mutex to allow
905 * for synchronization when the fields of the object are modified.
906 *
907 * PARAMETERS:
908 * "object"
909 * Address of Object whose Mutex is to be locked. Must be non-NULL.
910 * "plContext"
911 * Platform-specific context pointer.
912 * THREAD SAFETY:
913 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
914 * RETURNS:
915 * Returns NULL if the function succeeds.
916 * Returns a Fatal Error if the function fails in an unrecoverable way.
917 */
918 PKIX_Error *
919 PKIX_PL_Object_Lock(
920 PKIX_PL_Object *object,
921 void *plContext);
922
923 /*
924 * FUNCTION: PKIX_PL_Object_Unlock
925 * DESCRIPTION:
926 *
927 * Unlocks the Mutex associated with the Object pointed to by "object". When
928 * an object is created, it is associated with an object-specific Mutex to
929 * allow for synchronization when the fields of the object are modified.
930 *
931 * PARAMETERS:
932 * "object"
933 * Address of Object whose Mutex is to be unlocked. Must be non-NULL.
934 * "plContext"
935 * Platform-specific context pointer.
936 * THREAD SAFETY:
937 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
938 * RETURNS:
939 * Returns NULL if the function succeeds.
940 * Returns a Fatal Error if the function fails in an unrecoverable way.
941 */
942 PKIX_Error *
943 PKIX_PL_Object_Unlock(
944 PKIX_PL_Object *object,
945 void *plContext);
946
947 /* mutexes (locks) */
948
949 /*
950 * FUNCTION: PKIX_PL_Mutex_Create
951 * DESCRIPTION:
952 *
953 * Creates a new Mutex and stores it at "pNewLock".
954 *
955 * PARAMETERS:
956 * "pNewLock"
957 * Address where object pointer will be stored. Must be non-NULL.
958 * "plContext"
959 * Platform-specific context pointer.
960 * THREAD SAFETY:
961 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
962 * RETURNS:
963 * Returns NULL if the function succeeds.
964 * Returns a Fatal Error if the function fails in an unrecoverable way.
965 */
966 PKIX_Error *
967 PKIX_PL_Mutex_Create(
968 PKIX_PL_Mutex **pNewLock,
969 void *plContext);
970
971 /*
972 * FUNCTION: PKIX_PL_Mutex_Lock
973 * DESCRIPTION:
974 *
975 * Locks the Mutex pointed to by "lock". If the Mutex is already locked, this
976 * function will block the current thread until the mutex can be locked by
977 * this thread.
978 *
979 * PARAMETERS:
980 * "lock"
981 * Address of Mutex to lock. Must be non-NULL.
982 * "plContext"
983 * Platform-specific context pointer.
984 * THREAD SAFETY:
985 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
986 * RETURNS:
987 * Returns NULL if the function succeeds.
988 * Returns a Fatal Error if the function fails in an unrecoverable way.
989 */
990 PKIX_Error *
991 PKIX_PL_Mutex_Lock(
992 PKIX_PL_Mutex *lock,
993 void *plContext);
994
995 /*
996 * FUNCTION: PKIX_PL_Mutex_Unlock
997 * DESCRIPTION:
998 *
999 * Unlocks the Mutex pointed to by "lock" if the current thread holds the
1000 * Mutex.
1001 *
1002 * PARAMETERS:
1003 * "lock"
1004 * Address of Mutex to unlock. Must be non-NULL.
1005 * "plContext"
1006 * Platform-specific context pointer.
1007 * THREAD SAFETY:
1008 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
1009 * RETURNS:
1010 * Returns NULL if the function succeeds.
1011 * Returns a Fatal Error if the function fails in an unrecoverable way.
1012 */
1013 PKIX_Error *
1014 PKIX_PL_Mutex_Unlock(
1015 PKIX_PL_Mutex *lock,
1016 void *plContext);
1017
1018 /* monitor (locks) */
1019
1020 /*
1021 * FUNCTION: PKIX_PL_MonitorLock_Create
1022 * DESCRIPTION:
1023 *
1024 * Creates a new PKIX_PL_MonitorLock and stores it at "pNewLock".
1025 *
1026 * PARAMETERS:
1027 * "pNewLock"
1028 * Address where object pointer will be stored. Must be non-NULL.
1029 * "plContext"
1030 * Platform-specific context pointer.
1031 * THREAD SAFETY:
1032 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
1033 * RETURNS:
1034 * Returns NULL if the function succeeds.
1035 * Returns a Fatal Error if the function fails in an unrecoverable way.
1036 */
1037 PKIX_Error *
1038 PKIX_PL_MonitorLock_Create(
1039 PKIX_PL_MonitorLock **pNewLock,
1040 void *plContext);
1041
1042 /*
1043 * FUNCTION: PKIX_PL_MonitorLock_Enter
1044 * DESCRIPTION:
1045 *
1046 * Locks the MonitorLock pointed to by "lock". If the MonitorLock is already
1047 * locked by other thread, this function will block the current thread. If
1048 * the "lock" had been locked by current thread, this function will NOT block.
1049 *
1050 * PARAMETERS:
1051 * "lock"
1052 * Address of MonitorLock to lock. Must be non-NULL.
1053 * "plContext"
1054 * Platform-specific context pointer.
1055 * THREAD SAFETY:
1056 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
1057 * RETURNS:
1058 * Returns NULL if the function succeeds.
1059 * Returns a Fatal Error if the function fails in an unrecoverable way.
1060 */
1061 PKIX_Error *
1062 PKIX_PL_MonitorLock_Enter(
1063 PKIX_PL_MonitorLock *lock,
1064 void *plContext);
1065
1066 /*
1067 * FUNCTION: PKIX_PL_MonitorLock_Exit
1068 * DESCRIPTION:
1069 *
1070 * Unlocks the MonitorLock pointed to by "lock" if the lock counter of
1071 * current thread holds the MonitorLock reach 0, the lock is released.
1072 *
1073 * PARAMETERS:
1074 * "lock"
1075 * Address of MonitorLock to unlock. Must be non-NULL.
1076 * "plContext"
1077 * Platform-specific context pointer.
1078 * THREAD SAFETY:
1079 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
1080 * RETURNS:
1081 * Returns NULL if the function succeeds.
1082 * Returns a Fatal Error if the function fails in an unrecoverable way.
1083 */
1084 PKIX_Error *
1085 PKIX_PL_MonitorLock_Exit(
1086 PKIX_PL_MonitorLock *lock,
1087 void *plContext);
1088
1089 /* strings and formatted printing */
1090
1091 /*
1092 * FUNCTION: PKIX_PL_String_Create
1093 * DESCRIPTION:
1094 *
1095 * Creates a new String using the data pointed to by "pString", the
1096 * PKIX_UInt32 pointed to by "stringLen", and the PKIX_UInt32 pointed to by
1097 * "fmtIndicator" and stores it at "pString". If the format is PKIX_ESCASCII
1098 * the "stringLen" parameter is ignored and the string extends until a zero
1099 * byte is found. Once created, a String object is immutable.
1100 *
1101 * Valid formats are:
1102 * PKIX_ESCASCII
1103 * PKIX_ESCASCII_DEBUG
1104 * PKIX_UTF8
1105 * PKIX_UTF8_NULL_TERM
1106 * PKIX_UTF16
1107 *
1108 * PARAMETERS:
1109 * "fmtIndicator"
1110 * Format that "stringRep" is encoded with. Must be non-NULL.
1111 * "stringRep"
1112 * Address of encoded string representation. Must be non-NULL.
1113 * "stringLen"
1114 * Length of data stored at stringRep.
1115 * "pString"
1116 * Address where object pointer will be stored. Must be non-NULL.
1117 * "plContext"
1118 * Platform-specific context pointer.
1119 * THREAD SAFETY:
1120 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
1121 * RETURNS:
1122 * Returns NULL if the function succeeds.
1123 * Returns a String Error if the function fails in a non-fatal way.
1124 * Returns a Fatal Error if the function fails in an unrecoverable way.
1125 */
1126 PKIX_Error *
1127 PKIX_PL_String_Create(
1128 PKIX_UInt32 fmtIndicator,
1129 const void *stringRep,
1130 PKIX_UInt32 stringLen,
1131 PKIX_PL_String **pString,
1132 void *plContext);
1133
1134 /*
1135 * FUNCTION: PKIX_PL_Sprintf
1136 * DESCRIPTION:
1137 *
1138 * Creates a formatted string at "pOut" using the given format "fmt" and a
1139 * variable length list of arguments. The format flags are identical to
1140 * standard C with the exception that %s expects a PKIX_PL_String*, rather
1141 * than a char *, and that {%d, %i, %o, %u, %x, %X} expect PKIX_UInt32 or
1142 * PKIX_Int32 instead of int or unsigned int.
1143 *
1144 * PARAMETERS:
1145 * "pOut"
1146 * Address where object pointer will be stored. Must be non-NULL.
1147 * "plContext"
1148 * Platform-specific context pointer.
1149 * "fmt"
1150 * Address of format string. Must be non-NULL.
1151 * THREAD SAFETY:
1152 * Not Thread Safe - Caller must have exclusive access to all arguments.
1153 * (see Thread Safety Definitions in Programmer's Guide)
1154 * RETURNS:
1155 * Returns NULL if the function succeeds.
1156 * Returns a String Error if the function fails in a non-fatal way.
1157 * Returns a Fatal Error if the function fails in an unrecoverable way.
1158 */
1159 PKIX_Error *
1160 PKIX_PL_Sprintf(
1161 PKIX_PL_String **pOut,
1162 void *plContext,
1163 const PKIX_PL_String *fmt, ...);
1164
1165 /*
1166 * FUNCTION: PKIX_PL_GetString
1167 * DESCRIPTION:
1168 *
1169 * Retrieves the String associated with the value of "stringID" (if any) and
1170 * stores it at "pString". If no such string is associated with "stringID",
1171 * this function uses "defaultString" to create a String and stores it at
1172 * "pString".
1173 *
1174 * PARAMETERS:
1175 * "stringID"
1176 * PKIX_UInt32 valud of string identifier.
1177 * "defaultString"
1178 * Address of a PKIX_ESCASCII encoded string representation.
1179 * Must be non-NULL.
1180 * "pString"
1181 * Address where object pointer will be stored. Must be non-NULL.
1182 * "plContext"
1183 * Platform-specific context pointer.
1184 * THREAD SAFETY:
1185 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
1186 * RETURNS:
1187 * Returns NULL if the function succeeds.
1188 * Returns a String Error if the function fails in a non-fatal way.
1189 * Returns a Fatal Error if the function fails in an unrecoverable way.
1190 */
1191 PKIX_Error *
1192 PKIX_PL_GetString(
1193 PKIX_UInt32 stringID,
1194 char *defaultString,
1195 PKIX_PL_String **pString,
1196 void *plContext);
1197
1198 /*
1199 * FUNCTION: PKIX_PL_String_GetEncoded
1200 * DESCRIPTION:
1201 *
1202 * Retrieves the value of the String pointed to by "string" in the encoding
1203 * specified by "fmtIndicator" and stores the result in "pStringRep" and
1204 * "pLength", respectively. Note that "pStringRep" is not reference counted
1205 * and will need to be freed with PKIX_PL_Free().
1206 *
1207 * PARAMETERS:
1208 * "string"
1209 * Address of String whose encoded value is desired. Must be non-NULL.
1210 * "fmtIndicator"
1211 * Format of encoding. Supported formats are:
1212 * PKIX_ESCASCII, PKIX_ESCASII_DEBUG, PKIX_UTF8, PKIX_UTF8_NULL_TERM, and
1213 * PKIX_UTF16. XXX Where are these documented?
1214 * "pStringRep"
1215 * Address where pointer to encoded value will be stored.
1216 * Must be non-NULL.
1217 * "pLength"
1218 * Address where byte length of encoded value will be stored.
1219 * "plContext"
1220 * Platform-specific context pointer.
1221 * THREAD SAFETY:
1222 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
1223 * RETURNS:
1224 * Returns NULL if the function succeeds.
1225 * Returns a String Error if the function fails in a non-fatal way.
1226 * Returns a Fatal Error if the function fails in an unrecoverable way.
1227 */
1228 PKIX_Error *
1229 PKIX_PL_String_GetEncoded(
1230 PKIX_PL_String *string,
1231 PKIX_UInt32 fmtIndicator,
1232 void **pStringRep,
1233 PKIX_UInt32 *pLength,
1234 void *plContext);
1235
1236 /*
1237 * Hashtable
1238 *
1239 * A hashtable is a very efficient data structure used for mapping keys to
1240 * values. Any non-null PKIX_PL_Object can be used as a key or as a value,
1241 * provided that it correctly implements the PKIX_PL_EqualsCallback and the
1242 * PKIX_PL_HashcodeCallback. A hashtable consists of several buckets, with
1243 * each bucket capable of holding a linked list of key/value mappings. When
1244 * adding, retrieving, or deleting a value, the hashcode of the key is used to
1245 * determine which bucket's linked list is relevant. The corresponding
1246 * key/value pair is then appended, retrieved, or deleted.
1247 */
1248
1249 /*
1250 * FUNCTION: PKIX_PL_HashTable_Create
1251 * DESCRIPTION:
1252 *
1253 * Creates a new Hashtable with an initial capacity of "numBuckets" buckets
1254 * and "maxEntriesPerBucket" of entries limit for each bucket and stores it
1255 * at "pResult".
1256 *
1257 * PARAMETERS:
1258 * "numBuckets"
1259 * The initial number of hash table buckets. Must be non-zero.
1260 * "maxEntriesPerBucket"
1261 * The limit of entries per bucket. Zero means no limit.
1262 * "pResult"
1263 * Address where object pointer will be stored. Must be non-NULL.
1264 * "plContext"
1265 * Platform-specific context pointer.
1266 * THREAD SAFETY:
1267 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
1268 * RETURNS:
1269 * Returns NULL if the function succeeds.
1270 * Returns a Fatal Error if the function fails in an unrecoverable way.
1271 */
1272 PKIX_Error *
1273 PKIX_PL_HashTable_Create(
1274 PKIX_UInt32 numBuckets,
1275 PKIX_UInt32 maxEntriesPerBucket,
1276 PKIX_PL_HashTable **pResult,
1277 void *plContext);
1278
1279 /*
1280 * FUNCTION: PKIX_PL_HashTable_Add
1281 * DESCRIPTION:
1282 *
1283 * Adds a key/value mapping using the Objects pointed to by "key" and "value"
1284 * to the Hashtable pointed to by "ht".
1285 *
1286 * Function increments key/value reference counts. Caller is responsible to
1287 * to decrement(destroy) key/value ref counts(objects).
1288 *
1289 * PARAMETERS:
1290 * "ht"
1291 * Address of Hashtable to be added to. Must be non-NULL.
1292 * "key"
1293 * Address of Object to be associated with "value". Must be non-NULL.
1294 * "value"
1295 * Address of Object to be added to Hashtable. Must be non-NULL.
1296 * "plContext"
1297 * Platform-specific context pointer.
1298 * THREAD SAFETY:
1299 * Not Thread Safe - assumes exclusive access to "ht"
1300 * (see Thread Safety Definitions in Programmer's Guide)
1301 * RETURNS:
1302 * Returns NULL if the function succeeds.
1303 * Returns a Hashtable Error if the function fails in a non-fatal way.
1304 * Returns a Fatal Error if the function fails in an unrecoverable way.
1305 */
1306 PKIX_Error *
1307 PKIX_PL_HashTable_Add(
1308 PKIX_PL_HashTable *ht,
1309 PKIX_PL_Object *key,
1310 PKIX_PL_Object *value,
1311 void *plContext);
1312
1313 /*
1314 * FUNCTION: PKIX_PL_HashTable_Remove
1315 * DESCRIPTION:
1316 *
1317 * Removes the Object value whose key is equal to the Object pointed to by
1318 * "key" from the Hashtable pointed to by "ht". If no such object exists,
1319 * this function throws an Error.
1320 *
1321 * Function frees "value" object. Caller is responsible to free "key"
1322 * object.
1323 *
1324 * PARAMETERS:
1325 * "ht"
1326 * Address of Hashtable to remove object from. Must be non-NULL.
1327 * "key"
1328 * Address of Object used for lookup. Must be non-NULL.
1329 * "plContext"
1330 * Platform-specific context pointer.
1331 * THREAD SAFETY:
1332 * Not Thread Safe - assumes exclusive access to "ht"
1333 * (see Thread Safety Definitions in Programmer's Guide)
1334 * RETURNS:
1335 * Returns NULL if the function succeeds.
1336 * Returns a Hashtable Error if the function fails in a non-fatal way.
1337 * Returns a Fatal Error if the function fails in an unrecoverable way.
1338 */
1339 PKIX_Error *
1340 PKIX_PL_HashTable_Remove(
1341 PKIX_PL_HashTable *ht,
1342 PKIX_PL_Object *key,
1343 void *plContext);
1344
1345 /*
1346 * FUNCTION: PKIX_PL_HashTable_Lookup
1347 * DESCRIPTION:
1348 *
1349 * Retrieves the Object whose key equals the Object pointed to by "key" from
1350 * the Hashtable associated with "ht" and stores it at "pResult". If no
1351 * Object is found, this function stores NULL at "pResult".
1352 *
1353 * PARAMETERS:
1354 * "ht"
1355 * Address of Hashtable to lookup Object from. Must be non-NULL.
1356 * "key"
1357 * Address of key Object used for lookup. Must be non-NULL.
1358 * "pResult"
1359 * Address where object pointer will be stored. Must be non-NULL.
1360 * "plContext"
1361 * Platform-specific context pointer.
1362 * THREAD SAFETY:
1363 * Conditionally Thread Safe
1364 * (see Thread Safety Definitions in Programmer's Guide)
1365 * RETURNS:
1366 * Returns NULL if the function succeeds.
1367 * Returns a Hashtable Error if the function fails in a non-fatal way.
1368 * Returns a Fatal Error if the function fails in an unrecoverable way.
1369 */
1370 PKIX_Error *
1371 PKIX_PL_HashTable_Lookup(
1372 PKIX_PL_HashTable *ht,
1373 PKIX_PL_Object *key,
1374 PKIX_PL_Object **pResult,
1375 void *plContext);
1376
1377 /*
1378 * FUNCTION: PKIX_PL_ByteArray_Create
1379 * DESCRIPTION:
1380 *
1381 * Creates a new ByteArray using "length" bytes of data pointed to by "array"
1382 * and stores it at "pByteArray". Once created, a ByteArray is immutable.
1383 *
1384 * PARAMETERS:
1385 * "array"
1386 * Address of source data.
1387 * "length"
1388 * Number of bytes to copy.
1389 * "pByteArray"
1390 * Address where object pointer will be stored. Must be non-NULL.
1391 * "plContext"
1392 * Platform-specific context pointer.
1393 * THREAD SAFETY:
1394 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
1395 * RETURNS:
1396 * Returns NULL if the function succeeds.
1397 * Returns a Fatal Error if the function fails in an unrecoverable way.
1398 */
1399 PKIX_Error *
1400 PKIX_PL_ByteArray_Create(
1401 void *array,
1402 PKIX_UInt32 length,
1403 PKIX_PL_ByteArray **pByteArray,
1404 void *plContext);
1405
1406 /*
1407 * FUNCTION: PKIX_PL_ByteArray_GetPointer
1408 * DESCRIPTION:
1409 *
1410 * Allocates enough memory to hold the contents of the ByteArray pointed to
1411 * by "byteArray", copies the data from the ByteArray pointed to by
1412 * "byteArray" into the newly allocated memory, and stores a pointer to the
1413 * memory at "pArray". Note that "pArray" is not reference counted. It will
1414 * need to be freed with PKIX_PL_Free().
1415 *
1416 * PARAMETERS:
1417 * "byteArray"
1418 * Address of ByteArray whose data is desired. Must be non-NULL.
1419 * "pArray"
1420 * Address where object pointer will be stored. Must be non-NULL.
1421 * "plContext"
1422 * Platform-specific context pointer.
1423 * THREAD SAFETY:
1424 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
1425 * RETURNS:
1426 * Returns NULL if the function succeeds.
1427 * Returns a Fatal Error if the function fails in an unrecoverable way.
1428 */
1429 PKIX_Error *
1430 PKIX_PL_ByteArray_GetPointer(
1431 PKIX_PL_ByteArray *byteArray,
1432 void **pArray,
1433 void *plContext);
1434
1435 /*
1436 * FUNCTION: PKIX_PL_ByteArray_GetLength
1437 * DESCRIPTION:
1438 *
1439 * Retrieves the length of the ByteArray pointed to by "byteArray" and stores
1440 * the length at "pLength".
1441 *
1442 * PARAMETERS:
1443 * "byteArray"
1444 * Address of ByteArray whose length is desired. Must be non-NULL.
1445 * "pLength"
1446 * Address where PKIX_UInt32 will be stored. Must be non-NULL.
1447 * "plContext"
1448 * Platform-specific context pointer.
1449 * THREAD SAFETY:
1450 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
1451 * RETURNS:
1452 * Returns NULL if the function succeeds.
1453 * Returns a Fatal Error if the function fails in an unrecoverable way.
1454 */
1455 PKIX_Error *
1456 PKIX_PL_ByteArray_GetLength(
1457 PKIX_PL_ByteArray *byteArray,
1458 PKIX_UInt32 *pLength,
1459 void *plContext);
1460
1461 /*
1462 * FUNCTION: PKIX_PL_OID_Create
1463 * DESCRIPTION:
1464 *
1465 * Creates a new OID using NSS oid tag.
1466 *
1467 * PARAMETERS:
1468 * "idtag"
1469 * nss oid id tag.
1470 * "pOID"
1471 * Address where object pointer will be stored. Must be non-NULL.
1472 * "plContext"
1473 * Platform-specific context pointer.
1474 * THREAD SAFETY:
1475 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
1476 * RETURNS:
1477 * Returns NULL if the function succeeds.
1478 * Returns an OID Error if the function fails in a non-fatal way.
1479 * Returns a Fatal Error if the function fails in an unrecoverable way.
1480 */
1481 PKIX_Error *
1482 PKIX_PL_OID_Create(
1483 SECOidTag idtag,
1484 PKIX_PL_OID **pOID,
1485 void *plContext);
1486
1487 /*
1488 * FUNCTION: PKIX_PL_OID_CreateBySECItem
1489 * DESCRIPTION:
1490 *
1491 * Creates a new OID using a DER encoded OID stored as SECItem.
1492 *
1493 * PARAMETERS:
1494 * "derOid"
1495 * Address of SECItem that holds DER encoded OID.
1496 * "pOID"
1497 * Address where object pointer will be stored. Must be non-NULL.
1498 * "plContext"
1499 * Platform-specific context pointer.
1500 * THREAD SAFETY:
1501 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
1502 * RETURNS:
1503 * Returns NULL if the function succeeds.
1504 * Returns an OID Error if the function fails in a non-fatal way.
1505 * Returns a Fatal Error if the function fails in an unrecoverable way.
1506 */
1507 PKIX_Error *
1508 PKIX_PL_OID_CreateBySECItem(
1509 SECItem *derOid,
1510 PKIX_PL_OID **pOID,
1511 void *plContext);
1512
1513 /*
1514 * FUNCTION: PKIX_PL_BigInt_Create
1515 * DESCRIPTION:
1516 *
1517 * Creates a new BigInt using the source String pointed to by "stringRep" and
1518 * stores it at "pBigInt". Valid source Strings consist of an even number of
1519 * hexadecimal digits, which are always interpreted as a positive number.
1520 * Once created, a BigInt is immutable.
1521 *
1522 * The regexp format is:
1523 * HexDigit ::= [0-9] | [A-F] | [a-f]
1524 * DoubleHex ::= HexDigit HexDigit
1525 * BigIntSrc ::= (DoubleHex)+
1526 *
1527 * Note that since we are using DoubleHex, the number of characters in the
1528 * source MUST be even. Additionally, the first DoubleHex MUST NOT be "00"
1529 * unless it is the only DoubleHex.
1530 *
1531 * Valid : "09"
1532 * Valid : "00" (special case where first and only DoubleHex is "00")
1533 * Invalid: "9" (not DoubleHex: odd number of characters)
1534 * Invalid: "0009" (first DoubleHex is "00")
1535 *
1536 * XXX Why does this take a String object while OID_Create takes a char* ?
1537 * Perhaps because OID_Create is often used with constant strings and
1538 * this function isn't. That's a good reason, but we should explain it
1539 * (if it's right)
1540 * PARAMETERS:
1541 * "stringRep"
1542 * Address of String representing a BigInt. Must be non-NULL.
1543 * "pBigInt"
1544 * Address where object pointer will be stored. Must be non-NULL.
1545 * "plContext"
1546 * Platform-specific context pointer.
1547 * THREAD SAFETY:
1548 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
1549 * RETURNS:
1550 * Returns NULL if the function succeeds.
1551 * Returns a BigInt Error if the function fails in a non-fatal way.
1552 * Returns a Fatal Error if the function fails in an unrecoverable way.
1553 */
1554 PKIX_Error *
1555 PKIX_PL_BigInt_Create(
1556 PKIX_PL_String *stringRep,
1557 PKIX_PL_BigInt **pBigInt,
1558 void *plContext);
1559
1560 #ifdef __cplusplus
1561 }
1562 #endif
1563
1564 /*
1565 * FUNCTION: PKIX_PL_GetPLErrorCode
1566 * DESCRIPTION:
1567 *
1568 * Returns error code from PL layer.
1569 *
1570 * THREAD SAFETY:
1571 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
1572 * RETURNS:
1573 * PL layer error code.
1574 */
1575 int
1576 PKIX_PL_GetPLErrorCode();
1577
1578 #endif /* _LIBPKIX_SYSTEM_H */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698