Changeset 2273 for trunk/psLib/src/sysUtils
- Timestamp:
- Nov 3, 2004, 3:05:00 PM (22 years ago)
- Location:
- trunk/psLib/src/sysUtils
- Files:
-
- 8 edited
-
psError.c (modified) (4 diffs)
-
psError.h (modified) (2 diffs)
-
psErrorCodes.c (modified) (4 diffs)
-
psErrorCodes.h (modified) (2 diffs)
-
psLogMsg.c (modified) (6 diffs)
-
psMemory.c (modified) (5 diffs)
-
psString.c (modified) (2 diffs)
-
psTrace.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sysUtils/psError.c
r2204 r2273 10 10 * @author Eric Van Alst, MHPCC 11 11 * 12 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-1 0-27 00:57:31$12 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-11-04 01:05:00 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 67 67 } 68 68 69 void psError(const char *name, const char *fmt, ...) 69 psErrorCode p_psError(const char* file, 70 int lineno, 71 const char* func, 72 psErrorCode code, 73 psBool new, 74 const char* fmt, 75 ...) 70 76 { 71 va_list argPtr; // variable list arguement pointer 77 char errMsg[2048]; 78 psErr* err; 79 char msgName[256]; 72 80 73 // Get the variable list parameters to pass to logging function 74 va_start(argPtr, fmt); 75 76 // Call logging function with PS_LOG_ERROR level 77 psLogMsgV(name, PS_LOG_ERROR, fmt, argPtr); 78 79 // Clean up stack after variable argument has been used 80 va_end(argPtr); 81 } 82 83 void psErrorClear() 84 { 85 pthread_mutex_lock(&lockErrorStack); 86 for (psS32 lcv=0;lcv<errorStackSize;lcv++) { 87 p_psMemSetPersistent(errorStack[lcv]->msg,false); 88 p_psMemSetPersistent(errorStack[lcv]->name,false); 89 p_psMemSetPersistent(errorStack[lcv],false); 90 psFree(errorStack[lcv]); 91 } 92 errorStackSize = 0; 93 pthread_mutex_unlock(&lockErrorStack); 94 } 95 96 psErrorCode psErrorMsg(const char *name, psErrorCode code, psBool new, const char* fmt, ...) 97 { 98 char errMsg[1024]; 99 psErr* err; 100 char* msgName; 101 102 // Check for null pointer and if found set to empty string; 103 if ( name == NULL ) { 104 msgName = ""; 105 } else { 106 msgName = (char*)name; 107 } 81 snprintf(msgName,256,"%s (%s:%d)",func,file,lineno); 108 82 109 83 va_list argPtr; // variable list arguement pointer … … 116 90 va_start(argPtr, fmt); 117 91 118 vsnprintf(errMsg, 1024,fmt,argPtr);92 vsnprintf(errMsg,2048,fmt,argPtr); 119 93 err = psErrAlloc(msgName,code,errMsg); 120 94 pushErrorStack(err); … … 160 134 } 161 135 136 void psErrorClear(void) 137 { 138 pthread_mutex_lock(&lockErrorStack); 139 140 for (int lcv=0;lcv < errorStackSize; lcv++) { 141 p_psMemSetPersistent(errorStack[lcv],false); 142 p_psMemSetPersistent(errorStack[lcv]->msg,false); 143 p_psMemSetPersistent(errorStack[lcv]->name,false); 144 psFree(errorStack[lcv]); 145 } 146 errorStackSize = 0; 147 148 pthread_mutex_unlock(&lockErrorStack); 149 150 } 162 151 void psErrorStackPrint(FILE *fd, const char *fmt, ...) 163 152 { -
trunk/psLib/src/sysUtils/psError.h
r2204 r2273 12 12 * @author Eric Van Alst, MHPCC 13 13 * 14 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-1 0-27 00:57:31$14 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-11-04 01:05:00 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 104 104 * log message. 105 105 * 106 * This function modifies the error stack. 107 * 108 * @return psErrorCode the given error code 106 109 */ 107 void psError( 108 const char *name, ///< Source of error such as file or function detected 109 const char *fmt, ///< A printf style formatting statement defining msg 110 psErrorCode p_psError( 111 const char* file, 112 int lineno, 113 const char* func, 114 psErrorCode code, ///< Error class code 115 psBool new, ///< true if error originates at this location 116 const char* fmt, 110 117 ... 111 118 ); 112 119 113 /** Reports an error message to the logging facility 114 * 115 * This function will invoke the psLogMsg function with a level of 116 * PS_LOG_ERROR and pass the parameters name and fmt to generate a proper 117 * log message. 118 * 119 */ 120 psErrorCode psErrorMsg( 121 const char *name, ///< Name of error in the form aaa.bbb.ccc 122 psErrorCode code, ///< Error class code 123 psBool new, ///< true if error originates at this location 124 const char* fmt, ///< printf style formatting statement defining error message 125 ... 126 ); 120 #define psError(code,new,...) p_psError(__FILE__,__LINE__,__func__,code,new,__VA_ARGS__) 127 121 128 122 /** Create a new psErr struct -
trunk/psLib/src/sysUtils/psErrorCodes.c
r2204 r2273 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-1 0-27 00:57:31$9 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-11-04 01:05:00 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 46 46 {PS_ERR_BAD_PARAMETER_NULL,"parameter is null"}, 47 47 {PS_ERR_BAD_PARAMETER_SIZE,"size of parameter's data is outside of acceptable range."}, 48 {PS_ERR_UNEXPECTED_NULL,"unexpected NULL foun"}, 48 {PS_ERR_UNEXPECTED_NULL,"unexpected NULL found"}, 49 {PS_ERR_OS_CALL_FAILED,"unexpected result from an OS standard library call"}, 49 50 //~End 50 51 {PS_ERR_N_ERR_CLASSES,"error classes end marker"} … … 132 133 133 134 if (errors == NULL) { 134 psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister", 135 PS_ERR_BAD_PARAMETER_NULL, true, 136 PS_ERRORTEXT_psErrorCode_NULL_ERRORDESCRIPTION); 135 psError(PS_ERR_BAD_PARAMETER_NULL, true, 136 PS_ERRORTEXT_psErrorCode_NULL_ERRORDESCRIPTION); 137 137 return; 138 138 } … … 152 152 err) ) { 153 153 154 psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister", 155 PS_ERR_UNKNOWN, false, 156 PS_ERRORTEXT_psErrorCode_ERRORCODE_REGISTER_FAILED, 157 i); 154 psError(PS_ERR_UNKNOWN, false, 155 PS_ERRORTEXT_psErrorCode_ERRORCODE_REGISTER_FAILED, 156 i); 158 157 } 159 158 p_psMemSetPersistent(dynamicErrorCodes->head,true); -
trunk/psLib/src/sysUtils/psErrorCodes.h
r2204 r2273 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-1 0-27 00:57:31$9 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-11-04 01:05:00 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 52 52 PS_ERR_BAD_PARAMETER_NULL, ///< parameter is null 53 53 PS_ERR_BAD_PARAMETER_SIZE, ///< size of parameter's data is outside of acceptable range. 54 PS_ERR_UNEXPECTED_NULL, ///< unexpected NULL foun 54 PS_ERR_UNEXPECTED_NULL, ///< unexpected NULL found 55 PS_ERR_OS_CALL_FAILED, ///< unexpected result from an OS standard library call 55 56 //~End 56 57 PS_ERR_N_ERR_CLASSES ///< end marker - should not be used as a true error -
trunk/psLib/src/sysUtils/psLogMsg.c
r2204 r2273 11 11 * @author George Gusciora, MHPCC 12 12 * 13 * @version $Revision: 1.3 4$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-1 0-27 00:57:31$13 * @version $Revision: 1.35 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-11-04 01:05:00 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 110 110 111 111 if (sscanf(dest, "%4s:%256s", protocol, location) < 2) { 112 psError Msg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_LOCATION_INVALID,113 PS_ERRORTEXT_psLogMsg_DESTINATION_MALFORMED,114 dest);112 psError(PS_ERR_LOCATION_INVALID, true, 113 PS_ERRORTEXT_psLogMsg_DESTINATION_MALFORMED, 114 dest); 115 115 return false; 116 116 } … … 131 131 return true; 132 132 } 133 psError Msg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_LOCATION_INVALID,134 PS_ERRORTEXT_psLogMsg_DEST_LOCATION_INVALID,135 location);133 psError(PS_ERR_LOCATION_INVALID, true, 134 PS_ERRORTEXT_psLogMsg_DEST_LOCATION_INVALID, 135 location); 136 136 return 1; 137 137 } else if (strcmp(protocol, "file") == 0) { … … 139 139 140 140 if (file == NULL) { 141 psError Msg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_IO,142 PS_ERRORTEXT_psLogMsg_OPEN_FILE_FAILED,143 location);141 psError(PS_ERR_IO, true, 142 PS_ERRORTEXT_psLogMsg_OPEN_FILE_FAILED, 143 location); 144 144 return false; 145 145 } … … 151 151 } 152 152 153 psError Msg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_LOCATION_INVALID,154 PS_ERRORTEXT_psLogMsg_UNSUPPORTED_PROTOCOL,155 protocol);153 psError(PS_ERR_LOCATION_INVALID, true, 154 PS_ERRORTEXT_psLogMsg_UNSUPPORTED_PROTOCOL, 155 protocol); 156 156 return false; 157 157 } … … 215 215 break; 216 216 default: 217 psError Msg(PS_ERRORNAME_DOMAIN "psLogSetFormat", true, PS_ERR_BAD_PARAMETER_VALUE,218 PS_ERRORTEXT_psLogMsg_UNKNOWN_KEY, *ptr);217 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 218 PS_ERRORTEXT_psLogMsg_UNKNOWN_KEY, *ptr); 219 219 break; 220 220 } -
trunk/psLib/src/sysUtils/psMemory.c
r2210 r2273 8 8 * @author Robert Lupton, Princeton University 9 9 * 10 * @version $Revision: 1.4 3$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-1 0-27 19:35:59$10 * @version $Revision: 1.44 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-11-04 01:05:00 $ 12 12 * 13 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 100 100 { 101 101 if (ptr->refCounter < 1) { 102 psError Msg(PS_ERRORNAME_DOMAIN "memProblemCallbackDefault", false, PS_ERR_MEMORY_CORRUPTION,103 PS_ERRORTEXT_psMemory_MULTIPLE_FREE,104 ptr->id, ptr->file, ptr->lineno, file, lineno);102 psError(PS_ERR_MEMORY_CORRUPTION, false, 103 PS_ERRORTEXT_psMemory_MULTIPLE_FREE, 104 ptr->id, ptr->file, ptr->lineno, file, lineno); 105 105 } 106 106 … … 228 228 229 229 if (m == NULL) { 230 psError Msg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,231 PS_ERRORTEXT_psMemory_NULL_BLOCK);230 psError(PS_ERR_MEMORY_CORRUPTION, true, 231 PS_ERRORTEXT_psMemory_NULL_BLOCK); 232 232 return 1; 233 233 } … … 235 235 if (m->refCounter == 0) { 236 236 // using an unreferenced block of memory, are you? 237 psError Msg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,238 PS_ERRORTEXT_psMemory_DEREF_BLOCK_USE,239 m->id);237 psError(PS_ERR_MEMORY_CORRUPTION, true, 238 PS_ERRORTEXT_psMemory_DEREF_BLOCK_USE, 239 m->id); 240 240 return 1; 241 241 } 242 242 243 243 if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC) { 244 psError Msg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,245 PS_ERRORTEXT_psMemory_UNDERFLOW,246 m->id);244 psError(PS_ERR_MEMORY_CORRUPTION, true, 245 PS_ERRORTEXT_psMemory_UNDERFLOW, 246 m->id); 247 247 return 1; 248 248 } 249 249 if (*(psPtr *)((int8_t *) (m + 1) + m->userMemorySize) != P_PS_MEMMAGIC) { 250 psError Msg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,251 PS_ERRORTEXT_psMemory_OVERFLOW,252 m->id);250 psError(PS_ERR_MEMORY_CORRUPTION, true, 251 PS_ERRORTEXT_psMemory_OVERFLOW, 252 m->id); 253 253 return 1; 254 254 } … … 431 431 psMemBlock* ptr = ((psMemBlock* ) vptr) - 1; 432 432 433 psError Msg(PS_ERRORNAME_DOMAIN "psFree",PS_ERR_MEMORY_DEREF_USAGE,true,434 PS_ERRORTEXT_psMemory_MULTIPLE_FREE,435 ptr->id, ptr->file, ptr->lineno, file, lineno);433 psError(PS_ERR_MEMORY_DEREF_USAGE,true, 434 PS_ERRORTEXT_psMemory_MULTIPLE_FREE, 435 ptr->id, ptr->file, ptr->lineno, file, lineno); 436 436 437 437 return; -
trunk/psLib/src/sysUtils/psString.c
r2204 r2273 9 9 * @author Eric Van Alst, MHPCC 10 10 * 11 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-1 0-27 00:57:31$11 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-04 01:05:00 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 38 38 if (nChar < 0) { 39 39 // Log error message and return NULL 40 psError Msg(PS_ERRORNAME_DOMAIN "psStringNCopy",PS_ERR_BAD_PARAMETER_VALUE, true,41 PS_ERRORTEXT_psString_NCHAR_NEGATIVE,42 nChar);40 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 41 PS_ERRORTEXT_psString_NCHAR_NEGATIVE, 42 nChar); 43 43 return NULL; 44 44 } -
trunk/psLib/src/sysUtils/psTrace.c
r2221 r2273 9 9 * @author George Gusciora, MHPCC 10 10 * 11 * @version $Revision: 1.3 7$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-1 0-27 23:31:44$11 * @version $Revision: 1.38 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-04 01:05:00 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 161 161 // XXX: Verify that this is the correct behavior. 162 162 if (strcmp("", addNodeName) == 0) { 163 psError Msg(PS_ERRORNAME_DOMAIN "componentAdd",PS_ERR_BAD_PARAMETER_NULL,true,164 PS_ERRORTEXT_psTrace_ADD_NULL_COMPONENT);163 psError(PS_ERR_BAD_PARAMETER_NULL,true, 164 PS_ERRORTEXT_psTrace_ADD_NULL_COMPONENT); 165 165 return false; 166 166 } … … 173 173 174 174 if (addNodeName[0] != '.') { 175 psError Msg(PS_ERRORNAME_DOMAIN "componentAdd",PS_ERR_BAD_PARAMETER_VALUE,true,176 PS_ERRORTEXT_psTrace_MALFORMED_COMPONENT_NAME,177 addNodeName);175 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 176 PS_ERRORTEXT_psTrace_MALFORMED_COMPONENT_NAME, 177 addNodeName); 178 178 return false; 179 179 } … … 262 262 // Add the new component to the component tree. 263 263 if ( !componentAdd(compName, level) ) { 264 psErrorMsg(PS_ERRORNAME_DOMAIN "psTraceSetLevel", 265 PS_ERR_UNKNOWN, 266 false, 267 PS_ERRORTEXT_psTrace_FAILED_TO_ADD_COMPONENT, 268 level, 269 compName); 264 psError(PS_ERR_UNKNOWN, false, 265 PS_ERRORTEXT_psTrace_FAILED_TO_ADD_COMPONENT, 266 level, 267 compName); 270 268 271 269 if (comp[0] != '.') { … … 482 480 483 481 if (NULL == comp) { 484 psError Msg(PS_ERRORNAME_DOMAIN "psTrace",PS_ERR_BAD_PARAMETER_NULL, true,485 PS_ERRORTEXT_psTrace_NULL_TRACETREE,486 __func__);482 psError(PS_ERR_BAD_PARAMETER_NULL, true, 483 PS_ERRORTEXT_psTrace_NULL_TRACETREE, 484 __func__); 487 485 return; 488 486 }
Note:
See TracChangeset
for help on using the changeset viewer.
