security/nss/lib/base/base.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/lib/base/base.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,1394 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef BASE_H
     1.9 +#define BASE_H
    1.10 +
    1.11 +/*
    1.12 + * base.h
    1.13 + *
    1.14 + * This header file contains basic prototypes and preprocessor 
    1.15 + * definitions used throughout nss but not available publicly.
    1.16 + */
    1.17 +
    1.18 +#ifndef BASET_H
    1.19 +#include "baset.h"
    1.20 +#endif /* BASET_H */
    1.21 +
    1.22 +#ifndef NSSBASE_H
    1.23 +#include "nssbase.h"
    1.24 +#endif /* NSSBASE_H */
    1.25 +
    1.26 +#include "plhash.h"
    1.27 +
    1.28 +PR_BEGIN_EXTERN_C
    1.29 +
    1.30 +/*
    1.31 + * NSSArena
    1.32 + *
    1.33 + * The nonpublic methods relating to this type are:
    1.34 + *
    1.35 + *  nssArena_Create  -- constructor
    1.36 + *  nssArena_Destroy
    1.37 + *  nssArena_Mark
    1.38 + *  nssArena_Release
    1.39 + *  nssArena_Unmark
    1.40 + *
    1.41 + *  nss_ZAlloc
    1.42 + *  nss_ZFreeIf
    1.43 + *  nss_ZRealloc
    1.44 + *
    1.45 + * Additionally, there are some preprocessor macros:
    1.46 + *
    1.47 + *  nss_ZNEW
    1.48 + *  nss_ZNEWARRAY
    1.49 + *
    1.50 + * In debug builds, the following calls are available:
    1.51 + *
    1.52 + *  nssArena_verifyPointer
    1.53 + *  nssArena_registerDestructor
    1.54 + *  nssArena_deregisterDestructor
    1.55 + *
    1.56 + * The following preprocessor macro is also always available:
    1.57 + *
    1.58 + *  nssArena_VERIFYPOINTER
    1.59 + *
    1.60 + * A constant PLHashAllocOps structure is available for users
    1.61 + * of the NSPL PLHashTable routines.
    1.62 + *
    1.63 + *  nssArenaHashAllocOps
    1.64 + */
    1.65 +
    1.66 +/*
    1.67 + * nssArena_Create
    1.68 + *
    1.69 + * This routine creates a new memory arena.  This routine may return
    1.70 + * NULL upon error, in which case it will have set an error on the 
    1.71 + * error stack.
    1.72 + *
    1.73 + * The error may be one of the following values:
    1.74 + *  NSS_ERROR_NO_MEMORY
    1.75 + *
    1.76 + * Return value:
    1.77 + *  NULL upon error
    1.78 + *  A pointer to an NSSArena upon success
    1.79 + */
    1.80 +
    1.81 +/*
    1.82 + * XXX fgmr
    1.83 + * Arenas can be named upon creation; this is mostly of use when
    1.84 + * debugging.  Should we expose that here, allowing an optional
    1.85 + * "const char *name" argument?  Should the public version of this
    1.86 + * call (NSSArena_Create) have it too?
    1.87 + */
    1.88 +
    1.89 +NSS_EXTERN NSSArena *
    1.90 +nssArena_Create
    1.91 +(
    1.92 +  void
    1.93 +);
    1.94 +
    1.95 +extern const NSSError NSS_ERROR_NO_MEMORY;
    1.96 +
    1.97 +/*
    1.98 + * nssArena_Destroy
    1.99 + *
   1.100 + * This routine will destroy the specified arena, freeing all memory
   1.101 + * allocated from it.  This routine returns a PRStatus value; if 
   1.102 + * successful, it will return PR_SUCCESS.  If unsuccessful, it will
   1.103 + * set an error on the error stack and return PR_FAILURE.
   1.104 + *
   1.105 + * The error may be one of the following values:
   1.106 + *  NSS_ERROR_INVALID_ARENA
   1.107 + *
   1.108 + * Return value:
   1.109 + *  PR_SUCCESS
   1.110 + *  PR_FAILURE
   1.111 + */
   1.112 +
   1.113 +NSS_EXTERN PRStatus
   1.114 +nssArena_Destroy
   1.115 +(
   1.116 +  NSSArena *arena
   1.117 +);
   1.118 +
   1.119 +extern const NSSError NSS_ERROR_INVALID_ARENA;
   1.120 +
   1.121 +/*
   1.122 + * nssArena_Mark
   1.123 + *
   1.124 + * This routine "marks" the current state of an arena.  Space
   1.125 + * allocated after the arena has been marked can be freed by
   1.126 + * releasing the arena back to the mark with nssArena_Release,
   1.127 + * or committed by calling nssArena_Unmark.  When successful, 
   1.128 + * this routine returns a valid nssArenaMark pointer.  This 
   1.129 + * routine may return NULL upon error, in which case it will 
   1.130 + * have set an error on the error stack.
   1.131 + *
   1.132 + * The error may be one of the following values:
   1.133 + *  NSS_ERROR_INVALID_ARENA
   1.134 + *  NSS_ERROR_NO_MEMORY
   1.135 + *  NSS_ERROR_ARENA_MARKED_BY_ANOTHER_THREAD
   1.136 + *
   1.137 + * Return value:
   1.138 + *  NULL upon failure
   1.139 + *  An nssArenaMark pointer upon success
   1.140 + */
   1.141 +
   1.142 +NSS_EXTERN nssArenaMark *
   1.143 +nssArena_Mark
   1.144 +(
   1.145 +  NSSArena *arena
   1.146 +);
   1.147 +
   1.148 +extern const NSSError NSS_ERROR_INVALID_ARENA;
   1.149 +extern const NSSError NSS_ERROR_NO_MEMORY;
   1.150 +extern const NSSError NSS_ERROR_ARENA_MARKED_BY_ANOTHER_THREAD;
   1.151 +
   1.152 +/*
   1.153 + * nssArena_Release
   1.154 + *
   1.155 + * This routine invalidates and releases all memory allocated from
   1.156 + * the specified arena after the point at which the specified mark
   1.157 + * was obtained.  This routine returns a PRStatus value; if successful,
   1.158 + * it will return PR_SUCCESS.  If unsuccessful, it will set an error
   1.159 + * on the error stack and return PR_FAILURE.
   1.160 + *
   1.161 + * The error may be one of the following values:
   1.162 + *  NSS_ERROR_INVALID_ARENA
   1.163 + *  NSS_ERROR_INVALID_ARENA_MARK
   1.164 + *  NSS_ERROR_ARENA_MARKED_BY_ANOTHER_THREAD
   1.165 + *
   1.166 + * Return value:
   1.167 + *  PR_SUCCESS
   1.168 + *  PR_FAILURE
   1.169 + */
   1.170 +
   1.171 +NSS_EXTERN PRStatus
   1.172 +nssArena_Release
   1.173 +(
   1.174 +  NSSArena *arena,
   1.175 +  nssArenaMark *arenaMark
   1.176 +);
   1.177 +
   1.178 +extern const NSSError NSS_ERROR_INVALID_ARENA;
   1.179 +extern const NSSError NSS_ERROR_INVALID_ARENA_MARK;
   1.180 +
   1.181 +/*
   1.182 + * nssArena_Unmark
   1.183 + *
   1.184 + * This routine "commits" the indicated mark and any marks after
   1.185 + * it, making them unreleasable.  Note that any earlier marks can
   1.186 + * still be released, and such a release will invalidate these
   1.187 + * later unmarked regions.  If an arena is to be safely shared by
   1.188 + * more than one thread, all marks must be either released or
   1.189 + * unmarked.  This routine returns a PRStatus value; if successful,
   1.190 + * it will return PR_SUCCESS.  If unsuccessful, it will set an error
   1.191 + * on the error stack and return PR_FAILURE.
   1.192 + *
   1.193 + * The error may be one of the following values:
   1.194 + *  NSS_ERROR_INVALID_ARENA
   1.195 + *  NSS_ERROR_INVALID_ARENA_MARK
   1.196 + *  NSS_ERROR_ARENA_MARKED_BY_ANOTHER_THREAD
   1.197 + *
   1.198 + * Return value:
   1.199 + *  PR_SUCCESS
   1.200 + *  PR_FAILURE
   1.201 + */
   1.202 +
   1.203 +NSS_EXTERN PRStatus
   1.204 +nssArena_Unmark
   1.205 +(
   1.206 +  NSSArena *arena,
   1.207 +  nssArenaMark *arenaMark
   1.208 +);
   1.209 +
   1.210 +extern const NSSError NSS_ERROR_INVALID_ARENA;
   1.211 +extern const NSSError NSS_ERROR_INVALID_ARENA_MARK;
   1.212 +extern const NSSError NSS_ERROR_ARENA_MARKED_BY_ANOTHER_THREAD;
   1.213 +
   1.214 +#ifdef ARENA_DESTRUCTOR_LIST
   1.215 +
   1.216 +/*
   1.217 + * nssArena_registerDestructor
   1.218 + *
   1.219 + * This routine stores a pointer to a callback and an arbitrary
   1.220 + * pointer-sized argument in the arena, at the current point in
   1.221 + * the mark stack.  If the arena is destroyed, or an "earlier"
   1.222 + * mark is released, then this destructor will be called at that
   1.223 + * time.  Note that the destructor will be called with the arena
   1.224 + * locked, which means the destructor may free memory in that
   1.225 + * arena, but it may not allocate or cause to be allocated any
   1.226 + * memory.  This callback facility was included to support our
   1.227 + * debug-version pointer-tracker feature; overuse runs counter to
   1.228 + * the the original intent of arenas.  This routine returns a 
   1.229 + * PRStatus value; if successful, it will return PR_SUCCESS.  If 
   1.230 + * unsuccessful, it will set an error on the error stack and 
   1.231 + * return PR_FAILURE.
   1.232 + *
   1.233 + * The error may be one of the following values:
   1.234 + *  NSS_ERROR_INVALID_ARENA
   1.235 + *  NSS_ERROR_NO_MEMORY
   1.236 + *
   1.237 + * Return value:
   1.238 + *  PR_SUCCESS
   1.239 + *  PR_FAILURE
   1.240 + */
   1.241 +
   1.242 +NSS_EXTERN PRStatus
   1.243 +nssArena_registerDestructor
   1.244 +(
   1.245 +  NSSArena *arena,
   1.246 +  void (*destructor)(void *argument),
   1.247 +  void *arg
   1.248 +);
   1.249 +
   1.250 +extern const NSSError NSS_ERROR_INVALID_ARENA;
   1.251 +extern const NSSError NSS_ERROR_NO_MEMORY;
   1.252 +
   1.253 +/*
   1.254 + * nssArena_deregisterDestructor
   1.255 + *
   1.256 + * This routine will remove the first destructor in the specified
   1.257 + * arena which has the specified destructor and argument values.
   1.258 + * The destructor will not be called.  This routine returns a
   1.259 + * PRStatus value; if successful, it will return PR_SUCCESS.  If 
   1.260 + * unsuccessful, it will set an error on the error stack and 
   1.261 + * return PR_FAILURE.
   1.262 + *
   1.263 + * The error may be one of the following values:
   1.264 + *  NSS_ERROR_INVALID_ARENA
   1.265 + *  NSS_ERROR_NOT_FOUND
   1.266 + *
   1.267 + * Return value:
   1.268 + *  PR_SUCCESS
   1.269 + *  PR_FAILURE
   1.270 + */
   1.271 +
   1.272 +NSS_EXTERN PRStatus
   1.273 +nssArena_deregisterDestructor
   1.274 +(
   1.275 +  NSSArena *arena,
   1.276 +  void (*destructor)(void *argument),
   1.277 +  void *arg
   1.278 +);
   1.279 +
   1.280 +extern const NSSError NSS_ERROR_INVALID_ITEM;
   1.281 +extern const NSSError NSS_ERROR_INVALID_ARENA;
   1.282 +extern const NSSError NSS_ERROR_NOT_FOUND;
   1.283 +
   1.284 +#endif /* ARENA_DESTRUCTOR_LIST */
   1.285 +
   1.286 +/*
   1.287 + * nss_ZAlloc
   1.288 + *
   1.289 + * This routine allocates and zeroes a section of memory of the 
   1.290 + * size, and returns to the caller a pointer to that memory.  If
   1.291 + * the optional arena argument is non-null, the memory will be
   1.292 + * obtained from that arena; otherwise, the memory will be obtained
   1.293 + * from the heap.  This routine may return NULL upon error, in
   1.294 + * which case it will have set an error upon the error stack.  The
   1.295 + * value specified for size may be zero; in which case a valid 
   1.296 + * zero-length block of memory will be allocated.  This block may
   1.297 + * be expanded by calling nss_ZRealloc.
   1.298 + *
   1.299 + * The error may be one of the following values:
   1.300 + *  NSS_ERROR_INVALID_ARENA
   1.301 + *  NSS_ERROR_NO_MEMORY
   1.302 + *  NSS_ERROR_ARENA_MARKED_BY_ANOTHER_THREAD
   1.303 + *
   1.304 + * Return value:
   1.305 + *  NULL upon error
   1.306 + *  A pointer to the new segment of zeroed memory
   1.307 + */
   1.308 +
   1.309 +NSS_EXTERN void *
   1.310 +nss_ZAlloc
   1.311 +(
   1.312 +  NSSArena *arenaOpt,
   1.313 +  PRUint32 size
   1.314 +);
   1.315 +
   1.316 +extern const NSSError NSS_ERROR_INVALID_ARENA;
   1.317 +extern const NSSError NSS_ERROR_NO_MEMORY;
   1.318 +extern const NSSError NSS_ERROR_ARENA_MARKED_BY_ANOTHER_THREAD;
   1.319 +
   1.320 +/*
   1.321 + * nss_ZFreeIf
   1.322 + *
   1.323 + * If the specified pointer is non-null, then the region of memory 
   1.324 + * to which it points -- which must have been allocated with 
   1.325 + * nss_ZAlloc -- will be zeroed and released.  This routine 
   1.326 + * returns a PRStatus value; if successful, it will return PR_SUCCESS.
   1.327 + * If unsuccessful, it will set an error on the error stack and return 
   1.328 + * PR_FAILURE.
   1.329 + *
   1.330 + * The error may be one of the following values:
   1.331 + *  NSS_ERROR_INVALID_POINTER
   1.332 + *
   1.333 + * Return value:
   1.334 + *  PR_SUCCESS
   1.335 + *  PR_FAILURE
   1.336 + */
   1.337 +
   1.338 +NSS_EXTERN PRStatus
   1.339 +nss_ZFreeIf
   1.340 +(
   1.341 +  void *pointer
   1.342 +);
   1.343 +
   1.344 +extern const NSSError NSS_ERROR_INVALID_POINTER;
   1.345 +
   1.346 +/*
   1.347 + * nss_ZRealloc
   1.348 + *
   1.349 + * This routine reallocates a block of memory obtained by calling
   1.350 + * nss_ZAlloc or nss_ZRealloc.  The portion of memory 
   1.351 + * between the new and old sizes -- which is either being newly
   1.352 + * obtained or released -- is in either case zeroed.  This routine 
   1.353 + * may return NULL upon failure, in which case it will have placed 
   1.354 + * an error on the error stack.
   1.355 + *
   1.356 + * The error may be one of the following values:
   1.357 + *  NSS_ERROR_INVALID_POINTER
   1.358 + *  NSS_ERROR_NO_MEMORY
   1.359 + *  NSS_ERROR_ARENA_MARKED_BY_ANOTHER_THREAD
   1.360 + *
   1.361 + * Return value:
   1.362 + *  NULL upon error
   1.363 + *  A pointer to the replacement segment of memory
   1.364 + */
   1.365 +
   1.366 +NSS_EXTERN void *
   1.367 +nss_ZRealloc
   1.368 +(
   1.369 +  void *pointer,
   1.370 +  PRUint32 newSize
   1.371 +);
   1.372 +
   1.373 +extern const NSSError NSS_ERROR_INVALID_POINTER;
   1.374 +extern const NSSError NSS_ERROR_NO_MEMORY;
   1.375 +extern const NSSError NSS_ERROR_ARENA_MARKED_BY_ANOTHER_THREAD;
   1.376 +
   1.377 +/*
   1.378 + * nss_ZNEW
   1.379 + *
   1.380 + * This preprocessor macro will allocate memory for a new object
   1.381 + * of the specified type with nss_ZAlloc, and will cast the
   1.382 + * return value appropriately.  If the optional arena argument is 
   1.383 + * non-null, the memory will be obtained from that arena; otherwise, 
   1.384 + * the memory will be obtained from the heap.  This routine may 
   1.385 + * return NULL upon error, in which case it will have set an error 
   1.386 + * upon the error stack.
   1.387 + *
   1.388 + * The error may be one of the following values:
   1.389 + *  NSS_ERROR_INVALID_ARENA
   1.390 + *  NSS_ERROR_NO_MEMORY
   1.391 + *
   1.392 + * Return value:
   1.393 + *  NULL upon error
   1.394 + *  A pointer to the new segment of zeroed memory
   1.395 + */
   1.396 +
   1.397 +/* The following line exceeds 72 characters, but emacs screws up if I split it. */
   1.398 +#define nss_ZNEW(arenaOpt, type) ((type *)nss_ZAlloc((arenaOpt), sizeof(type)))
   1.399 +
   1.400 +/*
   1.401 + * nss_ZNEWARRAY
   1.402 + *
   1.403 + * This preprocessor macro will allocate memory for an array of
   1.404 + * new objects, and will cast the return value appropriately.
   1.405 + * If the optional arena argument is non-null, the memory will 
   1.406 + * be obtained from that arena; otherwise, the memory will be 
   1.407 + * obtained from the heap.  This routine may return NULL upon 
   1.408 + * error, in which case it will have set an error upon the error 
   1.409 + * stack.  The array size may be specified as zero.
   1.410 + *
   1.411 + * The error may be one of the following values:
   1.412 + *  NSS_ERROR_INVALID_ARENA
   1.413 + *  NSS_ERROR_NO_MEMORY
   1.414 + *
   1.415 + * Return value:
   1.416 + *  NULL upon error
   1.417 + *  A pointer to the new segment of zeroed memory
   1.418 + */
   1.419 +
   1.420 +/* The following line exceeds 72 characters, but emacs screws up if I split it. */
   1.421 +#define nss_ZNEWARRAY(arenaOpt, type, quantity) ((type *)nss_ZAlloc((arenaOpt), sizeof(type) * (quantity)))
   1.422 +
   1.423 +/*
   1.424 + * nss_ZREALLOCARRAY
   1.425 + *
   1.426 + * This preprocessor macro will reallocate memory for an array of
   1.427 + * new objects, and will cast the return value appropriately.
   1.428 + * This routine may return NULL upon error, in which case it will 
   1.429 + *  have set an error upon the error stack.
   1.430 + *
   1.431 + * The error may be one of the following values:
   1.432 + *  NSS_ERROR_INVALID_POINTER
   1.433 + *  NSS_ERROR_NO_MEMORY
   1.434 + *  NSS_ERROR_ARENA_MARKED_BY_ANOTHER_THREAD
   1.435 + *
   1.436 + * Return value:
   1.437 + *  NULL upon error
   1.438 + *  A pointer to the replacement segment of memory
   1.439 + */
   1.440 +#define nss_ZREALLOCARRAY(p, type, quantity) ((type *)nss_ZRealloc((p), sizeof(type) * (quantity)))
   1.441 +
   1.442 +/*
   1.443 + * nssArena_verifyPointer
   1.444 + *
   1.445 + * This method is only present in debug builds.
   1.446 + *
   1.447 + * If the specified pointer is a valid pointer to an NSSArena object,
   1.448 + * this routine will return PR_SUCCESS.  Otherwise, it will put an
   1.449 + * error on the error stack and return PR_FAILURE.
   1.450 + *
   1.451 + * The error may be one of the following values:
   1.452 + *  NSS_ERROR_INVALID_ARENA
   1.453 + *
   1.454 + * Return value:
   1.455 + *  PR_SUCCESS if the pointer is valid
   1.456 + *  PR_FAILURE if it isn't
   1.457 + */
   1.458 +
   1.459 +#ifdef DEBUG
   1.460 +NSS_EXTERN PRStatus
   1.461 +nssArena_verifyPointer
   1.462 +(
   1.463 +  const NSSArena *arena
   1.464 +);
   1.465 +
   1.466 +extern const NSSError NSS_ERROR_INVALID_ARENA;
   1.467 +#endif /* DEBUG */
   1.468 +
   1.469 +/*
   1.470 + * nssArena_VERIFYPOINTER
   1.471 + *
   1.472 + * This macro is always available.  In debug builds it will call
   1.473 + * nssArena_verifyPointer; in non-debug builds, it will merely
   1.474 + * check that the pointer is not null.  Note that in non-debug
   1.475 + * builds it cannot place an error on the error stack.
   1.476 + *
   1.477 + * Return value:
   1.478 + *  PR_SUCCESS if the pointer is valid
   1.479 + *  PR_FAILURE if it isn't
   1.480 + */
   1.481 +
   1.482 +#ifdef DEBUG
   1.483 +#define nssArena_VERIFYPOINTER(p) nssArena_verifyPointer(p)
   1.484 +#else /* DEBUG */
   1.485 +/* The following line exceeds 72 characters, but emacs screws up if I split it. */
   1.486 +#define nssArena_VERIFYPOINTER(p) (((NSSArena *)NULL == (p))?PR_FAILURE:PR_SUCCESS)
   1.487 +#endif /* DEBUG */
   1.488 +
   1.489 +/*
   1.490 + * Private function to be called by NSS_Shutdown to cleanup nssArena 
   1.491 + * bookkeeping.
   1.492 + */
   1.493 +extern PRStatus
   1.494 +nssArena_Shutdown(void);
   1.495 +
   1.496 +/*
   1.497 + * nssArenaHashAllocOps
   1.498 + *
   1.499 + * This constant structure contains allocation callbacks designed for
   1.500 + * use with the NSPL routine PL_NewHashTable.  For example:
   1.501 + *
   1.502 + *  NSSArena *hashTableArena = nssArena_Create();
   1.503 + *  PLHashTable *t = PL_NewHashTable(n, hasher, key_compare, 
   1.504 + *    value_compare, nssArenaHashAllocOps, hashTableArena);
   1.505 + */
   1.506 +
   1.507 +NSS_EXTERN_DATA PLHashAllocOps nssArenaHashAllocOps;
   1.508 +
   1.509 +/*
   1.510 + * The error stack
   1.511 + *
   1.512 + * The nonpublic methods relating to the error stack are:
   1.513 + *
   1.514 + *  nss_SetError
   1.515 + *  nss_ClearErrorStack
   1.516 + */
   1.517 +
   1.518 +/*
   1.519 + * nss_SetError
   1.520 + *
   1.521 + * This routine places a new error code on the top of the calling 
   1.522 + * thread's error stack.  Calling this routine wiht an error code
   1.523 + * of zero will clear the error stack.
   1.524 + */
   1.525 +
   1.526 +NSS_EXTERN void
   1.527 +nss_SetError
   1.528 +(
   1.529 +  PRUint32 error
   1.530 +);
   1.531 +
   1.532 +/*
   1.533 + * nss_ClearErrorStack
   1.534 + *
   1.535 + * This routine clears the calling thread's error stack.
   1.536 + */
   1.537 +
   1.538 +NSS_EXTERN void
   1.539 +nss_ClearErrorStack
   1.540 +(
   1.541 +  void
   1.542 +);
   1.543 +
   1.544 +/*
   1.545 + * nss_DestroyErrorStack
   1.546 + *
   1.547 + * This routine frees the calling thread's error stack.
   1.548 + */
   1.549 +
   1.550 +NSS_EXTERN void
   1.551 +nss_DestroyErrorStack
   1.552 +(
   1.553 +  void
   1.554 +);
   1.555 +
   1.556 +/*
   1.557 + * NSSItem
   1.558 + *
   1.559 + * nssItem_Create
   1.560 + * nssItem_Duplicate
   1.561 + * nssItem_Equal
   1.562 + */
   1.563 +
   1.564 +NSS_EXTERN NSSItem *
   1.565 +nssItem_Create
   1.566 +(
   1.567 +  NSSArena *arenaOpt,
   1.568 +  NSSItem *rvOpt,
   1.569 +  PRUint32 length,
   1.570 +  const void *data
   1.571 +);
   1.572 +
   1.573 +NSS_EXTERN void
   1.574 +nssItem_Destroy
   1.575 +(
   1.576 +  NSSItem *item
   1.577 +);
   1.578 +
   1.579 +NSS_EXTERN NSSItem *
   1.580 +nssItem_Duplicate
   1.581 +(
   1.582 +  NSSItem *obj,
   1.583 +  NSSArena *arenaOpt,
   1.584 +  NSSItem *rvOpt
   1.585 +);
   1.586 +
   1.587 +NSS_EXTERN PRBool
   1.588 +nssItem_Equal
   1.589 +(
   1.590 +  const NSSItem *one,
   1.591 +  const NSSItem *two,
   1.592 +  PRStatus *statusOpt
   1.593 +);
   1.594 +
   1.595 +/*
   1.596 + * NSSUTF8
   1.597 + *
   1.598 + *  nssUTF8_CaseIgnoreMatch
   1.599 + *  nssUTF8_Duplicate
   1.600 + *  nssUTF8_Size
   1.601 + *  nssUTF8_Length
   1.602 + *  nssUTF8_CopyIntoFixedBuffer
   1.603 + */
   1.604 +
   1.605 +/*
   1.606 + * nssUTF8_CaseIgnoreMatch
   1.607 + * 
   1.608 + * Returns true if the two UTF8-encoded strings pointed to by the 
   1.609 + * two specified NSSUTF8 pointers differ only in typcase.
   1.610 + *
   1.611 + * The error may be one of the following values:
   1.612 + *  NSS_ERROR_INVALID_POINTER
   1.613 + *
   1.614 + * Return value:
   1.615 + *  PR_TRUE if the strings match, ignoring case
   1.616 + *  PR_FALSE if they don't
   1.617 + *  PR_FALSE upon error
   1.618 + */
   1.619 +
   1.620 +NSS_EXTERN PRBool
   1.621 +nssUTF8_CaseIgnoreMatch
   1.622 +(
   1.623 +  const NSSUTF8 *a,
   1.624 +  const NSSUTF8 *b,
   1.625 +  PRStatus *statusOpt
   1.626 +);
   1.627 +
   1.628 +/*
   1.629 + * nssUTF8_Duplicate
   1.630 + *
   1.631 + * This routine duplicates the UTF8-encoded string pointed to by the
   1.632 + * specified NSSUTF8 pointer.  If the optional arenaOpt argument is
   1.633 + * not null, the memory required will be obtained from that arena;
   1.634 + * otherwise, the memory required will be obtained from the heap.
   1.635 + * A pointer to the new string will be returned.  In case of error,
   1.636 + * an error will be placed on the error stack and NULL will be 
   1.637 + * returned.
   1.638 + *
   1.639 + * The error may be one of the following values:
   1.640 + *  NSS_ERROR_INVALID_POINTER
   1.641 + *  NSS_ERROR_INVALID_ARENA
   1.642 + *  NSS_ERROR_NO_MEMORY
   1.643 + */
   1.644 +
   1.645 +NSS_EXTERN NSSUTF8 *
   1.646 +nssUTF8_Duplicate
   1.647 +(
   1.648 +  const NSSUTF8 *s,
   1.649 +  NSSArena *arenaOpt
   1.650 +);
   1.651 +
   1.652 +/*
   1.653 + * nssUTF8_PrintableMatch
   1.654 + *
   1.655 + * Returns true if the two Printable strings pointed to by the 
   1.656 + * two specified NSSUTF8 pointers match when compared with the 
   1.657 + * rules for Printable String (leading and trailing spaces are 
   1.658 + * disregarded, extents of whitespace match irregardless of length, 
   1.659 + * and case is not significant), then PR_TRUE will be returned.
   1.660 + * Otherwise, PR_FALSE will be returned.  Upon failure, PR_FALSE
   1.661 + * will be returned.  If the optional statusOpt argument is not
   1.662 + * NULL, then PR_SUCCESS or PR_FAILURE will be stored in that
   1.663 + * location.
   1.664 + *
   1.665 + * The error may be one of the following values:
   1.666 + *  NSS_ERROR_INVALID_POINTER
   1.667 + *
   1.668 + * Return value:
   1.669 + *  PR_TRUE if the strings match, ignoring case
   1.670 + *  PR_FALSE if they don't
   1.671 + *  PR_FALSE upon error
   1.672 + */
   1.673 +
   1.674 +NSS_EXTERN PRBool
   1.675 +nssUTF8_PrintableMatch
   1.676 +(
   1.677 +  const NSSUTF8 *a,
   1.678 +  const NSSUTF8 *b,
   1.679 +  PRStatus *statusOpt
   1.680 +);
   1.681 +
   1.682 +/*
   1.683 + * nssUTF8_Size
   1.684 + *
   1.685 + * This routine returns the length in bytes (including the terminating
   1.686 + * null) of the UTF8-encoded string pointed to by the specified
   1.687 + * NSSUTF8 pointer.  Zero is returned on error.
   1.688 + *
   1.689 + * The error may be one of the following values:
   1.690 + *  NSS_ERROR_INVALID_POINTER
   1.691 + *  NSS_ERROR_VALUE_TOO_LARGE
   1.692 + *
   1.693 + * Return value:
   1.694 + *  nonzero size of the string
   1.695 + *  0 on error
   1.696 + */
   1.697 +
   1.698 +NSS_EXTERN PRUint32
   1.699 +nssUTF8_Size
   1.700 +(
   1.701 +  const NSSUTF8 *s,
   1.702 +  PRStatus *statusOpt
   1.703 +);
   1.704 +
   1.705 +extern const NSSError NSS_ERROR_INVALID_POINTER;
   1.706 +extern const NSSError NSS_ERROR_VALUE_TOO_LARGE;
   1.707 +
   1.708 +/*
   1.709 + * nssUTF8_Length
   1.710 + *
   1.711 + * This routine returns the length in characters (not including the
   1.712 + * terminating null) of the UTF8-encoded string pointed to by the
   1.713 + * specified NSSUTF8 pointer.
   1.714 + *
   1.715 + * The error may be one of the following values:
   1.716 + *  NSS_ERROR_INVALID_POINTER
   1.717 + *  NSS_ERROR_VALUE_TOO_LARGE
   1.718 + *  NSS_ERROR_INVALID_STRING
   1.719 + *
   1.720 + * Return value:
   1.721 + *  length of the string (which may be zero)
   1.722 + *  0 on error
   1.723 + */
   1.724 +
   1.725 +NSS_EXTERN PRUint32
   1.726 +nssUTF8_Length
   1.727 +(
   1.728 +  const NSSUTF8 *s,
   1.729 +  PRStatus *statusOpt
   1.730 +);
   1.731 +
   1.732 +extern const NSSError NSS_ERROR_INVALID_POINTER;
   1.733 +extern const NSSError NSS_ERROR_VALUE_TOO_LARGE;
   1.734 +extern const NSSError NSS_ERROR_INVALID_STRING;
   1.735 +
   1.736 +/*
   1.737 + * nssUTF8_Create
   1.738 + *
   1.739 + * This routine creates a UTF8 string from a string in some other
   1.740 + * format.  Some types of string may include embedded null characters,
   1.741 + * so for them the length parameter must be used.  For string types
   1.742 + * that are null-terminated, the length parameter is optional; if it
   1.743 + * is zero, it will be ignored.  If the optional arena argument is
   1.744 + * non-null, the memory used for the new string will be obtained from
   1.745 + * that arena, otherwise it will be obtained from the heap.  This
   1.746 + * routine may return NULL upon error, in which case it will have
   1.747 + * placed an error on the error stack.
   1.748 + *
   1.749 + * The error may be one of the following:
   1.750 + *  NSS_ERROR_INVALID_POINTER
   1.751 + *  NSS_ERROR_NO_MEMORY
   1.752 + *  NSS_ERROR_UNSUPPORTED_TYPE
   1.753 + *
   1.754 + * Return value:
   1.755 + *  NULL upon error
   1.756 + *  A non-null pointer to a new UTF8 string otherwise
   1.757 + */
   1.758 +
   1.759 +NSS_EXTERN NSSUTF8 *
   1.760 +nssUTF8_Create
   1.761 +(
   1.762 +  NSSArena *arenaOpt,
   1.763 +  nssStringType type,
   1.764 +  const void *inputString,
   1.765 +  PRUint32 size /* in bytes, not characters */
   1.766 +);
   1.767 +
   1.768 +extern const NSSError NSS_ERROR_INVALID_POINTER;
   1.769 +extern const NSSError NSS_ERROR_NO_MEMORY;
   1.770 +extern const NSSError NSS_ERROR_UNSUPPORTED_TYPE;
   1.771 +
   1.772 +NSS_EXTERN NSSItem *
   1.773 +nssUTF8_GetEncoding
   1.774 +(
   1.775 +  NSSArena *arenaOpt,
   1.776 +  NSSItem *rvOpt,
   1.777 +  nssStringType type,
   1.778 +  NSSUTF8 *string
   1.779 +);
   1.780 +
   1.781 +/*
   1.782 + * nssUTF8_CopyIntoFixedBuffer
   1.783 + *
   1.784 + * This will copy a UTF8 string into a fixed-length buffer, making 
   1.785 + * sure that the all characters are valid.  Any remaining space will
   1.786 + * be padded with the specified ASCII character, typically either 
   1.787 + * null or space.
   1.788 + *
   1.789 + * Blah, blah, blah.
   1.790 + */
   1.791 +
   1.792 +extern const NSSError NSS_ERROR_INVALID_POINTER;
   1.793 +extern const NSSError NSS_ERROR_INVALID_ARGUMENT;
   1.794 +
   1.795 +NSS_EXTERN PRStatus
   1.796 +nssUTF8_CopyIntoFixedBuffer
   1.797 +(
   1.798 +  NSSUTF8 *string,
   1.799 +  char *buffer,
   1.800 +  PRUint32 bufferSize,
   1.801 +  char pad
   1.802 +);
   1.803 +
   1.804 +/*
   1.805 + * nssUTF8_Equal
   1.806 + *
   1.807 + */
   1.808 +
   1.809 +NSS_EXTERN PRBool
   1.810 +nssUTF8_Equal
   1.811 +(
   1.812 +  const NSSUTF8 *a,
   1.813 +  const NSSUTF8 *b,
   1.814 +  PRStatus *statusOpt
   1.815 +);
   1.816 +
   1.817 +/*
   1.818 + * nssList
   1.819 + *
   1.820 + * The goal is to provide a simple, optionally threadsafe, linked list
   1.821 + * class.  Since NSS did not seem to use the circularity of PRCList
   1.822 + * much before, this provides a list that appears to be a linear,
   1.823 + * NULL-terminated list.
   1.824 + */
   1.825 +
   1.826 +/*
   1.827 + * nssList_Create
   1.828 + *
   1.829 + * If threadsafe is true, the list will be locked during modifications
   1.830 + * and traversals.
   1.831 + */
   1.832 +NSS_EXTERN nssList *
   1.833 +nssList_Create
   1.834 +(
   1.835 +  NSSArena *arenaOpt,
   1.836 +  PRBool threadSafe
   1.837 +);
   1.838 +
   1.839 +/*
   1.840 + * nssList_Destroy
   1.841 + */
   1.842 +NSS_EXTERN PRStatus
   1.843 +nssList_Destroy
   1.844 +(
   1.845 +  nssList *list
   1.846 +);
   1.847 +
   1.848 +NSS_EXTERN void
   1.849 +nssList_Clear
   1.850 +(
   1.851 +  nssList *list, 
   1.852 +  nssListElementDestructorFunc destructor
   1.853 +);
   1.854 +
   1.855 +/*
   1.856 + * nssList_SetCompareFunction
   1.857 + *
   1.858 + * By default, two list elements will be compared by comparing their
   1.859 + * data pointers.  By setting this function, the user can control
   1.860 + * how elements are compared.
   1.861 + */
   1.862 +NSS_EXTERN void
   1.863 +nssList_SetCompareFunction
   1.864 +(
   1.865 +  nssList *list, 
   1.866 +  nssListCompareFunc compareFunc
   1.867 +);
   1.868 +
   1.869 +/*
   1.870 + * nssList_SetSortFunction
   1.871 + *
   1.872 + * Sort function to use for an ordered list.
   1.873 + */
   1.874 +NSS_EXTERN void
   1.875 +nssList_SetSortFunction
   1.876 +(
   1.877 +  nssList *list, 
   1.878 +  nssListSortFunc sortFunc
   1.879 +);
   1.880 +
   1.881 +/*
   1.882 + * nssList_Add
   1.883 + */
   1.884 +NSS_EXTERN PRStatus
   1.885 +nssList_Add
   1.886 +(
   1.887 +  nssList *list, 
   1.888 +  void *data
   1.889 +);
   1.890 +
   1.891 +/*
   1.892 + * nssList_AddUnique
   1.893 + *
   1.894 + * This will use the compare function to see if the element is already
   1.895 + * in the list.
   1.896 + */
   1.897 +NSS_EXTERN PRStatus
   1.898 +nssList_AddUnique
   1.899 +(
   1.900 +  nssList *list, 
   1.901 +  void *data
   1.902 +);
   1.903 +
   1.904 +/*
   1.905 + * nssList_Remove
   1.906 + *
   1.907 + * Uses the compare function to locate the element and remove it.
   1.908 + */
   1.909 +NSS_EXTERN PRStatus
   1.910 +nssList_Remove(nssList *list, void *data);
   1.911 +
   1.912 +/*
   1.913 + * nssList_Get
   1.914 + *
   1.915 + * Uses the compare function to locate an element.  Also serves as
   1.916 + * nssList_Exists.
   1.917 + */
   1.918 +NSS_EXTERN void *
   1.919 +nssList_Get
   1.920 +(
   1.921 +  nssList *list, 
   1.922 +  void *data
   1.923 +);
   1.924 +
   1.925 +/*
   1.926 + * nssList_Count
   1.927 + */
   1.928 +NSS_EXTERN PRUint32
   1.929 +nssList_Count
   1.930 +(
   1.931 +  nssList *list
   1.932 +);
   1.933 +
   1.934 +/*
   1.935 + * nssList_GetArray
   1.936 + *
   1.937 + * Fill rvArray, up to maxElements, with elements in the list.  The
   1.938 + * array is NULL-terminated, so its allocated size must be maxElements + 1.
   1.939 + */
   1.940 +NSS_EXTERN PRStatus
   1.941 +nssList_GetArray
   1.942 +(
   1.943 +  nssList *list, 
   1.944 +  void **rvArray, 
   1.945 +  PRUint32 maxElements
   1.946 +);
   1.947 +
   1.948 +/*
   1.949 + * nssList_CreateIterator
   1.950 + *
   1.951 + * Create an iterator for list traversal.
   1.952 + */
   1.953 +NSS_EXTERN nssListIterator *
   1.954 +nssList_CreateIterator
   1.955 +(
   1.956 +  nssList *list
   1.957 +);
   1.958 +
   1.959 +NSS_EXTERN nssList *
   1.960 +nssList_Clone
   1.961 +(
   1.962 +  nssList *list
   1.963 +);
   1.964 +
   1.965 +/*
   1.966 + * nssListIterator_Destroy
   1.967 + */
   1.968 +NSS_EXTERN void
   1.969 +nssListIterator_Destroy
   1.970 +(
   1.971 +  nssListIterator *iter
   1.972 +);
   1.973 +
   1.974 +/*
   1.975 + * nssListIterator_Start
   1.976 + *
   1.977 + * Begin a list iteration.  After this call, if the list is threadSafe,
   1.978 + * the list is *locked*.
   1.979 + */
   1.980 +NSS_EXTERN void *
   1.981 +nssListIterator_Start
   1.982 +(
   1.983 +  nssListIterator *iter
   1.984 +);
   1.985 +
   1.986 +/*
   1.987 + * nssListIterator_Next
   1.988 + *
   1.989 + * Continue a list iteration.
   1.990 + */
   1.991 +NSS_EXTERN void *
   1.992 +nssListIterator_Next
   1.993 +(
   1.994 +  nssListIterator *iter
   1.995 +);
   1.996 +
   1.997 +/*
   1.998 + * nssListIterator_Finish
   1.999 + *
  1.1000 + * Complete a list iteration.  This *must* be called in order for the
  1.1001 + * lock to be released.
  1.1002 + */
  1.1003 +NSS_EXTERN PRStatus
  1.1004 +nssListIterator_Finish
  1.1005 +(
  1.1006 +  nssListIterator *iter
  1.1007 +);
  1.1008 +
  1.1009 +/*
  1.1010 + * nssHash
  1.1011 + *
  1.1012 + *  nssHash_Create
  1.1013 + *  nssHash_Destroy
  1.1014 + *  nssHash_Add
  1.1015 + *  nssHash_Remove
  1.1016 + *  nssHash_Count
  1.1017 + *  nssHash_Exists
  1.1018 + *  nssHash_Lookup
  1.1019 + *  nssHash_Iterate
  1.1020 + */
  1.1021 +
  1.1022 +/*
  1.1023 + * nssHash_Create
  1.1024 + *
  1.1025 + */
  1.1026 +
  1.1027 +NSS_EXTERN nssHash *
  1.1028 +nssHash_Create
  1.1029 +(
  1.1030 +  NSSArena *arenaOpt,
  1.1031 +  PRUint32 numBuckets,
  1.1032 +  PLHashFunction keyHash,
  1.1033 +  PLHashComparator keyCompare,
  1.1034 +  PLHashComparator valueCompare
  1.1035 +);
  1.1036 +
  1.1037 +NSS_EXTERN nssHash *
  1.1038 +nssHash_CreatePointer
  1.1039 +(
  1.1040 +  NSSArena *arenaOpt,
  1.1041 +  PRUint32 numBuckets
  1.1042 +);
  1.1043 +
  1.1044 +NSS_EXTERN nssHash *
  1.1045 +nssHash_CreateString
  1.1046 +(
  1.1047 +  NSSArena *arenaOpt,
  1.1048 +  PRUint32 numBuckets
  1.1049 +);
  1.1050 +
  1.1051 +NSS_EXTERN nssHash *
  1.1052 +nssHash_CreateItem
  1.1053 +(
  1.1054 +  NSSArena *arenaOpt,
  1.1055 +  PRUint32 numBuckets
  1.1056 +);
  1.1057 +
  1.1058 +/*
  1.1059 + * nssHash_Destroy
  1.1060 + *
  1.1061 + */
  1.1062 +NSS_EXTERN void
  1.1063 +nssHash_Destroy
  1.1064 +(
  1.1065 +  nssHash *hash
  1.1066 +);
  1.1067 +
  1.1068 +/*
  1.1069 + * nssHash_Add
  1.1070 + *
  1.1071 + */
  1.1072 +
  1.1073 +extern const NSSError NSS_ERROR_HASH_COLLISION;
  1.1074 +
  1.1075 +NSS_EXTERN PRStatus
  1.1076 +nssHash_Add
  1.1077 +(
  1.1078 +  nssHash *hash,
  1.1079 +  const void *key,
  1.1080 +  const void *value
  1.1081 +);
  1.1082 +
  1.1083 +/*
  1.1084 + * nssHash_Remove
  1.1085 + *
  1.1086 + */
  1.1087 +NSS_EXTERN void
  1.1088 +nssHash_Remove
  1.1089 +(
  1.1090 +  nssHash *hash,
  1.1091 +  const void *it
  1.1092 +);
  1.1093 +
  1.1094 +/*
  1.1095 + * nssHash_Count
  1.1096 + *
  1.1097 + */
  1.1098 +NSS_EXTERN PRUint32
  1.1099 +nssHash_Count
  1.1100 +(
  1.1101 +  nssHash *hash
  1.1102 +);
  1.1103 +
  1.1104 +/*
  1.1105 + * nssHash_Exists
  1.1106 + *
  1.1107 + */
  1.1108 +NSS_EXTERN PRBool
  1.1109 +nssHash_Exists
  1.1110 +(
  1.1111 +  nssHash *hash,
  1.1112 +  const void *it
  1.1113 +);
  1.1114 +
  1.1115 +/*
  1.1116 + * nssHash_Lookup
  1.1117 + *
  1.1118 + */
  1.1119 +NSS_EXTERN void *
  1.1120 +nssHash_Lookup
  1.1121 +(
  1.1122 +  nssHash *hash,
  1.1123 +  const void *it
  1.1124 +);
  1.1125 +
  1.1126 +/*
  1.1127 + * nssHash_Iterate
  1.1128 + *
  1.1129 + */
  1.1130 +NSS_EXTERN void
  1.1131 +nssHash_Iterate
  1.1132 +(
  1.1133 +  nssHash *hash,
  1.1134 +  nssHashIterator fcn,
  1.1135 +  void *closure
  1.1136 +);
  1.1137 +
  1.1138 +
  1.1139 +/*
  1.1140 + * nssPointerTracker
  1.1141 + *
  1.1142 + * This type and these methods are only present in debug builds.
  1.1143 + * 
  1.1144 + * The nonpublic methods relating to this type are:
  1.1145 + *
  1.1146 + *  nssPointerTracker_initialize
  1.1147 + *  nssPointerTracker_finalize
  1.1148 + *  nssPointerTracker_add
  1.1149 + *  nssPointerTracker_remove
  1.1150 + *  nssPointerTracker_verify
  1.1151 + */
  1.1152 +
  1.1153 +/*
  1.1154 + * nssPointerTracker_initialize
  1.1155 + *
  1.1156 + * This method is only present in debug builds.
  1.1157 + * 
  1.1158 + * This routine initializes an nssPointerTracker object.  Note that
  1.1159 + * the object must have been declared *static* to guarantee that it
  1.1160 + * is in a zeroed state initially.  This routine is idempotent, and
  1.1161 + * may even be safely called by multiple threads simultaneously with 
  1.1162 + * the same argument.  This routine returns a PRStatus value; if 
  1.1163 + * successful, it will return PR_SUCCESS.  On failure it will set an 
  1.1164 + * error on the error stack and return PR_FAILURE.
  1.1165 + *
  1.1166 + * The error may be one of the following values:
  1.1167 + *  NSS_ERROR_NO_MEMORY
  1.1168 + *
  1.1169 + * Return value:
  1.1170 + *  PR_SUCCESS
  1.1171 + *  PR_FAILURE
  1.1172 + */
  1.1173 +
  1.1174 +#ifdef DEBUG
  1.1175 +NSS_EXTERN PRStatus
  1.1176 +nssPointerTracker_initialize
  1.1177 +(
  1.1178 +  nssPointerTracker *tracker
  1.1179 +);
  1.1180 +
  1.1181 +extern const NSSError NSS_ERROR_NO_MEMORY;
  1.1182 +#endif /* DEBUG */
  1.1183 +
  1.1184 +/*
  1.1185 + * nssPointerTracker_finalize
  1.1186 + *
  1.1187 + * This method is only present in debug builds.
  1.1188 + * 
  1.1189 + * This routine returns the nssPointerTracker object to the pre-
  1.1190 + * initialized state, releasing all resources used by the object.
  1.1191 + * It will *NOT* destroy the objects being tracked by the pointer
  1.1192 + * (should any remain), and therefore cannot be used to "sweep up"
  1.1193 + * remaining objects.  This routine returns a PRStatus value; if
  1.1194 + * successful, it will return PR_SUCCES.  On failure it will set an
  1.1195 + * error on the error stack and return PR_FAILURE.  If any objects
  1.1196 + * remain in the tracker when it is finalized, that will be treated
  1.1197 + * as an error.
  1.1198 + *
  1.1199 + * The error may be one of the following values:
  1.1200 + *  NSS_ERROR_TRACKER_NOT_EMPTY
  1.1201 + *
  1.1202 + * Return value:
  1.1203 + *  PR_SUCCESS
  1.1204 + *  PR_FAILURE
  1.1205 + */
  1.1206 +
  1.1207 +#ifdef DEBUG
  1.1208 +NSS_EXTERN PRStatus
  1.1209 +nssPointerTracker_finalize
  1.1210 +(
  1.1211 +  nssPointerTracker *tracker
  1.1212 +);
  1.1213 +
  1.1214 +extern const NSSError NSS_ERROR_TRACKER_NOT_EMPTY;
  1.1215 +#endif /* DEBUG */
  1.1216 +
  1.1217 +/*
  1.1218 + * nssPointerTracker_add
  1.1219 + *
  1.1220 + * This method is only present in debug builds.
  1.1221 + *
  1.1222 + * This routine adds the specified pointer to the nssPointerTracker
  1.1223 + * object.  It should be called in constructor objects to register
  1.1224 + * new valid objects.  The nssPointerTracker is threadsafe, but this
  1.1225 + * call is not idempotent.  This routine returns a PRStatus value;
  1.1226 + * if successful it will return PR_SUCCESS.  On failure it will set
  1.1227 + * an error on the error stack and return PR_FAILURE.
  1.1228 + *
  1.1229 + * The error may be one of the following values:
  1.1230 + *  NSS_ERROR_NO_MEMORY
  1.1231 + *  NSS_ERROR_TRACKER_NOT_INITIALIZED
  1.1232 + *  NSS_ERROR_DUPLICATE_POINTER
  1.1233 + *
  1.1234 + * Return value:
  1.1235 + *  PR_SUCCESS
  1.1236 + *  PR_FAILURE
  1.1237 + */
  1.1238 +
  1.1239 +#ifdef DEBUG
  1.1240 +NSS_EXTERN PRStatus
  1.1241 +nssPointerTracker_add
  1.1242 +(
  1.1243 +  nssPointerTracker *tracker,
  1.1244 +  const void *pointer
  1.1245 +);
  1.1246 +
  1.1247 +extern const NSSError NSS_ERROR_NO_MEMORY;
  1.1248 +extern const NSSError NSS_ERROR_TRACKER_NOT_INITIALIZED;
  1.1249 +extern const NSSError NSS_ERROR_DUPLICATE_POINTER;
  1.1250 +#endif /* DEBUG */
  1.1251 +
  1.1252 +/*
  1.1253 + * nssPointerTracker_remove
  1.1254 + *
  1.1255 + * This method is only present in debug builds.
  1.1256 + *
  1.1257 + * This routine removes the specified pointer from the 
  1.1258 + * nssPointerTracker object.  It does not call any destructor for the
  1.1259 + * object; rather, this should be called from the object's destructor.
  1.1260 + * The nssPointerTracker is threadsafe, but this call is not 
  1.1261 + * idempotent.  This routine returns a PRStatus value; if successful 
  1.1262 + * it will return PR_SUCCESS.  On failure it will set an error on the 
  1.1263 + * error stack and return PR_FAILURE.
  1.1264 + *
  1.1265 + * The error may be one of the following values:
  1.1266 + *  NSS_ERROR_TRACKER_NOT_INITIALIZED
  1.1267 + *  NSS_ERROR_POINTER_NOT_REGISTERED
  1.1268 + *
  1.1269 + * Return value:
  1.1270 + *  PR_SUCCESS
  1.1271 + *  PR_FAILURE
  1.1272 + */
  1.1273 +
  1.1274 +#ifdef DEBUG
  1.1275 +NSS_EXTERN PRStatus
  1.1276 +nssPointerTracker_remove
  1.1277 +(
  1.1278 +  nssPointerTracker *tracker,
  1.1279 +  const void *pointer
  1.1280 +);
  1.1281 +
  1.1282 +extern const NSSError NSS_ERROR_TRACKER_NOT_INITIALIZED;
  1.1283 +extern const NSSError NSS_ERROR_POINTER_NOT_REGISTERED;
  1.1284 +#endif /* DEBUG */
  1.1285 +
  1.1286 +/*
  1.1287 + * nssPointerTracker_verify
  1.1288 + *
  1.1289 + * This method is only present in debug builds.
  1.1290 + *
  1.1291 + * This routine verifies that the specified pointer has been registered
  1.1292 + * with the nssPointerTracker object.  The nssPointerTracker object is
  1.1293 + * threadsafe, and this call may be safely called from multiple threads
  1.1294 + * simultaneously with the same arguments.  This routine returns a
  1.1295 + * PRStatus value; if the pointer is registered this will return 
  1.1296 + * PR_SUCCESS.  Otherwise it will set an error on the error stack and 
  1.1297 + * return PR_FAILURE.  Although the error is suitable for leaving on 
  1.1298 + * the stack, callers may wish to augment the information available by 
  1.1299 + * placing a more type-specific error on the stack.
  1.1300 + *
  1.1301 + * The error may be one of the following values:
  1.1302 + *  NSS_ERROR_POINTER_NOT_REGISTERED
  1.1303 + *
  1.1304 + * Return value:
  1.1305 + *  PR_SUCCESS
  1.1306 + *  PR_FAILRUE
  1.1307 + */
  1.1308 +
  1.1309 +#ifdef DEBUG
  1.1310 +NSS_EXTERN PRStatus
  1.1311 +nssPointerTracker_verify
  1.1312 +(
  1.1313 +  nssPointerTracker *tracker,
  1.1314 +  const void *pointer
  1.1315 +);
  1.1316 +
  1.1317 +extern const NSSError NSS_ERROR_POINTER_NOT_REGISTERED;
  1.1318 +#endif /* DEBUG */
  1.1319 +
  1.1320 +/*
  1.1321 + * libc
  1.1322 + *
  1.1323 + * nsslibc_memcpy
  1.1324 + * nsslibc_memset
  1.1325 + * nsslibc_offsetof
  1.1326 + */
  1.1327 +
  1.1328 +/*
  1.1329 + * nsslibc_memcpy
  1.1330 + *
  1.1331 + * Errors:
  1.1332 + *  NSS_ERROR_INVALID_POINTER
  1.1333 + *
  1.1334 + * Return value:
  1.1335 + *  NULL on error
  1.1336 + *  The destination pointer on success
  1.1337 + */
  1.1338 +
  1.1339 +NSS_EXTERN void *
  1.1340 +nsslibc_memcpy
  1.1341 +(
  1.1342 +  void *dest,
  1.1343 +  const void *source,
  1.1344 +  PRUint32 n
  1.1345 +);
  1.1346 +
  1.1347 +extern const NSSError NSS_ERROR_INVALID_POINTER;
  1.1348 +
  1.1349 +/*
  1.1350 + * nsslibc_memset
  1.1351 + *
  1.1352 + * Errors:
  1.1353 + *  NSS_ERROR_INVALID_POINTER
  1.1354 + *
  1.1355 + * Return value:
  1.1356 + *  NULL on error
  1.1357 + *  The destination pointer on success
  1.1358 + */
  1.1359 +
  1.1360 +NSS_EXTERN void *
  1.1361 +nsslibc_memset
  1.1362 +(
  1.1363 +  void *dest,
  1.1364 +  PRUint8 byte,
  1.1365 +  PRUint32 n
  1.1366 +);
  1.1367 +
  1.1368 +extern const NSSError NSS_ERROR_INVALID_POINTER;
  1.1369 +
  1.1370 +/*
  1.1371 + * nsslibc_memequal
  1.1372 + *
  1.1373 + * Errors:
  1.1374 + *  NSS_ERROR_INVALID_POINTER
  1.1375 + *
  1.1376 + * Return value:
  1.1377 + *  PR_TRUE if they match
  1.1378 + *  PR_FALSE if they don't
  1.1379 + *  PR_FALSE upon error
  1.1380 + */
  1.1381 +
  1.1382 +NSS_EXTERN PRBool
  1.1383 +nsslibc_memequal
  1.1384 +(
  1.1385 +  const void *a,
  1.1386 +  const void *b,
  1.1387 +  PRUint32 len,
  1.1388 +  PRStatus *statusOpt
  1.1389 +);
  1.1390 +
  1.1391 +extern const NSSError NSS_ERROR_INVALID_POINTER;
  1.1392 +
  1.1393 +#define nsslibc_offsetof(str, memb) ((PRPtrdiff)(&(((str *)0)->memb)))
  1.1394 +
  1.1395 +PR_END_EXTERN_C
  1.1396 +
  1.1397 +#endif /* BASE_H */

mercurial