libCom: Darwin has setenv(), use it.

This commit is contained in:
Andrew Johnson
2014-08-26 14:51:18 -07:00
parent 2aea693faf
commit 83d22ce164

View File

@@ -25,41 +25,19 @@
* Starting in Mac OS X 10.5 (Leopard) shared libraries and
* bundles don't have direct access to environ (man environ).
*/
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
#include <crt_externs.h>
#define environ (*_NSGetEnviron())
#define epicsExportSharedSymbols
#include "epicsStdio.h"
#include <errlog.h>
#include <cantProceed.h>
#include <envDefs.h>
#include <osiUnistd.h>
#include "epicsFindSymbol.h"
/*
* Set the value of an environment variable
* Leaks memory, but the assumption is that this routine won't be
* called often enough for the leak to be a problem.
*/
epicsShareFunc void epicsShareAPI epicsEnvSet (const char *name, const char *value)
{
char *cp;
cp = mallocMustSucceed (strlen (name) + strlen (value) + 2, "epicsEnvSet");
strcpy (cp, name);
strcat (cp, "=");
strcat (cp, value);
if (putenv (cp) < 0) {
errPrintf(
-1L,
__FILE__,
__LINE__,
"Failed to set environment parameter \"%s\" to \"%s\": %s\n",
name,
value,
strerror (errno));
free (cp);
}
setenv(name, value, 1);
}
/*