EPICS Base  7.0.7.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
iocsh.h
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2002 The University of Chicago, 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 * SPDX-License-Identifier: EPICS
7 * EPICS Base is distributed subject to a Software License Agreement found
8 * in file LICENSE that is included with this distribution.
9 \*************************************************************************/
10 /* iocsh.h ioc: call registered function*/
11 /* Author: Marty Kraimer Date: 27APR2000 */
12 
34 #ifndef INCiocshH
35 #define INCiocshH
36 
37 #include <stdio.h>
38 #include "compilerDependencies.h"
39 #include "libComAPI.h"
40 
41 #if defined(vxWorks) || defined(__rtems__)
42 #define IOCSH_STATIC_FUNC
43 #else
44 #define IOCSH_STATIC_FUNC static EPICS_ALWAYS_INLINE
45 #endif
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
62 typedef enum {
63  iocshArgInt,
64  iocshArgDouble,
65  iocshArgString,
66  iocshArgPdbbase,
67  iocshArgArgv,
68  iocshArgPersistentString
70 
85 typedef union iocshArgBuf {
86  int ival;
87  double dval;
88  char *sval;
89  void *vval;
90  struct {
91  int ac;
92  char **av;
93  }aval;
95 
103 typedef struct iocshVarDef {
104  const char *name;
105  iocshArgType type;
106  void * pval;
107 }iocshVarDef;
108 
125 typedef struct iocshArg {
126  const char *name;
127  iocshArgType type;
128 }iocshArg;
129 
146 typedef struct iocshFuncDef {
147  const char *name;
148  int nargs;
149  const iocshArg * const *arg;
150  const char* usage;
151 }iocshFuncDef;
152 #define IOCSHFUNCDEF_HAS_USAGE
153 
172 typedef void (*iocshCallFunc)(const iocshArgBuf *argBuf);
173 
179 typedef struct iocshCmdDef {
180  iocshFuncDef const *pFuncDef;
181  iocshCallFunc func;
182 }iocshCmdDef;
183 
191 LIBCOM_API void epicsStdCall iocshRegister(
192  const iocshFuncDef *piocshFuncDef, iocshCallFunc func);
193 
200 LIBCOM_API void epicsStdCall iocshRegisterVariable (
201  const iocshVarDef *piocshVarDef);
202 
211 LIBCOM_API const iocshCmdDef * epicsStdCall iocshFindCommand(
212  const char* name) EPICS_DEPRECATED;
213 
222 LIBCOM_API const iocshVarDef * epicsStdCall iocshFindVariable(
223  const char* name);
224 
225 /* iocshFree frees storage used by iocshRegister*/
226 /* This should only be called when iocsh is no longer needed*/
232 LIBCOM_API void epicsStdCall iocshFree(void);
233 
245 LIBCOM_API int epicsStdCall iocsh(const char *pathname);
246 
255 LIBCOM_API int epicsStdCall iocshCmd(const char *cmd);
265 LIBCOM_API int epicsStdCall iocshLoad(const char *pathname, const char* macros);
275 LIBCOM_API int epicsStdCall iocshRun(const char *cmd, const char* macros);
276 
283 LIBCOM_API int iocshSetError(int err);
284 
285 /* Makes macros that shadow environment variables work correctly with epicsEnvSet */
295 LIBCOM_API void epicsStdCall iocshEnvClear(const char *name);
296 
297 /* 'weak' link to pdbbase */
298 LIBCOM_API extern struct dbBase **iocshPpdbbase;
299 
300 #ifdef __cplusplus
301 }
302 #endif
303 
304 #endif /*INCiocshH*/
LIBCOM_API void epicsStdCall iocshEnvClear(const char *name)
Unsets macro values.
LIBCOM_API int iocshSetError(int err)
Signal error from an IOC shell function.
iocshArgType
Definition: iocsh.h:62
LIBCOM_API int epicsStdCall iocsh(const char *pathname)
This function is used to execute IOC shell commands from a file.
LIBCOM_API const iocshCmdDef *epicsStdCall iocshFindCommand(const char *name) EPICS_DEPRECATED
Returns a struct of type iocshCmdDef whose element values are determined by the name parameter...
LIBCOM_API int epicsStdCall iocshCmd(const char *cmd)
This function is used to exectute a single IOC shell command.
Compiler specific declarations.
LIBCOM_API const iocshVarDef *epicsStdCall iocshFindVariable(const char *name)
Returns a struct of type iocshVarDef whose element values are determined by the name parameter...
LIBCOM_API void epicsStdCall iocshRegisterVariable(const iocshVarDef *piocshVarDef)
LIBCOM_API int epicsStdCall iocshLoad(const char *pathname, const char *macros)
Read and evaluate IOC shell commands from the given file. A list of macros can be supplied as a param...
Definition: dbBase.h:171
LIBCOM_API void epicsStdCall iocshRegister(const iocshFuncDef *piocshFuncDef, iocshCallFunc func)
This function is used to register a command with the IOC shell.
LIBCOM_API int epicsStdCall iocshRun(const char *cmd, const char *macros)
Evaluate a single IOC shell command. A list of macros can be supplied as a parameter. These macros are treated as environment variables during exectution of the command.
LIBCOM_API void epicsStdCall iocshFree(void)
Frees all memory allocated to registered commands and variables.