This is Unofficial EPICS BASE Doxygen Site
envDefs.h File Reference

Routines to get and set EPICS environment parameters. More...

#include "libComAPI.h"
+ Include dependency graph for envDefs.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  envParam
 A structure to hold a single environment parameter. More...
 

Typedefs

typedef struct envParam ENV_PARAM
 A structure to hold a single environment parameter. More...
 

Functions

LIBCOM_API char *epicsStdCall envGetConfigParam (const ENV_PARAM *pParam, int bufDim, char *pBuf)
 Get value of a configuration parameter. More...
 
LIBCOM_API const char *epicsStdCall envGetConfigParamPtr (const ENV_PARAM *pParam)
 Get a configuration parameter's value or default string. More...
 
LIBCOM_API long epicsStdCall envPrtConfigParam (const ENV_PARAM *pParam)
 Print the value of a configuration parameter. More...
 
LIBCOM_API long epicsStdCall envGetInetAddrConfigParam (const ENV_PARAM *pParam, struct in_addr *pAddr)
 Get value of an inet addr config parameter. More...
 
LIBCOM_API long epicsStdCall envGetDoubleConfigParam (const ENV_PARAM *pParam, double *pDouble)
 Get value of a double configuration parameter. More...
 
LIBCOM_API long epicsStdCall envGetLongConfigParam (const ENV_PARAM *pParam, long *pLong)
 Get value of a long configuration parameter. More...
 
LIBCOM_API unsigned short epicsStdCall envGetInetPortConfigParam (const ENV_PARAM *pEnv, unsigned short defaultPort)
 Get value of a port number configuration parameter. More...
 
LIBCOM_API long epicsStdCall envGetBoolConfigParam (const ENV_PARAM *pParam, int *pBool)
 Get value of a boolean configuration parameter. More...
 
LIBCOM_API long epicsStdCall epicsPrtEnvParams (void)
 Prints all configuration parameters and their current value. More...
 
LIBCOM_API void epicsStdCall epicsEnvSet (const char *name, const char *value)
 Set an environment variable's value. More...
 
LIBCOM_API void epicsStdCall epicsEnvUnset (const char *name)
 Clear the value of an environment variable. More...
 
LIBCOM_API void epicsStdCall epicsEnvShow (const char *name)
 Print value of an environment variable, or all variables. More...
 

Variables

LIBCOM_API const ENV_PARAM EPICS_CA_ADDR_LIST
 
LIBCOM_API const ENV_PARAM EPICS_CA_CONN_TMO
 
LIBCOM_API const ENV_PARAM EPICS_CA_AUTO_ADDR_LIST
 
LIBCOM_API const ENV_PARAM EPICS_CA_REPEATER_PORT
 
LIBCOM_API const ENV_PARAM EPICS_CA_SERVER_PORT
 
LIBCOM_API const ENV_PARAM EPICS_CA_MAX_ARRAY_BYTES
 
LIBCOM_API const ENV_PARAM EPICS_CA_AUTO_ARRAY_BYTES
 
LIBCOM_API const ENV_PARAM EPICS_CA_MAX_SEARCH_PERIOD
 
LIBCOM_API const ENV_PARAM EPICS_CA_NAME_SERVERS
 
LIBCOM_API const ENV_PARAM EPICS_CA_MCAST_TTL
 
LIBCOM_API const ENV_PARAM EPICS_CAS_INTF_ADDR_LIST
 
LIBCOM_API const ENV_PARAM EPICS_CAS_IGNORE_ADDR_LIST
 
LIBCOM_API const ENV_PARAM EPICS_CAS_AUTO_BEACON_ADDR_LIST
 
LIBCOM_API const ENV_PARAM EPICS_CAS_BEACON_ADDR_LIST
 
LIBCOM_API const ENV_PARAM EPICS_CAS_SERVER_PORT
 
LIBCOM_API const ENV_PARAM EPICS_CA_BEACON_PERIOD
 deprecated More...
 
LIBCOM_API const ENV_PARAM EPICS_CAS_BEACON_PERIOD
 
LIBCOM_API const ENV_PARAM EPICS_CAS_BEACON_PORT
 
LIBCOM_API const ENV_PARAM EPICS_BUILD_COMPILER_CLASS
 
LIBCOM_API const ENV_PARAM EPICS_BUILD_OS_CLASS
 
LIBCOM_API const ENV_PARAM EPICS_BUILD_TARGET_ARCH
 
LIBCOM_API const ENV_PARAM EPICS_TZ
 
