EPICS Base  7.0.8.1
 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,
82 
97 typedef union iocshArgBuf {
98  int ival;
99  double dval;
100  char *sval;
101  void *vval;
102  struct {
103  int ac;
104  char **av;
105  }aval;
106 }iocshArgBuf;
107 
115 typedef struct iocshVarDef {
116  const char *name;
117  iocshArgType type;
118  void * pval;
119 }iocshVarDef;
120 
137 typedef struct iocshArg {
138  const char *name;
139  iocshArgType type;
140 }iocshArg;
141 
158 typedef struct iocshFuncDef {
159  const char *name;
160  int nargs;
161  const iocshArg * const *arg;
162  const char* usage;
163 }iocshFuncDef;
164 #define IOCSHFUNCDEF_HAS_USAGE
165 
184 typedef void (*iocshCallFunc)(const iocshArgBuf *argBuf);
185 
191 typedef struct iocshCmdDef {
192  iocshFuncDef const *pFuncDef;
193  iocshCallFunc func;
194 }iocshCmdDef;
195 
203 LIBCOM_API void epicsStdCall iocshRegister(
204  const iocshFuncDef *piocshFuncDef, iocshCallFunc func);
205 
212 LIBCOM_API void epicsStdCall iocshRegisterVariable (
213  const iocshVarDef *piocshVarDef);
214 
223 LIBCOM_API const iocshCmdDef * epicsStdCall iocshFindCommand(
224  const char* name) EPICS_DEPRECATED;
225 
234 LIBCOM_API const iocshVarDef * epicsStdCall iocshFindVariable(
235  const char* name);
236 
237 /* iocshFree frees storage used by iocshRegister*/
238 /* This should only be called when iocsh is no longer needed*/
244 LIBCOM_API void epicsStdCall iocshFree(void);
245 
257 LIBCOM_API int epicsStdCall iocsh(const char *pathname);
258 
267 LIBCOM_API int epicsStdCall iocshCmd(const char *cmd);
277 LIBCOM_API int epicsStdCall iocshLoad(const char *pathname, const char* macros);
287 LIBCOM_API int epicsStdCall iocshRun(const char *cmd, const char* macros);
288 
296 LIBCOM_API int iocshSetError(int err);
297 
298 /* Makes macros that shadow environment variables work correctly with epicsEnvSet */
308 LIBCOM_API void epicsStdCall iocshEnvClear(const char *name);
309 
310 /* 'weak' link to pdbbase */
311 LIBCOM_API extern struct dbBase **iocshPpdbbase;
312 
313 #ifdef EPICS_PRIVATE_API
314 
315 LIBCOM_API
316 extern char** (*iocshCompleteRecord)(const char *word);
317 #endif
318 
319 #ifdef __cplusplus
320 }
321 #endif
322 
323 #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:175
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.