andre@0: /* This Source Code Form is subject to the terms of the Mozilla Public andre@0: * License, v. 2.0. If a copy of the MPL was not distributed with this andre@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ andre@0: /* andre@0: * These functions provide support for a number of other functions andre@0: * by creating and manipulating data structures used by those functions. andre@0: * andre@0: */ andre@0: andre@0: #ifndef _PKIX_UTIL_H andre@0: #define _PKIX_UTIL_H andre@0: andre@0: #include "pkixt.h" andre@0: andre@0: #ifdef __cplusplus andre@0: extern "C" { andre@0: #endif andre@0: andre@0: /* General andre@0: * andre@0: * Please refer to the libpkix Programmer's Guide for detailed information andre@0: * about how to use the libpkix library. Certain key warnings and notices from andre@0: * that document are repeated here for emphasis. andre@0: * andre@0: * All identifiers in this file (and all public identifiers defined in andre@0: * libpkix) begin with "PKIX_". Private identifiers only intended for use andre@0: * within the library begin with "pkix_". andre@0: * andre@0: * A function returns NULL upon success, and a PKIX_Error pointer upon failure. andre@0: * andre@0: * Unless otherwise noted, for all accessor (gettor) functions that return a andre@0: * PKIX_PL_Object pointer, callers should assume that this pointer refers to a andre@0: * shared object. Therefore, the caller should treat this shared object as andre@0: * read-only and should not modify this shared object. When done using the andre@0: * shared object, the caller should release the reference to the object by andre@0: * using the PKIX_PL_Object_DecRef function. andre@0: * andre@0: * While a function is executing, if its arguments (or anything referred to by andre@0: * its arguments) are modified, free'd, or destroyed, the function's behavior andre@0: * is undefined. andre@0: * andre@0: */ andre@0: andre@0: /* PKIX_Logger andre@0: * andre@0: * PKIX_Loggers provide a standard way for the caller to insert custom logging andre@0: * facilities. These are used by libpkix to log errors, debug information, andre@0: * status, etc. The LogCallback allows custom logging to take place. andre@0: * Additionally, a Logger can be initialized with a loggerContext, which is andre@0: * where the caller can specify configuration data such as the name of a andre@0: * logfile or database. Note that this loggerContext must be a PKIX_PL_Object, andre@0: * allowing it to be reference-counted and allowing it to provide the standard andre@0: * PKIX_PL_Object functions (Equals, Hashcode, ToString, Compare, Duplicate). andre@0: * andre@0: * Once the caller has created the Logger object(s) (and set the loggerContext andre@0: * (if any) and the Log callback), the caller then registers these Loggers andre@0: * with the system by calling PKIX_SetLoggers or PKIX_AddLogger. All log andre@0: * entries will then be logged using the specified Loggers. If multiple andre@0: * Loggers are specified, every log entry will be logged with each of them. andre@0: * andre@0: * XXX Maybe give some guidance somewhere on how much detail each logging andre@0: * level should have and where component boundaries should be. Maybe in andre@0: * Implementor's Guide or Programmer's Guide. andre@0: */ andre@0: andre@0: #define PKIX_LOGGER_LEVEL_TRACE 5 andre@0: #define PKIX_LOGGER_LEVEL_DEBUG 4 andre@0: #define PKIX_LOGGER_LEVEL_WARNING 3 andre@0: #define PKIX_LOGGER_LEVEL_ERROR 2 andre@0: #define PKIX_LOGGER_LEVEL_FATALERROR 1 andre@0: andre@0: #define PKIX_LOGGER_LEVEL_MAX 5 andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_Logger_LogCallback andre@0: * DESCRIPTION: andre@0: * andre@0: * This callback function logs a log entry containing the String pointed to andre@0: * by "message", the integer value of logLevel, and the String pointed to by andre@0: * "logComponent". A log entry can be associated with a particular log andre@0: * level (i.e. level 3) and a particular log component (i.e. "CertStore"). andre@0: * For example, someone reading the log may only be interested in very general andre@0: * log entries so they look only for log level 1. Similarly, they may only be andre@0: * interested in log entries pertaining to the CertStore component so they andre@0: * look only for that log component. This function can be used before calling andre@0: * PKIX_Initialize. andre@0: * andre@0: * PARAMETERS: andre@0: * "logger" andre@0: * Address of logger whose LogCallback is to be used. Must be non-NULL. andre@0: * "message" andre@0: * Address of String that is to be logged used "logger". Must be non-NULL. andre@0: * "logLevel" andre@0: * Integer value representing the log level for this entry. The higher the andre@0: * level, the more detail. Must be non-NULL. andre@0: * "logComponent" andre@0: * PKIXERRORNUM value (defined in pkixt.h) designating the log component andre@0: * for this entry. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Thread Safe andre@0: * andre@0: * Multiple threads must be able to safely call this function without andre@0: * worrying about conflicts, even if they're operating on the same objects. andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Logger Error if the function fails in a non-fatal way. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: typedef PKIX_Error * andre@0: (*PKIX_Logger_LogCallback)( andre@0: PKIX_Logger *logger, andre@0: PKIX_PL_String *message, andre@0: PKIX_UInt32 logLevel, andre@0: PKIX_ERRORCLASS logComponent, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_Logger_Create andre@0: * DESCRIPTION: andre@0: * andre@0: * Creates a new Logger using the Object pointed to by "loggerContext" andre@0: * (if any) and stores it at "pLogger". The new Logger uses the LogCallback andre@0: * pointed to by "callback". The Logger's maximum logging level is initially andre@0: * set to a very high level and its logging component is set to NULL (all andre@0: * components). andre@0: * andre@0: * PARAMETERS: andre@0: * "callback" andre@0: * The LogCallback function to be used. Must be non-NULL. andre@0: * "loggerContext" andre@0: * Address of Object representing the Logger's context (if any). andre@0: * "pLogger" andre@0: * Address where object pointer will be stored. Must be non-NULL. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Thread Safe (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Logger Error if the function fails in a non-fatal way. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_Logger_Create( andre@0: PKIX_Logger_LogCallback callback, andre@0: PKIX_PL_Object *loggerContext, andre@0: PKIX_Logger **pLogger, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_Logger_GetLogCallback andre@0: * DESCRIPTION: andre@0: * andre@0: * Retrieves a pointer to "logger's" Log callback function and puts it in andre@0: * "pCallback". andre@0: * andre@0: * PARAMETERS: andre@0: * "logger" andre@0: * Address of Logger whose Log callback is desired. Must be non-NULL. andre@0: * "pCallback" andre@0: * Address where Log callback function pointer will be stored. andre@0: * Must be non-NULL. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Thread Safe (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Logger Error if the function fails in a non-fatal way. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_Logger_GetLogCallback( andre@0: PKIX_Logger *logger, andre@0: PKIX_Logger_LogCallback *pCallback, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_Logger_GetLoggerContext andre@0: * DESCRIPTION: andre@0: * andre@0: * Retrieves a pointer to a PKIX_PL_Object representing the context (if any) andre@0: * of the Logger pointed to by "logger" and stores it at "pLoggerContext". andre@0: * andre@0: * PARAMETERS: andre@0: * "logger" andre@0: * Address of Logger whose context is to be stored. Must be non-NULL. andre@0: * "pLoggerContext" andre@0: * Address where object pointer will be stored. Must be non-NULL. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Thread Safe (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Logger Error if the function fails in a non-fatal way. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_Logger_GetLoggerContext( andre@0: PKIX_Logger *logger, andre@0: PKIX_PL_Object **pLoggerContext, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_Logger_GetMaxLoggingLevel andre@0: * DESCRIPTION: andre@0: * andre@0: * Retrieves a pointer to a PKIX_UInt32 representing the maximum logging andre@0: * level of the Logger pointed to by "logger" and stores it at "pLevel". Only andre@0: * log entries whose log level is less than or equal to this maximum logging andre@0: * level will be logged. andre@0: * andre@0: * PARAMETERS: andre@0: * "logger" andre@0: * Address of Logger whose maximum logging level is to be stored. andre@0: * Must be non-NULL. andre@0: * "pLevel" andre@0: * Address where PKIX_UInt32 will be stored. Must be non-NULL. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Conditionally Thread Safe andre@0: * (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Logger Error if the function fails in a non-fatal way. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_Logger_GetMaxLoggingLevel( andre@0: PKIX_Logger *logger, andre@0: PKIX_UInt32 *pLevel, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_Logger_SetMaxLoggingLevel andre@0: * DESCRIPTION: andre@0: * andre@0: * Sets the maximum logging level of the Logger pointed to by "logger" with andre@0: * the integer value of "level". andre@0: * andre@0: * PARAMETERS: andre@0: * "logger" andre@0: * Address of Logger whose maximum logging level is to be set. andre@0: * Must be non-NULL. andre@0: * "level" andre@0: * Maximum logging level to be set andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Not Thread Safe - assumes exclusive access to "logger" andre@0: * (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Logger Error if the function fails in a non-fatal way. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_Logger_SetMaxLoggingLevel( andre@0: PKIX_Logger *logger, andre@0: PKIX_UInt32 level, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_Logger_GetLoggingComponent andre@0: * DESCRIPTION: andre@0: * andre@0: * Retrieves a pointer to a String representing the logging component of the andre@0: * Logger pointed to by "logger" and stores it at "pComponent". Only log andre@0: * entries whose log component matches the specified logging component will andre@0: * be logged. andre@0: * andre@0: * PARAMETERS: andre@0: * "logger" andre@0: * Address of Logger whose logging component is to be stored. andre@0: * Must be non-NULL. andre@0: * "pComponent" andre@0: * Address where PKIXERRORNUM will be stored. Must be non-NULL. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Conditionally Thread Safe andre@0: * (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Logger Error if the function fails in a non-fatal way. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_Logger_GetLoggingComponent( andre@0: PKIX_Logger *logger, andre@0: PKIX_ERRORCLASS *pComponent, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_Logger_SetLoggingComponent andre@0: * DESCRIPTION: andre@0: * andre@0: * Sets the logging component of the Logger pointed to by "logger" with the andre@0: * PKIXERRORNUM pointed to by "component". To match a small set of components, andre@0: * create a Logger for each. andre@0: * andre@0: * PARAMETERS: andre@0: * "logger" andre@0: * Address of Logger whose logging component is to be set. andre@0: * Must be non-NULL. andre@0: * "component" andre@0: * PKIXERRORNUM value representing logging component to be set. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Not Thread Safe - assumes exclusive access to "logger" andre@0: * (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Logger Error if the function fails in a non-fatal way. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_Logger_SetLoggingComponent( andre@0: PKIX_Logger *logger, andre@0: PKIX_ERRORCLASS component, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_GetLoggers andre@0: * DESCRIPTION: andre@0: * andre@0: * Retrieves a pointer to the List of Loggers (if any) being used for logging andre@0: * by libpkix and stores it at "pLoggers". If no loggers are being used, this andre@0: * function stores an empty List at "pLoggers". andre@0: * andre@0: * Note that the List returned by this function is immutable. andre@0: * andre@0: * PARAMETERS: andre@0: * "pLoggers" andre@0: * Address where object pointer will be stored. Must be non-NULL. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Conditionally Thread Safe andre@0: * (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Logger Error if the function fails in a non-fatal way. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_GetLoggers( andre@0: PKIX_List **pLoggers, /* list of PKIX_Logger */ andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_SetLoggers andre@0: * DESCRIPTION: andre@0: * andre@0: * Sets the Loggers to be used by libpkix to the List of Loggers pointed to andre@0: * by "loggers". If "loggers" is NULL, no Loggers will be used. andre@0: * andre@0: * PARAMETERS: andre@0: * "loggers" andre@0: * Address of List of Loggers to be set. NULL for no Loggers. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Not Thread Safe andre@0: * (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Logger Error if the function fails in a non-fatal way. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_SetLoggers( andre@0: PKIX_List *loggers, /* list of PKIX_Logger */ andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_AddLogger andre@0: * DESCRIPTION: andre@0: * andre@0: * Adds the Logger pointed to by "logger" to the List of Loggers used by andre@0: * libpkix. andre@0: * andre@0: * PARAMETERS: andre@0: * "logger" andre@0: * Address of Logger to be added. Must be non-NULL. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Not Thread Safe andre@0: * (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Logger Error if the function fails in a non-fatal way. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_AddLogger( andre@0: PKIX_Logger *logger, andre@0: void *plContext); andre@0: andre@0: /* Functions pertaining to the PKIX_Error type */ andre@0: andre@0: /* Error andre@0: * andre@0: * An Error object is returned by a function upon encountering some error andre@0: * condition. Each Error is associated with an errorCode specified in pkixt.h. andre@0: * The remaining components of an Error are optional. An Error's description andre@0: * specifies a text message describing the Error. An Error's supplementary info andre@0: * specifies additional information that might be useful. Finally, an Error's andre@0: * cause specifies the underlying Error (if any) that resulted in this Error andre@0: * being returned, thereby allowing Errors to be chained so that an entire andre@0: * "error stack trace" can be represented. Once created, an Error is immutable. andre@0: * andre@0: * Note that the Error's supplementary info must be an Object (although any andre@0: * object type), allowing it to be reference-counted and allowing it to andre@0: * provide the standard Object functions (Equals, Hashcode, ToString, Compare, andre@0: * Duplicate). andre@0: * andre@0: * Errors are classified as either being fatal or non-fatal. If a function andre@0: * fails in an unrecoverable way, it returns an Error whose errorCode is andre@0: * PKIX_FATAL_ERROR. If such an error is encountered, the caller should andre@0: * not attempt to recover since something seriously wrong has happened andre@0: * (e.g. corrupted memory, memory finished, etc.). All other errorCodes andre@0: * are considered non-fatal errors and can be handled by the caller as they andre@0: * see fit. andre@0: */ andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_Error_Create andre@0: * DESCRIPTION: andre@0: * andre@0: * Creates a new Error using the value of "errorCode", the Error pointed to by andre@0: * "cause" (if any), the Object pointed to by "info" (if any), and the String andre@0: * pointed to by "desc" and stores it at "pError". If any error occurs during andre@0: * error allocation, it will be returned without chaining, since new errors andre@0: * cannot be created. Once created, an Error is immutable. andre@0: * andre@0: * PARAMETERS: andre@0: * "errorCode" andre@0: * Value of error code. andre@0: * "cause" andre@0: * Address of Error representing error's cause. andre@0: * NULL if none or unspecified. andre@0: * "info" andre@0: * Address of Object representing error's supplementary information. andre@0: * NULL if none. andre@0: * "desc" andre@0: * Address of String representing error's description. NULL if none. andre@0: * "pError" andre@0: * Address where object pointer will be stored. Must be non-NULL. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Thread Safe (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns an Error Error if the function fails in a non-fatal way. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_Error_Create( andre@0: PKIX_ERRORCLASS errClass, andre@0: PKIX_Error *cause, andre@0: PKIX_PL_Object *info, andre@0: PKIX_ERRORCODE errCode, andre@0: PKIX_Error **pError, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_Error_GetErrorClass andre@0: * DESCRIPTION: andre@0: * andre@0: * Retrieves the error class of the Error pointed to by "error" and andre@0: * stores it at "pClass". Supported error codes are defined in pkixt.h. andre@0: * andre@0: * PARAMETERS: andre@0: * "error" andre@0: * Address of Error whose error code is desired. Must be non-NULL. andre@0: * "pClass" andre@0: * Address where PKIX_UInt32 will be stored. Must be non-NULL. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Thread Safe (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns an Error Error if the function fails in a non-fatal way. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_Error_GetErrorClass( andre@0: PKIX_Error *error, andre@0: PKIX_ERRORCLASS *pClass, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_Error_GetErrorCode andre@0: * DESCRIPTION: andre@0: * andre@0: * Retrieves the error code of the Error pointed to by "error" and andre@0: * stores it at "pCode". Supported error codes are defined in pkixt.h. andre@0: * andre@0: * PARAMETERS: andre@0: * "error" andre@0: * Address of Error whose error code is desired. Must be non-NULL. andre@0: * "pCode" andre@0: * Address where PKIX_UInt32 will be stored. Must be non-NULL. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Thread Safe (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns an Error Error if the function fails in a non-fatal way. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_Error_GetErrorCode( andre@0: PKIX_Error *error, andre@0: PKIX_ERRORCODE *pCode, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_Error_GetCause andre@0: * DESCRIPTION: andre@0: * andre@0: * Retrieves the cause of the Error pointed to by "error" and stores it at andre@0: * "pCause". If no cause was specified, NULL will be stored at "pCause". andre@0: * andre@0: * PARAMETERS: andre@0: * "error" andre@0: * Address of Error whose cause is desired. Must be non-NULL. andre@0: * "pCause" andre@0: * Address where object pointer will be stored. Must be non-NULL. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Thread Safe (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns an Error Error if the function fails in a non-fatal way. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_Error_GetCause( andre@0: PKIX_Error *error, andre@0: PKIX_Error **pCause, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_Error_GetSupplementaryInfo andre@0: * DESCRIPTION: andre@0: * andre@0: * Retrieves the supplementary info of the Error pointed to by "error" and andre@0: * stores it at "pInfo". andre@0: * andre@0: * PARAMETERS: andre@0: * "error" andre@0: * Address of Error whose info is desired. Must be non-NULL. andre@0: * "pInfo" andre@0: * Address where info pointer will be stored. Must be non-NULL. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Thread Safe (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns an Error Error if the function fails in a non-fatal way. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_Error_GetSupplementaryInfo( andre@0: PKIX_Error *error, andre@0: PKIX_PL_Object **pInfo, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_Error_GetDescription andre@0: * DESCRIPTION: andre@0: * andre@0: * Retrieves the description of the Error pointed to by "error" and stores it andre@0: * at "pDesc". If no description was specified, NULL will be stored at andre@0: * "pDesc". andre@0: * andre@0: * PARAMETERS: andre@0: * "error" andre@0: * Address of Error whose description is desired. Must be non-NULL. andre@0: * "pDesc" andre@0: * Address where object pointer will be stored. Must be non-NULL. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Thread Safe (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns an Error Error if the function fails in a non-fatal way. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_Error_GetDescription( andre@0: PKIX_Error *error, andre@0: PKIX_PL_String **pDesc, andre@0: void *plContext); andre@0: andre@0: /* PKIX_List andre@0: * andre@0: * Represents a collection of items. NULL is considered a valid item. andre@0: */ andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_List_Create andre@0: * DESCRIPTION: andre@0: * andre@0: * Creates a new List and stores it at "pList". The List is initially empty andre@0: * and holds no items. To initially add items to the List, use andre@0: * PKIX_List_AppendItem andre@0: * andre@0: * PARAMETERS: andre@0: * "pList" andre@0: * Address where object pointer will be stored. Must be non-NULL. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Thread Safe (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_List_Create( andre@0: PKIX_List **pList, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_List_SetImmutable andre@0: * DESCRIPTION: andre@0: * andre@0: * Sets the List pointed to by "list" to be immutable. If a caller tries to andre@0: * change a List after it has been marked immutable (i.e. by calling andre@0: * PKIX_List_AppendItem, PKIX_List_InsertItem, PKIX_List_SetItem, or andre@0: * PKIX_List_DeleteItem), an Error is returned. andre@0: * andre@0: * PARAMETERS: andre@0: * "list" andre@0: * Address of List to be marked immutable. Must be non-NULL. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Not Thread Safe - assumes exclusive access to "list" andre@0: * (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_List_SetImmutable( andre@0: PKIX_List *list, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_List_IsImmutable andre@0: * DESCRIPTION: andre@0: * andre@0: * Checks whether the List pointed to by "list" is immutable and stores andre@0: * the Boolean result at "pImmutable". If a caller tries to change a List andre@0: * after it has been marked immutable (i.e. by calling PKIX_List_AppendItem, andre@0: * PKIX_List_InsertItem, PKIX_List_SetItem, or PKIX_List_DeleteItem), an andre@0: * Error is returned. andre@0: * andre@0: * PARAMETERS: andre@0: * "list" andre@0: * Address of List whose immutability is to be determined. andre@0: * Must be non-NULL. andre@0: * "pImmutable" andre@0: * Address where PKIX_Boolean will be stored. Must be non-NULL. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Conditionally Thread Safe andre@0: * (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_List_IsImmutable( andre@0: PKIX_List *list, andre@0: PKIX_Boolean *pImmutable, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_List_GetLength andre@0: * DESCRIPTION: andre@0: * andre@0: * Retrieves the length of the List pointed to by "list" and stores it at andre@0: * "pLength". andre@0: * andre@0: * PARAMETERS: andre@0: * "list" andre@0: * Address of List whose length is desired. Must be non-NULL. andre@0: * "pLength" andre@0: * Address where PKIX_UInt32 will be stored. Must be non-NULL. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Conditionally Thread Safe andre@0: * (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_List_GetLength( andre@0: PKIX_List *list, andre@0: PKIX_UInt32 *pLength, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_List_IsEmpty andre@0: * DESCRIPTION: andre@0: * andre@0: * Checks whether the List pointed to by "list" is empty and stores andre@0: * the Boolean result at "pEmpty". andre@0: * andre@0: * PARAMETERS: andre@0: * "list" andre@0: * Address of List whose emptiness is to be determined. Must be non-NULL. andre@0: * "pEmpty" andre@0: * Address where PKIX_Boolean will be stored. Must be non-NULL. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Conditionally Thread Safe andre@0: * (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_List_IsEmpty( andre@0: PKIX_List *list, andre@0: PKIX_Boolean *pEmpty, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_List_AppendItem andre@0: * DESCRIPTION: andre@0: * andre@0: * Appends the Object pointed to by "item" after the last non-NULL item in andre@0: * List pointed to by "list", if any. Note that a List may validly contain andre@0: * NULL items. Appending "c" into the List ("a", NULL, "b", NULL) will result andre@0: * in ("a", NULL, "b", "c"). andre@0: * andre@0: * PARAMETERS: andre@0: * "list" andre@0: * Address of List to append to. Must be non-NULL. andre@0: * "item" andre@0: * Address of new item to append. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Not Thread Safe - assumes exclusive access to "list" andre@0: * (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_List_AppendItem( andre@0: PKIX_List *list, andre@0: PKIX_PL_Object *item, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_List_InsertItem andre@0: * DESCRIPTION: andre@0: * andre@0: * Inserts the Object pointed to by "item" into the List pointed to by "list" andre@0: * at the given "index". The index counts from zero and must be less than the andre@0: * List's length. Existing list entries at or after this index will be moved andre@0: * to the next highest index. andre@0: * andre@0: * XXX why not allow equal to length which would be equivalent to AppendItem? andre@0: * andre@0: * PARAMETERS: andre@0: * "list" andre@0: * Address of List to insert into. Must be non-NULL. andre@0: * "index" andre@0: * Position to insert into. Must be less than List's length. andre@0: * "item" andre@0: * Address of new item to append. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Not Thread Safe - assumes exclusive access to "list" andre@0: * (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_List_InsertItem( andre@0: PKIX_List *list, andre@0: PKIX_UInt32 index, andre@0: PKIX_PL_Object *item, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_List_GetItem andre@0: * DESCRIPTION: andre@0: * andre@0: * Copies the "list"'s item at "index" into "pItem". The index counts from andre@0: * zero and must be less than the list's length. Increments the reference andre@0: * count on the returned object, if non-NULL. andre@0: * andre@0: * PARAMETERS: andre@0: * "list" andre@0: * Address of List to get item from. Must be non-NULL. andre@0: * "index" andre@0: * Index of list to get item from. Must be less than List's length. andre@0: * "pItem" andre@0: * Address where object pointer will be stored. Must be non-NULL. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Conditionally Thread Safe andre@0: * (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_List_GetItem( andre@0: PKIX_List *list, andre@0: PKIX_UInt32 index, andre@0: PKIX_PL_Object **pItem, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_List_SetItem andre@0: * DESCRIPTION: andre@0: * andre@0: * Sets the item at "index" of the List pointed to by "list" with the Object andre@0: * pointed to by "item". The index counts from zero and must be less than the andre@0: * List's length. The previous entry at this index will have its reference andre@0: * count decremented and the new entry will have its reference count andre@0: * incremented. andre@0: * andre@0: * PARAMETERS: andre@0: * "list" andre@0: * Address of List to modify. Must be non-NULL. andre@0: * "index" andre@0: * Position in List to set. Must be less than List's length. andre@0: * "item" andre@0: * Address of Object to set at "index". andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Not Thread Safe - assumes exclusive access to "list" andre@0: * (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_List_SetItem( andre@0: PKIX_List *list, andre@0: PKIX_UInt32 index, andre@0: PKIX_PL_Object *item, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_List_DeleteItem andre@0: * andre@0: * Deletes the item at "index" from the List pointed to by "list". The index andre@0: * counts from zero and must be less than the List's length. Note that this andre@0: * function does not destroy the List. It simply decrements the reference andre@0: * count of the item at "index" in the List, deletes that item from the list andre@0: * and moves all subsequent entries to a lower index in the list. If there is andre@0: * only a single element in the List and that element is deleted, then the andre@0: * List will be empty. andre@0: * andre@0: * PARAMETERS: andre@0: * "list" andre@0: * Address of List to delete from. Must be non-NULL. andre@0: * "index" andre@0: * Position in List to delete. Must be less than List's length. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Not Thread Safe - assumes exclusive access to "list" andre@0: * (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_List_DeleteItem( andre@0: PKIX_List *list, andre@0: PKIX_UInt32 index, andre@0: void *plContext); andre@0: andre@0: /* andre@0: * FUNCTION: PKIX_List_ReverseList andre@0: * DESCRIPTION: andre@0: * andre@0: * Creates a new List whose elements are in the reverse order as the elements andre@0: * of the Object pointed to by "list" and stores the copy at "pReversedList". andre@0: * If "list" is empty, the new reversed List will be a copy of "list". andre@0: * Changes to the new object will not affect the original and vice versa. andre@0: * andre@0: * PARAMETERS: andre@0: * "list" andre@0: * Address of List whose elements are to be reversed. Must be non-NULL. andre@0: * "pReversedList" andre@0: * Address where object pointer will be stored. Must be non-NULL. andre@0: * "plContext" andre@0: * Platform-specific context pointer. andre@0: * THREAD SAFETY: andre@0: * Conditionally Thread Safe andre@0: * (see Thread Safety Definitions in Programmer's Guide) andre@0: * RETURNS: andre@0: * Returns NULL if the function succeeds. andre@0: * Returns a Fatal Error if the function fails in an unrecoverable way. andre@0: */ andre@0: PKIX_Error * andre@0: PKIX_List_ReverseList( andre@0: PKIX_List *list, andre@0: PKIX_List **pReversedList, andre@0: void *plContext); andre@0: andre@0: #ifdef __cplusplus andre@0: } andre@0: #endif andre@0: andre@0: #endif /* _PKIX_UTIL_H */