LIBCOM_API const ENV_PARAM EPICS_TS_NTP_INET
 
LIBCOM_API const ENV_PARAM EPICS_IOC_IGNORE_SERVERS
 
LIBCOM_API const ENV_PARAM EPICS_IOC_LOG_PORT
 
LIBCOM_API const ENV_PARAM EPICS_IOC_LOG_INET
 
LIBCOM_API const ENV_PARAM EPICS_IOC_LOG_FILE_LIMIT
 
LIBCOM_API const ENV_PARAM EPICS_IOC_LOG_FILE_NAME
 
LIBCOM_API const ENV_PARAM EPICS_IOC_LOG_FILE_COMMAND
 
LIBCOM_API const ENV_PARAM IOCSH_PS1
 
LIBCOM_API const ENV_PARAM IOCSH_HISTSIZE
 
LIBCOM_API const ENV_PARAM IOCSH_HISTEDIT_DISABLE
 
LIBCOM_API const ENV_PARAMenv_param_list []
 

Detailed Description

Routines to get and set EPICS environment parameters.

Author
Roger A. Cole

This file defines environment parameters used by EPICS and the routines used to get and set those parameter values.

The ENV_PARAM's declared here are defined in the generated file envData.c by the bldEnvData.pl Perl script, which parses this file and the build system's CONFIG_ENV and CONFIG_SITE_ENV files. User programs can define their own environment parameters for their own use–the only caveat is that such parameters aren't automatically setup by EPICS.

Note
bldEnvData.pl looks for "LIBCOM_API extern const ENV_PARAM <name>;"

Definition in file envDefs.h.

Typedef Documentation

typedef struct envParam ENV_PARAM

A structure to hold a single environment parameter.

Function Documentation

LIBCOM_API long epicsStdCall envGetBoolConfigParam ( const ENV_PARAM pParam,
int *  pBool 
)

Get value of a boolean configuration parameter.

Gets the value of a configuration parameter, and puts the value 0 or 1 into the caller's buffer depending on the value. If the configuration parameter isn't found in the environment, the default value for the parameter is used instead.

A value is treated as True (1) if it compares equal to the string "yes" with a case-independent string comparison. All other strings are treated as False (0).

If no parameter is found and there is no default, then -1 is returned and the callers buffer is unmodified.

Parameters
pParamPointer to config param structure.
pBoolPointer to place to store value.
Returns
0, or -1 if an error is encountered

Definition at line 325 of file envSubr.c.

326 {
327  char text[20];
328 
329  if(!envGetConfigParam(pParam, sizeof(text), text))
330  return -1;
331  *pBool = epicsStrCaseCmp(text, "yes")==0;
332  return 0;
333 }
int epicsStrCaseCmp(const char *s1, const char *s2)
Definition: epicsString.c:191
char *epicsStdCall envGetConfigParam(const ENV_PARAM *pParam, int bufDim, char *pBuf)
Get value of a configuration parameter.
Definition: envSubr.c:139
LIBCOM_API char* epicsStdCall envGetConfigParam ( const ENV_PARAM pParam,
int  bufDim,
char *  pBuf 
)

Get value of a configuration parameter.

Gets the value of a configuration parameter from the environment and copies it into the caller's buffer. If the parameter isn't set in the environment, the default value for the parameter is copied instead. If neither provides a non-empty string the buffer is set to '\0' and NULL is returned.

Parameters
pParamPointer to config param structure.
bufDimDimension of parameter buffer
pBufPointer to parameter buffer
Returns
Pointer to the environment variable value string, or NULL if no parameter value and default value was empty.

Definition at line 139 of file envSubr.c.

144 {
145  const char *pEnv; /* pointer to environment string */
146 
147  pEnv = envGetConfigParamPtr(pParam);
148  if (!pEnv) {
149  return NULL;
150  }
151 
152  strncpy(pBuf, pEnv, bufDim-1);
153  pBuf[bufDim-1] = '\0';
154 
155  return pBuf;
156 }
#define NULL
Definition: catime.c:38
const char *epicsStdCall envGetConfigParamPtr(const ENV_PARAM *pParam)
Get a configuration parameter&#39;s value or default string.
Definition: envSubr.c:81
LIBCOM_API const char* epicsStdCall envGetConfigParamPtr ( const ENV_PARAM pParam)

Get a configuration parameter's value or default string.

Parameters
pParamPointer to config param structure.
Returns
Pointer to the environment variable value string, or to the default value for the parameter, or NULL if those strings were empty or not set.

Definition at line 81 of file envSubr.c.

