From ecb63cc5c4c23cd9703ce5a9f3161ac1b922a467 Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Thu, 25 May 2000 19:18:00 +0000 Subject: [PATCH] changed name --- src/iocsh/Makefile | 4 ++-- src/iocsh/ioccrf.c | 23 +++++++++++++++++- src/iocsh/ioccrf.h | 3 +++ src/iocsh/ioccrfRegisterCommon.c | 41 ++++++++++++++++++++++++++++++++ src/iocsh/ioccrfRegisterCommon.h | 26 ++++++++++++++++++++ 5 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 src/iocsh/ioccrfRegisterCommon.c create mode 100644 src/iocsh/ioccrfRegisterCommon.h diff --git a/src/iocsh/Makefile b/src/iocsh/Makefile index b13734492..db714a801 100644 --- a/src/iocsh/Makefile +++ b/src/iocsh/Makefile @@ -13,7 +13,7 @@ INC += dbBkptRegister.h INC += dbCaTestRegister.h INC += caTestRegister.h INC += dbAccessRegister.h -INC += ioccrfRegister.h +INC += ioccrfRegisterCommon.h INC += asTestRegister.h INC += envRegister.h INC += registerRecordDeviceDriverRegister.h @@ -34,7 +34,7 @@ LIBSRCS += dbBkptRegister.c LIBSRCS += dbCaTestRegister.c LIBSRCS += caTestRegister.c LIBSRCS += dbAccessRegister.c -LIBSRCS += ioccrfRegister.c +LIBSRCS += ioccrfRegisterCommon.c LIBSRCS += asTestRegister.c LIBSRCS += envRegister.c LIBSRCS += iocUtil.c diff --git a/src/iocsh/ioccrf.c b/src/iocsh/ioccrf.c index 12076992e..cbf6c3e1b 100644 --- a/src/iocsh/ioccrf.c +++ b/src/iocsh/ioccrf.c @@ -32,8 +32,11 @@ typedef struct argvalue { typedef struct ioccrfFunc { ioccrfFuncDef *pioccrfFuncDef; ioccrfCallFunc func; + struct ioccrfFunc *pprev; } ioccrfFunc; +static ioccrfFunc *pioccrfFuncHead = 0; + static char ioccrfID[] = "ioccrf"; #ifdef IOCSH_USE_READLINE @@ -60,12 +63,28 @@ void epicsShareAPI ioccrfRegister (ioccrfFuncDef *pioccrfFuncDef, ioccrfCallFunc ioccrfFunc *pioccrfFunc; pioccrfFunc = callocMustSucceed (1, sizeof(ioccrfFunc), "ioccrfRegister"); + pioccrfFunc->pprev = pioccrfFuncHead; + /* keep list of allocated ioccrfFunc so they can be freed*/ + pioccrfFuncHead = pioccrfFunc; pioccrfFunc->pioccrfFuncDef = pioccrfFuncDef; pioccrfFunc->func = func; if (!registryAdd(ioccrfID, pioccrfFuncDef->name, (void *)pioccrfFunc)) errlogPrintf ("ioccrfRegister failed to add %s\n", pioccrfFuncDef->name); } +/* free storage created by ioccrfRegister */ +void epicsShareAPI ioccrfFree(void) +{ + ioccrfFunc *pioccrfFunc = pioccrfFuncHead; + pioccrfFuncHead = 0; + while(pioccrfFunc) { + ioccrfFunc *pprev = pioccrfFunc->pprev; + free(pioccrfFunc); + pioccrfFunc = pprev; + } +} + + /* * Read a line of input */ @@ -352,7 +371,9 @@ ioccrf (const char *pathname) /* * Look up command */ - pioccrfFunc = (ioccrfFunc *)registryFind (ioccrfID, argv[0]); + pioccrfFunc = 0; + if(pioccrfFuncHead) + pioccrfFunc = (ioccrfFunc *)registryFind (ioccrfID, argv[0]); if (!pioccrfFunc) { showError (filename, lineno, "Command %s not found.", argv[0]); continue; diff --git a/src/iocsh/ioccrf.h b/src/iocsh/ioccrf.h index e48b2557e..088c480a3 100644 --- a/src/iocsh/ioccrf.h +++ b/src/iocsh/ioccrf.h @@ -41,6 +41,9 @@ typedef void (*ioccrfCallFunc)(ioccrfArg **argList); epicsShareFunc void epicsShareAPI ioccrfRegister( ioccrfFuncDef *pioccrfFuncDef,ioccrfCallFunc func); +/* ioccrfFree frees storage used by ioccrfRegister*/ +/* This should only be called when ioccrf is no longer needed*/ +epicsShareFunc void epicsShareAPI ioccrfFree(void); epicsShareFunc int epicsShareAPI ioccrf(const char *pathname); diff --git a/src/iocsh/ioccrfRegisterCommon.c b/src/iocsh/ioccrfRegisterCommon.c new file mode 100644 index 000000000..1101bb942 --- /dev/null +++ b/src/iocsh/ioccrfRegisterCommon.c @@ -0,0 +1,41 @@ +/* ioccrfRegisterCommon.c */ +/* Author: Marty Kraimer Date: 26APR2000 */ + +/********************COPYRIGHT NOTIFICATION********************************** +This software was developed under a United States Government license +described on the COPYRIGHT_UniversityOfChicago file included as part +of this distribution. +****************************************************************************/ +#include +#include +#include +#include +#include + +#define epicsExportSharedSymbols +#include "dbStaticRegister.h" +#include "iocUtilRegister.h" +#include "dbTestRegister.h" +#include "dbBkptRegister.h" +#include "dbCaTestRegister.h" +#include "caTestRegister.h" +#include "dbAccessRegister.h" +#include "asTestRegister.h" +#include "envRegister.h" +#include "ioccrfRegisterCommon.h" +#include "osiRegister.h" +#include "ioccrf.h" + +void epicsShareAPI ioccrfRegisterCommon(void) +{ + osiRegister(); + iocUtilRegister(); + dbStaticRegister(); + dbTestRegister(); + dbBkptRegister(); + dbCaTestRegister(); + caTestRegister(); + dbAccessRegister(); + asTestRegister(); + envRegister(); +} diff --git a/src/iocsh/ioccrfRegisterCommon.h b/src/iocsh/ioccrfRegisterCommon.h new file mode 100644 index 000000000..ebcf3f9f8 --- /dev/null +++ b/src/iocsh/ioccrfRegisterCommon.h @@ -0,0 +1,26 @@ +/* ioccrfRegisterCommon.h */ +/* Author: Marty Kraimer Date: 27APR2000 */ + +/********************COPYRIGHT NOTIFICATION********************************** +This software was developed under a United States Government license +described on the COPYRIGHT_UniversityOfChicago file included as part +of this distribution. +****************************************************************************/ + +#ifndef INCioccrfRegisterCommonH +#define INCioccrfRegisterCommonH + +#include "shareLib.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* register many useful commands */ +epicsShareFunc void epicsShareAPI ioccrfRegisterCommon(void); + +#ifdef __cplusplus +} +#endif + +#endif /*INCioccrfRegisterCommonH*/