From a65220c6c740814d93f002d43e1646d0fff9cb6a Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Sun, 10 May 2015 21:45:06 +0100 Subject: [PATCH] Don't leak internal macros into public in lws_config.h. --- CMakeLists.txt | 7 +- lib/libwebsockets.h | 1 - lib/private-libwebsockets.h | 1 + lws_config.h.in | 128 +----------------------------------- lws_config_private.h.in | 128 ++++++++++++++++++++++++++++++++++++ test-server/test-client.c | 2 - test-server/test-echo.c | 2 - test-server/test-ping.c | 2 - test-server/test-server.c | 2 - 9 files changed, 136 insertions(+), 137 deletions(-) create mode 100644 lws_config_private.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 43630f7e2..432bf4318 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -293,11 +293,16 @@ if (NOT HAVE_REALLOC) set(realloc rpl_realloc) endif() -# Generate the lws_config.h that includes all the compilation settings. +# Generate lws_config.h that includes all the public compilation settings. configure_file( "${PROJECT_SOURCE_DIR}/lws_config.h.in" "${PROJECT_BINARY_DIR}/lws_config.h") +# Generate lws_config_private.h that includes all the private compilation settings. +configure_file( + "${PROJECT_SOURCE_DIR}/lws_config_private.h.in" + "${PROJECT_BINARY_DIR}/lws_config_private.h") + if (MSVC) # Turn off stupid microsoft security warnings. add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h index b253d9284..99a9ab0bd 100644 --- a/lib/libwebsockets.h +++ b/lib/libwebsockets.h @@ -30,7 +30,6 @@ extern "C" { #include #endif -/* That's a bad idea since it will leak all internal defines outside */ #include "lws_config.h" #if defined(WIN32) || defined(_WIN32) diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h index a862234ac..9e43aec50 100644 --- a/lib/private-libwebsockets.h +++ b/lib/private-libwebsockets.h @@ -20,6 +20,7 @@ */ #include "lws_config.h" +#include "lws_config_private.h" #ifdef HAVE_SYS_TYPES_H #include diff --git a/lws_config.h.in b/lws_config.h.in index 251cb18e4..79441c6d3 100644 --- a/lws_config.h.in +++ b/lws_config.h.in @@ -1,14 +1,4 @@ -/* config.h.in. Generated from configure.ac by autoheader. */ - -#ifndef NDEBUG - #ifndef _DEBUG - #define _DEBUG - #endif -#endif - -/* Define to 1 to use CyaSSL as a replacement for OpenSSL. - * LWS_OPENSSL_SUPPORT needs to be set also for this to work. */ -#cmakedefine USE_CYASSL +/* lws_config.h.in. Public compilation option information. */ /* The Libwebsocket version */ #cmakedefine LWS_LIBRARY_VERSION "${LWS_LIBRARY_VERSION}" @@ -55,119 +45,3 @@ /* Use the BSD getifaddrs that comes with libwebsocket, for uclibc support */ #cmakedefine LWS_BUILTIN_GETIFADDRS -/* Define to 1 if you have the `bzero' function. */ -#cmakedefine HAVE_BZERO - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_DLFCN_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_FCNTL_H - -/* 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 header file. */ -#cmakedefine HAVE_IN6ADDR_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_INTTYPES_H - -/* Define to 1 if you have the `ssl' library (-lssl). */ -//#cmakedefine HAVE_LIBSSL - -/* Define to 1 if your system has a GNU libc compatible `malloc' function, and - to 0 otherwise. */ -#cmakedefine HAVE_MALLOC - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_MEMORY_H - -/* Define to 1 if you have the `memset' function. */ -#cmakedefine HAVE_MEMSET - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_NETINET_IN_H - -/* Define to 1 if your system has a GNU libc compatible `realloc' function, - and to 0 otherwise. */ -#cmakedefine HAVE_REALLOC - -/* Define to 1 if you have the `socket' function. */ -#cmakedefine HAVE_SOCKET - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STDLIB_H - -/* Define to 1 if you have the `strerror' function. */ -#cmakedefine HAVE_STRERROR - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STRING_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_PRCTL_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_SOCKET_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_UNISTD_H - -/* Define to 1 if you have the `vfork' function. */ -#cmakedefine HAVE_VFORK - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_VFORK_H - -/* Define to 1 if `fork' works. */ -#cmakedefine HAVE_WORKING_FORK - -/* Define to 1 if `vfork' works. */ -#cmakedefine HAVE_WORKING_VFORK - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_ZLIB_H - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#undef LT_OBJDIR // We're not using libtool - -/* Version number of package */ -#cmakedefine VERSION - -/* Define to rpl_malloc if the replacement function should be used. */ -#cmakedefine malloc - -/* Define to `int' if does not define. */ -#cmakedefine pid_t - -/* Define to rpl_realloc if the replacement function should be used. */ -#cmakedefine realloc - -/* Define to `unsigned int' if does not define. */ -#cmakedefine size_t - -/* Define to 1 if we have getifaddrs */ -#cmakedefine HAVE_GETIFADDRS - -/* Define as `fork' if `vfork' does not work. */ -//#cmakedefine vfork - -/* Define if the inline keyword doesn't exist. */ -#cmakedefine inline ${inline} diff --git a/lws_config_private.h.in b/lws_config_private.h.in new file mode 100644 index 000000000..29595737b --- /dev/null +++ b/lws_config_private.h.in @@ -0,0 +1,128 @@ +/* lws_config_private.h.in. Private compilation options. */ + +#ifndef NDEBUG + #ifndef _DEBUG + #define _DEBUG + #endif +#endif + +/* Define to 1 to use CyaSSL as a replacement for OpenSSL. + * LWS_OPENSSL_SUPPORT needs to be set also for this to work. */ +#cmakedefine USE_CYASSL + +/* Define to 1 if you have the `bzero' function. */ +#cmakedefine HAVE_BZERO + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_FCNTL_H + +/* 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 header file. */ +#cmakedefine HAVE_IN6ADDR_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_INTTYPES_H + +/* Define to 1 if you have the `ssl' library (-lssl). */ +#cmakedefine HAVE_LIBSSL + +/* Define to 1 if your system has a GNU libc compatible `malloc' function, and + to 0 otherwise. */ +#cmakedefine HAVE_MALLOC + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MEMORY_H + +/* Define to 1 if you have the `memset' function. */ +#cmakedefine HAVE_MEMSET + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETINET_IN_H + +/* Define to 1 if your system has a GNU libc compatible `realloc' function, + and to 0 otherwise. */ +#cmakedefine HAVE_REALLOC + +/* Define to 1 if you have the `socket' function. */ +#cmakedefine HAVE_SOCKET + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDLIB_H + +/* Define to 1 if you have the `strerror' function. */ +#cmakedefine HAVE_STRERROR + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_PRCTL_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_SOCKET_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H + +/* Define to 1 if you have the `vfork' function. */ +#cmakedefine HAVE_VFORK + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_VFORK_H + +/* Define to 1 if `fork' works. */ +#cmakedefine HAVE_WORKING_FORK + +/* Define to 1 if `vfork' works. */ +#cmakedefine HAVE_WORKING_VFORK + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ZLIB_H + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#undef LT_OBJDIR // We're not using libtool + +/* Version number of package */ +#cmakedefine VERSION + +/* Define to rpl_malloc if the replacement function should be used. */ +#cmakedefine malloc + +/* Define to `int' if does not define. */ +#cmakedefine pid_t + +/* Define to rpl_realloc if the replacement function should be used. */ +#cmakedefine realloc + +/* Define to `unsigned int' if does not define. */ +#cmakedefine size_t + +/* Define to 1 if we have getifaddrs */ +#cmakedefine HAVE_GETIFADDRS + +/* Define as `fork' if `vfork' does not work. */ +//#cmakedefine vfork + +/* Define if the inline keyword doesn't exist. */ +#cmakedefine inline ${inline} diff --git a/test-server/test-client.c b/test-server/test-client.c index 624e2bf52..5d3b68041 100644 --- a/test-server/test-client.c +++ b/test-server/test-client.c @@ -31,8 +31,6 @@ #include #endif -#include "lws_config.h" - #include "../lib/libwebsockets.h" static unsigned int opts; diff --git a/test-server/test-echo.c b/test-server/test-echo.c index e26e4772a..77795c5f5 100644 --- a/test-server/test-echo.c +++ b/test-server/test-echo.c @@ -35,8 +35,6 @@ #include #endif -#include "lws_config.h" - #include "../lib/libwebsockets.h" static volatile int force_exit = 0; diff --git a/test-server/test-ping.c b/test-server/test-ping.c index fefca31d5..f414b0880 100644 --- a/test-server/test-ping.c +++ b/test-server/test-ping.c @@ -35,8 +35,6 @@ #include #endif -#include "lws_config.h" - #include "../lib/libwebsockets.h" /* diff --git a/test-server/test-server.c b/test-server/test-server.c index 8643c93de..9e875ab05 100644 --- a/test-server/test-server.c +++ b/test-server/test-server.c @@ -18,8 +18,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ -#include "lws_config.h" - #include #include #include