OLD | NEW |
| (Empty) |
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 #ifndef _SECITEM_H_ | |
6 #define _SECITEM_H_ | |
7 | |
8 #include "utilrename.h" | |
9 | |
10 /* | |
11 * secitem.h - public data structures and prototypes for handling | |
12 * SECItems | |
13 * | |
14 * $Id: secitem.h,v 1.9 2012/04/25 14:50:16 gerv%gerv.net Exp $ | |
15 */ | |
16 | |
17 #include "plarena.h" | |
18 #include "plhash.h" | |
19 #include "seccomon.h" | |
20 | |
21 SEC_BEGIN_PROTOS | |
22 | |
23 /* | |
24 ** Allocate an item. If "arena" is not NULL, then allocate from there, | |
25 ** otherwise allocate from the heap. If "item" is not NULL, allocate | |
26 ** only the data buffer for the item, not the item itself. If "len" is | |
27 ** 0, do not allocate the data buffer for the item; simply set the data | |
28 ** field to NULL and the len field to 0. The item structure is allocated | |
29 ** zero-filled; the data buffer is not zeroed. The caller is responsible | |
30 ** for initializing the type field of the item. | |
31 ** | |
32 ** The resulting item is returned; NULL if any error occurs. | |
33 ** | |
34 ** XXX This probably should take a SECItemType, but since that is mostly | |
35 ** unused and our improved APIs (aka Stan) are looming, I left it out. | |
36 */ | |
37 extern SECItem *SECITEM_AllocItem(PLArenaPool *arena, SECItem *item, | |
38 unsigned int len); | |
39 | |
40 /* | |
41 ** Reallocate the data for the specified "item". If "arena" is not NULL, | |
42 ** then reallocate from there, otherwise reallocate from the heap. | |
43 ** In the case where oldlen is 0, the data is allocated (not reallocated). | |
44 ** In any case, "item" is expected to be a valid SECItem pointer; | |
45 ** SECFailure is returned if it is not. If the allocation succeeds, | |
46 ** SECSuccess is returned. | |
47 */ | |
48 extern SECStatus SECITEM_ReallocItem(PLArenaPool *arena, SECItem *item, | |
49 unsigned int oldlen, unsigned int newlen); | |
50 | |
51 /* | |
52 ** Compare two items returning the difference between them. | |
53 */ | |
54 extern SECComparison SECITEM_CompareItem(const SECItem *a, const SECItem *b); | |
55 | |
56 /* | |
57 ** Compare two items -- if they are the same, return true; otherwise false. | |
58 */ | |
59 extern PRBool SECITEM_ItemsAreEqual(const SECItem *a, const SECItem *b); | |
60 | |
61 /* | |
62 ** Copy "from" to "to" | |
63 */ | |
64 extern SECStatus SECITEM_CopyItem(PLArenaPool *arena, SECItem *to, | |
65 const SECItem *from); | |
66 | |
67 /* | |
68 ** Allocate an item and copy "from" into it. | |
69 */ | |
70 extern SECItem *SECITEM_DupItem(const SECItem *from); | |
71 | |
72 /* | |
73 ** Allocate an item and copy "from" into it. The item itself and the | |
74 ** data it points to are both allocated from the arena. If arena is | |
75 ** NULL, this function is equivalent to SECITEM_DupItem. | |
76 */ | |
77 extern SECItem *SECITEM_ArenaDupItem(PLArenaPool *arena, const SECItem *from); | |
78 | |
79 /* | |
80 ** Free "zap". If freeit is PR_TRUE then "zap" itself is freed. | |
81 */ | |
82 extern void SECITEM_FreeItem(SECItem *zap, PRBool freeit); | |
83 | |
84 /* | |
85 ** Zero and then free "zap". If freeit is PR_TRUE then "zap" itself is freed. | |
86 */ | |
87 extern void SECITEM_ZfreeItem(SECItem *zap, PRBool freeit); | |
88 | |
89 PLHashNumber PR_CALLBACK SECITEM_Hash ( const void *key); | |
90 | |
91 PRIntn PR_CALLBACK SECITEM_HashCompare ( const void *k1, const void *k2); | |
92 | |
93 | |
94 SEC_END_PROTOS | |
95 | |
96 #endif /* _SECITEM_H_ */ | |
OLD | NEW |