Collaboration diagram for System Utilities:
|
Modules | |
| MemoryManagement | |
Data Structures | |
| struct | psErr |
| Error message object. More... | |
| struct | psErrorDescription |
| An error code with description. More... | |
| struct | psLine |
| Structure to carry a dynamic string. More... | |
| struct | p_psComponent |
| Basic structure for the component tree. More... | |
Defines | |
| #define | PS_ASSERT_PTR(NAME, RVAL) |
| #define | PS_ASSERT_INT_UNEQUAL(NAME1, NAME2, RVAL) |
| #define | PS_ASSERT_INT_EQUAL(NAME1, NAME2, RVAL) |
| #define | PS_ASSERT_INT_NONNEGATIVE(NAME, RVAL) |
| #define | PS_ASSERT_INT_POSITIVE(NAME, RVAL) |
| #define | PS_ASSERT_INT_ZERO(NAME, RVAL) |
| #define | PS_ASSERT_INT_NONZERO(NAME, RVAL) |
| #define | PS_ASSERT_INT_WITHIN_RANGE(NAME, LOWER, UPPER, RVAL) |
| #define | PS_ASSERT_INT_LESS_THAN(VAR1, VAR2, RVAL) |
| #define | PS_ASSERT_INT_LESS_THAN_OR_EQUAL(VAR1, VAR2, RVAL) |
| #define | PS_ASSERT_INT_LARGER_THAN(NAME1, NAME2, RVAL) |
| #define | PS_ASSERT_INT_LARGER_THAN_OR_EQUAL(NAME1, NAME2, RVAL) |
| #define | PS_ASSERT_FLOAT_LARGER_THAN(NAME1, NAME2, RVAL) |
| #define | PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(NAME1, NAME2, RVAL) |
| #define | PS_ASSERT_FLOAT_LESS_THAN(NAME1, NAME2, RVAL) |
| #define | PS_ASSERT_FLOAT_LESS_THAN_OR_EQUAL(NAME1, NAME2, RVAL) |
| #define | PS_ASSERT_FLOAT_NON_EQUAL(NAME1, NAME2, RVAL) |
| #define | PS_ASSERT_FLOAT_EQUAL(NAME1, NAME2, RVAL) |
| #define | PS_ASSERT_FLOAT_WITHIN_RANGE(NAME, LOWER, UPPER, RVAL) |
| #define | PS_ASSERT_FLOAT_REAL(NAME, RVAL) |
| #define | PS_ASSERT_DOUBLE_WITHIN_RANGE(NAME, LOWER, UPPER, RVAL) |
| #define | PS_ASSERT_LONG_WITHIN_RANGE(NAME, LOWER, UPPER, RVAL) |
| #define | PS_ASSERT_LONG_LARGER_THAN_OR_EQUAL(NAME1, NAME2, RVAL) |
| #define | PS_ASSERT_S64_WITHIN_RANGE(NAME, LOWER, UPPER, RVAL) |
| #define | PS_WARN_PTR_NON_NULL(NAME) |
| #define | PS_ASSERT_PTR_NON_NULL(NAME, RVAL) PS_ASSERT_GENERAL_PTR_NON_NULL(NAME, return RVAL) |
| #define | PS_ASSERT_GENERAL_PTR_NON_NULL(NAME, CLEANUP) |
| #define | PS_ASSERT_PTR_TYPE(NAME, TYPE, RVAL) |
| #define | PS_ASSERT_PTR_DIMEN(NAME, DIMEN, RVAL) PS_ASSERT_GENERAL_PTR_DIMEN(NAME, DIMEN, return RVAL) |
| #define | PS_ASSERT_GENERAL_PTR_DIMEN(NAME, DIMEN, CLEANUP) |
| #define | PS_ASSERT_PTR_DIMEN_GENERAL_NOT(NAME, DIMEN, CLEANUP) |
| #define | PS_ASSERT_PTRS_SIZE_EQUAL(PTR1, PTR2, RVAL) |
| #define | PS_ASSERT_PTR_TYPE_EQUAL(PTR1, PTR2, RVAL) PS_ASSERT_PTRS_TYPE_EQUAL_GENERAL(PTR1, PTR2, return RVAL) |
| #define | PS_ASSERT_PTRS_TYPE_EQUAL_GENERAL(PTR1, PTR2, CLEANUP) |
| #define | _(string) string |
| #define | PS_STRING(S) #S |
| This macro will convert the argument to a quoted string. | |
| #define | PS_FILE_LINE p_psFileLine(__FILE__,__LINE__) |
| #define | PS_ASSERT_STRING_NON_EMPTY(NAME, RVAL) |
| #define | PS_UNKNOWN_TRACE_LEVEL -9999 |
| #define | PS_DEFAULT_TRACE_LEVEL -1 |
| #define | PS_THE_OTHER_DEFAULT_TRACE_LEVEL 0 |
| #define | PS_TRACE_ON 1 |
| Functions. | |
Enumerations | |
| enum | psErrorCode { PS_ERR_NONE = 0, PS_ERR_BASE = 256, PS_ERR_UNKNOWN, PS_ERR_IO, PS_ERR_LOCATION_INVALID, PS_ERR_MEMORY_CORRUPTION, PS_ERR_MEMORY_DEREF_USAGE, PS_ERR_BAD_PARAMETER_VALUE, PS_ERR_BAD_PARAMETER_TYPE, PS_ERR_BAD_PARAMETER_NULL, PS_ERR_BAD_PARAMETER_SIZE, PS_ERR_UNEXPECTED_NULL, PS_ERR_OS_CALL_FAILED, PS_ERR_BAD_FITS, PS_ERR_IEEE, PS_ERR_DB_CLIENT, PS_ERR_DB_SERVER, PS_ERR_N_ERR_CLASSES } |
| enumeration of the static error code classes More... | |
| enum | psExit { PS_EXIT_SUCCESS = 0, PS_EXIT_UNKNOWN_ERROR = 1, PS_EXIT_SYS_ERROR, PS_EXIT_CONFIG_ERROR, PS_EXIT_PROG_ERROR, PS_EXIT_DATA_ERROR, PS_EXIT_TIMEOUT_ERROR } |
| Exit status codes. More... | |
| enum | { PS_LOG_ABORT = 0, PS_LOG_ERROR, PS_LOG_WARN, PS_LOG_INFO, PS_LOG_DETAIL, PS_LOG_MINUTIA } |
| < Status codes for log messages More... | |
| enum | { PS_LOG_TO_NONE = 0, PS_LOG_TO_STDERR = 1, PS_LOG_TO_STDOUT = 2 } |
| enum | { PS_TRACE_TO_NONE = 0, PS_TRACE_TO_STDOUT = 1, PS_TRACE_TO_STDERR = 2 } |
Functions | |
| void | psAbort (const char *name, const char *format,...) |
| Reports an abort message to logging facility. | |
| psString | psLibVersion (void) |
| Get current psLib version. | |
| psString | psLibVersionLong (void) |
| Get current psLib version (full identification). | |
| void | psLibInit (const char *timeConfig) |
| Initializes persistent memory. | |
| void | psLibFinalize (void) |
| Removes persistant memory created with the psLibInit function. | |
| void | p_psMemoryCheck (void) |
| psErr * | psErrorGet (long which) |
| Get a error from the error stack. | |
| psErr * | psErrorLast (void) |
| Get last error put on the error stack. | |
| psErrorCode | psErrorCodeLast (void) |
| Get errorCode of last error put on the error stack. | |
| void | psErrorClear (void) |
| Clears the error stack. | |
| long | psErrorGetStackSize () |
| Get the error stack depth. | |
| void | psErrorStackPrint (FILE *fd, const char *format,...) |
| Prints error stack to specified open file descriptor. | |
| void | psErrorStackPrintV (FILE *fd, const char *format, va_list va) |
| Prints error stack to specified open file descriptor. | |
| psErrorCode | psError (psErrorCode code, psBool new, const char *format,...) |
| Reports an error message to the logging facility. | |
| void | psWarning (const char *format,...) |
| Logs a warning message. | |
| psErr * | psErrAlloc (const char *name, psErrorCode code, const char *msg) |
| Create a new psErr struct. | |
| psErrorDescription * | psErrorDescriptionAlloc (psErrorCode code, const char *description) |
| Allocates a new psErrorDescription. | |
| const char * | psErrorCodeString (psErrorCode code) |
| Retrieves the description of an error code. | |
| void | psErrorRegister (const psErrorDescription *errors, int errorCode) |
| Register an error code. | |
| psBool | p_psErrorUnregister (psErrorCode code) |
| Clears error codes registered via psErrorRegister. | |
| psLine * | psLineAlloc (long Nline) |
| Allocates a line object of length Nline. | |
| bool | psMemCheckLine (psPtr ptr) |
| Checks the type of a particular pointer. | |
| bool | psLineInit (psLine *line) |
| Initializes or re-initializes a line. | |
| bool | psLineAdd (psLine *line, const char *format,...) |
| Adds the line segment to the string. | |
| bool | psLogSetDestination (int fd) |
| This procedure sets the destination for future log messages. | |
| int | psLogGetDestination () |
| This procedure returns the current log destination file descriptor. | |
| int | psLogSetLevel (int level) |
| This procedure sets the message level for future log messages. | |
| int | psLogGetLevel () |
| This procedures returns the current log message level. | |
| bool | psLogSetFormat (const char *format) |
| This procedure sets the log format for future log messages. | |
| int | psMessageDestination (const char *dest) |
| This procedures uses a string to set the destination for which to send the corresponding log messages. | |
| void | psLogMsg (const char *name, int level, const char *format,...) |
| This procedure logs a message to the destination set by a prior call to psLogSetDestination(), if myLevel is less than the level specified by a prior call to psLogSetLevel(). | |
| void | psLogMsgV (const char *name, int level, const char *format, va_list ap) |
| This procedure is functionally equivalent to psLogMsg(), except that it takes a va_list as the message parameter, not a printf-style string. | |
| const char * | p_psFileLine (const char *file, int line) |
| This macro returns a (static buffer containing) "file:line". | |
| psString | psStringAlloc (long nChar) |
| Allocates a new psString. | |
| bool | psMemCheckString (psPtr ptr) |
| Checks the type of a particular pointer. | |
| psString | psStringCopy (const char *string) |
| Copies the input string. | |
| psString | psStringNCopy (const char *string, unsigned int nChar) |
| Copies the input string up to the specified number of characters. | |
| ssize_t | psStringAppend (char **dest, const char *format,...) |
| Appends a format onto a string. | |
| ssize_t | psStringAppendV (char **dest, const char *format, va_list ap) |
| Appends a format onto a string. | |
| ssize_t | psStringPrepend (char **dest, const char *format,...) |
| Prepends a format onto a string. | |
| ssize_t | psStringPrependV (char **dest, const char *format, va_list ap) |
| Prepends a format onto a string. | |
| psList * | psStringSplit (const char *string, const char *splitters, bool multipleAreSignificant) |
| Procedure to split the input string into a psList of psStrings. | |
| psArray * | psStringSplitArray (const char *string, const char *splitters, bool multipleAreSignificant) |
| Procedure to split the input string into a psArray of psStrings. | |
| ssize_t | psStringSubstitute (psString *input, const char *replace, const char *key) |
| Procedure to search an input string and substitute strings where desired. | |
| size_t | psStringStrip (char *string) |
| Procedure to strip the whitespace from the head and tail of a string. | |
| psString | psStringStripCVS (const char *string, const char *tagName) |
| Given a CVS keyword string, strip off the CVS-specific keyword to get the value. | |
| bool | psTraceSetFormat (const char *format) |
| This procedure sets the trace format for future trace messages. | |
| void | psTrace (const char *facil, int level, const char *format,...) |
| Sends a trace message. | |
| int | psTraceGetLevel (const char *facil) |
| Get the trace level. | |
| int | psTraceSetLevel (const char *facil, int level) |
| Set trace level. | |
| void | psTraceReset (void) |
| Set all trace levels to zero (do not free nodes in the facility tree). | |
| void | psTracePrintLevels (void) |
| print trace levels | |
| bool | psTraceSetDestination (int fd) |
| Set the destination of future trace messages. | |
| int | psTraceGetDestination (void) |
| Get the current destination for trace messages. | |
| psMetadata * | psTraceLevels (void) |
| Return a psMetadata summarising the trace levels. | |
| int | psArgumentVerbosity (int *argc, char **argv) |
| Implements the various verbosity controls. | |
| int | psArgumentGet (int argc, char **argv, const char *arg) |
| Checks for an argument and returns its index position if found. | |
| bool | psArgumentRemove (int argnum, int *argc, char **argv) |
| Removes from the argument list the argument whose index is argnum. | |
| bool | psArgumentParse (psMetadata *arguments, int *argc, char **argv) |
| Parses the command line arguments into a metadata container of arguments. | |
| void | psArgumentHelp (psMetadata *arguments) |
| Prints to stdout a guide to the command-line arguments. | |
Variables | |
| psMemBlock * | psMemBlock::previousBlock |
| previous block in allocation list | |
| psMemBlock * | psMemBlock::nextBlock |
| next block allocation list | |
| psFreeFunc | psMemBlock::freeFunc |
| deallocator. If NULL, use generic deallocation. | |
| size_t | psMemBlock::userMemorySize |
| the size of the user-portion of the memory block | |
| const psMemId | psMemBlock::id |
| a unique ID for this allocation | |
| const pthread_t | psMemBlock::tid |
| set from pthread_self(); | |
| const char * | psMemBlock::file |
| set from __FILE__ in e.g. p_psAlloc | |
| const unsigned int | psMemBlock::lineno |
| set from __LINE__ in e.g. p_psAlloc | |
| const char * | psMemBlock::func |
| set from __func__ | |
| psReferenceCount | psMemBlock::refCounter |
| how many times pointer is referenced | |
| bool | psMemBlock::persistent |
| marks if this non-user persistent data like error stack, etc. | |
| const psU32 | psMemBlock::endblock |
| initialised to p_psMEMMAGIC | |
| #define PS_ASSERT_DOUBLE_WITHIN_RANGE | ( | NAME, | |||
| LOWER, | |||||
| UPPER, | |||||
| RVAL | ) |
Value:
if ((NAME) < (LOWER) || (NAME) > (UPPER)) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ "Error: %s, %lf, is out of range. Must be between %lf and %lf.", \ #NAME, NAME, LOWER, UPPER); \ return RVAL; \ }
Definition at line 175 of file psAssert.h.
| #define PS_ASSERT_FLOAT_EQUAL | ( | NAME1, | |||
| NAME2, | |||||
| RVAL | ) |
Value:
if (fabs((NAME2) - (NAME1)) > FLT_EPSILON) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ "Error: %s and %s are not equal.", \ #NAME1, #NAME2); \ return(RVAL); \ }
Definition at line 150 of file psAssert.h.
| #define PS_ASSERT_FLOAT_LARGER_THAN | ( | NAME1, | |||
| NAME2, | |||||
| RVAL | ) |
Value:
if (!((NAME1) > (NAME2))) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ "Error: !(%s > %s) (%f %f).", \ #NAME1, #NAME2, NAME1, NAME2); \ return(RVAL); \ }
Definition at line 110 of file psAssert.h.
| #define PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL | ( | NAME1, | |||
| NAME2, | |||||
| RVAL | ) |
Value:
if (!((NAME1) >= (NAME2))) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ "Error: !(%s >= %s) (%f %f).", \ #NAME1, #NAME2, NAME1, NAME2); \ return(RVAL); \ }
Definition at line 118 of file psAssert.h.
| #define PS_ASSERT_FLOAT_LESS_THAN | ( | NAME1, | |||
| NAME2, | |||||
| RVAL | ) |
Value:
if (!((NAME1) < (NAME2))) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ "Error: !(%s < %s) (%f %f).", \ #NAME1, #NAME2, NAME1, NAME2); \ return(RVAL); \ }
Definition at line 126 of file psAssert.h.
| #define PS_ASSERT_FLOAT_LESS_THAN_OR_EQUAL | ( | NAME1, | |||
| NAME2, | |||||
| RVAL | ) |
Value:
if (!((NAME1) <= (NAME2))) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ "Error: !(%s <= %s) (%f %f).", \ #NAME1, #NAME2, NAME1, NAME2); \ return(RVAL); \ }
Definition at line 134 of file psAssert.h.
| #define PS_ASSERT_FLOAT_NON_EQUAL | ( | NAME1, | |||
| NAME2, | |||||
| RVAL | ) |
Value:
if (fabs((NAME2) - (NAME1)) < FLT_EPSILON) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ "Error: %s and %s are equal.", \ #NAME1, #NAME2); \ return(RVAL); \ }
Definition at line 142 of file psAssert.h.
| #define PS_ASSERT_FLOAT_REAL | ( | NAME, | |||
| RVAL | ) |
Value:
if (!isfinite(NAME)) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ "Error: %s=%f is not a real value.\n", \ #NAME, NAME); \ return RVAL; \ }
Definition at line 167 of file psAssert.h.
| #define PS_ASSERT_FLOAT_WITHIN_RANGE | ( | NAME, | |||
| LOWER, | |||||
| UPPER, | |||||
| RVAL | ) |
Value:
if ((NAME) < (LOWER) || (NAME) > (UPPER)) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ "Error: %s, %f, is out of range. Must be between %f and %f.", \ #NAME, NAME, LOWER, UPPER); \ return RVAL; \ }
Definition at line 159 of file psAssert.h.
| #define PS_ASSERT_GENERAL_PTR_DIMEN | ( | NAME, | |||
| DIMEN, | |||||
| CLEANUP | ) |
Value:
if ((NAME)->type.dimen != DIMEN) { \ psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ "Unallowable operation: %s has incorrect dimensionality.", \ #NAME); \ CLEANUP; \ }
Definition at line 233 of file psAssert.h.
| #define PS_ASSERT_GENERAL_PTR_NON_NULL | ( | NAME, | |||
| CLEANUP | ) |
Value:
if ((NAME) == NULL) { \ psError(PS_ERR_BAD_PARAMETER_NULL, true, \ "Unallowable operation: %s is NULL.", \ #NAME); \ CLEANUP; \ }
Definition at line 216 of file psAssert.h.
| #define PS_ASSERT_INT_EQUAL | ( | NAME1, | |||
| NAME2, | |||||
| RVAL | ) |
Value:
if ((NAME1) != (NAME2)) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ "Error: %s and %s are not equal.", \ #NAME1, #NAME2); \ return(RVAL); \ }
Definition at line 37 of file psAssert.h.
| #define PS_ASSERT_INT_LARGER_THAN | ( | NAME1, | |||
| NAME2, | |||||
| RVAL | ) |
Value:
if (!((NAME1) > (NAME2))) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ "Error: !(%s > %s) (%d %d).", \ #NAME1, #NAME2, NAME1, NAME2); \ return(RVAL); \ }
Definition at line 95 of file psAssert.h.
| #define PS_ASSERT_INT_LARGER_THAN_OR_EQUAL | ( | NAME1, | |||
| NAME2, | |||||
| RVAL | ) |
Value:
if (!((NAME1) >= (NAME2))) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ "Error: !(%s >= %s) (%d %d).", \ #NAME1, #NAME2, NAME1, NAME2); \ return(RVAL); \ }
Definition at line 103 of file psAssert.h.
| #define PS_ASSERT_INT_LESS_THAN | ( | VAR1, | |||
| VAR2, | |||||
| RVAL | ) |
Value:
if (!(VAR1 < VAR2)) { \ psError(PS_ERR_UNKNOWN, true, \ "Error: %s is not less than %s (%d, %d)", #VAR1, #VAR2, VAR1, VAR2); \ return(RVAL); \ }
Definition at line 81 of file psAssert.h.
| #define PS_ASSERT_INT_LESS_THAN_OR_EQUAL | ( | VAR1, | |||
| VAR2, | |||||
| RVAL | ) |
Value:
if (!(VAR1 <= VAR2)) { \ psError(PS_ERR_UNKNOWN, true, \ "Error: %s is not less than %s (%d, %d)", #VAR1, #VAR2, VAR1, VAR2); \ return(RVAL); \ }
Definition at line 88 of file psAssert.h.
| #define PS_ASSERT_INT_NONNEGATIVE | ( | NAME, | |||
| RVAL | ) |
Value:
if ((NAME) < 0) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Error: %s is less than 0.", #NAME); \ return(RVAL); \ }
Definition at line 45 of file psAssert.h.
| #define PS_ASSERT_INT_NONZERO | ( | NAME, | |||
| RVAL | ) |
Value:
if ((NAME) == 0) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ "Error: %s is 0.", #NAME); \ return(RVAL); \ }
Definition at line 65 of file psAssert.h.
| #define PS_ASSERT_INT_POSITIVE | ( | NAME, | |||
| RVAL | ) |
Value:
if ((NAME) < 1) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ "Error: %s is 0 or less.", #NAME); \ return(RVAL); \ }
Definition at line 51 of file psAssert.h.
| #define PS_ASSERT_INT_UNEQUAL | ( | NAME1, | |||
| NAME2, | |||||
| RVAL | ) |
Value:
if ((NAME1) == (NAME2)) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ "Error: %s and %s are equal.", \ #NAME1, #NAME2); \ return(RVAL); \ }
Definition at line 29 of file psAssert.h.
| #define PS_ASSERT_INT_WITHIN_RANGE | ( | NAME, | |||
| LOWER, | |||||
| UPPER, | |||||
| RVAL | ) |
Value:
if ((int)(NAME) < LOWER || (int)(NAME) > UPPER) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ "Error: %s, %d, is out of range. Must be between %d and %d.", \ #NAME,(int)NAME,LOWER,UPPER); \ return RVAL; \ }
Definition at line 73 of file psAssert.h.
| #define PS_ASSERT_INT_ZERO | ( | NAME, | |||
| RVAL | ) |
Value:
if ((NAME) != 0) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ "Error: %s is 0.", #NAME); \ return(RVAL); \ }
Definition at line 58 of file psAssert.h.
| #define PS_ASSERT_LONG_LARGER_THAN_OR_EQUAL | ( | NAME1, | |||
| NAME2, | |||||
| RVAL | ) |
Value:
if (!((NAME1) >= (NAME2))) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Error: !(%s >= %s) (%ld %ld).",\ #NAME1, #NAME2, NAME1, NAME2); \ return(RVAL); \ }
Definition at line 191 of file psAssert.h.
| #define PS_ASSERT_LONG_WITHIN_RANGE | ( | NAME, | |||
| LOWER, | |||||
| UPPER, | |||||
| RVAL | ) |
Value:
if ((NAME) < (LOWER) || (NAME) > (UPPER)) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ "Error: %s, %ld, is out of range. Must be between %ld and %ld.", \ #NAME, NAME, LOWER, UPPER); \ return RVAL; \ }
Definition at line 183 of file psAssert.h.
| #define PS_ASSERT_PTR | ( | NAME, | |||
| RVAL | ) |
Value:
{ \
if (NAME == NULL) return(RVAL); \
psMemBlock *mb = (psMemBlock*)(NAME) - 1; \
if (mb->startblock != P_PS_MEMMAGIC || mb->endblock != P_PS_MEMMAGIC || \
*(psU32 *)((char *)(mb + 1) + mb->userMemorySize) != P_PS_MEMMAGIC) { \
psError(PS_ERR_MEMORY_CORRUPTION, false, \
"Error: Pointer %s is corrupted or not on the PS memory system.", \
#NAME); \
return (RVAL); \
} \
}
Definition at line 16 of file psAssert.h.
| #define PS_ASSERT_PTR_DIMEN | ( | NAME, | |||
| DIMEN, | |||||
| RVAL | ) | PS_ASSERT_GENERAL_PTR_DIMEN(NAME, DIMEN, return RVAL) |
Definition at line 232 of file psAssert.h.
| #define PS_ASSERT_PTR_DIMEN_GENERAL_NOT | ( | NAME, | |||
| DIMEN, | |||||
| CLEANUP | ) |
Value:
if ((NAME)->type.dimen == DIMEN) { \ psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ "Unallowable operation: %s has incorrect dimensionality.", \ #NAME); \ CLEANUP; \ }
Definition at line 241 of file psAssert.h.
| #define PS_ASSERT_PTR_NON_NULL | ( | NAME, | |||
| RVAL | ) | PS_ASSERT_GENERAL_PTR_NON_NULL(NAME, return RVAL) |
Definition at line 215 of file psAssert.h.
| #define PS_ASSERT_PTR_TYPE | ( | NAME, | |||
| TYPE, | |||||
| RVAL | ) |
Value:
if ((NAME)->type.type != TYPE) { \ psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ "Unallowable operation: %s has incorrect type.", \ #NAME); \ return(RVAL); \ }
Definition at line 224 of file psAssert.h.
| #define PS_ASSERT_PTR_TYPE_EQUAL | ( | PTR1, | |||
| PTR2, | |||||
| RVAL | ) | PS_ASSERT_PTRS_TYPE_EQUAL_GENERAL(PTR1, PTR2, return RVAL) |
Definition at line 258 of file psAssert.h.
| #define PS_ASSERT_PTRS_SIZE_EQUAL | ( | PTR1, | |||
| PTR2, | |||||
| RVAL | ) |
Value:
if (PTR1->n != PTR2->n) { \ psError(PS_ERR_BAD_PARAMETER_SIZE, true, \ "ptr %s has size %d, ptr %s has size %d.", \ #PTR1, PTR1->n, #PTR2, PTR2->n); \ return(RVAL); \ }
Definition at line 250 of file psAssert.h.
| #define PS_ASSERT_PTRS_TYPE_EQUAL_GENERAL | ( | PTR1, | |||
| PTR2, | |||||
| CLEANUP | ) |
Value:
if (PTR1->type.type != PTR2->type.type) { \ psError(PS_ERR_BAD_PARAMETER_TYPE, true, \ "ptr %s has type %d, ptr %s has type %d.", \ #PTR1, PTR1->type.type, #PTR2, PTR2->type.type); \ CLEANUP; \ }
Definition at line 259 of file psAssert.h.
| #define PS_ASSERT_S64_WITHIN_RANGE | ( | NAME, | |||
| LOWER, | |||||
| UPPER, | |||||
| RVAL | ) |
Value:
if ((NAME) < (LOWER) || (NAME) > (UPPER)) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ "Error: %s, %" PRId64 ", is out of range. Must be between %" PRId64 " and %" PRId64 ".", \ #NAME, NAME, LOWER, UPPER); \ return RVAL; \ }
Definition at line 198 of file psAssert.h.
| #define PS_ASSERT_STRING_NON_EMPTY | ( | NAME, | |||
| RVAL | ) |
Value:
if (!(NAME) || strlen(NAME) == 0) { \ psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ "Error: String %s is NULL or empty.", \ #NAME); \ return(RVAL); \ }
Definition at line 207 of file psString.h.
| #define PS_FILE_LINE p_psFileLine(__FILE__,__LINE__) |
Definition at line 34 of file psString.h.
| #define PS_STRING | ( | S | ) | #S |
| #define PS_WARN_PTR_NON_NULL | ( | NAME | ) |
Value:
if ((NAME) == NULL) { \ psLogMsg(__func__, PS_LOG_WARN, "WARNING: %s is NULL.", #NAME); \ } \
Definition at line 210 of file psAssert.h.
| anonymous enum |
< Status codes for log messages
Definition at line 121 of file psLogMsg.h.
| anonymous enum |
| PS_LOG_TO_NONE | turn off logging |
| PS_LOG_TO_STDERR | log to system's stderr |
| PS_LOG_TO_STDOUT | log to system's stdout |
Definition at line 131 of file psLogMsg.h.
| anonymous enum |
| enum psErrorCode |
enumeration of the static error code classes
Definition at line 24 of file psErrorCodes.h.
| enum psExit |
Exit status codes.
These provide a bit finer granularity compared to success/fail
| psBool p_psErrorUnregister | ( | psErrorCode | code | ) |
Clears error codes registered via psErrorRegister.
| code | the error code to find and remove |
| const char* p_psFileLine | ( | const char * | file, | |
| int | line | |||
| ) |
This macro returns a (static buffer containing) "file:line".
| void p_psMemoryCheck | ( | void | ) |
| void psAbort | ( | const char * | name, | |
| const char * | format, | |||
| ... | ||||
| ) |
Reports an abort message to logging facility.
This function will invoke the psLogMsg function with a level of PS_LOG_ABORT and pass the parameters name and fmt to generate a proper log message. After logging, this function will call system abort function to abnormally terminate the program.
| name | Source of abort such as file or function detected |
| format | A printf style formatting statement defining msg |
| int psArgumentGet | ( | int | argc, | |
| char ** | argv, | |||
| const char * | arg | |||
| ) |
Checks for an argument and returns its index position if found.
| argc | number of arguments |
| argv | the argument list |
| arg | the specified argument to match |
| void psArgumentHelp | ( | psMetadata * | arguments | ) |
Prints to stdout a guide to the command-line arguments.
| arguments | metadata container for arguments |
| bool psArgumentParse | ( | psMetadata * | arguments, | |
| int * | argc, | |||
| char ** | argv | |||
| ) |
Parses the command line arguments into a metadata container of arguments.
The input arguments shall contain the list of possible arguments as the keywords providing the default values. As matching arguments are found on the command line, the values shall be read into the arguments metadata, with the appropriate type. The arguments and their values shall be removed from the list of command line arguments as they are processed.
| arguments | metadata container for arguments |
| argc | number of arguments |
| argv | the argument list |
| bool psArgumentRemove | ( | int | argnum, | |
| int * | argc, | |||
| char ** | argv | |||
| ) |
Removes from the argument list the argument whose index is argnum.
The number of entries in the argument list shall be decremented.
| argnum | the argument to remove |
| argc | number of arguments |
| argv | the argument list |
| int psArgumentVerbosity | ( | int * | argc, | |
| char ** | argv | |||
| ) |
Implements the various verbosity controls.
Arguments shall be removed from the argument list as they are processed.
| argc | number of arguments |
| argv | the argument list |
| psErr* psErrAlloc | ( | const char * | name, | |
| psErrorCode | code, | |||
| const char * | msg | |||
| ) |
| psErrorCode psError | ( | psErrorCode | code, | |
| psBool | new, | |||
| const char * | format, | |||
| ... | ||||
| ) |
Reports an error message to the logging facility.
This function will invoke the psLogMsg function with a level of PS_LOG_ERROR and pass the parameters name and format to generate a proper log message.
This function modifies the error stack.
| code | Error class code |
| new | true if error originates at this location |
| format | printf-style format of header line |
| void psErrorClear | ( | void | ) |
Clears the error stack.
The error stack may be completely cleared with psErrorClear.
| psErrorCode psErrorCodeLast | ( | void | ) |
Get errorCode of last error put on the error stack.
| const char* psErrorCodeString | ( | psErrorCode | code | ) |
Retrieves the description of an error code.
The routine psErrorCodeString returns the string associated with an error code.
| code | the associated error code |
| psErrorDescription* psErrorDescriptionAlloc | ( | psErrorCode | code, | |
| const char * | description | |||
| ) |
Allocates a new psErrorDescription.
| code | An error code |
| description | the associated description |
| psErr* psErrorGet | ( | long | which | ) |
Get a error from the error stack.
Previous errors on the stack are returned by psErrorGet (a value of 0 passed to psErrorGet is equivalent to a call to psErrorLast).
if no error is at the which position, a non-NULL psErr is returned with code PS_ERR_NONE.
| which | position in the error stack. 0 is last error on stack. |
| long psErrorGetStackSize | ( | ) |
Get the error stack depth.
| psErr* psErrorLast | ( | void | ) |
Get last error put on the error stack.
The last error reported is available from psErrorLast; if no errors are current, a non-NULL psErr is returned with code PS_ERR_NONE.
| void psErrorRegister | ( | const psErrorDescription * | errors, | |
| int | errorCode | |||
| ) |
Register an error code.
Any project needed to use psLib must define the necessary error codes and associated message strings. This function registers an array of error codes with the error handling subsystem.
| errors | Array of error codes to register |
| errorCode | number of errors in input array |
| void psErrorStackPrint | ( | FILE * | fd, | |
| const char * | format, | |||
| ... | ||||
| ) |
Prints error stack to specified open file descriptor.
The entire error stack may be printed to an open file descriptor by calling psErrorStackPrint; if and only if there are current errors, the printf-style string format is first printed to the file descriptor fd. In this printout, error codes are replaced by their string equivalents.
| fd | destination file descriptor |
| format | printf-style format of header line |
| void psErrorStackPrintV | ( | FILE * | fd, | |
| const char * | format, | |||
| va_list | va | |||
| ) |
Prints error stack to specified open file descriptor.
The entire error stack may be printed to an open file descriptor by calling psErrorStackPrintV; if and only if there are current errors, the vprintf-style string format is first printed to the file descriptor fd. In this printout, error codes are replaced by their string equivalents.
| fd | destination file descriptor |
| format | printf-style format of header line |
| va | any parameters required in format |
| void psLibFinalize | ( | void | ) |
Removes persistant memory created with the psLibInit function.
The memory created but not freed by psLib modules should be freed within this function at the end of a psLib execution cycle.
| void psLibInit | ( | const char * | timeConfig | ) |
| psString psLibVersion | ( | void | ) |
Get current psLib version.
Returns the current psLib version name as a string.
| psString psLibVersionLong | ( | void | ) |
Get current psLib version (full identification).
Returns the current psLib version name and other information identifying the compilation.
| bool psLineAdd | ( | psLine * | line, | |
| const char * | format, | |||
| ... | ||||
| ) |
Adds the line segment to the string.
Appends a line segment to the string, returning false if the new segment would overflow the allocated string length.
| line | the line segment to append |
| format | printf-style format of line |
| psLine* psLineAlloc | ( | long | Nline | ) |
Allocates a line object of length Nline.
| Nline | length of line object to allocate |
| bool psLineInit | ( | psLine * | line | ) |
Initializes or re-initializes a line.
Initializes or re-initializes a line, setting the current length to zero and setting the string data values to 0. If the function is passed NULL, false is returned.
| line | line to (re-)initialize |
| int psLogGetDestination | ( | ) |
This procedure returns the current log destination file descriptor.
If the destination has not been defined by the use, the descriptor for stdout is returned.
| int psLogGetLevel | ( | ) |
This procedures returns the current log message level.
| void psLogMsg | ( | const char * | name, | |
| int | level, | |||
| const char * | format, | |||
| ... | ||||
| ) |
This procedure logs a message to the destination set by a prior call to psLogSetDestination(), if myLevel is less than the level specified by a prior call to psLogSetLevel().
The message is specified with a printf-type string and arguments.
| name | name of the log source |
| level | severity level of this log message |
| format | printf-style format command |
| void psLogMsgV | ( | const char * | name, | |
| int | level, | |||
| const char * | format, | |||
| va_list | ap | |||
| ) |
This procedure is functionally equivalent to psLogMsg(), except that it takes a va_list as the message parameter, not a printf-style string.
| name | name of the log source |
| level | severity level of this log message |
| format | printf-style format command |
| ap | varargs argument list |
| bool psLogSetDestination | ( | int | fd | ) |
This procedure sets the destination for future log messages.
This procedure will take an integer as an argument which can specify general log destinations.
| fd | Specifies where to send messages. |
| bool psLogSetFormat | ( | const char * | format | ) |
This procedure sets the log format for future log messages.
The argument must be a character string consistsing of the letters H (host), L (level), M (message), N (name), and T (time). The default is "THLNM". Deleting a letter from the string will cause the associated information to not be logged. This procedure does not alter the order in which the messages are displayed.
| format | Specifies the system log format |
| int psLogSetLevel | ( | int | level | ) |
This procedure sets the message level for future log messages.
Subsequent log messages, with a log level of "mylevel", will only be logged if "mylevel" is less than the current log level set by this procedure. Ie. higher values set by this procedure will cause more log messages to be displayed. The old log level will be returned.
| level | Specifies the system log level |
| bool psMemCheckLine | ( | psPtr | ptr | ) |
Checks the type of a particular pointer.
Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
| ptr | the pointer whose type to check |
| bool psMemCheckString | ( | psPtr | ptr | ) |
Checks the type of a particular pointer.
Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
| ptr | the pointer whose type to check |
| int psMessageDestination | ( | const char * | dest | ) |
This procedures uses a string to set the destination for which to send the corresponding log messages.
| dest | Specifies where to send the message |
| psString psStringAlloc | ( | long | nChar | ) |
Allocates a new psString.
| nChar | Size of psString to allocate. |
| ssize_t psStringAppend | ( | char ** | dest, | |
| const char * | format, | |||
| ... | ||||
| ) |
Appends a format onto a string.
This function shall allocate a new string if dest is NULL. dest shall be automatically extended to the size of the new string.
| dest | existing string |
| format | format to append |
| ssize_t psStringAppendV | ( | char ** | dest, | |
| const char * | format, | |||
| va_list | ap | |||
| ) |
Appends a format onto a string.
This function shall allocate a new string if dest is NULL. dest shall be automatically extended to the size of the new string.
| dest | existing string |
| format | format to append |
| ap | va_list of format arguments |
| psString psStringCopy | ( | const char * | string | ) |
Copies the input string.
This function shall allocate memory to the length of the input string plus one and copy the input string to the newly allocated memory. If 'string' is 'NULL' then 'NULL' is returned.
| string | Input string of characters to copy |
| psString psStringNCopy | ( | const char * | string, | |
| unsigned int | nChar | |||
| ) |
Copies the input string up to the specified number of characters.
This function shall allocate memory to the length specified by nChar plus one and copy the input string to the newly allocated memory. This function will only copy nChar bytes from the input to new string, so if the input string is larger than nChar characters the copied string will be a substring of the input string. If the input string is smaller than nChar bytes then the remaining bytes allocated will be set to NULL. If 'string' is 'NULL' then 'NULL' is returned.
| string | Input string of characters to copy |
| nChar | Number of bytes to allocate for string copy |
| ssize_t psStringPrepend | ( | char ** | dest, | |
| const char * | format, | |||
| ... | ||||
| ) |
Prepends a format onto a string.
This function shall allocate a new string if dest is NULL. dest shall be automatically extended to the size of the new string.
| dest | existing string |
| format | format to append |
| ssize_t psStringPrependV | ( | char ** | dest, | |
| const char * | format, | |||
| va_list | ap | |||
| ) |
Prepends a format onto a string.
This function shall allocate a new string if dest is NULL. dest shall be automatically extended to the size of the new string.
| dest | existing string |
| format | format to append |
| ap | va_list of format arguments |
| psList* psStringSplit | ( | const char * | string, | |
| const char * | splitters, | |||
| bool | multipleAreSignificant | |||
| ) |
Procedure to split the input string into a psList of psStrings.
The string is split at any one of the characters in splitters. Split strings of zero length should not be included in the output list.
| string | String to split |
| splitters | Characters on which to split |
| multipleAreSignificant | Are multiple occurences significant? |
| psArray* psStringSplitArray | ( | const char * | string, | |
| const char * | splitters, | |||
| bool | multipleAreSignificant | |||
| ) |
Procedure to split the input string into a psArray of psStrings.
The string is split at any one of the characters in splitters. Split strings of zero length should not be included in the output list.
| string | String to split |
| splitters | Characters on which to split |
| multipleAreSignificant | Are multiple occurences significant? |
| size_t psStringStrip | ( | char * | string | ) |
Procedure to strip the whitespace from the head and tail of a string.
| string | input string to be stripped. |
| psString psStringStripCVS | ( | const char * | string, | |
| const char * | tagName | |||
| ) |
Given a CVS keyword string, strip off the CVS-specific keyword to get the value.
| string | The string, something like "$CVSKEYWORD: Value$" |
| tagName | The name of the tag to remove, something like "CVSKEYWORD" |
| ssize_t psStringSubstitute | ( | psString * | input, | |
| const char * | replace, | |||
| const char * | key | |||
| ) |
Procedure to search an input string and substitute strings where desired.
The input string is searched for all instances of the key, which is then replaced with the replacement value wherever found. The input string may be freed if not needed.
| input | ptr to input string to be modified |
| replace | replacement value |
| key | string to be replaced in input |
| void psTrace | ( | const char * | facil, | |
| int | level, | |||
| const char * | format, | |||
| ... | ||||
| ) |
Sends a trace message.
| facil | facilty of interest |
| level | desired trace level |
| format | printf-style format command |
| int psTraceGetDestination | ( | void | ) |
Get the current destination for trace messages.
| int psTraceGetLevel | ( | const char * | facil | ) |
Get the trace level.
| facil | facilty of interest |
| psMetadata* psTraceLevels | ( | void | ) |
Return a psMetadata summarising the trace levels.
| void psTracePrintLevels | ( | void | ) |
print trace levels
| void psTraceReset | ( | void | ) |
Set all trace levels to zero (do not free nodes in the facility tree).
| bool psTraceSetDestination | ( | int | fd | ) |
Set the destination of future trace messages.
| fd | File descriptor |
| bool psTraceSetFormat | ( | const char * | format | ) |
This procedure sets the trace format for future trace messages.
The argument must be a character string consistsing of the letters H (host), L (level), M (message), N (name), and T (time). The default is "THLNM". Deleting a letter from the string will cause the associated information to not be logged. This procedure does not alter the order in which the messages are displayed.
| format | Specifies the system trace format |
| int psTraceSetLevel | ( | const char * | facil, | |
| int | level | |||
| ) |
Set trace level.
| facil | facilty of interest |
| level | desired trace level |
| void psWarning | ( | const char * | format, | |
| ... | ||||
| ) |
Logs a warning message.
This procedure logs a message to the destination set by a prior call to psLogSetDestination(), This is equivalent to calling psLogMsg with a level of PS_LOG_WARN.
| format | printf-style format of header line |
const psU32 psMemBlock::endblock [inherited] |
const char* psMemBlock::file [inherited] |
psFreeFunc psMemBlock::freeFunc [inherited] |
const char* psMemBlock::func [inherited] |
const psMemId psMemBlock::id [inherited] |
const unsigned int psMemBlock::lineno [inherited] |
struct psMemBlock* psMemBlock::nextBlock [inherited] |
bool psMemBlock::persistent [inherited] |
marks if this non-user persistent data like error stack, etc.
Definition at line 76 of file psMemory.h.
struct psMemBlock* psMemBlock::previousBlock [inherited] |
psReferenceCount psMemBlock::refCounter [inherited] |
const pthread_t psMemBlock::tid [inherited] |
size_t psMemBlock::userMemorySize [inherited] |
1.5.1