This is Unofficial EPICS BASE Doxygen Site
osdEnv.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include "epicsStdio.h"
#include "envDefs.h"
#include "osiUnistd.h"
#include "iocsh.h"
+ Include dependency graph for osdEnv.c:

Go to the source code of this file.

Functions

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...
 

Function Documentation

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 26 of file osdEnv.c.

27 {
28  iocshEnvClear(name);
29  setenv(name, value, 1);
30 }
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 45 of file osdEnv.c.

46 {
47  if (name == NULL) {
48  extern char **environ;
49  char **sp;
50 
51  for (sp = environ ; (sp != NULL) && (*sp != NULL) ; sp++)
52  printf ("%s\n", *sp);
53  }
54  else {
55  const char *cp = getenv (name);
56  if (cp == NULL)
57  printf ("%s is not an environment variable.\n", name);
58  else
59  printf ("%s=%s\n", name, cp);
60  }
61 }
#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 36 of file osdEnv.c.

37 {
38  iocshEnvClear(name);
39  unsetenv(name);
40 }
void epicsStdCall iocshEnvClear(const char *name)
Definition: iocsh.cpp:1054