security/nss/lib/libpkix/include/pkix_util.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rwxr-xr-x

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4 /*
michael@0 5 * These functions provide support for a number of other functions
michael@0 6 * by creating and manipulating data structures used by those functions.
michael@0 7 *
michael@0 8 */
michael@0 9
michael@0 10 #ifndef _PKIX_UTIL_H
michael@0 11 #define _PKIX_UTIL_H
michael@0 12
michael@0 13 #include "pkixt.h"
michael@0 14
michael@0 15 #ifdef __cplusplus
michael@0 16 extern "C" {
michael@0 17 #endif
michael@0 18
michael@0 19 /* General
michael@0 20 *
michael@0 21 * Please refer to the libpkix Programmer's Guide for detailed information
michael@0 22 * about how to use the libpkix library. Certain key warnings and notices from
michael@0 23 * that document are repeated here for emphasis.
michael@0 24 *
michael@0 25 * All identifiers in this file (and all public identifiers defined in
michael@0 26 * libpkix) begin with "PKIX_". Private identifiers only intended for use
michael@0 27 * within the library begin with "pkix_".
michael@0 28 *
michael@0 29 * A function returns NULL upon success, and a PKIX_Error pointer upon failure.
michael@0 30 *
michael@0 31 * Unless otherwise noted, for all accessor (gettor) functions that return a
michael@0 32 * PKIX_PL_Object pointer, callers should assume that this pointer refers to a
michael@0 33 * shared object. Therefore, the caller should treat this shared object as
michael@0 34 * read-only and should not modify this shared object. When done using the
michael@0 35 * shared object, the caller should release the reference to the object by
michael@0 36 * using the PKIX_PL_Object_DecRef function.
michael@0 37 *
michael@0 38 * While a function is executing, if its arguments (or anything referred to by
michael@0 39 * its arguments) are modified, free'd, or destroyed, the function's behavior
michael@0 40 * is undefined.
michael@0 41 *
michael@0 42 */
michael@0 43
michael@0 44 /* PKIX_Logger
michael@0 45 *
michael@0 46 * PKIX_Loggers provide a standard way for the caller to insert custom logging
michael@0 47 * facilities. These are used by libpkix to log errors, debug information,
michael@0 48 * status, etc. The LogCallback allows custom logging to take place.
michael@0 49 * Additionally, a Logger can be initialized with a loggerContext, which is
michael@0 50 * where the caller can specify configuration data such as the name of a
michael@0 51 * logfile or database. Note that this loggerContext must be a PKIX_PL_Object,
michael@0 52 * allowing it to be reference-counted and allowing it to provide the standard
michael@0 53 * PKIX_PL_Object functions (Equals, Hashcode, ToString, Compare, Duplicate).
michael@0 54 *
michael@0 55 * Once the caller has created the Logger object(s) (and set the loggerContext
michael@0 56 * (if any) and the Log callback), the caller then registers these Loggers
michael@0 57 * with the system by calling PKIX_SetLoggers or PKIX_AddLogger. All log
michael@0 58 * entries will then be logged using the specified Loggers. If multiple
michael@0 59 * Loggers are specified, every log entry will be logged with each of them.
michael@0 60 *
michael@0 61 * XXX Maybe give some guidance somewhere on how much detail each logging
michael@0 62 * level should have and where component boundaries should be. Maybe in
michael@0 63 * Implementor's Guide or Programmer's Guide.
michael@0 64 */
michael@0 65
michael@0 66 #define PKIX_LOGGER_LEVEL_TRACE 5
michael@0 67 #define PKIX_LOGGER_LEVEL_DEBUG 4
michael@0 68 #define PKIX_LOGGER_LEVEL_WARNING 3
michael@0 69 #define PKIX_LOGGER_LEVEL_ERROR 2
michael@0 70 #define PKIX_LOGGER_LEVEL_FATALERROR 1
michael@0 71
michael@0 72 #define PKIX_LOGGER_LEVEL_MAX 5
michael@0 73
michael@0 74 /*
michael@0 75 * FUNCTION: PKIX_Logger_LogCallback
michael@0 76 * DESCRIPTION:
michael@0 77 *
michael@0 78 * This callback function logs a log entry containing the String pointed to
michael@0 79 * by "message", the integer value of logLevel, and the String pointed to by
michael@0 80 * "logComponent". A log entry can be associated with a particular log
michael@0 81 * level (i.e. level 3) and a particular log component (i.e. "CertStore").
michael@0 82 * For example, someone reading the log may only be interested in very general
michael@0 83 * log entries so they look only for log level 1. Similarly, they may only be
michael@0 84 * interested in log entries pertaining to the CertStore component so they
michael@0 85 * look only for that log component. This function can be used before calling
michael@0 86 * PKIX_Initialize.
michael@0 87 *
michael@0 88 * PARAMETERS:
michael@0 89 * "logger"
michael@0 90 * Address of logger whose LogCallback is to be used. Must be non-NULL.
michael@0 91 * "message"
michael@0 92 * Address of String that is to be logged used "logger". Must be non-NULL.
michael@0 93 * "logLevel"
michael@0 94 * Integer value representing the log level for this entry. The higher the
michael@0 95 * level, the more detail. Must be non-NULL.
michael@0 96 * "logComponent"
michael@0 97 * PKIXERRORNUM value (defined in pkixt.h) designating the log component
michael@0 98 * for this entry.
michael@0 99 * "plContext"
michael@0 100 * Platform-specific context pointer.
michael@0 101 * THREAD SAFETY:
michael@0 102 * Thread Safe
michael@0 103 *
michael@0 104 * Multiple threads must be able to safely call this function without
michael@0 105 * worrying about conflicts, even if they're operating on the same objects.
michael@0 106 * RETURNS:
michael@0 107 * Returns NULL if the function succeeds.
michael@0 108 * Returns a Logger Error if the function fails in a non-fatal way.
michael@0 109 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 110 */
michael@0 111 typedef PKIX_Error *
michael@0 112 (*PKIX_Logger_LogCallback)(
michael@0 113 PKIX_Logger *logger,
michael@0 114 PKIX_PL_String *message,
michael@0 115 PKIX_UInt32 logLevel,
michael@0 116 PKIX_ERRORCLASS logComponent,
michael@0 117 void *plContext);
michael@0 118
michael@0 119 /*
michael@0 120 * FUNCTION: PKIX_Logger_Create
michael@0 121 * DESCRIPTION:
michael@0 122 *
michael@0 123 * Creates a new Logger using the Object pointed to by "loggerContext"
michael@0 124 * (if any) and stores it at "pLogger". The new Logger uses the LogCallback
michael@0 125 * pointed to by "callback". The Logger's maximum logging level is initially
michael@0 126 * set to a very high level and its logging component is set to NULL (all
michael@0 127 * components).
michael@0 128 *
michael@0 129 * PARAMETERS:
michael@0 130 * "callback"
michael@0 131 * The LogCallback function to be used. Must be non-NULL.
michael@0 132 * "loggerContext"
michael@0 133 * Address of Object representing the Logger's context (if any).
michael@0 134 * "pLogger"
michael@0 135 * Address where object pointer will be stored. Must be non-NULL.
michael@0 136 * "plContext"
michael@0 137 * Platform-specific context pointer.
michael@0 138 * THREAD SAFETY:
michael@0 139 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 140 * RETURNS:
michael@0 141 * Returns NULL if the function succeeds.
michael@0 142 * Returns a Logger Error if the function fails in a non-fatal way.
michael@0 143 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 144 */
michael@0 145 PKIX_Error *
michael@0 146 PKIX_Logger_Create(
michael@0 147 PKIX_Logger_LogCallback callback,
michael@0 148 PKIX_PL_Object *loggerContext,
michael@0 149 PKIX_Logger **pLogger,
michael@0 150 void *plContext);
michael@0 151
michael@0 152 /*
michael@0 153 * FUNCTION: PKIX_Logger_GetLogCallback
michael@0 154 * DESCRIPTION:
michael@0 155 *
michael@0 156 * Retrieves a pointer to "logger's" Log callback function and puts it in
michael@0 157 * "pCallback".
michael@0 158 *
michael@0 159 * PARAMETERS:
michael@0 160 * "logger"
michael@0 161 * Address of Logger whose Log callback is desired. Must be non-NULL.
michael@0 162 * "pCallback"
michael@0 163 * Address where Log callback function pointer will be stored.
michael@0 164 * Must be non-NULL.
michael@0 165 * "plContext"
michael@0 166 * Platform-specific context pointer.
michael@0 167 * THREAD SAFETY:
michael@0 168 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 169 * RETURNS:
michael@0 170 * Returns NULL if the function succeeds.
michael@0 171 * Returns a Logger Error if the function fails in a non-fatal way.
michael@0 172 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 173 */
michael@0 174 PKIX_Error *
michael@0 175 PKIX_Logger_GetLogCallback(
michael@0 176 PKIX_Logger *logger,
michael@0 177 PKIX_Logger_LogCallback *pCallback,
michael@0 178 void *plContext);
michael@0 179
michael@0 180 /*
michael@0 181 * FUNCTION: PKIX_Logger_GetLoggerContext
michael@0 182 * DESCRIPTION:
michael@0 183 *
michael@0 184 * Retrieves a pointer to a PKIX_PL_Object representing the context (if any)
michael@0 185 * of the Logger pointed to by "logger" and stores it at "pLoggerContext".
michael@0 186 *
michael@0 187 * PARAMETERS:
michael@0 188 * "logger"
michael@0 189 * Address of Logger whose context is to be stored. Must be non-NULL.
michael@0 190 * "pLoggerContext"
michael@0 191 * Address where object pointer will be stored. Must be non-NULL.
michael@0 192 * "plContext"
michael@0 193 * Platform-specific context pointer.
michael@0 194 * THREAD SAFETY:
michael@0 195 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 196 * RETURNS:
michael@0 197 * Returns NULL if the function succeeds.
michael@0 198 * Returns a Logger Error if the function fails in a non-fatal way.
michael@0 199 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 200 */
michael@0 201 PKIX_Error *
michael@0 202 PKIX_Logger_GetLoggerContext(
michael@0 203 PKIX_Logger *logger,
michael@0 204 PKIX_PL_Object **pLoggerContext,
michael@0 205 void *plContext);
michael@0 206
michael@0 207 /*
michael@0 208 * FUNCTION: PKIX_Logger_GetMaxLoggingLevel
michael@0 209 * DESCRIPTION:
michael@0 210 *
michael@0 211 * Retrieves a pointer to a PKIX_UInt32 representing the maximum logging
michael@0 212 * level of the Logger pointed to by "logger" and stores it at "pLevel". Only
michael@0 213 * log entries whose log level is less than or equal to this maximum logging
michael@0 214 * level will be logged.
michael@0 215 *
michael@0 216 * PARAMETERS:
michael@0 217 * "logger"
michael@0 218 * Address of Logger whose maximum logging level is to be stored.
michael@0 219 * Must be non-NULL.
michael@0 220 * "pLevel"
michael@0 221 * Address where PKIX_UInt32 will be stored. Must be non-NULL.
michael@0 222 * "plContext"
michael@0 223 * Platform-specific context pointer.
michael@0 224 * THREAD SAFETY:
michael@0 225 * Conditionally Thread Safe
michael@0 226 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 227 * RETURNS:
michael@0 228 * Returns NULL if the function succeeds.
michael@0 229 * Returns a Logger Error if the function fails in a non-fatal way.
michael@0 230 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 231 */
michael@0 232 PKIX_Error *
michael@0 233 PKIX_Logger_GetMaxLoggingLevel(
michael@0 234 PKIX_Logger *logger,
michael@0 235 PKIX_UInt32 *pLevel,
michael@0 236 void *plContext);
michael@0 237
michael@0 238 /*
michael@0 239 * FUNCTION: PKIX_Logger_SetMaxLoggingLevel
michael@0 240 * DESCRIPTION:
michael@0 241 *
michael@0 242 * Sets the maximum logging level of the Logger pointed to by "logger" with
michael@0 243 * the integer value of "level".
michael@0 244 *
michael@0 245 * PARAMETERS:
michael@0 246 * "logger"
michael@0 247 * Address of Logger whose maximum logging level is to be set.
michael@0 248 * Must be non-NULL.
michael@0 249 * "level"
michael@0 250 * Maximum logging level to be set
michael@0 251 * "plContext"
michael@0 252 * Platform-specific context pointer.
michael@0 253 * THREAD SAFETY:
michael@0 254 * Not Thread Safe - assumes exclusive access to "logger"
michael@0 255 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 256 * RETURNS:
michael@0 257 * Returns NULL if the function succeeds.
michael@0 258 * Returns a Logger Error if the function fails in a non-fatal way.
michael@0 259 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 260 */
michael@0 261 PKIX_Error *
michael@0 262 PKIX_Logger_SetMaxLoggingLevel(
michael@0 263 PKIX_Logger *logger,
michael@0 264 PKIX_UInt32 level,
michael@0 265 void *plContext);
michael@0 266
michael@0 267 /*
michael@0 268 * FUNCTION: PKIX_Logger_GetLoggingComponent
michael@0 269 * DESCRIPTION:
michael@0 270 *
michael@0 271 * Retrieves a pointer to a String representing the logging component of the
michael@0 272 * Logger pointed to by "logger" and stores it at "pComponent". Only log
michael@0 273 * entries whose log component matches the specified logging component will
michael@0 274 * be logged.
michael@0 275 *
michael@0 276 * PARAMETERS:
michael@0 277 * "logger"
michael@0 278 * Address of Logger whose logging component is to be stored.
michael@0 279 * Must be non-NULL.
michael@0 280 * "pComponent"
michael@0 281 * Address where PKIXERRORNUM will be stored. Must be non-NULL.
michael@0 282 * "plContext"
michael@0 283 * Platform-specific context pointer.
michael@0 284 * THREAD SAFETY:
michael@0 285 * Conditionally Thread Safe
michael@0 286 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 287 * RETURNS:
michael@0 288 * Returns NULL if the function succeeds.
michael@0 289 * Returns a Logger Error if the function fails in a non-fatal way.
michael@0 290 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 291 */
michael@0 292 PKIX_Error *
michael@0 293 PKIX_Logger_GetLoggingComponent(
michael@0 294 PKIX_Logger *logger,
michael@0 295 PKIX_ERRORCLASS *pComponent,
michael@0 296 void *plContext);
michael@0 297
michael@0 298 /*
michael@0 299 * FUNCTION: PKIX_Logger_SetLoggingComponent
michael@0 300 * DESCRIPTION:
michael@0 301 *
michael@0 302 * Sets the logging component of the Logger pointed to by "logger" with the
michael@0 303 * PKIXERRORNUM pointed to by "component". To match a small set of components,
michael@0 304 * create a Logger for each.
michael@0 305 *
michael@0 306 * PARAMETERS:
michael@0 307 * "logger"
michael@0 308 * Address of Logger whose logging component is to be set.
michael@0 309 * Must be non-NULL.
michael@0 310 * "component"
michael@0 311 * PKIXERRORNUM value representing logging component to be set.
michael@0 312 * "plContext"
michael@0 313 * Platform-specific context pointer.
michael@0 314 * THREAD SAFETY:
michael@0 315 * Not Thread Safe - assumes exclusive access to "logger"
michael@0 316 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 317 * RETURNS:
michael@0 318 * Returns NULL if the function succeeds.
michael@0 319 * Returns a Logger Error if the function fails in a non-fatal way.
michael@0 320 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 321 */
michael@0 322 PKIX_Error *
michael@0 323 PKIX_Logger_SetLoggingComponent(
michael@0 324 PKIX_Logger *logger,
michael@0 325 PKIX_ERRORCLASS component,
michael@0 326 void *plContext);
michael@0 327
michael@0 328 /*
michael@0 329 * FUNCTION: PKIX_GetLoggers
michael@0 330 * DESCRIPTION:
michael@0 331 *
michael@0 332 * Retrieves a pointer to the List of Loggers (if any) being used for logging
michael@0 333 * by libpkix and stores it at "pLoggers". If no loggers are being used, this
michael@0 334 * function stores an empty List at "pLoggers".
michael@0 335 *
michael@0 336 * Note that the List returned by this function is immutable.
michael@0 337 *
michael@0 338 * PARAMETERS:
michael@0 339 * "pLoggers"
michael@0 340 * Address where object pointer will be stored. Must be non-NULL.
michael@0 341 * "plContext"
michael@0 342 * Platform-specific context pointer.
michael@0 343 * THREAD SAFETY:
michael@0 344 * Conditionally Thread Safe
michael@0 345 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 346 * RETURNS:
michael@0 347 * Returns NULL if the function succeeds.
michael@0 348 * Returns a Logger Error if the function fails in a non-fatal way.
michael@0 349 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 350 */
michael@0 351 PKIX_Error *
michael@0 352 PKIX_GetLoggers(
michael@0 353 PKIX_List **pLoggers, /* list of PKIX_Logger */
michael@0 354 void *plContext);
michael@0 355
michael@0 356 /*
michael@0 357 * FUNCTION: PKIX_SetLoggers
michael@0 358 * DESCRIPTION:
michael@0 359 *
michael@0 360 * Sets the Loggers to be used by libpkix to the List of Loggers pointed to
michael@0 361 * by "loggers". If "loggers" is NULL, no Loggers will be used.
michael@0 362 *
michael@0 363 * PARAMETERS:
michael@0 364 * "loggers"
michael@0 365 * Address of List of Loggers to be set. NULL for no Loggers.
michael@0 366 * "plContext"
michael@0 367 * Platform-specific context pointer.
michael@0 368 * THREAD SAFETY:
michael@0 369 * Not Thread Safe
michael@0 370 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 371 * RETURNS:
michael@0 372 * Returns NULL if the function succeeds.
michael@0 373 * Returns a Logger Error if the function fails in a non-fatal way.
michael@0 374 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 375 */
michael@0 376 PKIX_Error *
michael@0 377 PKIX_SetLoggers(
michael@0 378 PKIX_List *loggers, /* list of PKIX_Logger */
michael@0 379 void *plContext);
michael@0 380
michael@0 381 /*
michael@0 382 * FUNCTION: PKIX_AddLogger
michael@0 383 * DESCRIPTION:
michael@0 384 *
michael@0 385 * Adds the Logger pointed to by "logger" to the List of Loggers used by
michael@0 386 * libpkix.
michael@0 387 *
michael@0 388 * PARAMETERS:
michael@0 389 * "logger"
michael@0 390 * Address of Logger to be added. Must be non-NULL.
michael@0 391 * "plContext"
michael@0 392 * Platform-specific context pointer.
michael@0 393 * THREAD SAFETY:
michael@0 394 * Not Thread Safe
michael@0 395 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 396 * RETURNS:
michael@0 397 * Returns NULL if the function succeeds.
michael@0 398 * Returns a Logger Error if the function fails in a non-fatal way.
michael@0 399 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 400 */
michael@0 401 PKIX_Error *
michael@0 402 PKIX_AddLogger(
michael@0 403 PKIX_Logger *logger,
michael@0 404 void *plContext);
michael@0 405
michael@0 406 /* Functions pertaining to the PKIX_Error type */
michael@0 407
michael@0 408 /* Error
michael@0 409 *
michael@0 410 * An Error object is returned by a function upon encountering some error
michael@0 411 * condition. Each Error is associated with an errorCode specified in pkixt.h.
michael@0 412 * The remaining components of an Error are optional. An Error's description
michael@0 413 * specifies a text message describing the Error. An Error's supplementary info
michael@0 414 * specifies additional information that might be useful. Finally, an Error's
michael@0 415 * cause specifies the underlying Error (if any) that resulted in this Error
michael@0 416 * being returned, thereby allowing Errors to be chained so that an entire
michael@0 417 * "error stack trace" can be represented. Once created, an Error is immutable.
michael@0 418 *
michael@0 419 * Note that the Error's supplementary info must be an Object (although any
michael@0 420 * object type), allowing it to be reference-counted and allowing it to
michael@0 421 * provide the standard Object functions (Equals, Hashcode, ToString, Compare,
michael@0 422 * Duplicate).
michael@0 423 *
michael@0 424 * Errors are classified as either being fatal or non-fatal. If a function
michael@0 425 * fails in an unrecoverable way, it returns an Error whose errorCode is
michael@0 426 * PKIX_FATAL_ERROR. If such an error is encountered, the caller should
michael@0 427 * not attempt to recover since something seriously wrong has happened
michael@0 428 * (e.g. corrupted memory, memory finished, etc.). All other errorCodes
michael@0 429 * are considered non-fatal errors and can be handled by the caller as they
michael@0 430 * see fit.
michael@0 431 */
michael@0 432
michael@0 433 /*
michael@0 434 * FUNCTION: PKIX_Error_Create
michael@0 435 * DESCRIPTION:
michael@0 436 *
michael@0 437 * Creates a new Error using the value of "errorCode", the Error pointed to by
michael@0 438 * "cause" (if any), the Object pointed to by "info" (if any), and the String
michael@0 439 * pointed to by "desc" and stores it at "pError". If any error occurs during
michael@0 440 * error allocation, it will be returned without chaining, since new errors
michael@0 441 * cannot be created. Once created, an Error is immutable.
michael@0 442 *
michael@0 443 * PARAMETERS:
michael@0 444 * "errorCode"
michael@0 445 * Value of error code.
michael@0 446 * "cause"
michael@0 447 * Address of Error representing error's cause.
michael@0 448 * NULL if none or unspecified.
michael@0 449 * "info"
michael@0 450 * Address of Object representing error's supplementary information.
michael@0 451 * NULL if none.
michael@0 452 * "desc"
michael@0 453 * Address of String representing error's description. NULL if none.
michael@0 454 * "pError"
michael@0 455 * Address where object pointer will be stored. Must be non-NULL.
michael@0 456 * "plContext"
michael@0 457 * Platform-specific context pointer.
michael@0 458 * THREAD SAFETY:
michael@0 459 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 460 * RETURNS:
michael@0 461 * Returns NULL if the function succeeds.
michael@0 462 * Returns an Error Error if the function fails in a non-fatal way.
michael@0 463 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 464 */
michael@0 465 PKIX_Error *
michael@0 466 PKIX_Error_Create(
michael@0 467 PKIX_ERRORCLASS errClass,
michael@0 468 PKIX_Error *cause,
michael@0 469 PKIX_PL_Object *info,
michael@0 470 PKIX_ERRORCODE errCode,
michael@0 471 PKIX_Error **pError,
michael@0 472 void *plContext);
michael@0 473
michael@0 474 /*
michael@0 475 * FUNCTION: PKIX_Error_GetErrorClass
michael@0 476 * DESCRIPTION:
michael@0 477 *
michael@0 478 * Retrieves the error class of the Error pointed to by "error" and
michael@0 479 * stores it at "pClass". Supported error codes are defined in pkixt.h.
michael@0 480 *
michael@0 481 * PARAMETERS:
michael@0 482 * "error"
michael@0 483 * Address of Error whose error code is desired. Must be non-NULL.
michael@0 484 * "pClass"
michael@0 485 * Address where PKIX_UInt32 will be stored. Must be non-NULL.
michael@0 486 * "plContext"
michael@0 487 * Platform-specific context pointer.
michael@0 488 * THREAD SAFETY:
michael@0 489 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 490 * RETURNS:
michael@0 491 * Returns NULL if the function succeeds.
michael@0 492 * Returns an Error Error if the function fails in a non-fatal way.
michael@0 493 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 494 */
michael@0 495 PKIX_Error *
michael@0 496 PKIX_Error_GetErrorClass(
michael@0 497 PKIX_Error *error,
michael@0 498 PKIX_ERRORCLASS *pClass,
michael@0 499 void *plContext);
michael@0 500
michael@0 501 /*
michael@0 502 * FUNCTION: PKIX_Error_GetErrorCode
michael@0 503 * DESCRIPTION:
michael@0 504 *
michael@0 505 * Retrieves the error code of the Error pointed to by "error" and
michael@0 506 * stores it at "pCode". Supported error codes are defined in pkixt.h.
michael@0 507 *
michael@0 508 * PARAMETERS:
michael@0 509 * "error"
michael@0 510 * Address of Error whose error code is desired. Must be non-NULL.
michael@0 511 * "pCode"
michael@0 512 * Address where PKIX_UInt32 will be stored. Must be non-NULL.
michael@0 513 * "plContext"
michael@0 514 * Platform-specific context pointer.
michael@0 515 * THREAD SAFETY:
michael@0 516 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 517 * RETURNS:
michael@0 518 * Returns NULL if the function succeeds.
michael@0 519 * Returns an Error Error if the function fails in a non-fatal way.
michael@0 520 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 521 */
michael@0 522 PKIX_Error *
michael@0 523 PKIX_Error_GetErrorCode(
michael@0 524 PKIX_Error *error,
michael@0 525 PKIX_ERRORCODE *pCode,
michael@0 526 void *plContext);
michael@0 527
michael@0 528 /*
michael@0 529 * FUNCTION: PKIX_Error_GetCause
michael@0 530 * DESCRIPTION:
michael@0 531 *
michael@0 532 * Retrieves the cause of the Error pointed to by "error" and stores it at
michael@0 533 * "pCause". If no cause was specified, NULL will be stored at "pCause".
michael@0 534 *
michael@0 535 * PARAMETERS:
michael@0 536 * "error"
michael@0 537 * Address of Error whose cause is desired. Must be non-NULL.
michael@0 538 * "pCause"
michael@0 539 * Address where object pointer will be stored. Must be non-NULL.
michael@0 540 * "plContext"
michael@0 541 * Platform-specific context pointer.
michael@0 542 * THREAD SAFETY:
michael@0 543 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 544 * RETURNS:
michael@0 545 * Returns NULL if the function succeeds.
michael@0 546 * Returns an Error Error if the function fails in a non-fatal way.
michael@0 547 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 548 */
michael@0 549 PKIX_Error *
michael@0 550 PKIX_Error_GetCause(
michael@0 551 PKIX_Error *error,
michael@0 552 PKIX_Error **pCause,
michael@0 553 void *plContext);
michael@0 554
michael@0 555 /*
michael@0 556 * FUNCTION: PKIX_Error_GetSupplementaryInfo
michael@0 557 * DESCRIPTION:
michael@0 558 *
michael@0 559 * Retrieves the supplementary info of the Error pointed to by "error" and
michael@0 560 * stores it at "pInfo".
michael@0 561 *
michael@0 562 * PARAMETERS:
michael@0 563 * "error"
michael@0 564 * Address of Error whose info is desired. Must be non-NULL.
michael@0 565 * "pInfo"
michael@0 566 * Address where info pointer will be stored. Must be non-NULL.
michael@0 567 * "plContext"
michael@0 568 * Platform-specific context pointer.
michael@0 569 * THREAD SAFETY:
michael@0 570 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 571 * RETURNS:
michael@0 572 * Returns NULL if the function succeeds.
michael@0 573 * Returns an Error Error if the function fails in a non-fatal way.
michael@0 574 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 575 */
michael@0 576 PKIX_Error *
michael@0 577 PKIX_Error_GetSupplementaryInfo(
michael@0 578 PKIX_Error *error,
michael@0 579 PKIX_PL_Object **pInfo,
michael@0 580 void *plContext);
michael@0 581
michael@0 582 /*
michael@0 583 * FUNCTION: PKIX_Error_GetDescription
michael@0 584 * DESCRIPTION:
michael@0 585 *
michael@0 586 * Retrieves the description of the Error pointed to by "error" and stores it
michael@0 587 * at "pDesc". If no description was specified, NULL will be stored at
michael@0 588 * "pDesc".
michael@0 589 *
michael@0 590 * PARAMETERS:
michael@0 591 * "error"
michael@0 592 * Address of Error whose description is desired. Must be non-NULL.
michael@0 593 * "pDesc"
michael@0 594 * Address where object pointer will be stored. Must be non-NULL.
michael@0 595 * "plContext"
michael@0 596 * Platform-specific context pointer.
michael@0 597 * THREAD SAFETY:
michael@0 598 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 599 * RETURNS:
michael@0 600 * Returns NULL if the function succeeds.
michael@0 601 * Returns an Error Error if the function fails in a non-fatal way.
michael@0 602 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 603 */
michael@0 604 PKIX_Error *
michael@0 605 PKIX_Error_GetDescription(
michael@0 606 PKIX_Error *error,
michael@0 607 PKIX_PL_String **pDesc,
michael@0 608 void *plContext);
michael@0 609
michael@0 610 /* PKIX_List
michael@0 611 *
michael@0 612 * Represents a collection of items. NULL is considered a valid item.
michael@0 613 */
michael@0 614
michael@0 615 /*
michael@0 616 * FUNCTION: PKIX_List_Create
michael@0 617 * DESCRIPTION:
michael@0 618 *
michael@0 619 * Creates a new List and stores it at "pList". The List is initially empty
michael@0 620 * and holds no items. To initially add items to the List, use
michael@0 621 * PKIX_List_AppendItem
michael@0 622 *
michael@0 623 * PARAMETERS:
michael@0 624 * "pList"
michael@0 625 * Address where object pointer will be stored. Must be non-NULL.
michael@0 626 * "plContext"
michael@0 627 * Platform-specific context pointer.
michael@0 628 * THREAD SAFETY:
michael@0 629 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 630 * RETURNS:
michael@0 631 * Returns NULL if the function succeeds.
michael@0 632 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 633 */
michael@0 634 PKIX_Error *
michael@0 635 PKIX_List_Create(
michael@0 636 PKIX_List **pList,
michael@0 637 void *plContext);
michael@0 638
michael@0 639 /*
michael@0 640 * FUNCTION: PKIX_List_SetImmutable
michael@0 641 * DESCRIPTION:
michael@0 642 *
michael@0 643 * Sets the List pointed to by "list" to be immutable. If a caller tries to
michael@0 644 * change a List after it has been marked immutable (i.e. by calling
michael@0 645 * PKIX_List_AppendItem, PKIX_List_InsertItem, PKIX_List_SetItem, or
michael@0 646 * PKIX_List_DeleteItem), an Error is returned.
michael@0 647 *
michael@0 648 * PARAMETERS:
michael@0 649 * "list"
michael@0 650 * Address of List to be marked immutable. Must be non-NULL.
michael@0 651 * "plContext"
michael@0 652 * Platform-specific context pointer.
michael@0 653 * THREAD SAFETY:
michael@0 654 * Not Thread Safe - assumes exclusive access to "list"
michael@0 655 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 656 * RETURNS:
michael@0 657 * Returns NULL if the function succeeds.
michael@0 658 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 659 */
michael@0 660 PKIX_Error *
michael@0 661 PKIX_List_SetImmutable(
michael@0 662 PKIX_List *list,
michael@0 663 void *plContext);
michael@0 664
michael@0 665 /*
michael@0 666 * FUNCTION: PKIX_List_IsImmutable
michael@0 667 * DESCRIPTION:
michael@0 668 *
michael@0 669 * Checks whether the List pointed to by "list" is immutable and stores
michael@0 670 * the Boolean result at "pImmutable". If a caller tries to change a List
michael@0 671 * after it has been marked immutable (i.e. by calling PKIX_List_AppendItem,
michael@0 672 * PKIX_List_InsertItem, PKIX_List_SetItem, or PKIX_List_DeleteItem), an
michael@0 673 * Error is returned.
michael@0 674 *
michael@0 675 * PARAMETERS:
michael@0 676 * "list"
michael@0 677 * Address of List whose immutability is to be determined.
michael@0 678 * Must be non-NULL.
michael@0 679 * "pImmutable"
michael@0 680 * Address where PKIX_Boolean will be stored. Must be non-NULL.
michael@0 681 * "plContext"
michael@0 682 * Platform-specific context pointer.
michael@0 683 * THREAD SAFETY:
michael@0 684 * Conditionally Thread Safe
michael@0 685 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 686 * RETURNS:
michael@0 687 * Returns NULL if the function succeeds.
michael@0 688 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 689 */
michael@0 690 PKIX_Error *
michael@0 691 PKIX_List_IsImmutable(
michael@0 692 PKIX_List *list,
michael@0 693 PKIX_Boolean *pImmutable,
michael@0 694 void *plContext);
michael@0 695
michael@0 696 /*
michael@0 697 * FUNCTION: PKIX_List_GetLength
michael@0 698 * DESCRIPTION:
michael@0 699 *
michael@0 700 * Retrieves the length of the List pointed to by "list" and stores it at
michael@0 701 * "pLength".
michael@0 702 *
michael@0 703 * PARAMETERS:
michael@0 704 * "list"
michael@0 705 * Address of List whose length is desired. Must be non-NULL.
michael@0 706 * "pLength"
michael@0 707 * Address where PKIX_UInt32 will be stored. Must be non-NULL.
michael@0 708 * "plContext"
michael@0 709 * Platform-specific context pointer.
michael@0 710 * THREAD SAFETY:
michael@0 711 * Conditionally Thread Safe
michael@0 712 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 713 * RETURNS:
michael@0 714 * Returns NULL if the function succeeds.
michael@0 715 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 716 */
michael@0 717 PKIX_Error *
michael@0 718 PKIX_List_GetLength(
michael@0 719 PKIX_List *list,
michael@0 720 PKIX_UInt32 *pLength,
michael@0 721 void *plContext);
michael@0 722
michael@0 723 /*
michael@0 724 * FUNCTION: PKIX_List_IsEmpty
michael@0 725 * DESCRIPTION:
michael@0 726 *
michael@0 727 * Checks whether the List pointed to by "list" is empty and stores
michael@0 728 * the Boolean result at "pEmpty".
michael@0 729 *
michael@0 730 * PARAMETERS:
michael@0 731 * "list"
michael@0 732 * Address of List whose emptiness is to be determined. Must be non-NULL.
michael@0 733 * "pEmpty"
michael@0 734 * Address where PKIX_Boolean will be stored. Must be non-NULL.
michael@0 735 * "plContext"
michael@0 736 * Platform-specific context pointer.
michael@0 737 * THREAD SAFETY:
michael@0 738 * Conditionally Thread Safe
michael@0 739 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 740 * RETURNS:
michael@0 741 * Returns NULL if the function succeeds.
michael@0 742 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 743 */
michael@0 744 PKIX_Error *
michael@0 745 PKIX_List_IsEmpty(
michael@0 746 PKIX_List *list,
michael@0 747 PKIX_Boolean *pEmpty,
michael@0 748 void *plContext);
michael@0 749
michael@0 750 /*
michael@0 751 * FUNCTION: PKIX_List_AppendItem
michael@0 752 * DESCRIPTION:
michael@0 753 *
michael@0 754 * Appends the Object pointed to by "item" after the last non-NULL item in
michael@0 755 * List pointed to by "list", if any. Note that a List may validly contain
michael@0 756 * NULL items. Appending "c" into the List ("a", NULL, "b", NULL) will result
michael@0 757 * in ("a", NULL, "b", "c").
michael@0 758 *
michael@0 759 * PARAMETERS:
michael@0 760 * "list"
michael@0 761 * Address of List to append to. Must be non-NULL.
michael@0 762 * "item"
michael@0 763 * Address of new item to append.
michael@0 764 * "plContext"
michael@0 765 * Platform-specific context pointer.
michael@0 766 * THREAD SAFETY:
michael@0 767 * Not Thread Safe - assumes exclusive access to "list"
michael@0 768 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 769 * RETURNS:
michael@0 770 * Returns NULL if the function succeeds.
michael@0 771 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 772 */
michael@0 773 PKIX_Error *
michael@0 774 PKIX_List_AppendItem(
michael@0 775 PKIX_List *list,
michael@0 776 PKIX_PL_Object *item,
michael@0 777 void *plContext);
michael@0 778
michael@0 779 /*
michael@0 780 * FUNCTION: PKIX_List_InsertItem
michael@0 781 * DESCRIPTION:
michael@0 782 *
michael@0 783 * Inserts the Object pointed to by "item" into the List pointed to by "list"
michael@0 784 * at the given "index". The index counts from zero and must be less than the
michael@0 785 * List's length. Existing list entries at or after this index will be moved
michael@0 786 * to the next highest index.
michael@0 787 *
michael@0 788 * XXX why not allow equal to length which would be equivalent to AppendItem?
michael@0 789 *
michael@0 790 * PARAMETERS:
michael@0 791 * "list"
michael@0 792 * Address of List to insert into. Must be non-NULL.
michael@0 793 * "index"
michael@0 794 * Position to insert into. Must be less than List's length.
michael@0 795 * "item"
michael@0 796 * Address of new item to append.
michael@0 797 * "plContext"
michael@0 798 * Platform-specific context pointer.
michael@0 799 * THREAD SAFETY:
michael@0 800 * Not Thread Safe - assumes exclusive access to "list"
michael@0 801 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 802 * RETURNS:
michael@0 803 * Returns NULL if the function succeeds.
michael@0 804 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 805 */
michael@0 806 PKIX_Error *
michael@0 807 PKIX_List_InsertItem(
michael@0 808 PKIX_List *list,
michael@0 809 PKIX_UInt32 index,
michael@0 810 PKIX_PL_Object *item,
michael@0 811 void *plContext);
michael@0 812
michael@0 813 /*
michael@0 814 * FUNCTION: PKIX_List_GetItem
michael@0 815 * DESCRIPTION:
michael@0 816 *
michael@0 817 * Copies the "list"'s item at "index" into "pItem". The index counts from
michael@0 818 * zero and must be less than the list's length. Increments the reference
michael@0 819 * count on the returned object, if non-NULL.
michael@0 820 *
michael@0 821 * PARAMETERS:
michael@0 822 * "list"
michael@0 823 * Address of List to get item from. Must be non-NULL.
michael@0 824 * "index"
michael@0 825 * Index of list to get item from. Must be less than List's length.
michael@0 826 * "pItem"
michael@0 827 * Address where object pointer will be stored. Must be non-NULL.
michael@0 828 * "plContext"
michael@0 829 * Platform-specific context pointer.
michael@0 830 * THREAD SAFETY:
michael@0 831 * Conditionally Thread Safe
michael@0 832 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 833 * RETURNS:
michael@0 834 * Returns NULL if the function succeeds.
michael@0 835 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 836 */
michael@0 837 PKIX_Error *
michael@0 838 PKIX_List_GetItem(
michael@0 839 PKIX_List *list,
michael@0 840 PKIX_UInt32 index,
michael@0 841 PKIX_PL_Object **pItem,
michael@0 842 void *plContext);
michael@0 843
michael@0 844 /*
michael@0 845 * FUNCTION: PKIX_List_SetItem
michael@0 846 * DESCRIPTION:
michael@0 847 *
michael@0 848 * Sets the item at "index" of the List pointed to by "list" with the Object
michael@0 849 * pointed to by "item". The index counts from zero and must be less than the
michael@0 850 * List's length. The previous entry at this index will have its reference
michael@0 851 * count decremented and the new entry will have its reference count
michael@0 852 * incremented.
michael@0 853 *
michael@0 854 * PARAMETERS:
michael@0 855 * "list"
michael@0 856 * Address of List to modify. Must be non-NULL.
michael@0 857 * "index"
michael@0 858 * Position in List to set. Must be less than List's length.
michael@0 859 * "item"
michael@0 860 * Address of Object to set at "index".
michael@0 861 * "plContext"
michael@0 862 * Platform-specific context pointer.
michael@0 863 * THREAD SAFETY:
michael@0 864 * Not Thread Safe - assumes exclusive access to "list"
michael@0 865 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 866 * RETURNS:
michael@0 867 * Returns NULL if the function succeeds.
michael@0 868 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 869 */
michael@0 870 PKIX_Error *
michael@0 871 PKIX_List_SetItem(
michael@0 872 PKIX_List *list,
michael@0 873 PKIX_UInt32 index,
michael@0 874 PKIX_PL_Object *item,
michael@0 875 void *plContext);
michael@0 876
michael@0 877 /*
michael@0 878 * FUNCTION: PKIX_List_DeleteItem
michael@0 879 *
michael@0 880 * Deletes the item at "index" from the List pointed to by "list". The index
michael@0 881 * counts from zero and must be less than the List's length. Note that this
michael@0 882 * function does not destroy the List. It simply decrements the reference
michael@0 883 * count of the item at "index" in the List, deletes that item from the list
michael@0 884 * and moves all subsequent entries to a lower index in the list. If there is
michael@0 885 * only a single element in the List and that element is deleted, then the
michael@0 886 * List will be empty.
michael@0 887 *
michael@0 888 * PARAMETERS:
michael@0 889 * "list"
michael@0 890 * Address of List to delete from. Must be non-NULL.
michael@0 891 * "index"
michael@0 892 * Position in List to delete. Must be less than List's length.
michael@0 893 * "plContext"
michael@0 894 * Platform-specific context pointer.
michael@0 895 * THREAD SAFETY:
michael@0 896 * Not Thread Safe - assumes exclusive access to "list"
michael@0 897 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 898 * RETURNS:
michael@0 899 * Returns NULL if the function succeeds.
michael@0 900 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 901 */
michael@0 902 PKIX_Error *
michael@0 903 PKIX_List_DeleteItem(
michael@0 904 PKIX_List *list,
michael@0 905 PKIX_UInt32 index,
michael@0 906 void *plContext);
michael@0 907
michael@0 908 /*
michael@0 909 * FUNCTION: PKIX_List_ReverseList
michael@0 910 * DESCRIPTION:
michael@0 911 *
michael@0 912 * Creates a new List whose elements are in the reverse order as the elements
michael@0 913 * of the Object pointed to by "list" and stores the copy at "pReversedList".
michael@0 914 * If "list" is empty, the new reversed List will be a copy of "list".
michael@0 915 * Changes to the new object will not affect the original and vice versa.
michael@0 916 *
michael@0 917 * PARAMETERS:
michael@0 918 * "list"
michael@0 919 * Address of List whose elements are to be reversed. Must be non-NULL.
michael@0 920 * "pReversedList"
michael@0 921 * Address where object pointer will be stored. Must be non-NULL.
michael@0 922 * "plContext"
michael@0 923 * Platform-specific context pointer.
michael@0 924 * THREAD SAFETY:
michael@0 925 * Conditionally Thread Safe
michael@0 926 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 927 * RETURNS:
michael@0 928 * Returns NULL if the function succeeds.
michael@0 929 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 930 */
michael@0 931 PKIX_Error *
michael@0 932 PKIX_List_ReverseList(
michael@0 933 PKIX_List *list,
michael@0 934 PKIX_List **pReversedList,
michael@0 935 void *plContext);
michael@0 936
michael@0 937 #ifdef __cplusplus
michael@0 938 }
michael@0 939 #endif
michael@0 940
michael@0 941 #endif /* _PKIX_UTIL_H */

mercurial