84 {
85  const char *pEnv; /* pointer to environment string */
86 
87  pEnv = getenv(pParam->name);
88 
89  if (pEnv == NULL) {
90  pEnv = pParam->pdflt;
91  }
92 
93  if (pEnv) {
94  if (pEnv[0u] == '\0') {
95  pEnv = NULL;
96  }
97  }
98 
99  return pEnv;
100 }
char * name
Name of the parameter.
Definition: envDefs.h:42
#define NULL
Definition: catime.c:38
char * pdflt
Default value.
Definition: envDefs.h:43
LIBCOM_API long epicsStdCall envGetDoubleConfigParam ( const ENV_PARAM pParam,
double *  pDouble 
)

Get value of a double configuration parameter.

Gets the value of a configuration parameter, converts it into a double value and copies that into the caller's buffer. If the configuration parameter isn't found in the environment, the default value for the parameter is used instead.

If no parameter is found and there is no default, then -1 is returned and the callers buffer is unmodified.

Parameters
pParamPointer to config param structure.
pDoublePointer to place to store value.
Returns
0, or -1 if an error is encountered

Definition at line 191 of file envSubr.c.

195 {
196  char text[128];
197  char *ptext;
198  int count;
199 
200  ptext = envGetConfigParam(pParam, sizeof text, text);
201  if (ptext != NULL) {
202  count = epicsScanDouble(text, pDouble);
203  if (count == 1) {
204  return 0;
205  }
206  (void)fprintf(stderr,"Unable to find a real number in %s=%s\n",
207  pParam->name, text);
208  }
209 
210  return -1;
211 }
char * name
Name of the parameter.
Definition: envDefs.h:42
#define NULL
Definition: catime.c:38
#define epicsScanDouble(str, to)
Definition: epicsStdlib.h:78
char *epicsStdCall envGetConfigParam(const ENV_PARAM *pParam, int bufDim, char *pBuf)
Get value of a configuration parameter.
Definition: envSubr.c:139
#define stderr
Definition: epicsStdio.h:32
LIBCOM_API long epicsStdCall envGetInetAddrConfigParam ( const ENV_PARAM pParam,
struct in_addr *  pAddr 
)

Get value of an inet addr config parameter.

Gets the value of a configuration parameter and copies it into the caller's (struct in_addr) buffer. If the configuration parameter isn't found in the environment, the default value for that parameter will be used. The resulting string is converted from a dotted-quad format or looked up using the DNS and copied into the inet structure.

If no parameter is found and there is no default, then -1 is returned and the callers buffer is unmodified.

Parameters
pParamPointer to config param structure.
pAddrPointer to struct to receive inet addr.
Returns
0, or -1 if an error is encountered

Definition at line 246 of file envSubr.c.

250 {
251  char text[128];
252  char *ptext;
253  long status;
254  struct sockaddr_in sin;
255 
256  ptext = envGetConfigParam(pParam, sizeof text, text);
257  if (ptext) {
258  status = aToIPAddr (text, 0u, &sin);
259  if (status == 0) {
260  *pAddr = sin.sin_addr;
261  return 0;
262  }
263  (void)fprintf(stderr,"Unable to find an IP address or valid host name in %s=%s\n",
264  pParam->name, text);
265  }
266  return -1;
267 }
LIBCOM_API int epicsStdCall aToIPAddr(const char *pAddrString, unsigned short defaultPort, struct sockaddr_in *pIP)
Definition: aToIPAddr.c:78
pvd::Status status
char * name
Name of the parameter.
Definition: envDefs.h:42
char *epicsStdCall envGetConfigParam(const ENV_PARAM *pParam, int bufDim, char *pBuf)
Get value of a configuration parameter.
Definition: envSubr.c:139
#define stderr
Definition: epicsStdio.h:32
LIBCOM_API unsigned short epicsStdCall envGetInetPortConfigParam ( const ENV_PARAM pEnv,
unsigned short  defaultPort 
)

Get value of a port number configuration parameter.

Returns the value of a configuration parameter that represents an inet port number. If no environment variable is found the default parameter value is used, and if that is also unset the defaultPort argument returned instead. The integer value must fall between the values IPPORT_USERRESERVED and USHRT_MAX or the defaultPort argument will be substituted instead.

Parameters
pEnvPointer to config param structure.
defaultPortPort number to be used if environment settings invalid.
Returns
Port number.

Definition at line 398 of file envSubr.c.

