This is Unofficial EPICS BASE Doxygen Site
miscIocRegister.c
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2007 UChicago Argonne LLC, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * EPICS BASE is distributed subject to a Software License Agreement found
7 * in file LICENSE that is included with this distribution.
8 \*************************************************************************/
9 
10 #include <stdlib.h>
11 
12 #include "iocsh.h"
13 #include "errlog.h"
14 
15 #define epicsExportSharedSymbols
16 #include "iocInit.h"
17 #include "epicsExport.h"
18 #include "epicsRelease.h"
19 #include "miscIocRegister.h"
20 
21 /* iocInit */
22 static const iocshFuncDef iocInitFuncDef = {"iocInit",0,NULL};
23 static void iocInitCallFunc(const iocshArgBuf *args)
24 {
26 }
27 
28 /* iocBuild */
29 static const iocshFuncDef iocBuildFuncDef = {"iocBuild",0,NULL};
30 static void iocBuildCallFunc(const iocshArgBuf *args)
31 {
33 }
34 
35 /* iocRun */
36 static const iocshFuncDef iocRunFuncDef = {"iocRun",0,NULL};
37 static void iocRunCallFunc(const iocshArgBuf *args)
38 {
40 }
41 
42 /* iocPause */
43 static const iocshFuncDef iocPauseFuncDef = {"iocPause",0,NULL};
44 static void iocPauseCallFunc(const iocshArgBuf *args)
45 {
47 }
48 
49 /* coreRelease */
50 static const iocshFuncDef coreReleaseFuncDef = {"coreRelease",0,NULL};
51 static void coreReleaseCallFunc(const iocshArgBuf *args)
52 {
53  coreRelease ();
54 }
55 
56 
57 void miscIocRegister(void)
58 {
59  iocshRegister(&iocInitFuncDef,iocInitCallFunc);
60  iocshRegister(&iocBuildFuncDef,iocBuildCallFunc);
61  iocshRegister(&iocRunFuncDef,iocRunCallFunc);
62  iocshRegister(&iocPauseFuncDef,iocPauseCallFunc);
63  iocshRegister(&coreReleaseFuncDef, coreReleaseCallFunc);
64 }
65 
66 
67 /* system -- escape to system command interpreter.
68  *
69  * Disabled by default for security reasons, not available on all OSs.
70  * To enable this command, add
71  * registrar(iocshSystemCommand)
72  * to an application dbd file, or include system.dbd
73  */
74 #ifndef SYSTEM_UNAVAILABLE
75 static const iocshArg systemArg0 = { "command string",iocshArgString};
76 static const iocshArg * const systemArgs[] = {&systemArg0};
77 static const iocshFuncDef systemFuncDef = {"system",1,systemArgs};
78 static void systemCallFunc(const iocshArgBuf *args)
79 {
80  iocshSetError(system(args[0].sval));
81 }
82 #endif
83 
84 static void iocshSystemCommand(void)
85 {
86 #ifndef SYSTEM_UNAVAILABLE
87  if (system(NULL))
88  iocshRegister(&systemFuncDef, systemCallFunc);
89  else
90 #endif
91  errlogPrintf ("Can't register 'system' command -- no command interpreter available.\n");
92 }
93 epicsExportRegistrar(iocshSystemCommand);
int iocBuild(void)
Definition: iocInit.c:196
void epicsStdCall iocshRegister(const iocshFuncDef *piocshFuncDef, iocshCallFunc func)
Definition: iocsh.cpp:111
#define NULL
Definition: catime.c:38
epicsExportRegistrar(iocshSystemCommand)
int iocshSetError(int err)
Signal error from an IOC shell function.
Definition: iocsh.cpp:536
epicsShareFunc int coreRelease(void)
Definition: epicsRelease.c:21
int errlogPrintf(const char *pFormat,...)
Definition: errlog.c:105
void miscIocRegister(void)
int iocInit(void)
Definition: iocInit.c:108
int iocRun(void)
Definition: iocInit.c:236
int iocPause(void)
Definition: iocInit.c:267
Definition: iocsh.h:56
Exporting IOC objects.