honeyd/setenv.c

Mon, 01 Jul 2013 20:55:56 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Mon, 01 Jul 2013 20:55:56 +0200
changeset 773
849be77d11d6
permissions
-rw-r--r--

Update version to almost most recent upstream vendor release.

michael@574 1
michael@574 2 #ifndef HAVE_SETENV
michael@574 3 #ifdef HAVE_CONFIG_H
michael@574 4 #include "config.h"
michael@574 5 #endif
michael@574 6 #include <sys/types.h>
michael@574 7 #include <stdlib.h>
michael@574 8 #include <string.h>
michael@574 9
michael@574 10 int setenv(const char *kszName, const char *kszValue, int nOverwrite)
michael@574 11 {
michael@574 12 char *szPair = NULL;
michael@574 13
michael@574 14 if (nOverwrite == 0 && getenv(kszName) != 0)
michael@574 15 return 0;
michael@574 16 szPair = malloc(strlen(kszName) + 1 + strlen(kszValue) + 1);
michael@574 17 if (szPair == NULL)
michael@574 18 return -1;
michael@574 19 strcpy(szPair, kszName);
michael@574 20 strcat(szPair, "=");
michael@574 21 strcat(szPair, kszValue);
michael@574 22 putenv(szPair);
michael@574 23 return 0;
michael@574 24 }
michael@574 25 #endif /* !HAVE_SETENV */
michael@574 26

mercurial