44 static int initialized = 0;
69 for (i = 0; i < errSymTbl->
nsymbols; i++, errArray++) {
70 modnum = errArray->
errNum >> 16;
72 fprintf(
stderr,
"errSymBld: ERROR - Module number in errSymTbl < 501 was Module=%lx Name=%s\n",
77 fprintf(
stderr,
"errSymBld: ERROR - errSymbolAdd() failed \n");
91 pNextNode = *phashnode;
93 *phashnode = perrNumNode;
109 modnum = (
unsigned short) (errNum >> 16);
110 errnum = (
unsigned short) (errNum & 0xffff);
111 return (((modnum - 500) * 20) + errnum) %
NHASH;
132 static void errRawCopy(
long statusToDecode,
char *pBuf,
size_t bufLength)
134 epicsUInt16 modnum = (statusToDecode >>= 16) & 0xffff;
143 epicsSnprintf(pBuf, bufLength,
"Error (%u,%u)", modnum, errnum);
148 const char* errSymLookupInternal(
long status)
157 modNum = (unsigned) status;
161 const char * pStr = strerror ((
int) status);
167 unsigned hashInd = errhash(status);
168 phashnode = (
ERRNUMNODE**)&hashtable[hashInd];
169 pNextNode = *phashnode;
171 if (pNextNode->
errNum==status){
175 pNextNode = *phashnode;
183 const char* msg = errSymLookupInternal(status);
184 return msg ? msg :
"<Unknown code>";
192 const char* msg = errSymLookupInternal(status);
194 strncpy(pBuf, msg, bufLength-1);
195 pBuf[bufLength-1] =
'\0';
198 errRawCopy(status, pBuf, bufLength);
212 printf(
"errSymDump: number of hash slots = %d\n",
NHASH);
213 for (i = 0; i <
NHASH; i++) {
219 int modnum = pNextNode->
errNum >> 16;
220 int errnum = pNextNode->
errNum & 0xffff;
223 printf(
"HASHNODE = %d\n", i);
225 printf(
"\tmod %d num %d \"%s\"\n",
226 modnum , errnum , pNextNode->
message);
228 pNextNode = *phashnode;
232 printf(
"\nerrSymDump: total number of error messages = %d\n", msgcount);
251 fprintf(
stderr,
"Usage: errSymTestPrint(long errNum) \n");
252 fprintf(
stderr,
"errSymTestPrint: module number < 501 \n");
256 if ( message[0] ==
'\0' )
return;
257 printf(
"module %hu number %hu message=\"%s\"\n",
258 modnum, errnum, message);
276 for (errnum = begErrNum; errnum <= endErrNum; errnum++) {
277 errNum = modnum << 16;
278 errNum |= (errnum & 0xffff);
#define assert(exp)
Declare that a condition should be true.
An EPICS-specific replacement for ANSI C's assert.
void errSymTestPrint(long errNum)
struct errnumnode ERRNUMNODE
unsigned short epicsUInt16
void errSymLookup(long status, char *pBuf, size_t bufLength)
#define ELLLIST_INIT
Value of an empty list.
A doubly-linked list library.
void ellAdd(ELLLIST *pList, ELLNODE *pNode)
Adds a node to the end of a list.
#define ellNext(PNODE)
Find the next node in list.
LIBCOM_API void * callocMustSucceed(size_t count, size_t size, const char *msg)
A calloc() that never returns NULL.
int errSymbolAdd(long errNum, const char *name)
Routines for code that can't continue or return after an error.
struct errnumnode * hashnode
const char * errSymMsg(long status)
LIBCOM_API int epicsStdCall epicsSnprintf(char *str, size_t size, const char *format,...) EPICS_PRINTF_STYLE(3
void errSymTest(epicsUInt16 modnum, epicsUInt16 begErrNum, epicsUInt16 endErrNum)
#define ellFirst(PLIST)
Find the first node in list.