399 {
400  long longStatus;
401  long epicsParam;
402 
403  longStatus = envGetLongConfigParam (pEnv, &epicsParam);
404  if (longStatus!=0) {
405  epicsParam = (long) defaultPort;
406  errlogPrintf ("EPICS Environment \"%s\" integer fetch failed\n", pEnv->name);
407  errlogPrintf ("setting \"%s\" = %ld\n", pEnv->name, epicsParam);
408  }
409 
410  if (epicsParam<=IPPORT_USERRESERVED || epicsParam>USHRT_MAX) {
411  errlogPrintf ("EPICS Environment \"%s\" out of range\n", pEnv->name);
412  /*
413  * Quit if the port is wrong due coding error
414  */
415  assert (epicsParam != (long) defaultPort);
416  epicsParam = (long) defaultPort;
417  errlogPrintf ("Setting \"%s\" = %ld\n", pEnv->name, epicsParam);
418  }
419 
420  /*
421  * ok to clip to unsigned short here because we checked the range
422  */
423  return (unsigned short) epicsParam;
424 }
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
char * name
Name of the parameter.
Definition: envDefs.h:42
long epicsStdCall envGetLongConfigParam(const ENV_PARAM *pParam, long *pLong)
Get value of a long configuration parameter.
Definition: envSubr.c:303
int errlogPrintf(const char *pFormat,...)
Definition: errlog.c:105
LIBCOM_API long epicsStdCall envGetLongConfigParam ( const ENV_PARAM pParam,
long *  pLong 
)

Get value of a long configuration parameter.

Gets the value of a configuration parameter, converts it into a long value and copies that into the caller's buffer. If the configuration parameter isn't found in the environment, the default value for the parameter is used instead.

If no parameter is found and there is no default, then -1 is returned and the callers buffer is unmodified.

Parameters
pParamPointer to config param structure.
pLongPointer to place to store value.
Returns
0, or -1 if an error is encountered

Definition at line 303 of file envSubr.c.

307 {
308  char text[128];
309  char *ptext;
310  int count;
311 
312  ptext = envGetConfigParam(pParam, sizeof text, text);
313  if (ptext) {
314  count = sscanf(text, "%ld", pLong);
315  if (count == 1)
316  return 0;
317  (void)fprintf(stderr,"Unable to find an integer in %s=%s\n",
318  pParam->name, text);
319  }
320  return -1;
321 }
char * name
Name of the parameter.
Definition: envDefs.h:42
char *epicsStdCall envGetConfigParam(const ENV_PARAM *pParam, int bufDim, char *pBuf)
Get value of a configuration parameter.
Definition: envSubr.c:139
#define stderr
Definition: epicsStdio.h:32
LIBCOM_API long epicsStdCall envPrtConfigParam ( const ENV_PARAM pParam)

Print the value of a configuration parameter.

Parameters
pParamPointer to config param structure.
Returns
0

Definition at line 353 of file envSubr.c.

355 {
356  const char *pVal;
357 
358  pVal = envGetConfigParamPtr(pParam);
359  if (pVal == NULL)
360  fprintf(stdout, "%s is undefined\n", pParam->name);
361  else
362  fprintf(stdout,"%s: %s\n", pParam->name, pVal);
363  return 0;
364 }
char * name
Name of the parameter.
Definition: envDefs.h:42
#define NULL
Definition: catime.c:38
#define stdout
Definition: epicsStdio.h:30
const char *epicsStdCall envGetConfigParamPtr(const ENV_PARAM *pParam)
Get a configuration parameter&#39;s value or default string.
Definition: envSubr.c:81
LIBCOM_API void epicsStdCall epicsEnvSet ( const char *  name,
const char *  value 
)

Set an environment variable's value.

The setenv() routine is not available on all operating systems. This routine provides a portable alternative for all EPICS targets.

Parameters
nameEnvironment variable name.
valueNew value for environment variable.

Definition at line 35 of file osdEnv.c.

36 {
37  if (!name) return;
38  iocshEnvClear(name);
39  setenv(name, value, 1);
40 }
Definition: link.h:174
void epicsStdCall iocshEnvClear(const char *name)
Definition: iocsh.cpp:1054
LIBCOM_API void epicsStdCall epicsEnvShow ( const char *  name)

Print value of an environment variable, or all variables.

Parameters
nameEnvironment variable name, or NULL to show all.

Definition at line 55 of file osdEnv.c.

