From 85b58a1e05fd14185ad0cefca2c7bf83a86d869e Mon Sep 17 00:00:00 2001 From: "W. Eric Norum" Date: Tue, 19 Dec 2000 21:52:31 +0000 Subject: [PATCH] Register common IOC shell commands automatically as part of ioccrf constructors. --- src/iocsh/ioccrf.cpp | 44 +++++++++++++++++-- src/libCom/osi/os/RTEMS/rtems_init.c | 2 - .../top/exampleApp/src/exampleMain.c | 2 - 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/iocsh/ioccrf.cpp b/src/iocsh/ioccrf.cpp index 4ecbe36dc..dfef0f0ff 100644 --- a/src/iocsh/ioccrf.cpp +++ b/src/iocsh/ioccrf.cpp @@ -21,13 +21,15 @@ of this distribution. #include "dbAccess.h" #define epicsExportSharedSymbols #include "ioccrf.h" +#include "ioccrfRegisterCommon.h" #include "epicsReadline.h" -struct IoccrfFunc { +class IoccrfFunc { + public: ioccrfFuncDef const *pFuncDef; ioccrfCallFunc func; - IoccrfFunc() { pFuncDef=NULL; func=NULL; } - IoccrfFunc(const ioccrfFuncDef *d, ioccrfCallFunc f) { pFuncDef=d; func=f; } + IoccrfFunc(): pFuncDef(NULL), func(NULL) { } + IoccrfFunc(const ioccrfFuncDef *d, ioccrfCallFunc f): pFuncDef(d), func(f){} IoccrfFunc& operator=(const IoccrfFunc& rhs) { pFuncDef=rhs.pFuncDef; func=rhs.func; return *this; } @@ -449,3 +451,39 @@ ioccrf (const char *pathname) free (argBuf); return 0; } + +/* + * Dummy internal commands -- register and install in command table + * so they show up in the help display + */ + +/* help */ +static const ioccrfArg helpArg0 = { "command",ioccrfArgInt}; +static const ioccrfArg *helpArgs[1] = {&helpArg0}; +static const ioccrfFuncDef helpFuncDef = + {"help",1,helpArgs}; +static void helpCallFunc(const ioccrfArgBuf *args) +{ +} + +/* exit */ +static const ioccrfFuncDef exitFuncDef = + {"exit",0,0}; +static void exitCallFunc(const ioccrfArgBuf *args) +{ +} + +static void localRegister (void) +{ + ioccrfRegister(&helpFuncDef,helpCallFunc); + ioccrfRegister(&exitFuncDef,exitCallFunc); +} + +/* + * Register commands on application startup + */ +class IoccrfRegister { + public: + IoccrfRegister() { localRegister(); ioccrfRegisterCommon(); } +}; +static IoccrfRegister ioccrfRegisterObj; diff --git a/src/libCom/osi/os/RTEMS/rtems_init.c b/src/libCom/osi/os/RTEMS/rtems_init.c index 05bbea5a1..33978e12a 100644 --- a/src/libCom/osi/os/RTEMS/rtems_init.c +++ b/src/libCom/osi/os/RTEMS/rtems_init.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -319,7 +318,6 @@ Init (rtems_task_argument ignored) * Run the EPICS startup script */ printf ("***** Executing EPICS startup script *****\n"); - ioccrfRegisterCommon (); ioccrfRegisterRTEMS (); registerRecordDeviceDriverRegister (); ioccrf ("st.cmd"); diff --git a/src/makeBaseApp/top/exampleApp/src/exampleMain.c b/src/makeBaseApp/top/exampleApp/src/exampleMain.c index 54ec4f079..7af000b4c 100644 --- a/src/makeBaseApp/top/exampleApp/src/exampleMain.c +++ b/src/makeBaseApp/top/exampleApp/src/exampleMain.c @@ -19,12 +19,10 @@ of this distribution. #include "dbTest.h" #include "registryRecordType.h" #include "ioccrf.h" -#include "ioccrfRegisterCommon.h" #include "registerRecordDeviceDriverRegister.h" int main(int argc,char *argv[]) { - ioccrfRegisterCommon(); registerRecordDeviceDriverRegister(); if(argc>=2) { ioccrf(argv[1]);