X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsrc%2Fos.c;h=47af038f78216beaf73e6dcc1935dd28695dec21;hb=f10e2052dc60814e241eda952149459674906cdf;hp=a70bc61158a34e08a2fa1e8cd3540529b3b1ec76;hpb=5bfb4cdf352ad40304c6bbf0d826569dea761699;p=user%2Fhenk%2Fcode%2Fexim.git diff --git a/src/src/os.c b/src/src/os.c index a70bc6115..47af038f7 100644 --- a/src/src/os.c +++ b/src/src/os.c @@ -2,7 +2,7 @@ * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2009 */ +/* Copyright (c) University of Cambridge 1995 - 2016 */ /* See the file NOTICE for conditions of use and distribution. */ #ifdef STAND_ALONE @@ -807,7 +807,7 @@ directly, instead making you call a function per thread to get a handle. Other OSs handle thread-safe resolver differently, in ways which fail if the programmer creates their own structs. */ -#ifndef OS_GET_DNS_RESOLVER_RES +#if !defined(OS_GET_DNS_RESOLVER_RES) && !defined(COMPILE_UTILITY) #include @@ -833,9 +833,57 @@ os_get_dns_resolver_res(void) #endif /* OS_GET_DNS_RESOLVER_RES */ +/* ----------------------------------------------------------------------- */ + +/*********************************************************** +* unsetenv() * +***********************************************************/ + +/* Most modern systems define int unsetenv(const char*), +* some don't. */ + +#if !defined(OS_UNSETENV) +int +os_unsetenv(const unsigned char * name) +{ +return unsetenv((char *)name); +} +#endif /* ----------------------------------------------------------------------- */ +/*********************************************************** +* getcwd() * +***********************************************************/ + +/* Glibc allows getcwd(NULL, 0) to do auto-allocation. Some systems +do auto-allocation, but need the size of the buffer, and others +may not even do this. If the OS supports getcwd(NULL, 0) we'll use +this, for all other systems we provide our own getcwd() */ + +#if !defined(OS_GETCWD) +unsigned char * +os_getcwd(unsigned char * buffer, size_t size) +{ +return (unsigned char *) getcwd((char *)buffer, size); +} +#else +#ifndef PATH_MAX +# define PATH_MAX 4096 +#endif +unsigned char * +os_getcwd(unsigned char * buffer, size_t size) +{ +char * b = (char *)buffer; + +if (!size) size = PATH_MAX; +if (!b && !(b = malloc(size))) return NULL; +if (!(b = getcwd(b, size))) return NULL; +return realloc(b, strlen(b) + 1); +} +#endif + +/* ----------------------------------------------------------------------- */