Check if getenv() exists

Do not call getenv() on platform which do not support it
This commit is contained in:
Patrick Gansterer 2014-02-28 02:32:03 +01:00 committed by Andy Green
parent 148b945f7f
commit 61a6ae4f77
3 changed files with 6 additions and 0 deletions

View file

@ -158,6 +158,7 @@ include(CheckTypeSize)
CHECK_FUNCTION_EXISTS(bzero HAVE_BZERO)
CHECK_FUNCTION_EXISTS(fork HAVE_FORK)
CHECK_FUNCTION_EXISTS(getenv HAVE_GETENV)
CHECK_FUNCTION_EXISTS(malloc HAVE_MALLOC)
CHECK_FUNCTION_EXISTS(memset HAVE_MEMSET)
CHECK_FUNCTION_EXISTS(realloc HAVE_REALLOC)

View file

@ -53,6 +53,9 @@
/* Define to 1 if you have the `fork' function. */
#cmakedefine HAVE_FORK
/* Define to 1 if you have the `getenv function. */
#cmakedefine HAVE_GETENV
/* Define to 1 if you have the <inttypes.h> header file. */
#cmakedefine HAVE_INTTYPES_H

View file

@ -2097,6 +2097,7 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
sizeof(context->http_proxy_address) - 1] = '\0';
context->http_proxy_port = info->http_proxy_port;
} else {
#ifdef HAVE_GETENV
p = getenv("http_proxy");
if (p) {
strncpy(context->http_proxy_address, p,
@ -2112,6 +2113,7 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
*p = '\0';
context->http_proxy_port = atoi(p + 1);
}
#endif
}
if (context->http_proxy_address[0]) {