1/* 2 * The contents of this file are subject to the Mozilla Public 3 * License Version 1.1 (the "License"); you may not use this file 4 * except in compliance with the License. You may obtain a copy of 5 * the License at http://www.mozilla.org/MPL/ 6 * 7 * Software distributed under the License is distributed on an "AS 8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 * implied. See the License for the specific language governing 10 * rights and limitations under the License. 11 * 12 * The Original Code is the Netscape security libraries. 13 * 14 * The Initial Developer of the Original Code is Netscape 15 * Communications Corporation. Portions created by Netscape are 16 * Copyright (C) 1994-2000 Netscape Communications Corporation. All 17 * Rights Reserved. 18 * 19 * Contributor(s): 20 * 21 * Alternatively, the contents of this file may be used under the 22 * terms of the GNU General Public License Version 2 or later (the 23 * "GPL"), in which case the provisions of the GPL are applicable 24 * instead of those above. If you wish to allow use of your 25 * version of this file only under the terms of the GPL and not to 26 * allow others to use your version of this file under the MPL, 27 * indicate your decision by deleting the provisions above and 28 * replace them with the notice and other provisions required by 29 * the GPL. If you do not delete the provisions above, a recipient 30 * may use your version of this file under either the MPL or the 31 * GPL. 32 */ 33 34#ifndef _SECITEM_H_ 35#define _SECITEM_H_ 36/* 37 * SecAsn1Item.h - public data structures and prototypes for handling 38 * SecAsn1Items 39 */ 40 41#include <security_asn1/seccomon.h> 42#include <security_asn1/plarenas.h> 43#include "plhash.h" 44 45SEC_BEGIN_PROTOS 46 47/* 48** Allocate an item. If "arena" is not NULL, then allocate from there, 49** otherwise allocate from the heap. If "item" is not NULL, allocate 50** only the data for the item, not the item itself. The item structure 51** is allocated zero-filled; the data buffer is not zeroed. 52** 53** The resulting item is returned; NULL if any error occurs. 54** 55** XXX This probably should take a SecAsn1ItemType, but since that is mostly 56** unused and our improved APIs (aka Stan) are looming, I left it out. 57*/ 58extern SecAsn1Item *SECITEM_AllocItem(PRArenaPool *arena, SecAsn1Item *item, 59 size_t len); 60 61/* 62** Reallocate the data for the specified "item". If "arena" is not NULL, 63** then reallocate from there, otherwise reallocate from the heap. 64** In the case where oldlen is 0, the data is allocated (not reallocated). 65** In any case, "item" is expected to be a valid SecAsn1Item pointer; 66** SECFailure is returned if it is not. If the allocation succeeds, 67** SECSuccess is returned. 68*/ 69extern SECStatus SECITEM_ReallocItem(PRArenaPool *arena, SecAsn1Item *item, 70 size_t oldlen, size_t newlen); 71 72/* 73** Compare two items returning the difference between them. 74*/ 75extern SECComparison SECITEM_CompareItem(const SecAsn1Item *a, const SecAsn1Item *b); 76 77/* 78** Compare two items -- if they are the same, return true; otherwise false. 79*/ 80extern Boolean SECITEM_ItemsAreEqual(const SecAsn1Item *a, const SecAsn1Item *b); 81 82/* 83** Copy "from" to "to" 84*/ 85extern SECStatus SECITEM_CopyItem(PRArenaPool *arena, SecAsn1Item *to, 86 const SecAsn1Item *from); 87 88/* 89** Allocate an item and copy "from" into it. 90*/ 91extern SecAsn1Item *SECITEM_DupItem(const SecAsn1Item *from); 92 93/* 94 ** Allocate an item and copy "from" into it. The item itself and the 95 ** data it points to are both allocated from the arena. If arena is 96 ** NULL, this function is equivalent to SECITEM_DupItem. 97 */ 98extern SecAsn1Item *SECITEM_ArenaDupItem(PRArenaPool *arena, const SecAsn1Item *from); 99 100/* 101** Free "zap". If freeit is PR_TRUE then "zap" itself is freed. 102*/ 103extern void SECITEM_FreeItem(SecAsn1Item *zap, Boolean freeit); 104 105/* 106** Zero and then free "zap". If freeit is PR_TRUE then "zap" itself is freed. 107*/ 108extern void SECITEM_ZfreeItem(SecAsn1Item *zap, Boolean freeit); 109 110PLHashNumber PR_CALLBACK SECITEM_Hash ( const void *key); 111 112PRIntn PR_CALLBACK SECITEM_HashCompare ( const void *k1, const void *k2); 113 114 115SEC_END_PROTOS 116 117#endif /* _SECITEM_H_ */ 118