Back to index

lightning-sunbird  0.9+nobinonly
baset.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 BASET_H
00038 #define BASET_H
00039 
00040 #ifdef DEBUG
00041 static const char BASET_CVS_ID[] = "@(#) $RCSfile: baset.h,v $ $Revision: 1.8 $ $Date: 2005/01/20 02:25:45 $";
00042 #endif /* DEBUG */
00043 
00044 /*
00045  * baset.h
00046  *
00047  * This file contains definitions for the basic types used throughout
00048  * nss but not available publicly.
00049  */
00050 
00051 #ifndef NSSBASET_H
00052 #include "nssbaset.h"
00053 #endif /* NSSBASET_H */
00054 
00055 #include "plhash.h"
00056 
00057 PR_BEGIN_EXTERN_C
00058 
00059 /*
00060  * nssArenaMark
00061  *
00062  * This type is used to mark the current state of an NSSArena.
00063  */
00064 
00065 struct nssArenaMarkStr;
00066 typedef struct nssArenaMarkStr nssArenaMark;
00067 
00068 #ifdef DEBUG
00069 /*
00070  * ARENA_THREADMARK
00071  * 
00072  * Optionally, this arena implementation can be compiled with some
00073  * runtime checking enabled, which will catch the situation where
00074  * one thread "marks" the arena, another thread allocates memory,
00075  * and then the mark is released.  Usually this is a surprise to
00076  * the second thread, and this leads to weird runtime errors.
00077  * Define ARENA_THREADMARK to catch these cases; we define it for all
00078  * (internal and external) debug builds.
00079  */
00080 #define ARENA_THREADMARK
00081 
00082 /*
00083  * ARENA_DESTRUCTOR_LIST
00084  *
00085  * Unfortunately, our pointer-tracker facility, used in debug
00086  * builds to agressively fight invalid pointers, requries that
00087  * pointers be deregistered when objects are destroyed.  This
00088  * conflicts with the standard arena usage where "memory-only"
00089  * objects (that don't hold onto resources outside the arena)
00090  * can be allocated in an arena, and never destroyed other than
00091  * when the arena is destroyed.  Therefore we have added a
00092  * destructor-registratio facility to our arenas.  This was not
00093  * a simple decision, since we're getting ever-further away from
00094  * the original arena philosophy.  However, it was felt that
00095  * adding this in debug builds wouldn't be so bad; as it would
00096  * discourage them from being used for "serious" purposes.
00097  * This facility requires ARENA_THREADMARK to be defined.
00098  */
00099 #ifdef ARENA_THREADMARK
00100 #define ARENA_DESTRUCTOR_LIST
00101 #endif /* ARENA_THREADMARK */
00102 
00103 #endif /* DEBUG */
00104 
00105 typedef struct nssListStr nssList;
00106 typedef struct nssListIteratorStr nssListIterator;
00107 typedef PRBool (* nssListCompareFunc)(void *a, void *b);
00108 typedef PRIntn (* nssListSortFunc)(void *a, void *b);
00109 typedef void (* nssListElementDestructorFunc)(void *el);
00110 
00111 typedef struct nssHashStr nssHash;
00112 typedef void (PR_CALLBACK *nssHashIterator)(const void *key, 
00113                                             void *value, 
00114                                             void *arg);
00115 
00116 /*
00117  * nssPointerTracker
00118  *
00119  * This type is used in debug builds (both external and internal) to
00120  * track our object pointers.  Objects of this type must be statically
00121  * allocated, which means the structure size must be available to the
00122  * compiler.  Therefore we must expose the contents of this structure.
00123  * But please don't access elements directly; use the accessors.
00124  */
00125 
00126 #ifdef DEBUG
00127 struct nssPointerTrackerStr {
00128   PRCallOnceType once;
00129   PZLock *lock;
00130   PLHashTable *table;
00131 };
00132 typedef struct nssPointerTrackerStr nssPointerTracker;
00133 #endif /* DEBUG */
00134 
00135 /*
00136  * nssStringType
00137  *
00138  * There are several types of strings in the real world.  We try to
00139  * use only UTF8 and avoid the rest, but that's not always possible.
00140  * So we have a couple converter routines to go to and from the other
00141  * string types.  We have to be able to specify those string types,
00142  * so we have this enumeration.
00143  */
00144 
00145 enum nssStringTypeEnum {
00146   nssStringType_DirectoryString,
00147   nssStringType_TeletexString, /* Not "teletext" with trailing 't' */
00148   nssStringType_PrintableString,
00149   nssStringType_UniversalString,
00150   nssStringType_BMPString,
00151   nssStringType_UTF8String,
00152   nssStringType_PHGString,
00153   nssStringType_GeneralString,
00154 
00155   nssStringType_Unknown = -1
00156 };
00157 typedef enum nssStringTypeEnum nssStringType;
00158 
00159 PR_END_EXTERN_C
00160 
00161 #endif /* BASET_H */