This is Unofficial EPICS BASE Doxygen Site
osdEnv.c
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2002 The University of Saskatchewan
3 * EPICS BASE is distributed subject to a Software License Agreement found
4 * in file LICENSE that is included with this distribution.
5 \*************************************************************************/
6 /* osdEnv.c */
7 /*
8  * Author: Eric Norum
9  * Date: May 7, 2001
10  *
11  * Routines to modify/display environment variables and EPICS parameters
12  *
13  */
14 
15 #include <stdlib.h>
16 #include <stdio.h>
17 
18 #include "epicsStdio.h"
19 #include "envDefs.h"
20 #include "osiUnistd.h"
21 #include "iocsh.h"
22 
23 /*
24  * Set the value of an environment variable
25  */
26 LIBCOM_API void epicsStdCall epicsEnvSet (const char *name, const char *value)
27 {
28  iocshEnvClear(name);
29  setenv(name, value, 1);
30 }
31 
32 /*
33  * Unset an environment variable
34  */
35 
36 LIBCOM_API void epicsStdCall epicsEnvUnset (const char *name)
37 {
38  iocshEnvClear(name);
39  unsetenv(name);
40 }
41 
42 /*
43  * Show the value of the specified, or all, environment variables
44  */
45 LIBCOM_API void epicsStdCall epicsEnvShow (const char *name)
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 }
Definition: link.h:174
void epicsStdCall iocshEnvClear(const char *name)
Definition: iocsh.cpp:1054
Routines to get and set EPICS environment parameters.
#define printf
Definition: epicsStdio.h:41
#define NULL
Definition: catime.c:38
LIBCOM_API void epicsStdCall epicsEnvShow(const char *name)
Print value of an environment variable, or all variables.
Definition: osdEnv.c:55
LIBCOM_API void epicsStdCall epicsEnvSet(const char *name, const char *value)
Set an environment variable&#39;s value.
Definition: osdEnv.c:35
#define environ
Definition: osdEnv.c:26
LIBCOM_API void epicsStdCall epicsEnvUnset(const char *name)
Clear the value of an environment variable.
Definition: osdEnv.c:46