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 
7 /* osdEnv.c */
8 /*
9  * Author: Eric Norum
10  * Date: May 7, 2001
11  *
12  * Routines to modify/display environment variables and EPICS parameters
13  */
14 
15 #include <string.h>
16 #include <stdlib.h>
17 #include <stdio.h>
18 #include <ctype.h>
19 #include <errno.h>
20 
21 #include "epicsStdio.h"
22 #include <errlog.h>
23 #include <cantProceed.h>
24 #include <envDefs.h>
25 #include <osiUnistd.h>
26 #include "epicsFindSymbol.h"
27 #include <iocsh.h>
28 
29 /*
30  * Set the value of an environment variable
31  */
32 LIBCOM_API void epicsStdCall epicsEnvSet (const char *name, const char *value)
33 {
34  if (!name) return;
35  iocshEnvClear(name);
36  setenv(name, value, 1);
37 }
38 
39 /*
40  * Unset an environment variable
41  */
42 
43 LIBCOM_API void epicsStdCall epicsEnvUnset (const char *name)
44 {
45  iocshEnvClear(name);
46  unsetenv(name);
47 }
48 
49 /*
50  * Show the value of the specified, or all, environment variables
51  */
52 LIBCOM_API void epicsStdCall epicsEnvShow (const char *name)
53 {
54  if (name == NULL) {
55  extern char **environ;
56  char **sp;
57 
58  for (sp = environ ; (sp != NULL) && (*sp != NULL) ; sp++)
59  printf ("%s\n", *sp);
60  }
61  else {
62  const char *cp = getenv (name);
63  if (cp == NULL)
64  printf ("%s is not an environment variable.\n", name);
65  else
66  printf ("%s=%s\n", name, cp);
67  }
68 }
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
Routines for code that can&#39;t continue or return after an error.
LIBCOM_API void epicsStdCall epicsEnvUnset(const char *name)
Clear the value of an environment variable.
Definition: osdEnv.c:46