1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 /*
5  * pkix_pl_object.h
6  *
7  * Object Construction, Destruction and Callback Definitions
8  *
9  */
10 
11 #ifndef _PKIX_PL_OBJECT_H
12 #define _PKIX_PL_OBJECT_H
13 
14 #include "pkix_pl_common.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 /*
21  * Object Implementation Notes:
22  *
23  * Allocating a new object creates an object header and a block of
24  * uninitialized user data. A pointer to this uninitialized data is
25  * returned to the user. The structure looks as follows:
26  *
27  * +--------------------+
28  * | MAGIC HEADER       |
29  * | (object header)    |
30  * +--------------------+
31  * | user data          | -- pointer returned from PKIX_PL_Object_Alloc
32  * +--------------------+
33  *
34  * Object operations receive a pointer to raw user data as an argument.
35  * The macro HEADER(object) returns a pointer to the object header.
36  * An assertion then verifies that the first field is the MAGIC_HEADER.
37  */
38 
39 /* PKIX_PL_Object Structure Definition */
40 struct PKIX_PL_ObjectStruct {
41         PRUint64    magicHeader;
42         PKIX_UInt32 type;
43         PKIX_Int32 references;
44         PRLock *lock;
45         PKIX_PL_String *stringRep;
46         PKIX_UInt32 hashcode;
47         PKIX_Boolean hashcodeCached;
48 };
49 
50 /* see source file for function documentation */
51 
52 PKIX_Error *
53 pkix_pl_Object_RetrieveEqualsCallback(
54         PKIX_PL_Object *object,
55         PKIX_PL_EqualsCallback *equalsCallback,
56         void *plContext);
57 
58 extern PKIX_Boolean initializing;
59 extern PKIX_Boolean initialized;
60 
61 #ifdef PKIX_USER_OBJECT_TYPE
62 
63 extern PRLock *classTableLock;
64 
65 #endif
66 
67 extern pkix_ClassTable_Entry systemClasses[PKIX_NUMTYPES];
68 
69 PKIX_Error *
70 pkix_pl_Object_RegisterSelf(void *plContext);
71 
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif /* _PKIX_PL_OBJECT_H */
77