Back to index

lightning-sunbird  0.9+nobinonly
secitem.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is the Netscape security libraries.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 1994-2000
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPL"), or
00025  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 
00037 #ifndef _SECITEM_H_
00038 #define _SECITEM_H_
00039 /*
00040  * secitem.h - public data structures and prototypes for handling
00041  *            SECItems
00042  *
00043  * $Id: secitem.h,v 1.4.28.1 2006/04/24 23:48:05 wtchang%redhat.com Exp $
00044  */
00045 
00046 #include "plarena.h"
00047 #include "plhash.h"
00048 #include "seccomon.h"
00049 
00050 SEC_BEGIN_PROTOS
00051 
00052 /*
00053 ** Allocate an item.  If "arena" is not NULL, then allocate from there,
00054 ** otherwise allocate from the heap.  If "item" is not NULL, allocate
00055 ** only the data for the item, not the item itself.  The item structure
00056 ** is allocated zero-filled; the data buffer is not zeroed.  The caller
00057 ** is responsible for initializing the type field of the item.
00058 **
00059 ** The resulting item is returned; NULL if any error occurs.
00060 **
00061 ** XXX This probably should take a SECItemType, but since that is mostly
00062 ** unused and our improved APIs (aka Stan) are looming, I left it out.
00063 */
00064 extern SECItem *SECITEM_AllocItem(PRArenaPool *arena, SECItem *item,
00065                               unsigned int len);
00066 
00067 /*
00068 ** Reallocate the data for the specified "item".  If "arena" is not NULL,
00069 ** then reallocate from there, otherwise reallocate from the heap.
00070 ** In the case where oldlen is 0, the data is allocated (not reallocated).
00071 ** In any case, "item" is expected to be a valid SECItem pointer;
00072 ** SECFailure is returned if it is not.  If the allocation succeeds,
00073 ** SECSuccess is returned.
00074 */
00075 extern SECStatus SECITEM_ReallocItem(PRArenaPool *arena, SECItem *item,
00076                                  unsigned int oldlen, unsigned int newlen);
00077 
00078 /*
00079 ** Compare two items returning the difference between them.
00080 */
00081 extern SECComparison SECITEM_CompareItem(const SECItem *a, const SECItem *b);
00082 
00083 /*
00084 ** Compare two items -- if they are the same, return true; otherwise false.
00085 */
00086 extern PRBool SECITEM_ItemsAreEqual(const SECItem *a, const SECItem *b);
00087 
00088 /*
00089 ** Copy "from" to "to"
00090 */
00091 extern SECStatus SECITEM_CopyItem(PRArenaPool *arena, SECItem *to, 
00092                                   const SECItem *from);
00093 
00094 /*
00095 ** Allocate an item and copy "from" into it.
00096 */
00097 extern SECItem *SECITEM_DupItem(const SECItem *from);
00098 
00099 /*
00100 ** Allocate an item and copy "from" into it.  The item itself and the 
00101 ** data it points to are both allocated from the arena.  If arena is
00102 ** NULL, this function is equivalent to SECITEM_DupItem.
00103 */
00104 extern SECItem *SECITEM_ArenaDupItem(PRArenaPool *arena, const SECItem *from);
00105 
00106 /*
00107 ** Free "zap". If freeit is PR_TRUE then "zap" itself is freed.
00108 */
00109 extern void SECITEM_FreeItem(SECItem *zap, PRBool freeit);
00110 
00111 /*
00112 ** Zero and then free "zap". If freeit is PR_TRUE then "zap" itself is freed.
00113 */
00114 extern void SECITEM_ZfreeItem(SECItem *zap, PRBool freeit);
00115 
00116 PLHashNumber PR_CALLBACK SECITEM_Hash ( const void *key);
00117 
00118 PRIntn PR_CALLBACK SECITEM_HashCompare ( const void *k1, const void *k2);
00119 
00120 
00121 SEC_END_PROTOS
00122 
00123 #endif /* _SECITEM_H_ */