honeyd/setenv.c

Mon, 28 Jan 2013 17:37:18 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Mon, 28 Jan 2013 17:37:18 +0100
changeset 758
a2c6460cfb16
permissions
-rw-r--r--

Correct socket error reporting improvement with IPv6 portable code,
after helpful recommendation by Saúl Ibarra Corretgé on OSips devlist.

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