allow to add new error symbols from dynamicly loaded modules
This commit is contained in:
@@ -51,9 +51,8 @@ typedef struct errnumnode {
|
||||
#define NHASH 256
|
||||
|
||||
|
||||
static ELLLIST errnumlist = ELLLIST_INIT;
|
||||
static ERRNUMNODE **hashtable;
|
||||
static int initialized = FALSE;
|
||||
static ERRNUMNODE **hashtable = NULL;
|
||||
#define initialized (hashtable!=NULL)
|
||||
extern ERRSYMTAB_ID errSymTbl;
|
||||
|
||||
/****************************************************************
|
||||
@@ -67,12 +66,8 @@ extern ERRSYMTAB_ID errSymTbl;
|
||||
int epicsShareAPI errSymBld(void)
|
||||
{
|
||||
ERRSYMBOL *errArray = errSymTbl->symbols;
|
||||
ERRNUMNODE *perrNumNode = NULL;
|
||||
ERRNUMNODE *pNextNode = NULL;
|
||||
ERRNUMNODE **phashnode = NULL;
|
||||
int i;
|
||||
int modnum;
|
||||
unsigned short hashInd;
|
||||
|
||||
if(initialized) return(0);
|
||||
hashtable = (ERRNUMNODE**)callocMustSucceed
|
||||
@@ -89,21 +84,6 @@ int epicsShareAPI errSymBld(void)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
perrNumNode = (ERRNUMNODE *) ellFirst(&errnumlist);
|
||||
while (perrNumNode) {
|
||||
/* hash each perrNumNode->errNum */
|
||||
hashInd = errhash(perrNumNode->errNum);
|
||||
phashnode = (ERRNUMNODE**)&hashtable[hashInd];
|
||||
pNextNode = (ERRNUMNODE*) *phashnode;
|
||||
/* search for last node (NULL) of hashnode linked list */
|
||||
while (pNextNode) {
|
||||
phashnode = &pNextNode->hashnode;
|
||||
pNextNode = *phashnode;
|
||||
}
|
||||
*phashnode = perrNumNode;
|
||||
perrNumNode = (ERRNUMNODE *) ellNext((ELLNODE *) perrNumNode);
|
||||
}
|
||||
initialized = TRUE;
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -125,16 +105,33 @@ unsigned short errnum;
|
||||
|
||||
/****************************************************************
|
||||
* ERRSYMBOLADD
|
||||
* adds symbols to the master errnumlist as compiled from errSymTbl.c
|
||||
* adds symbols to the master hashtable as compiled from errSymTbl.c
|
||||
***************************************************************/
|
||||
int epicsShareAPI errSymbolAdd (long errNum,char *name)
|
||||
{
|
||||
ERRNUMNODE *pNew;
|
||||
ERRNUMNODE *perrNumNode;
|
||||
ERRNUMNODE *pNextNode = NULL;
|
||||
ERRNUMNODE **phashnode = NULL;
|
||||
unsigned short hashInd;
|
||||
|
||||
if(!initialized) errSymBld();
|
||||
|
||||
perrNumNode = (ERRNUMNODE*)callocMustSucceed(1,sizeof(ERRNUMNODE),"errSymbolAdd");
|
||||
perrNumNode->errNum = errNum;
|
||||
perrNumNode->message = name;
|
||||
|
||||
/* hash each perrNumNode->errNum */
|
||||
hashInd = errhash(perrNumNode->errNum);
|
||||
phashnode = (ERRNUMNODE**)&hashtable[hashInd];
|
||||
pNextNode = (ERRNUMNODE*) *phashnode;
|
||||
/* search for last node (NULL) of hashnode linked list */
|
||||
while (pNextNode) {
|
||||
phashnode = &pNextNode->hashnode;
|
||||
pNextNode = *phashnode;
|
||||
}
|
||||
*phashnode = perrNumNode;
|
||||
perrNumNode = (ERRNUMNODE *) ellNext((ELLNODE *) perrNumNode);
|
||||
|
||||
pNew = (ERRNUMNODE*)callocMustSucceed(1,sizeof(ERRNUMNODE),"errSymbolAdd");
|
||||
pNew->errNum = errNum;
|
||||
pNew->message = name;
|
||||
ellAdd(&errnumlist,(ELLNODE*)pNew);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user