1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/honeyd/setenv.c Tue Aug 28 18:35:30 2012 +0200 1.3 @@ -0,0 +1,26 @@ 1.4 + 1.5 +#ifndef HAVE_SETENV 1.6 +#ifdef HAVE_CONFIG_H 1.7 +#include "config.h" 1.8 +#endif 1.9 +#include <sys/types.h> 1.10 +#include <stdlib.h> 1.11 +#include <string.h> 1.12 + 1.13 +int setenv(const char *kszName, const char *kszValue, int nOverwrite) 1.14 +{ 1.15 + char *szPair = NULL; 1.16 + 1.17 + if (nOverwrite == 0 && getenv(kszName) != 0) 1.18 + return 0; 1.19 + szPair = malloc(strlen(kszName) + 1 + strlen(kszValue) + 1); 1.20 + if (szPair == NULL) 1.21 + return -1; 1.22 + strcpy(szPair, kszName); 1.23 + strcat(szPair, "="); 1.24 + strcat(szPair, kszValue); 1.25 + putenv(szPair); 1.26 + return 0; 1.27 +} 1.28 +#endif /* !HAVE_SETENV */ 1.29 +