56 {
57  if (name == NULL) {
58  extern char **environ;
59  char **sp;
60 
61  for (sp = environ ; (sp != NULL) && (*sp != NULL) ; sp++)
62  printf ("%s\n", *sp);
63  }
64  else {
65  const char *cp = getenv (name);
66  if (cp == NULL)
67  printf ("%s is not an environment variable.\n", name);
68  else
69  printf ("%s=%s\n", name, cp);
70  }
71 }
#define printf
Definition: epicsStdio.h:41
#define NULL
Definition: catime.c:38
#define environ
Definition: osdEnv.c:26
LIBCOM_API void epicsStdCall epicsEnvUnset ( const char *  name)

Clear the value of an environment variable.

Parameters
nameEnvironment variable name.

Definition at line 46 of file osdEnv.c.

47 {
48  iocshEnvClear(name);
49  unsetenv(name);
50 }
void epicsStdCall iocshEnvClear(const char *name)
Definition: iocsh.cpp:1054
LIBCOM_API long epicsStdCall epicsPrtEnvParams ( void  )

Prints all configuration parameters and their current value.

Returns
0

Definition at line 384 of file envSubr.c.

385 {
386  const ENV_PARAM **ppParam = env_param_list;
387 
388  while (*ppParam != NULL)
389  envPrtConfigParam(*(ppParam++));
390 
391  return 0;
392 }
#define NULL
Definition: catime.c:38
A structure to hold a single environment parameter.
Definition: envDefs.h:41
long epicsStdCall envPrtConfigParam(const ENV_PARAM *pParam)
Print the value of a configuration parameter.
Definition: envSubr.c:353
LIBCOM_API const ENV_PARAM * env_param_list[]

Variable Documentation

LIBCOM_API const ENV_PARAM* env_param_list[]
LIBCOM_API const ENV_PARAM EPICS_BUILD_COMPILER_CLASS
LIBCOM_API const ENV_PARAM EPICS_BUILD_OS_CLASS
LIBCOM_API const ENV_PARAM EPICS_BUILD_TARGET_ARCH
LIBCOM_API const ENV_PARAM EPICS_CA_ADDR_LIST
LIBCOM_API const ENV_PARAM EPICS_CA_AUTO_ADDR_LIST
LIBCOM_API const ENV_PARAM EPICS_CA_AUTO_ARRAY_BYTES
LIBCOM_API const ENV_PARAM EPICS_CA_BEACON_PERIOD

deprecated

LIBCOM_API const ENV_PARAM EPICS_CA_CONN_TMO
LIBCOM_API const ENV_PARAM EPICS_CA_MAX_ARRAY_BYTES
LIBCOM_API const ENV_PARAM EPICS_CA_MAX_SEARCH_PERIOD
LIBCOM_API const ENV_PARAM EPICS_CA_MCAST_TTL
LIBCOM_API const ENV_PARAM EPICS_CA_NAME_SERVERS
LIBCOM_API const ENV_PARAM EPICS_CA_REPEATER_PORT
LIBCOM_API const ENV_PARAM EPICS_CA_SERVER_PORT
LIBCOM_API const ENV_PARAM EPICS_CAS_AUTO_BEACON_ADDR_LIST
LIBCOM_API const ENV_PARAM EPICS_CAS_BEACON_ADDR_LIST
LIBCOM_API const ENV_PARAM EPICS_CAS_BEACON_PERIOD
LIBCOM_API const ENV_PARAM EPICS_CAS_BEACON_PORT
LIBCOM_API const ENV_PARAM EPICS_CAS_IGNORE_ADDR_LIST
LIBCOM_API const ENV_PARAM EPICS_CAS_INTF_ADDR_LIST
LIBCOM_API const ENV_PARAM EPICS_CAS_SERVER_PORT
LIBCOM_API const ENV_PARAM EPICS_IOC_IGNORE_SERVERS
LIBCOM_API const ENV_PARAM EPICS_IOC_LOG_FILE_COMMAND
LIBCOM_API const ENV_PARAM EPICS_IOC_LOG_FILE_LIMIT
LIBCOM_API const ENV_PARAM EPICS_IOC_LOG_FILE_NAME
LIBCOM_API const ENV_PARAM EPICS_IOC_LOG_INET
LIBCOM_API const ENV_PARAM EPICS_IOC_LOG_PORT
LIBCOM_API const ENV_PARAM EPICS_TS_NTP_INET
LIBCOM_API const ENV_PARAM EPICS_TZ
LIBCOM_API const ENV_PARAM IOCSH_HISTEDIT_DISABLE
LIBCOM_API const ENV_PARAM IOCSH_HISTSIZE
LIBCOM_API const ENV_PARAM IOCSH_PS1