1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
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/
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
14 * The Original Code is the Netscape security libraries.
16 * The Initial Developer of the Original Code is
17 * Netscape Communications Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 1994-2000
19 * the Initial Developer. All Rights Reserved.
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the MPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the MPL, the GPL or the LGPL.
35 * ***** END LICENSE BLOCK ***** */
41 static const char BASET_CVS_ID
[] = "@(#) $RCSfile: baset.h,v $ $Revision: 1.8 $ $Date: 2005/01/20 02:25:45 $";
47 * This file contains definitions for the basic types used throughout
48 * nss but not available publicly.
53 #endif /* NSSBASET_H */
62 * This type is used to mark the current state of an NSSArena.
65 struct nssArenaMarkStr
;
66 typedef struct nssArenaMarkStr nssArenaMark
;
72 * Optionally, this arena implementation can be compiled with some
73 * runtime checking enabled, which will catch the situation where
74 * one thread "marks" the arena, another thread allocates memory,
75 * and then the mark is released. Usually this is a surprise to
76 * the second thread, and this leads to weird runtime errors.
77 * Define ARENA_THREADMARK to catch these cases; we define it for all
78 * (internal and external) debug builds.
80 #define ARENA_THREADMARK
83 * ARENA_DESTRUCTOR_LIST
85 * Unfortunately, our pointer-tracker facility, used in debug
86 * builds to agressively fight invalid pointers, requries that
87 * pointers be deregistered when objects are destroyed. This
88 * conflicts with the standard arena usage where "memory-only"
89 * objects (that don't hold onto resources outside the arena)
90 * can be allocated in an arena, and never destroyed other than
91 * when the arena is destroyed. Therefore we have added a
92 * destructor-registratio facility to our arenas. This was not
93 * a simple decision, since we're getting ever-further away from
94 * the original arena philosophy. However, it was felt that
95 * adding this in debug builds wouldn't be so bad; as it would
96 * discourage them from being used for "serious" purposes.
97 * This facility requires ARENA_THREADMARK to be defined.
99 #ifdef ARENA_THREADMARK
100 #define ARENA_DESTRUCTOR_LIST
101 #endif /* ARENA_THREADMARK */
105 typedef struct nssListStr nssList
;
106 typedef struct nssListIteratorStr nssListIterator
;
107 typedef PRBool (* nssListCompareFunc
)(void *a
, void *b
);
108 typedef PRIntn (* nssListSortFunc
)(void *a
, void *b
);
109 typedef void (* nssListElementDestructorFunc
)(void *el
);
111 typedef struct nssHashStr nssHash
;
112 typedef void (PR_CALLBACK
*nssHashIterator
)(const void *key
,
119 * This type is used in debug builds (both external and internal) to
120 * track our object pointers. Objects of this type must be statically
121 * allocated, which means the structure size must be available to the
122 * compiler. Therefore we must expose the contents of this structure.
123 * But please don't access elements directly; use the accessors.
127 struct nssPointerTrackerStr
{
132 typedef struct nssPointerTrackerStr nssPointerTracker
;
138 * There are several types of strings in the real world. We try to
139 * use only UTF8 and avoid the rest, but that's not always possible.
140 * So we have a couple converter routines to go to and from the other
141 * string types. We have to be able to specify those string types,
142 * so we have this enumeration.
145 enum nssStringTypeEnum
{
146 nssStringType_DirectoryString
,
147 nssStringType_TeletexString
, /* Not "teletext" with trailing 't' */
148 nssStringType_PrintableString
,
149 nssStringType_UniversalString
,
150 nssStringType_BMPString
,
151 nssStringType_UTF8String
,
152 nssStringType_PHGString
,
153 nssStringType_GeneralString
,
155 nssStringType_Unknown
= -1
157 typedef enum nssStringTypeEnum nssStringType
;