Selaa lähdekoodia

Replace #ifdef by #if defined (for automated preprocessor define checking)

Prepare for automated checking of used preprocessor defines.
Add a list of all used defines.
bel2125 7 vuotta sitten
vanhempi
commit
39af534982
8 muutettua tiedostoa jossa 369 lisäystä ja 171 poistoa
  1. 80 0
      resources/check_defines.lua
  2. 118 0
      resources/used_defines.txt
  3. 123 122
      src/civetweb.c
  4. 1 1
      src/civetweb_private_lua.h
  5. 30 31
      src/main.c
  6. 5 5
      src/md5.inl
  7. 10 10
      src/mod_lua.inl
  8. 2 2
      src/timer.inl

+ 80 - 0
resources/check_defines.lua

@@ -0,0 +1,80 @@
+
+
+usedlines = {c={}, n={}}
+useddefs = {c={}, n={}}
+
+function AddElem(tab, q)
+  if (tab.c[q]) then 
+    tab.c[q] = tab.c[q] + 1
+  else
+    tab.c[q] = 1
+    tab.n[#tab.n+1]=q
+  end
+end
+
+function PrintTab(tab)
+  table.sort(tab.n)
+  for _,n in ipairs(tab.n) do
+    --print(tab.c[n], n)
+    print(n)
+  end
+end
+
+
+function noifdef(f)
+  local out = {}
+  local changed = false
+  for l in io.lines(f) do
+    local n = l:gsub("^#ifdef ([%w_]+)", "#if defined(%1)")
+    n = n:gsub("^#ifndef ([%w_]+)", "#if !defined(%1)")
+    out[#out+1] = (n)
+    if l ~= n then
+      --print(l , "-->", n)
+      changed = true
+    end
+
+    if n:match("^#if") then
+      local q = n:gsub("%/%*.+%*%/", "")
+      q = q:gsub("%s+$", "")
+      q = q:gsub("^%s+", "")
+      q = q:gsub("%s+", " ")
+      AddElem(usedlines, q)
+
+      for w in q:gmatch("%(%s*([%w_]+)%s*%)") do
+        AddElem(useddefs, w)
+      end
+    end
+  end
+
+  if changed then
+    local f = io.open(f, "w")
+    for _,l in pairs(out) do
+      f:write(l .. "\n")
+    end
+    f:close()   
+    print(f .. " rewritten")
+  end
+
+  -- print(#out .. " lines processed")
+end
+
+
+path = path or ""
+noifdef(path .. "src/civetweb.c")
+noifdef(path .. "src/civetweb_private_lua.h")
+noifdef(path .. "src/main.c")
+noifdef(path .. "src/md5.inl")
+noifdef(path .. "src/mod_duktape.inl")
+noifdef(path .. "src/mod_lua.inl")
+noifdef(path .. "src/sha1.inl")
+noifdef(path .. "src/timer.inl")
+noifdef(path .. "src/wolfssl_extras.inl")
+
+--PrintTab(usedlines)
+
+--print("Defines used")
+PrintTab(useddefs)
+
+
+
+

+ 118 - 0
resources/used_defines.txt

@@ -0,0 +1,118 @@
+ALTERNATIVE_QUEUE
+ANDROID
+ARCH_IS_BIG_ENDIAN
+CIVETWEB_HEADER_INCLUDED
+CIVETWEB_PRIVATE_LUA_H
+CLOCK_MONOTONIC
+CLOCK_PROCESS
+CLOCK_REALTIME
+CLOCK_THREAD
+CONFIG_FILE
+CONFIG_FILE2
+CRYPTO_LIB
+DEBUG
+DEBUG_ASSERT
+DEBUG_TRACE
+ENABLE_CREATE_CONFIG_FILE
+ENABLE_UNUSED_PTHREAD_FUNCTIONS
+EWOULDBLOCK
+HAVE_POLL
+IGNORE_UNUSED_RESULT
+INT64_MAX
+LSP_INCLUDE_MAX_DEPTH
+MAX_TIMERS
+MAX_WORKER_THREADS
+MD5_STATIC
+MEMORY_DEBUGGING
+MGSQLEN
+MG_ALLOW_USING_GET_REQUEST_INFO_FOR_RESPONSE
+MG_EXPERIMENTAL_INTERFACES
+MG_EXTERNAL_FUNCTION_log_access
+MG_EXTERNAL_FUNCTION_mg_cry_internal_impl
+MG_LEGACY_INTERFACE
+MG_MAX_UNANSWERED_PING
+MG_USE_OPEN_FILE
+MSG_NOSIGNAL
+MUST_IMPLEMENT_CLOCK_GETTIME
+NEED_DEBUG_TRACE_FUNC
+NEED_TIMEGM
+NO_ALTERNATIVE_QUEUE
+NO_ATOMICS
+NO_CACHING
+NO_CGI
+NO_FILES
+NO_NONCE_CHECK
+NO_POPEN
+NO_SOCKLEN_T
+NO_SSL
+NO_SSL_DL
+NO_THREAD_NAME
+OPENSSL_API_1_1
+O_BINARY
+PASSWORDS_FILE_NAME
+PATH_MAX
+POLLIN
+REENTRANT_TIME
+SOCKET_TIMEOUT_QUANTUM
+SOMAXCONN
+SSL_ALREADY_INITIALIZED
+SSL_LIB
+S_ISDIR
+TCP_USER_TIMEOUT
+USE_COCOA
+USE_DUKTAPE
+USE_IPV6
+USE_LUA
+USE_LUA_FILE_SYSTEM
+USE_LUA_LUAXML
+USE_LUA_SQLITE3
+USE_SERVER_STATS
+USE_STACK_SIZE
+USE_TIMERS
+USE_WEBSOCKET
+WIN32
+WIN32_LEAN_AND_MEAN
+WIN_PTHREADS_TIME_H
+WOLFSSL_VERSION
+W_OK
+_CRT_SECURE_NO_DEPRECATE
+_CRT_SECURE_NO_WARNINGS
+_DARWIN_UNLIMITED_SELECT
+_FILE_OFFSET_BITS
+_GNU_SOURCE
+_IN_PORT_T
+_LARGEFILE_SOURCE
+_MSC_VER
+_TIMESPEC_DEFINED
+_WIN32
+_WIN32_WCE
+_WIN32_WINNT
+_WIN64
+_XOPEN_SOURCE
+__CLOCK_AVAILABILITY
+__GNUC__
+__MACH__
+__MINGW32__
+__MINGW64__
+__STDC_FORMAT_MACROS
+__STDC_LIMIT_MACROS
+__STDC_VERSION__
+__SYMBIAN32__
+__clang__
+__clockid_t_defined
+__cplusplus
+__hpux
+__linux__
+__sun
+calloc
+fileno
+free
+in_port_t
+malloc
+md5_INCLUDED
+pclose
+popen
+realloc
+snprintf
+va_copy
+vsnprintf

+ 123 - 122
src/civetweb.c

@@ -37,7 +37,7 @@
 #if !defined(_CRT_SECURE_NO_WARNINGS)
 #if !defined(_CRT_SECURE_NO_WARNINGS)
 #define _CRT_SECURE_NO_WARNINGS /* Disable deprecation warning in VS2005 */
 #define _CRT_SECURE_NO_WARNINGS /* Disable deprecation warning in VS2005 */
 #endif
 #endif
-#ifndef _WIN32_WINNT /* defined for tdm-gcc so we can use getnameinfo */
+#if !defined(_WIN32_WINNT) /* defined for tdm-gcc so we can use getnameinfo */
 #define _WIN32_WINNT 0x0501
 #define _WIN32_WINNT 0x0501
 #endif
 #endif
 #else
 #else
@@ -47,22 +47,22 @@
 #if defined(__linux__) && !defined(_XOPEN_SOURCE)
 #if defined(__linux__) && !defined(_XOPEN_SOURCE)
 #define _XOPEN_SOURCE 600 /* For flockfile() on Linux */
 #define _XOPEN_SOURCE 600 /* For flockfile() on Linux */
 #endif
 #endif
-#ifndef _LARGEFILE_SOURCE
+#if !defined(_LARGEFILE_SOURCE)
 #define _LARGEFILE_SOURCE /* For fseeko(), ftello() */
 #define _LARGEFILE_SOURCE /* For fseeko(), ftello() */
 #endif
 #endif
-#ifndef _FILE_OFFSET_BITS
+#if !defined(_FILE_OFFSET_BITS)
 #define _FILE_OFFSET_BITS 64 /* Use 64-bit file offsets by default */
 #define _FILE_OFFSET_BITS 64 /* Use 64-bit file offsets by default */
 #endif
 #endif
-#ifndef __STDC_FORMAT_MACROS
+#if !defined(__STDC_FORMAT_MACROS)
 #define __STDC_FORMAT_MACROS /* <inttypes.h> wants this for C++ */
 #define __STDC_FORMAT_MACROS /* <inttypes.h> wants this for C++ */
 #endif
 #endif
-#ifndef __STDC_LIMIT_MACROS
+#if !defined(__STDC_LIMIT_MACROS)
 #define __STDC_LIMIT_MACROS /* C++ wants that for INT64_MAX */
 #define __STDC_LIMIT_MACROS /* C++ wants that for INT64_MAX */
 #endif
 #endif
-#ifndef _DARWIN_UNLIMITED_SELECT
+#if !defined(_DARWIN_UNLIMITED_SELECT)
 #define _DARWIN_UNLIMITED_SELECT
 #define _DARWIN_UNLIMITED_SELECT
 #endif
 #endif
-#ifdef __sun
+#if defined(__sun)
 #define __EXTENSIONS__  /* to expose flockfile and friends in stdio.h */
 #define __EXTENSIONS__  /* to expose flockfile and friends in stdio.h */
 #define __inline inline /* not recognized on older compiler versions */
 #define __inline inline /* not recognized on older compiler versions */
 #endif
 #endif
@@ -127,7 +127,7 @@ mg_static_assert(sizeof(void *) >= sizeof(int), "data type size check");
 
 
 
 
 /* DTL -- including winsock2.h works better if lean and mean */
 /* DTL -- including winsock2.h works better if lean and mean */
-#ifndef WIN32_LEAN_AND_MEAN
+#if !defined(WIN32_LEAN_AND_MEAN)
 #define WIN32_LEAN_AND_MEAN
 #define WIN32_LEAN_AND_MEAN
 #endif
 #endif
 
 
@@ -147,7 +147,7 @@ mg_static_assert(sizeof(void *) >= sizeof(int), "data type size check");
 #endif /* __SYMBIAN32__ */
 #endif /* __SYMBIAN32__ */
 
 
 
 
-#ifndef CIVETWEB_HEADER_INCLUDED
+#if !defined(CIVETWEB_HEADER_INCLUDED)
 /* Include the header file here, so the CivetWeb interface is defined for the
 /* Include the header file here, so the CivetWeb interface is defined for the
  * entire implementation, including the following forward definitions. */
  * entire implementation, including the following forward definitions. */
 #include "civetweb.h"
 #include "civetweb.h"
@@ -188,7 +188,7 @@ static void DEBUG_TRACE_FUNC(const char *func,
 #endif
 #endif
 
 
 
 
-#ifndef IGNORE_UNUSED_RESULT
+#if !defined(IGNORE_UNUSED_RESULT)
 #define IGNORE_UNUSED_RESULT(a) ((void)((a) && 1))
 #define IGNORE_UNUSED_RESULT(a) ((void)((a) && 1))
 #endif
 #endif
 
 
@@ -218,7 +218,8 @@ static void DEBUG_TRACE_FUNC(const char *func,
 #endif
 #endif
 
 
 
 
-#ifndef _WIN32_WCE /* Some ANSI #includes are not available on Windows CE */
+/* Some ANSI #includes are not available on Windows CE */
+#if !defined(_WIN32_WCE)
 #include <sys/types.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <errno.h>
@@ -253,7 +254,7 @@ static void DEBUG_TRACE_FUNC(const char *func,
 
 
 #if defined(__MACH__) /* Apple OSX section */
 #if defined(__MACH__) /* Apple OSX section */
 
 
-#ifdef __clang__
+#if defined(__clang__)
 #if (__clang_major__ == 3) && ((__clang_minor__ == 7) || (__clang_minor__ == 8))
 #if (__clang_major__ == 3) && ((__clang_minor__ == 7) || (__clang_minor__ == 8))
 /* Avoid warnings for Xcode 7. It seems it does no longer exist in Xcode 8 */
 /* Avoid warnings for Xcode 7. It seems it does no longer exist in Xcode 8 */
 #pragma clang diagnostic ignored "-Wno-reserved-id-macro"
 #pragma clang diagnostic ignored "-Wno-reserved-id-macro"
@@ -313,7 +314,7 @@ _civet_clock_gettime(int clk_id, struct timespec *t)
 }
 }
 
 
 /* if clock_gettime is declared, then __CLOCK_AVAILABILITY will be defined */
 /* if clock_gettime is declared, then __CLOCK_AVAILABILITY will be defined */
-#ifdef __CLOCK_AVAILABILITY
+#if defined(__CLOCK_AVAILABILITY)
 /* If we compiled with Mac OSX 10.12 or later, then clock_gettime will be
 /* If we compiled with Mac OSX 10.12 or later, then clock_gettime will be
  * declared but it may be NULL at runtime. So we need to check before using
  * declared but it may be NULL at runtime. So we need to check before using
  * it. */
  * it. */
@@ -343,16 +344,16 @@ _civet_safe_clock_gettime(int clk_id, struct timespec *t)
 #include <stdio.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <stdint.h>
 
 
-#ifndef INT64_MAX
+#if !defined(INT64_MAX)
 #define INT64_MAX (9223372036854775807)
 #define INT64_MAX (9223372036854775807)
 #endif
 #endif
 
 
 
 
-#ifndef MAX_WORKER_THREADS
+#if !defined(MAX_WORKER_THREADS)
 #define MAX_WORKER_THREADS (1024 * 64)
 #define MAX_WORKER_THREADS (1024 * 64)
 #endif
 #endif
 
 
-#ifndef SOCKET_TIMEOUT_QUANTUM /* in ms */
+#if !defined(SOCKET_TIMEOUT_QUANTUM) /* in ms */
 #define SOCKET_TIMEOUT_QUANTUM (2000)
 #define SOCKET_TIMEOUT_QUANTUM (2000)
 #endif
 #endif
 
 
@@ -366,8 +367,7 @@ mg_static_assert(MAX_WORKER_THREADS >= 1,
 mg_static_assert(sizeof(size_t) == 4 || sizeof(size_t) == 8,
 mg_static_assert(sizeof(size_t) == 4 || sizeof(size_t) == 8,
                  "size_t data type size check");
                  "size_t data type size check");
 
 
-#if defined(_WIN32)                                                            \
-    && !defined(__SYMBIAN32__) /* WINDOWS / UNIX include block */
+#if defined(_WIN32) && !defined(__SYMBIAN32__) /* WINDOWS include block */
 #include <windows.h>
 #include <windows.h>
 #include <winsock2.h> /* DTL add for SO_EXCLUSIVE */
 #include <winsock2.h> /* DTL add for SO_EXCLUSIVE */
 #include <ws2tcpip.h>
 #include <ws2tcpip.h>
@@ -384,13 +384,13 @@ typedef const char *SOCK_OPT_TYPE;
 
 
 mg_static_assert(PATH_MAX >= 1, "path length must be a positive number");
 mg_static_assert(PATH_MAX >= 1, "path length must be a positive number");
 
 
-#ifndef _IN_PORT_T
-#ifndef in_port_t
+#if !defined(_IN_PORT_T)
+#if !defined(in_port_t)
 #define in_port_t u_short
 #define in_port_t u_short
 #endif
 #endif
 #endif
 #endif
 
 
-#ifndef _WIN32_WCE
+#if !defined(_WIN32_WCE)
 #include <process.h>
 #include <process.h>
 #include <direct.h>
 #include <direct.h>
 #include <io.h>
 #include <io.h>
@@ -440,7 +440,7 @@ typedef long off_t;
 #endif
 #endif
 
 
 #define O_NONBLOCK (0)
 #define O_NONBLOCK (0)
-#ifndef W_OK
+#if !defined(W_OK)
 #define W_OK (2) /* http://msdn.microsoft.com/en-us/library/1w06ktdy.aspx */
 #define W_OK (2) /* http://msdn.microsoft.com/en-us/library/1w06ktdy.aspx */
 #endif
 #endif
 #if !defined(EWOULDBLOCK)
 #if !defined(EWOULDBLOCK)
@@ -456,10 +456,10 @@ typedef long off_t;
 #define mg_sleep(x) (Sleep(x))
 #define mg_sleep(x) (Sleep(x))
 
 
 #define pipe(x) _pipe(x, MG_BUF_LEN, _O_BINARY)
 #define pipe(x) _pipe(x, MG_BUF_LEN, _O_BINARY)
-#ifndef popen
+#if !defined(popen)
 #define popen(x, y) (_popen(x, y))
 #define popen(x, y) (_popen(x, y))
 #endif
 #endif
-#ifndef pclose
+#if !defined(pclose)
 #define pclose(x) (_pclose(x))
 #define pclose(x) (_pclose(x))
 #endif
 #endif
 #define close(x) (_close(x))
 #define close(x) (_close(x))
@@ -494,19 +494,19 @@ typedef struct {
 	struct mg_workerTLS *waiting_thread; /* The chain of threads */
 	struct mg_workerTLS *waiting_thread; /* The chain of threads */
 } pthread_cond_t;
 } pthread_cond_t;
 
 
-#ifndef __clockid_t_defined
+#if !defined(__clockid_t_defined)
 typedef DWORD clockid_t;
 typedef DWORD clockid_t;
 #endif
 #endif
-#ifndef CLOCK_MONOTONIC
+#if !defined(CLOCK_MONOTONIC)
 #define CLOCK_MONOTONIC (1)
 #define CLOCK_MONOTONIC (1)
 #endif
 #endif
-#ifndef CLOCK_REALTIME
+#if !defined(CLOCK_REALTIME)
 #define CLOCK_REALTIME (2)
 #define CLOCK_REALTIME (2)
 #endif
 #endif
-#ifndef CLOCK_THREAD
+#if !defined(CLOCK_THREAD)
 #define CLOCK_THREAD (3)
 #define CLOCK_THREAD (3)
 #endif
 #endif
-#ifndef CLOCK_PROCESS
+#if !defined(CLOCK_PROCESS)
 #define CLOCK_PROCESS (4)
 #define CLOCK_PROCESS (4)
 #endif
 #endif
 
 
@@ -514,7 +514,7 @@ typedef DWORD clockid_t;
 #if defined(_MSC_VER) && (_MSC_VER >= 1900)
 #if defined(_MSC_VER) && (_MSC_VER >= 1900)
 #define _TIMESPEC_DEFINED
 #define _TIMESPEC_DEFINED
 #endif
 #endif
-#ifndef _TIMESPEC_DEFINED
+#if !defined(_TIMESPEC_DEFINED)
 struct timespec {
 struct timespec {
 	time_t tv_sec; /* seconds */
 	time_t tv_sec; /* seconds */
 	long tv_nsec;  /* nanoseconds */
 	long tv_nsec;  /* nanoseconds */
@@ -525,7 +525,7 @@ struct timespec {
 #define MUST_IMPLEMENT_CLOCK_GETTIME
 #define MUST_IMPLEMENT_CLOCK_GETTIME
 #endif
 #endif
 
 
-#ifdef MUST_IMPLEMENT_CLOCK_GETTIME
+#if defined(MUST_IMPLEMENT_CLOCK_GETTIME)
 #define clock_gettime mg_clock_gettime
 #define clock_gettime mg_clock_gettime
 static int
 static int
 clock_gettime(clockid_t clk_id, struct timespec *tp)
 clock_gettime(clockid_t clk_id, struct timespec *tp)
@@ -650,7 +650,7 @@ typedef struct DIR {
 } DIR;
 } DIR;
 
 
 #if defined(_WIN32) && !defined(POLLIN)
 #if defined(_WIN32) && !defined(POLLIN)
-#ifndef HAVE_POLL
+#if !defined(HAVE_POLL)
 struct pollfd {
 struct pollfd {
 	SOCKET fd;
 	SOCKET fd;
 	short events;
 	short events;
@@ -706,7 +706,7 @@ typedef unsigned short int in_port_t;
 #define CRYPTO_LIB "libcrypto.so"
 #define CRYPTO_LIB "libcrypto.so"
 #endif
 #endif
 #endif
 #endif
-#ifndef O_BINARY
+#if !defined(O_BINARY)
 #define O_BINARY (0)
 #define O_BINARY (0)
 #endif /* O_BINARY */
 #endif /* O_BINARY */
 #define closesocket(a) (close(a))
 #define closesocket(a) (close(a))
@@ -725,7 +725,7 @@ typedef int SOCKET;
 
 
 #if defined(__hpux)
 #if defined(__hpux)
 /* HPUX 11 does not have monotonic, fall back to realtime */
 /* HPUX 11 does not have monotonic, fall back to realtime */
-#ifndef CLOCK_MONOTONIC
+#if !defined(CLOCK_MONOTONIC)
 #define CLOCK_MONOTONIC CLOCK_REALTIME
 #define CLOCK_MONOTONIC CLOCK_REALTIME
 #endif
 #endif
 
 
@@ -798,11 +798,11 @@ timegm(struct tm *tm)
 
 
 
 
 /* va_copy should always be a macro, C99 and C++11 - DTL */
 /* va_copy should always be a macro, C99 and C++11 - DTL */
-#ifndef va_copy
+#if !defined(va_copy)
 #define va_copy(x, y) ((x) = (y))
 #define va_copy(x, y) ((x) = (y))
 #endif
 #endif
 
 
-#ifdef _WIN32
+#if defined(_WIN32)
 /* Create substitutes for POSIX functions in Win32. */
 /* Create substitutes for POSIX functions in Win32. */
 
 
 #if defined(__MINGW32__)
 #if defined(__MINGW32__)
@@ -1438,22 +1438,22 @@ static void mg_snprintf(const struct mg_connection *conn,
 
 
 /* This following lines are just meant as a reminder to use the mg-functions
 /* This following lines are just meant as a reminder to use the mg-functions
  * for memory management */
  * for memory management */
-#ifdef malloc
+#if defined(malloc)
 #undef malloc
 #undef malloc
 #endif
 #endif
-#ifdef calloc
+#if defined(calloc)
 #undef calloc
 #undef calloc
 #endif
 #endif
-#ifdef realloc
+#if defined(realloc)
 #undef realloc
 #undef realloc
 #endif
 #endif
-#ifdef free
+#if defined(free)
 #undef free
 #undef free
 #endif
 #endif
-#ifdef snprintf
+#if defined(snprintf)
 #undef snprintf
 #undef snprintf
 #endif
 #endif
-#ifdef vsnprintf
+#if defined(vsnprintf)
 #undef vsnprintf
 #undef vsnprintf
 #endif
 #endif
 #define malloc DO_NOT_USE_THIS_FUNCTION__USE_mg_malloc
 #define malloc DO_NOT_USE_THIS_FUNCTION__USE_mg_malloc
@@ -1461,8 +1461,9 @@ static void mg_snprintf(const struct mg_connection *conn,
 #define realloc DO_NOT_USE_THIS_FUNCTION__USE_mg_realloc
 #define realloc DO_NOT_USE_THIS_FUNCTION__USE_mg_realloc
 #define free DO_NOT_USE_THIS_FUNCTION__USE_mg_free
 #define free DO_NOT_USE_THIS_FUNCTION__USE_mg_free
 #define snprintf DO_NOT_USE_THIS_FUNCTION__USE_mg_snprintf
 #define snprintf DO_NOT_USE_THIS_FUNCTION__USE_mg_snprintf
-#ifdef _WIN32 /* vsnprintf must not be used in any system, * \ \ \             \
-               * but this define only works well for Windows. */
+#if defined(_WIN32)
+/* vsnprintf must not be used in any system,
+ * but this define only works well for Windows. */
 #define vsnprintf DO_NOT_USE_THIS_FUNCTION__USE_mg_vsnprintf
 #define vsnprintf DO_NOT_USE_THIS_FUNCTION__USE_mg_vsnprintf
 #endif
 #endif
 
 
@@ -1522,11 +1523,11 @@ FUNCTION_MAY_BE_UNUSED
 static unsigned long
 static unsigned long
 mg_current_thread_id(void)
 mg_current_thread_id(void)
 {
 {
-#ifdef _WIN32
+#if defined(_WIN32)
 	return GetCurrentThreadId();
 	return GetCurrentThreadId();
 #else
 #else
 
 
-#ifdef __clang__
+#if defined(__clang__)
 #pragma clang diagnostic push
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wunreachable-code"
 #pragma clang diagnostic ignored "-Wunreachable-code"
 /* For every compiler, either "sizeof(pthread_t) > sizeof(unsigned long)"
 /* For every compiler, either "sizeof(pthread_t) > sizeof(unsigned long)"
@@ -1560,7 +1561,7 @@ mg_current_thread_id(void)
 		return ret;
 		return ret;
 	}
 	}
 
 
-#ifdef __clang__
+#if defined(__clang__)
 #pragma clang diagnostic pop
 #pragma clang diagnostic pop
 #endif
 #endif
 
 
@@ -1633,7 +1634,7 @@ DEBUG_TRACE_FUNC(const char *func, unsigned line, const char *fmt, ...)
 #include "md5.inl"
 #include "md5.inl"
 
 
 /* Darwin prior to 7.0 and Win32 do not have socklen_t */
 /* Darwin prior to 7.0 and Win32 do not have socklen_t */
-#ifdef NO_SOCKLEN_T
+#if defined(NO_SOCKLEN_T)
 typedef int socklen_t;
 typedef int socklen_t;
 #endif /* NO_SOCKLEN_T */
 #endif /* NO_SOCKLEN_T */
 
 
@@ -1669,7 +1670,7 @@ typedef struct SSL_CTX SSL_CTX;
 #include <openssl/bn.h>
 #include <openssl/bn.h>
 #include <openssl/opensslv.h>
 #include <openssl/opensslv.h>
 
 
-#ifdef WOLFSSL_VERSION
+#if defined(WOLFSSL_VERSION)
 /* Additional defines for WolfSSL, see
 /* Additional defines for WolfSSL, see
  * https://github.com/civetweb/civetweb/issues/583 */
  * https://github.com/civetweb/civetweb/issues/583 */
 #include "wolfssl_extras.inl"
 #include "wolfssl_extras.inl"
@@ -1742,7 +1743,7 @@ struct ssl_func {
 };
 };
 
 
 
 
-#ifdef OPENSSL_API_1_1
+#if defined(OPENSSL_API_1_1)
 
 
 #define SSL_free (*(void (*)(SSL *))ssl_sw[0].ptr)
 #define SSL_free (*(void (*)(SSL *))ssl_sw[0].ptr)
 #define SSL_accept (*(int (*)(SSL *))ssl_sw[1].ptr)
 #define SSL_accept (*(int (*)(SSL *))ssl_sw[1].ptr)
@@ -2354,7 +2355,7 @@ static struct mg_option config_options[] = {
     {"global_auth_file", MG_CONFIG_TYPE_FILE, NULL},
     {"global_auth_file", MG_CONFIG_TYPE_FILE, NULL},
     {"index_files",
     {"index_files",
      MG_CONFIG_TYPE_STRING_LIST,
      MG_CONFIG_TYPE_STRING_LIST,
-#ifdef USE_LUA
+#if defined(USE_LUA)
      "index.xhtml,index.html,index.htm,"
      "index.xhtml,index.html,index.htm,"
      "index.lp,index.lsp,index.lua,index.cgi,"
      "index.lp,index.lsp,index.lua,index.cgi,"
      "index.shtml,index.php"},
      "index.shtml,index.php"},
@@ -2520,7 +2521,7 @@ struct mg_context {
 	pthread_t *worker_threadids; /* The worker thread IDs */
 	pthread_t *worker_threadids; /* The worker thread IDs */
 
 
 /* Connection to thread dispatching */
 /* Connection to thread dispatching */
-#ifdef ALTERNATIVE_QUEUE
+#if defined(ALTERNATIVE_QUEUE)
 	struct socket *client_socks;
 	struct socket *client_socks;
 	void **client_wait_events;
 	void **client_wait_events;
 #else
 #else
@@ -2696,7 +2697,7 @@ typedef struct tagTHREADNAME_INFO {
 
 
 #include <sys/prctl.h>
 #include <sys/prctl.h>
 #include <sys/sendfile.h>
 #include <sys/sendfile.h>
-#ifdef ALTERNATIVE_QUEUE
+#if defined(ALTERNATIVE_QUEUE)
 #include <sys/eventfd.h>
 #include <sys/eventfd.h>
 #endif /* ALTERNATIVE_QUEUE */
 #endif /* ALTERNATIVE_QUEUE */
 
 
@@ -3064,7 +3065,7 @@ mg_fopen(const struct mg_connection *conn,
 			return 0;
 			return 0;
 		}
 		}
 
 
-#ifdef _WIN32
+#if defined(_WIN32)
 		{
 		{
 			wchar_t wbuf[W_PATH_MAX];
 			wchar_t wbuf[W_PATH_MAX];
 			path_to_unicode(conn, path, wbuf, ARRAY_SIZE(wbuf));
 			path_to_unicode(conn, path, wbuf, ARRAY_SIZE(wbuf));
@@ -3250,7 +3251,7 @@ mg_vsnprintf(const struct mg_connection *conn,
 		return;
 		return;
 	}
 	}
 
 
-#ifdef __clang__
+#if defined(__clang__)
 #pragma clang diagnostic push
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wformat-nonliteral"
 #pragma clang diagnostic ignored "-Wformat-nonliteral"
 /* Using fmt as a non-literal is intended here, since it is mostly called
 /* Using fmt as a non-literal is intended here, since it is mostly called
@@ -3260,7 +3261,7 @@ mg_vsnprintf(const struct mg_connection *conn,
 	n = (int)vsnprintf_impl(buf, buflen, fmt, ap);
 	n = (int)vsnprintf_impl(buf, buflen, fmt, ap);
 	ok = (n >= 0) && ((size_t)n < buflen);
 	ok = (n >= 0) && ((size_t)n < buflen);
 
 
-#ifdef __clang__
+#if defined(__clang__)
 #pragma clang diagnostic pop
 #pragma clang diagnostic pop
 #endif
 #endif
 
 
@@ -3466,7 +3467,7 @@ sockaddr_to_string(char *buf, size_t len, const union usa *usa)
 static void
 static void
 gmt_time_string(char *buf, size_t buf_len, time_t *t)
 gmt_time_string(char *buf, size_t buf_len, time_t *t)
 {
 {
-#ifndef REENTRANT_TIME
+#if !defined(REENTRANT_TIME)
 	struct tm *tm;
 	struct tm *tm;
 
 
 	tm = ((t != NULL) ? gmtime(t) : NULL);
 	tm = ((t != NULL) ? gmtime(t) : NULL);
@@ -3687,7 +3688,7 @@ mg_get_response_info(const struct mg_connection *conn)
 static const char *
 static const char *
 get_proto_name(const struct mg_connection *conn)
 get_proto_name(const struct mg_connection *conn)
 {
 {
-#ifdef __clang__
+#if defined(__clang__)
 #pragma clang diagnostic push
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wunreachable-code"
 #pragma clang diagnostic ignored "-Wunreachable-code"
 /* Depending on USE_WEBSOCKET and NO_SSL, some oft the protocols might be
 /* Depending on USE_WEBSOCKET and NO_SSL, some oft the protocols might be
@@ -3705,7 +3706,7 @@ get_proto_name(const struct mg_connection *conn)
 
 
 	return proto;
 	return proto;
 
 
-#ifdef __clang__
+#if defined(__clang__)
 #pragma clang diagnostic pop
 #pragma clang diagnostic pop
 #endif
 #endif
 }
 }
@@ -4613,7 +4614,7 @@ pthread_mutex_lock(pthread_mutex_t *mutex)
 }
 }
 
 
 
 
-#ifdef ENABLE_UNUSED_PTHREAD_FUNCTIONS
+#if defined(ENABLE_UNUSED_PTHREAD_FUNCTIONS)
 FUNCTION_MAY_BE_UNUSED
 FUNCTION_MAY_BE_UNUSED
 static int
 static int
 pthread_mutex_trylock(pthread_mutex_t *mutex)
 pthread_mutex_trylock(pthread_mutex_t *mutex)
@@ -4765,7 +4766,7 @@ pthread_cond_destroy(pthread_cond_t *cv)
 }
 }
 
 
 
 
-#ifdef ALTERNATIVE_QUEUE
+#if defined(ALTERNATIVE_QUEUE)
 FUNCTION_MAY_BE_UNUSED
 FUNCTION_MAY_BE_UNUSED
 static void *
 static void *
 event_create(void)
 event_create(void)
@@ -5118,7 +5119,7 @@ mg_readdir(DIR *dir)
 }
 }
 
 
 
 
-#ifndef HAVE_POLL
+#if !defined(HAVE_POLL)
 FUNCTION_MAY_BE_UNUSED
 FUNCTION_MAY_BE_UNUSED
 static int
 static int
 poll(struct pollfd *pfd, unsigned int n, int milliseconds)
 poll(struct pollfd *pfd, unsigned int n, int milliseconds)
@@ -5391,7 +5392,7 @@ spawn_process(struct mg_connection *conn,
 #if defined(MG_USE_OPEN_FILE)
 #if defined(MG_USE_OPEN_FILE)
 			p = (char *)file.access.membuf;
 			p = (char *)file.access.membuf;
 #else
 #else
-            p = (char *)NULL;
+			p = (char *)NULL;
 #endif
 #endif
 			mg_fgets(buf, sizeof(buf), &file, &p);
 			mg_fgets(buf, sizeof(buf), &file, &p);
 			(void)mg_fclose(&file.access); /* ignore error on read only file */
 			(void)mg_fclose(&file.access); /* ignore error on read only file */
@@ -5592,7 +5593,7 @@ mg_join_thread(pthread_t threadid)
 }
 }
 
 
 
 
-#ifndef NO_CGI
+#if !defined(NO_CGI)
 static pid_t
 static pid_t
 spawn_process(struct mg_connection *conn,
 spawn_process(struct mg_connection *conn,
               const char *prog,
               const char *prog,
@@ -5811,7 +5812,7 @@ push_inner(struct mg_context *ctx,
 	int n, err;
 	int n, err;
 	unsigned ms_wait = SOCKET_TIMEOUT_QUANTUM; /* Sleep quantum in ms */
 	unsigned ms_wait = SOCKET_TIMEOUT_QUANTUM; /* Sleep quantum in ms */
 
 
-#ifdef _WIN32
+#if defined(_WIN32)
 	typedef int len_t;
 	typedef int len_t;
 #else
 #else
 	typedef size_t len_t;
 	typedef size_t len_t;
@@ -5827,7 +5828,7 @@ push_inner(struct mg_context *ctx,
 		return -2;
 		return -2;
 	}
 	}
 
 
-#ifdef NO_SSL
+#if defined(NO_SSL)
 	if (ssl) {
 	if (ssl) {
 		return -2;
 		return -2;
 	}
 	}
@@ -5837,7 +5838,7 @@ push_inner(struct mg_context *ctx,
 	 * shuts down. */
 	 * shuts down. */
 	for (;;) {
 	for (;;) {
 
 
-#ifndef NO_SSL
+#if !defined(NO_SSL)
 		if (ssl != NULL) {
 		if (ssl != NULL) {
 			n = SSL_write(ssl, buf, len);
 			n = SSL_write(ssl, buf, len);
 			if (n <= 0) {
 			if (n <= 0) {
@@ -5867,7 +5868,7 @@ push_inner(struct mg_context *ctx,
 		} else {
 		} else {
 			n = (int)send(sock, buf, (len_t)len, MSG_NOSIGNAL);
 			n = (int)send(sock, buf, (len_t)len, MSG_NOSIGNAL);
 			err = (n < 0) ? ERRNO : 0;
 			err = (n < 0) ? ERRNO : 0;
-#ifdef _WIN32
+#if defined(_WIN32)
 			if (err == WSAEWOULDBLOCK) {
 			if (err == WSAEWOULDBLOCK) {
 				err = 0;
 				err = 0;
 				n = 0;
 				n = 0;
@@ -6013,12 +6014,12 @@ pull_inner(FILE *fp,
 {
 {
 	int nread, err = 0;
 	int nread, err = 0;
 
 
-#ifdef _WIN32
+#if defined(_WIN32)
 	typedef int len_t;
 	typedef int len_t;
 #else
 #else
 	typedef size_t len_t;
 	typedef size_t len_t;
 #endif
 #endif
-#ifndef NO_SSL
+#if !defined(NO_SSL)
 	int ssl_pending;
 	int ssl_pending;
 #endif
 #endif
 
 
@@ -6044,7 +6045,7 @@ pull_inner(FILE *fp,
 			return -2;
 			return -2;
 		}
 		}
 
 
-#ifndef NO_SSL
+#if !defined(NO_SSL)
 	} else if ((conn->ssl != NULL)
 	} else if ((conn->ssl != NULL)
 	           && ((ssl_pending = SSL_pending(conn->ssl)) > 0)) {
 	           && ((ssl_pending = SSL_pending(conn->ssl)) > 0)) {
 		/* We already know there is no more data buffered in conn->buf
 		/* We already know there is no more data buffered in conn->buf
@@ -6149,7 +6150,7 @@ pull_inner(FILE *fp,
 
 
 	if (nread < 0) {
 	if (nread < 0) {
 /* socket error - check errno */
 /* socket error - check errno */
-#ifdef _WIN32
+#if defined(_WIN32)
 		if (err == WSAEWOULDBLOCK) {
 		if (err == WSAEWOULDBLOCK) {
 			/* TODO (low): check if this is still required */
 			/* TODO (low): check if this is still required */
 			/* standard case if called from close_socket_gracefully */
 			/* standard case if called from close_socket_gracefully */
@@ -7742,7 +7743,7 @@ open_auth_file(struct mg_connection *conn,
 		if (gpass != NULL) {
 		if (gpass != NULL) {
 			/* Use global passwords file */
 			/* Use global passwords file */
 			if (!mg_fopen(conn, gpass, MG_FOPEN_MODE_READ, filep)) {
 			if (!mg_fopen(conn, gpass, MG_FOPEN_MODE_READ, filep)) {
-#ifdef DEBUG
+#if defined(DEBUG)
 				/* Use mg_cry_internal here, since gpass has been configured. */
 				/* Use mg_cry_internal here, since gpass has been configured. */
 				mg_cry_internal(conn, "fopen(%s): %s", gpass, strerror(ERRNO));
 				mg_cry_internal(conn, "fopen(%s): %s", gpass, strerror(ERRNO));
 #endif
 #endif
@@ -7763,7 +7764,7 @@ open_auth_file(struct mg_connection *conn,
 			            PASSWORDS_FILE_NAME);
 			            PASSWORDS_FILE_NAME);
 
 
 			if (truncated || !mg_fopen(conn, name, MG_FOPEN_MODE_READ, filep)) {
 			if (truncated || !mg_fopen(conn, name, MG_FOPEN_MODE_READ, filep)) {
-#ifdef DEBUG
+#if defined(DEBUG)
 				/* Don't use mg_cry_internal here, but only a trace, since this
 				/* Don't use mg_cry_internal here, but only a trace, since this
 				 * is
 				 * is
 				 * a typical case. It will occur for every directory
 				 * a typical case. It will occur for every directory
@@ -7788,7 +7789,7 @@ open_auth_file(struct mg_connection *conn,
 			            PASSWORDS_FILE_NAME);
 			            PASSWORDS_FILE_NAME);
 
 
 			if (truncated || !mg_fopen(conn, name, MG_FOPEN_MODE_READ, filep)) {
 			if (truncated || !mg_fopen(conn, name, MG_FOPEN_MODE_READ, filep)) {
-#ifdef DEBUG
+#if defined(DEBUG)
 				/* Don't use mg_cry_internal here, but only a trace, since this
 				/* Don't use mg_cry_internal here, but only a trace, since this
 				 * is
 				 * is
 				 * a typical case. It will occur for every directory
 				 * a typical case. It will occur for every directory
@@ -7872,7 +7873,7 @@ parse_auth_header(struct mg_connection *conn,
 		}
 		}
 	}
 	}
 
 
-#ifndef NO_NONCE_CHECK
+#if !defined(NO_NONCE_CHECK)
 	/* Read the nonce from the response. */
 	/* Read the nonce from the response. */
 	if (ah->nonce == NULL) {
 	if (ah->nonce == NULL) {
 		return 0;
 		return 0;
@@ -8472,7 +8473,7 @@ connect_socket(struct mg_context *ctx /* may be NULL */,
 
 
 #if !defined(NO_SSL)
 #if !defined(NO_SSL)
 #if !defined(NO_SSL_DL)
 #if !defined(NO_SSL_DL)
-#ifdef OPENSSL_API_1_1
+#if defined(OPENSSL_API_1_1)
 	if (use_ssl && (TLS_client_method == NULL)) {
 	if (use_ssl && (TLS_client_method == NULL)) {
 		mg_snprintf(NULL,
 		mg_snprintf(NULL,
 		            NULL, /* No truncation check for ebuf */
 		            NULL, /* No truncation check for ebuf */
@@ -8505,7 +8506,7 @@ connect_socket(struct mg_context *ctx /* may be NULL */,
 		sa->sin.sin_family = AF_INET;
 		sa->sin.sin_family = AF_INET;
 		sa->sin.sin_port = htons((uint16_t)port);
 		sa->sin.sin_port = htons((uint16_t)port);
 		ip_ver = 4;
 		ip_ver = 4;
-#ifdef USE_IPV6
+#if defined(USE_IPV6)
 	} else if (mg_inet_pton(AF_INET6, host, &sa->sin6, sizeof(sa->sin6))) {
 	} else if (mg_inet_pton(AF_INET6, host, &sa->sin6, sizeof(sa->sin6))) {
 		sa->sin6.sin6_family = AF_INET6;
 		sa->sin6.sin6_family = AF_INET6;
 		sa->sin6.sin6_port = htons((uint16_t)port);
 		sa->sin6.sin6_port = htons((uint16_t)port);
@@ -8540,7 +8541,7 @@ connect_socket(struct mg_context *ctx /* may be NULL */,
 	if (ip_ver == 4) {
 	if (ip_ver == 4) {
 		*sock = socket(PF_INET, SOCK_STREAM, 0);
 		*sock = socket(PF_INET, SOCK_STREAM, 0);
 	}
 	}
-#ifdef USE_IPV6
+#if defined(USE_IPV6)
 	else if (ip_ver == 6) {
 	else if (ip_ver == 6) {
 		*sock = socket(PF_INET6, SOCK_STREAM, 0);
 		*sock = socket(PF_INET6, SOCK_STREAM, 0);
 	}
 	}
@@ -8574,7 +8575,7 @@ connect_socket(struct mg_context *ctx /* may be NULL */,
 		/* connected with IPv4 */
 		/* connected with IPv4 */
 		conn_ret = connect(*sock, (struct sockaddr *)&sa->sin, sizeof(sa->sin));
 		conn_ret = connect(*sock, (struct sockaddr *)&sa->sin, sizeof(sa->sin));
 	}
 	}
-#ifdef USE_IPV6
+#if defined(USE_IPV6)
 	else if (ip_ver == 6) {
 	else if (ip_ver == 6) {
 		/* connected with IPv6 */
 		/* connected with IPv6 */
 		conn_ret =
 		conn_ret =
@@ -8672,7 +8673,7 @@ print_dir_entry(struct de *de)
 	size_t hrefsize;
 	size_t hrefsize;
 	char *href;
 	char *href;
 	char size[64], mod[64];
 	char size[64], mod[64];
-#ifdef REENTRANT_TIME
+#if defined(REENTRANT_TIME)
 	struct tm _tm;
 	struct tm _tm;
 	struct tm *tm = &_tm;
 	struct tm *tm = &_tm;
 #else
 #else
@@ -8728,7 +8729,7 @@ print_dir_entry(struct de *de)
 /* Note: mg_snprintf will not cause a buffer overflow above.
 /* Note: mg_snprintf will not cause a buffer overflow above.
  * So, string truncation checks are not required here. */
  * So, string truncation checks are not required here. */
 
 
-#ifdef REENTRANT_TIME
+#if defined(REENTRANT_TIME)
 	localtime_r(&de->file.last_modified, tm);
 	localtime_r(&de->file.last_modified, tm);
 #else
 #else
 	tm = localtime(&de->file.last_modified);
 	tm = localtime(&de->file.last_modified);
@@ -9197,7 +9198,7 @@ static void
 fclose_on_exec(struct mg_file_access *filep, struct mg_connection *conn)
 fclose_on_exec(struct mg_file_access *filep, struct mg_connection *conn)
 {
 {
 	if (filep != NULL && filep->fp != NULL) {
 	if (filep != NULL && filep->fp != NULL) {
-#ifdef _WIN32
+#if defined(_WIN32)
 		(void)conn; /* Unused. */
 		(void)conn; /* Unused. */
 #else
 #else
 		if (fcntl(fileno(filep->fp), F_SETFD, FD_CLOEXEC) != 0) {
 		if (fcntl(fileno(filep->fp), F_SETFD, FD_CLOEXEC) != 0) {
@@ -11578,11 +11579,11 @@ mg_unlock_context(struct mg_context *ctx)
 #include "timer.inl"
 #include "timer.inl"
 #endif /* USE_TIMERS */
 #endif /* USE_TIMERS */
 
 
-#ifdef USE_LUA
+#if defined(USE_LUA)
 #include "mod_lua.inl"
 #include "mod_lua.inl"
 #endif /* USE_LUA */
 #endif /* USE_LUA */
 
 
-#ifdef USE_DUKTAPE
+#if defined(USE_DUKTAPE)
 #include "mod_duktape.inl"
 #include "mod_duktape.inl"
 #endif /* USE_DUKTAPE */
 #endif /* USE_DUKTAPE */
 
 
@@ -13625,7 +13626,7 @@ handle_file_based_request(struct mg_connection *conn,
 	}
 	}
 
 
 	if (0) {
 	if (0) {
-#ifdef USE_LUA
+#if defined(USE_LUA)
 	} else if (match_prefix(
 	} else if (match_prefix(
 	               conn->dom_ctx->config[LUA_SERVER_PAGE_EXTENSIONS],
 	               conn->dom_ctx->config[LUA_SERVER_PAGE_EXTENSIONS],
 	               strlen(conn->dom_ctx->config[LUA_SERVER_PAGE_EXTENSIONS]),
 	               strlen(conn->dom_ctx->config[LUA_SERVER_PAGE_EXTENSIONS]),
@@ -13944,7 +13945,7 @@ set_ports_option(struct mg_context *phys_ctx)
 			continue;
 			continue;
 		}
 		}
 
 
-#ifdef _WIN32
+#if defined(_WIN32)
 		/* Windows SO_REUSEADDR lets many procs binds to a
 		/* Windows SO_REUSEADDR lets many procs binds to a
 		 * socket, SO_EXCLUSIVEADDRUSE makes the bind fail
 		 * socket, SO_EXCLUSIVEADDRUSE makes the bind fail
 		 * if someone already has the socket -- DTL */
 		 * if someone already has the socket -- DTL */
@@ -14452,7 +14453,7 @@ refresh_trust(struct mg_connection *conn)
 	return 1;
 	return 1;
 }
 }
 
 
-#ifdef OPENSSL_API_1_1
+#if defined(OPENSSL_API_1_1)
 #else
 #else
 static pthread_mutex_t *ssl_mutexes;
 static pthread_mutex_t *ssl_mutexes;
 #endif /* OPENSSL_API_1_1 */
 #endif /* OPENSSL_API_1_1 */
@@ -14496,7 +14497,7 @@ sslize(struct mg_connection *conn,
 		conn->ssl = NULL;
 		conn->ssl = NULL;
 /* Avoid CRYPTO_cleanup_all_ex_data(); See discussion:
 /* Avoid CRYPTO_cleanup_all_ex_data(); See discussion:
  * https://wiki.openssl.org/index.php/Talk:Library_Initialization */
  * https://wiki.openssl.org/index.php/Talk:Library_Initialization */
-#ifndef OPENSSL_API_1_1
+#if !defined(OPENSSL_API_1_1)
 		ERR_remove_state(0);
 		ERR_remove_state(0);
 #endif
 #endif
 		return 0;
 		return 0;
@@ -14545,7 +14546,7 @@ sslize(struct mg_connection *conn,
 		conn->ssl = NULL;
 		conn->ssl = NULL;
 /* Avoid CRYPTO_cleanup_all_ex_data(); See discussion:
 /* Avoid CRYPTO_cleanup_all_ex_data(); See discussion:
  * https://wiki.openssl.org/index.php/Talk:Library_Initialization */
  * https://wiki.openssl.org/index.php/Talk:Library_Initialization */
-#ifndef OPENSSL_API_1_1
+#if !defined(OPENSSL_API_1_1)
 		ERR_remove_state(0);
 		ERR_remove_state(0);
 #endif
 #endif
 		return 0;
 		return 0;
@@ -14676,7 +14677,7 @@ ssl_get_client_cert_info(struct mg_connection *conn)
 }
 }
 
 
 
 
-#ifdef OPENSSL_API_1_1
+#if defined(OPENSSL_API_1_1)
 #else
 #else
 static void
 static void
 ssl_locking_callback(int mode, int mutex_num, const char *file, int line)
 ssl_locking_callback(int mode, int mutex_num, const char *file, int line)
@@ -14720,7 +14721,7 @@ load_dll(char *ebuf, size_t ebuf_len, const char *dll_name, struct ssl_func *sw)
 
 
 	ok = 1;
 	ok = 1;
 	for (fp = sw; fp->name != NULL; fp++) {
 	for (fp = sw; fp->name != NULL; fp++) {
-#ifdef _WIN32
+#if defined(_WIN32)
 		/* GetProcAddress() returns pointer to function */
 		/* GetProcAddress() returns pointer to function */
 		u.fp = (void (*)(void))dlsym(dll_handle, fp->name);
 		u.fp = (void (*)(void))dlsym(dll_handle, fp->name);
 #else
 #else
@@ -14787,7 +14788,7 @@ static int cryptolib_users = 0; /* Reference counter for crypto library. */
 static int
 static int
 initialize_ssl(char *ebuf, size_t ebuf_len)
 initialize_ssl(char *ebuf, size_t ebuf_len)
 {
 {
-#ifdef OPENSSL_API_1_1
+#if defined(OPENSSL_API_1_1)
 	if (ebuf_len > 0) {
 	if (ebuf_len > 0) {
 		ebuf[0] = 0;
 		ebuf[0] = 0;
 	}
 	}
@@ -14883,7 +14884,7 @@ initialize_ssl(char *ebuf, size_t ebuf_len)
 	}
 	}
 #endif /* NO_SSL_DL */
 #endif /* NO_SSL_DL */
 
 
-#ifdef OPENSSL_API_1_1
+#if defined(OPENSSL_API_1_1)
 	/* Initialize SSL library */
 	/* Initialize SSL library */
 	OPENSSL_init_ssl(0, NULL);
 	OPENSSL_init_ssl(0, NULL);
 	OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS
 	OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS
@@ -14954,7 +14955,7 @@ ssl_use_pem_file(struct mg_context *phys_ctx,
 }
 }
 
 
 
 
-#ifdef OPENSSL_API_1_1
+#if defined(OPENSSL_API_1_1)
 static unsigned long
 static unsigned long
 ssl_get_protocol(int version_id)
 ssl_get_protocol(int version_id)
 {
 {
@@ -15098,7 +15099,7 @@ init_ssl_ctx_impl(struct mg_context *phys_ctx,
 	md5_state_t md5state;
 	md5_state_t md5state;
 	int protocol_ver;
 	int protocol_ver;
 
 
-#ifdef OPENSSL_API_1_1
+#if defined(OPENSSL_API_1_1)
 	if ((dom_ctx->ssl_ctx = SSL_CTX_new(TLS_server_method())) == NULL) {
 	if ((dom_ctx->ssl_ctx = SSL_CTX_new(TLS_server_method())) == NULL) {
 		mg_cry_internal(fc(phys_ctx),
 		mg_cry_internal(fc(phys_ctx),
 		                "SSL_CTX_new (server) error: %s",
 		                "SSL_CTX_new (server) error: %s",
@@ -15128,7 +15129,7 @@ init_ssl_ctx_impl(struct mg_context *phys_ctx,
 	SSL_CTX_set_ecdh_auto(dom_ctx->ssl_ctx, 1);
 	SSL_CTX_set_ecdh_auto(dom_ctx->ssl_ctx, 1);
 #endif /* NO_SSL_DL */
 #endif /* NO_SSL_DL */
 
 
-#ifdef __clang__
+#if defined(__clang__)
 #pragma clang diagnostic push
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wincompatible-pointer-types"
 #pragma clang diagnostic ignored "-Wincompatible-pointer-types"
 #endif
 #endif
@@ -15151,7 +15152,7 @@ init_ssl_ctx_impl(struct mg_context *phys_ctx,
 	                                       ssl_servername_callback);
 	                                       ssl_servername_callback);
 	SSL_CTX_set_tlsext_servername_arg(dom_ctx->ssl_ctx, phys_ctx);
 	SSL_CTX_set_tlsext_servername_arg(dom_ctx->ssl_ctx, phys_ctx);
 
 
-#ifdef __clang__
+#if defined(__clang__)
 #pragma clang diagnostic pop
 #pragma clang diagnostic pop
 #endif
 #endif
 
 
@@ -15354,7 +15355,7 @@ init_ssl_ctx(struct mg_context *phys_ctx, struct mg_domain_context *dom_ctx)
 static void
 static void
 uninitialize_ssl(void)
 uninitialize_ssl(void)
 {
 {
-#ifdef OPENSSL_API_1_1
+#if defined(OPENSSL_API_1_1)
 
 
 	if (mg_atomic_dec(&cryptolib_users) == 0) {
 	if (mg_atomic_dec(&cryptolib_users) == 0) {
 
 
@@ -15473,7 +15474,7 @@ set_sock_timeout(SOCKET sock, int milliseconds)
 {
 {
         int r0 = 0, r1, r2;
         int r0 = 0, r1, r2;
 
 
-#ifdef _WIN32
+#if defined(_WIN32)
         /* Windows specific */
         /* Windows specific */
 
 
         DWORD tv = (DWORD)milliseconds;
         DWORD tv = (DWORD)milliseconds;
@@ -15677,7 +15678,7 @@ close_connection(struct mg_connection *conn)
 	conn->conn_state = 7; /* closing */
 	conn->conn_state = 7; /* closing */
 #endif
 #endif
 
 
-#ifndef NO_SSL
+#if !defined(NO_SSL)
 	if (conn->ssl != NULL) {
 	if (conn->ssl != NULL) {
 		/* Run SSL_shutdown twice to ensure completely close SSL connection
 		/* Run SSL_shutdown twice to ensure completely close SSL connection
 		 */
 		 */
@@ -15685,7 +15686,7 @@ close_connection(struct mg_connection *conn)
 		SSL_free(conn->ssl);
 		SSL_free(conn->ssl);
 /* Avoid CRYPTO_cleanup_all_ex_data(); See discussion:
 /* Avoid CRYPTO_cleanup_all_ex_data(); See discussion:
  * https://wiki.openssl.org/index.php/Talk:Library_Initialization */
  * https://wiki.openssl.org/index.php/Talk:Library_Initialization */
-#ifndef OPENSSL_API_1_1
+#if !defined(OPENSSL_API_1_1)
 		ERR_remove_state(0);
 		ERR_remove_state(0);
 #endif
 #endif
 		conn->ssl = NULL;
 		conn->ssl = NULL;
@@ -15755,7 +15756,7 @@ mg_close_connection(struct mg_connection *conn)
 
 
 	close_connection(conn);
 	close_connection(conn);
 
 
-#ifndef NO_SSL
+#if !defined(NO_SSL)
 	if (conn->client_ssl_ctx != NULL) {
 	if (conn->client_ssl_ctx != NULL) {
 		SSL_CTX_free((SSL_CTX *)conn->client_ssl_ctx);
 		SSL_CTX_free((SSL_CTX *)conn->client_ssl_ctx);
 	}
 	}
@@ -15848,8 +15849,8 @@ mg_connect_client_impl(const struct mg_client_options *client_options,
 		return NULL;
 		return NULL;
 	}
 	}
 
 
-#ifndef NO_SSL
-#ifdef OPENSSL_API_1_1
+#if !defined(NO_SSL)
+#if defined(OPENSSL_API_1_1)
 	if (use_ssl
 	if (use_ssl
 	    && (conn->client_ssl_ctx = SSL_CTX_new(TLS_client_method())) == NULL) {
 	    && (conn->client_ssl_ctx = SSL_CTX_new(TLS_client_method())) == NULL) {
 		mg_snprintf(NULL,
 		mg_snprintf(NULL,
@@ -15878,7 +15879,7 @@ mg_connect_client_impl(const struct mg_client_options *client_options,
 #endif /* NO_SSL */
 #endif /* NO_SSL */
 
 
 
 
-#ifdef USE_IPV6
+#if defined(USE_IPV6)
 	len = (sa.sa.sa_family == AF_INET) ? sizeof(conn->client.rsa.sin)
 	len = (sa.sa.sa_family == AF_INET) ? sizeof(conn->client.rsa.sin)
 	                                   : sizeof(conn->client.rsa.sin6);
 	                                   : sizeof(conn->client.rsa.sin6);
 	psa = (sa.sa.sa_family == AF_INET)
 	psa = (sa.sa.sa_family == AF_INET)
@@ -15902,7 +15903,7 @@ mg_connect_client_impl(const struct mg_client_options *client_options,
 	conn->client.is_ssl = use_ssl ? 1 : 0;
 	conn->client.is_ssl = use_ssl ? 1 : 0;
 	(void)pthread_mutex_init(&conn->mutex, &pthread_mutex_attr);
 	(void)pthread_mutex_init(&conn->mutex, &pthread_mutex_attr);
 
 
-#ifndef NO_SSL
+#if !defined(NO_SSL)
 	if (use_ssl) {
 	if (use_ssl) {
 		common_client_context.dd.ssl_ctx = conn->client_ssl_ctx;
 		common_client_context.dd.ssl_ctx = conn->client_ssl_ctx;
 
 
@@ -16546,7 +16547,7 @@ struct websocket_client_thread_data {
 
 
 
 
 #if defined(USE_WEBSOCKET)
 #if defined(USE_WEBSOCKET)
-#ifdef _WIN32
+#if defined(_WIN32)
 static unsigned __stdcall websocket_client_thread(void *data)
 static unsigned __stdcall websocket_client_thread(void *data)
 #else
 #else
 static void *
 static void *
@@ -16590,7 +16591,7 @@ websocket_client_thread(void *data)
 
 
 	mg_free((void *)cdata);
 	mg_free((void *)cdata);
 
 
-#ifdef _WIN32
+#if defined(_WIN32)
 	return 0;
 	return 0;
 #else
 #else
 	return NULL;
 	return NULL;
@@ -16638,7 +16639,7 @@ mg_connect_websocket_client(const char *host,
 		                "\r\n";
 		                "\r\n";
 	}
 	}
 
 
-#ifdef __clang__
+#if defined(__clang__)
 #pragma clang diagnostic push
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wformat-nonliteral"
 #pragma clang diagnostic ignored "-Wformat-nonliteral"
 #endif
 #endif
@@ -16655,7 +16656,7 @@ mg_connect_websocket_client(const char *host,
 	                   magic,
 	                   magic,
 	                   origin);
 	                   origin);
 
 
-#ifdef __clang__
+#if defined(__clang__)
 #pragma clang diagnostic pop
 #pragma clang diagnostic pop
 #endif
 #endif
 
 
@@ -17189,7 +17190,7 @@ worker_thread_run(struct worker_thread_args *thread_args)
 		conn->request_info.is_ssl = conn->client.is_ssl;
 		conn->request_info.is_ssl = conn->client.is_ssl;
 
 
 		if (conn->client.is_ssl) {
 		if (conn->client.is_ssl) {
-#ifndef NO_SSL
+#if !defined(NO_SSL)
 			/* HTTPS connection */
 			/* HTTPS connection */
 			if (sslize(conn,
 			if (sslize(conn,
 			           conn->dom_ctx->ssl_ctx,
 			           conn->dom_ctx->ssl_ctx,
@@ -17252,7 +17253,7 @@ worker_thread_run(struct worker_thread_args *thread_args)
 
 
 
 
 /* Threads have different return types on Windows and Unix. */
 /* Threads have different return types on Windows and Unix. */
-#ifdef _WIN32
+#if defined(_WIN32)
 static unsigned __stdcall worker_thread(void *thread_func_param)
 static unsigned __stdcall worker_thread(void *thread_func_param)
 {
 {
 	struct worker_thread_args *pwta =
 	struct worker_thread_args *pwta =
@@ -17492,7 +17493,7 @@ master_thread_run(void *thread_func_param)
 
 
 
 
 /* Threads have different return types on Windows and Unix. */
 /* Threads have different return types on Windows and Unix. */
-#ifdef _WIN32
+#if defined(_WIN32)
 static unsigned __stdcall master_thread(void *thread_func_param)
 static unsigned __stdcall master_thread(void *thread_func_param)
 {
 {
 	master_thread_run(thread_func_param);
 	master_thread_run(thread_func_param);
@@ -17573,7 +17574,7 @@ free_context(struct mg_context *ctx)
 		mg_free(tmp_rh);
 		mg_free(tmp_rh);
 	}
 	}
 
 
-#ifndef NO_SSL
+#if !defined(NO_SSL)
 	/* Deallocate SSL context */
 	/* Deallocate SSL context */
 	if (ctx->dd.ssl_ctx != NULL) {
 	if (ctx->dd.ssl_ctx != NULL) {
 		void *ssl_ctx = (void *)ctx->dd.ssl_ctx;
 		void *ssl_ctx = (void *)ctx->dd.ssl_ctx;
@@ -17657,13 +17658,13 @@ get_system_name(char **sysName)
 	DWORD dwBuild = 0;
 	DWORD dwBuild = 0;
 	BOOL wowRet, isWoW = FALSE;
 	BOOL wowRet, isWoW = FALSE;
 
 
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
 #pragma warning(push)
 #pragma warning(push)
 /* GetVersion was declared deprecated */
 /* GetVersion was declared deprecated */
 #pragma warning(disable : 4996)
 #pragma warning(disable : 4996)
 #endif
 #endif
 	dwVersion = GetVersion();
 	dwVersion = GetVersion();
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
 #pragma warning(pop)
 #pragma warning(pop)
 #endif
 #endif
 
 
@@ -18275,13 +18276,13 @@ mg_get_system_info_impl(char *buffer, int buflen)
 
 
 		GetSystemInfo(&si);
 		GetSystemInfo(&si);
 
 
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
 #pragma warning(push)
 #pragma warning(push)
 /* GetVersion was declared deprecated */
 /* GetVersion was declared deprecated */
 #pragma warning(disable : 4996)
 #pragma warning(disable : 4996)
 #endif
 #endif
 		dwVersion = GetVersion();
 		dwVersion = GetVersion();
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
 #pragma warning(pop)
 #pragma warning(pop)
 #endif
 #endif
 
 
@@ -18370,7 +18371,7 @@ mg_get_system_info_impl(char *buffer, int buflen)
 			strcat0(buffer, block);
 			strcat0(buffer, block);
 		}
 		}
 
 
-#ifdef USE_LUA
+#if defined(USE_LUA)
 		mg_snprintf(NULL,
 		mg_snprintf(NULL,
 		            NULL,
 		            NULL,
 		            block,
 		            block,
@@ -18781,7 +18782,7 @@ mg_get_context_info_impl(const struct mg_context *ctx, char *buffer, int buflen)
 #endif
 #endif
 
 
 
 
-#ifdef MG_EXPERIMENTAL_INTERFACES
+#if defined(MG_EXPERIMENTAL_INTERFACES)
 /* Get connection information. It can be printed or stored by the caller.
 /* Get connection information. It can be printed or stored by the caller.
  * Return the size of available information. */
  * Return the size of available information. */
 static int
 static int
@@ -19080,7 +19081,7 @@ mg_get_context_info(const struct mg_context *ctx, char *buffer, int buflen)
 }
 }
 
 
 
 
-#ifdef MG_EXPERIMENTAL_INTERFACES
+#if defined(MG_EXPERIMENTAL_INTERFACES)
 int
 int
 mg_get_connection_info(const struct mg_context *ctx,
 mg_get_connection_info(const struct mg_context *ctx,
                        int idx,
                        int idx,

+ 1 - 1
src/civetweb_private_lua.h

@@ -2,7 +2,7 @@
 /* Project internal header to allow main.c to call a non-public function in
 /* Project internal header to allow main.c to call a non-public function in
  * mod_lua.inl */
  * mod_lua.inl */
 
 
-#ifndef CIVETWEB_PRIVATE_LUA_H
+#if !defined(CIVETWEB_PRIVATE_LUA_H)
 #define CIVETWEB_PRIVATE_LUA_H
 #define CIVETWEB_PRIVATE_LUA_H
 
 
 int run_lua(const char *file_name);
 int run_lua(const char *file_name);

+ 30 - 31
src/main.c

@@ -22,13 +22,13 @@
 
 
 #if defined(_WIN32)
 #if defined(_WIN32)
 
 
-#ifndef _CRT_SECURE_NO_WARNINGS
+#if !defined(_CRT_SECURE_NO_WARNINGS)
 #define _CRT_SECURE_NO_WARNINGS /* Disable deprecation warning in VS2005 */
 #define _CRT_SECURE_NO_WARNINGS /* Disable deprecation warning in VS2005 */
 #endif
 #endif
-#ifndef _CRT_SECURE_NO_DEPRECATE
+#if !defined(_CRT_SECURE_NO_DEPRECATE)
 #define _CRT_SECURE_NO_DEPRECATE
 #define _CRT_SECURE_NO_DEPRECATE
 #endif
 #endif
-#ifdef WIN32_LEAN_AND_MEAN
+#if defined(WIN32_LEAN_AND_MEAN)
 #undef WIN32_LEAN_AND_MEAN /* Required for some functions (tray icons, ...) */
 #undef WIN32_LEAN_AND_MEAN /* Required for some functions (tray icons, ...) */
 #endif
 #endif
 
 
@@ -44,7 +44,7 @@
  */
  */
 #endif
 #endif
 
 
-#ifndef IGNORE_UNUSED_RESULT
+#if !defined(IGNORE_UNUSED_RESULT)
 #define IGNORE_UNUSED_RESULT(a) ((void)((a) && 1))
 #define IGNORE_UNUSED_RESULT(a) ((void)((a) && 1))
 #endif
 #endif
 
 
@@ -59,16 +59,16 @@
 #endif
 #endif
 
 
 /* Use same defines as in civetweb.c before including system headers. */
 /* Use same defines as in civetweb.c before including system headers. */
-#ifndef _LARGEFILE_SOURCE
+#if !defined(_LARGEFILE_SOURCE)
 #define _LARGEFILE_SOURCE /* For fseeko(), ftello() */
 #define _LARGEFILE_SOURCE /* For fseeko(), ftello() */
 #endif
 #endif
-#ifndef _FILE_OFFSET_BITS
+#if !defined(_FILE_OFFSET_BITS)
 #define _FILE_OFFSET_BITS 64 /* Use 64-bit file offsets by default */
 #define _FILE_OFFSET_BITS 64 /* Use 64-bit file offsets by default */
 #endif
 #endif
-#ifndef __STDC_FORMAT_MACROS
+#if !defined(__STDC_FORMAT_MACROS)
 #define __STDC_FORMAT_MACROS /* <inttypes.h> wants this for C++ */
 #define __STDC_FORMAT_MACROS /* <inttypes.h> wants this for C++ */
 #endif
 #endif
-#ifndef __STDC_LIMIT_MACROS
+#if !defined(__STDC_LIMIT_MACROS)
 #define __STDC_LIMIT_MACROS /* C++ wants that for INT64_MAX */
 #define __STDC_LIMIT_MACROS /* C++ wants that for INT64_MAX */
 #endif
 #endif
 
 
@@ -89,9 +89,8 @@
 #define printf                                                                 \
 #define printf                                                                 \
 	DO_NOT_USE_THIS_FUNCTION__USE_fprintf /* Required for unit testing */
 	DO_NOT_USE_THIS_FUNCTION__USE_fprintf /* Required for unit testing */
 
 
-#if defined(_WIN32)                                                            \
-    && !defined(__SYMBIAN32__) /* WINDOWS / UNIX include block */
-#ifndef _WIN32_WINNT
+#if defined(_WIN32) && !defined(__SYMBIAN32__) /* WINDOWS include block */
+#if !defined(_WIN32_WINNT)
 #define _WIN32_WINNT 0x0501 /* for tdm-gcc so we can use getconsolewindow */
 #define _WIN32_WINNT 0x0501 /* for tdm-gcc so we can use getconsolewindow */
 #endif
 #endif
 #undef UNICODE
 #undef UNICODE
@@ -105,11 +104,11 @@
 extern char *_getcwd(char *buf, size_t size);
 extern char *_getcwd(char *buf, size_t size);
 #endif
 #endif
 
 
-#ifndef PATH_MAX
+#if !defined(PATH_MAX)
 #define PATH_MAX MAX_PATH
 #define PATH_MAX MAX_PATH
 #endif
 #endif
 
 
-#ifndef S_ISDIR
+#if !defined(S_ISDIR)
 #define S_ISDIR(x) ((x)&_S_IFDIR)
 #define S_ISDIR(x) ((x)&_S_IFDIR)
 #endif
 #endif
 
 
@@ -155,7 +154,7 @@ extern char *_getcwd(char *buf, size_t size);
 #endif /* DEBUG */
 #endif /* DEBUG */
 #endif
 #endif
 
 
-#ifndef PATH_MAX
+#if !defined(PATH_MAX)
 #define PATH_MAX (1024)
 #define PATH_MAX (1024)
 #endif
 #endif
 
 
@@ -247,7 +246,7 @@ die(const char *fmt, ...)
 }
 }
 
 
 
 
-#ifdef WIN32
+#if defined(WIN32)
 static int MakeConsole(void);
 static int MakeConsole(void);
 #endif
 #endif
 
 
@@ -255,7 +254,7 @@ static int MakeConsole(void);
 static void
 static void
 show_server_name(void)
 show_server_name(void)
 {
 {
-#ifdef WIN32
+#if defined(WIN32)
 	(void)MakeConsole();
 	(void)MakeConsole();
 #endif
 #endif
 
 
@@ -356,7 +355,7 @@ get_url_to_first_open_port(const struct mg_context *ctx)
 }
 }
 
 
 
 
-#ifdef ENABLE_CREATE_CONFIG_FILE
+#if defined(ENABLE_CREATE_CONFIG_FILE)
 static void
 static void
 create_config_file(const struct mg_context *ctx, const char *path)
 create_config_file(const struct mg_context *ctx, const char *path)
 {
 {
@@ -780,7 +779,7 @@ process_command_line_arguments(int argc, char *argv[], char **options)
 {
 {
 	char *p;
 	char *p;
 	size_t i, cmd_line_opts_start = 1;
 	size_t i, cmd_line_opts_start = 1;
-#ifdef CONFIG_FILE2
+#if defined(CONFIG_FILE2)
 	FILE *fp = NULL;
 	FILE *fp = NULL;
 #endif
 #endif
 
 
@@ -813,7 +812,7 @@ process_command_line_arguments(int argc, char *argv[], char **options)
 	}
 	}
 	g_config_file_name[sizeof(g_config_file_name) - 1] = 0;
 	g_config_file_name[sizeof(g_config_file_name) - 1] = 0;
 
 
-#ifdef CONFIG_FILE2
+#if defined(CONFIG_FILE2)
 	fp = fopen(g_config_file_name, "r");
 	fp = fopen(g_config_file_name, "r");
 
 
 	/* try alternate config file */
 	/* try alternate config file */
@@ -919,7 +918,7 @@ log_message(const struct mg_connection *conn, const char *message)
 static int
 static int
 is_path_absolute(const char *path)
 is_path_absolute(const char *path)
 {
 {
-#ifdef _WIN32
+#if defined(_WIN32)
 	return path != NULL
 	return path != NULL
 	       && ((path[0] == '\\' && path[1] == '\\') || /* UNC path, e.g.
 	       && ((path[0] == '\\' && path[1] == '\\') || /* UNC path, e.g.
 	                                                      \\server\dir */
 	                                                      \\server\dir */
@@ -937,7 +936,7 @@ verify_existence(char **options, const char *option_name, int must_be_dir)
 	struct stat st;
 	struct stat st;
 	const char *path = get_option(options, option_name);
 	const char *path = get_option(options, option_name);
 
 
-#ifdef _WIN32
+#if defined(_WIN32)
 	wchar_t wbuf[1024];
 	wchar_t wbuf[1024];
 	char mbbuf[1024];
 	char mbbuf[1024];
 	int len;
 	int len;
@@ -1007,14 +1006,14 @@ set_absolute_path(char *options[],
 }
 }
 
 
 
 
-#ifdef USE_LUA
+#if defined(USE_LUA)
 
 
 #include "civetweb_private_lua.h"
 #include "civetweb_private_lua.h"
 
 
 #endif
 #endif
 
 
 
 
-#ifdef USE_DUKTAPE
+#if defined(USE_DUKTAPE)
 
 
 #include "duktape.h"
 #include "duktape.h"
 
 
@@ -1200,7 +1199,7 @@ sanitize_options(char *options[] /* server options */,
 	set_absolute_path(options, "access_log_file", arg0);
 	set_absolute_path(options, "access_log_file", arg0);
 	set_absolute_path(options, "error_log_file", arg0);
 	set_absolute_path(options, "error_log_file", arg0);
 	set_absolute_path(options, "global_auth_file", arg0);
 	set_absolute_path(options, "global_auth_file", arg0);
-#ifdef USE_LUA
+#if defined(USE_LUA)
 	set_absolute_path(options, "lua_preload_file", arg0);
 	set_absolute_path(options, "lua_preload_file", arg0);
 #endif
 #endif
 	set_absolute_path(options, "ssl_certificate", arg0);
 	set_absolute_path(options, "ssl_certificate", arg0);
@@ -1211,7 +1210,7 @@ sanitize_options(char *options[] /* server options */,
 	verify_existence(options, "ssl_certificate", 0);
 	verify_existence(options, "ssl_certificate", 0);
 	verify_existence(options, "ssl_ca_path", 1);
 	verify_existence(options, "ssl_ca_path", 1);
 	verify_existence(options, "ssl_ca_file", 0);
 	verify_existence(options, "ssl_ca_file", 0);
-#ifdef USE_LUA
+#if defined(USE_LUA)
 	verify_existence(options, "lua_preload_file", 0);
 	verify_existence(options, "lua_preload_file", 0);
 #endif
 #endif
 }
 }
@@ -1229,7 +1228,7 @@ start_civetweb(int argc, char *argv[])
 	 * This is very useful for diagnosis. */
 	 * This is very useful for diagnosis. */
 	if (argc > 1 && !strcmp(argv[1], "-I")) {
 	if (argc > 1 && !strcmp(argv[1], "-I")) {
 
 
-#ifdef WIN32
+#if defined(WIN32)
 		(void)MakeConsole();
 		(void)MakeConsole();
 #endif
 #endif
 		fprintf(stdout,
 		fprintf(stdout,
@@ -1275,11 +1274,11 @@ start_civetweb(int argc, char *argv[])
 	 * is specified */
 	 * is specified */
 	if (argc > 1 && !strcmp(argv[1], "-L")) {
 	if (argc > 1 && !strcmp(argv[1], "-L")) {
 
 
-#ifdef USE_LUA
+#if defined(USE_LUA)
 		if (argc != 3) {
 		if (argc != 3) {
 			show_usage_and_exit(argv[0]);
 			show_usage_and_exit(argv[0]);
 		}
 		}
-#ifdef WIN32
+#if defined(WIN32)
 		(void)MakeConsole();
 		(void)MakeConsole();
 #endif
 #endif
 		exit(run_lua(argv[2]));
 		exit(run_lua(argv[2]));
@@ -1293,11 +1292,11 @@ start_civetweb(int argc, char *argv[])
 	/* Call Duktape, if -E option is specified */
 	/* Call Duktape, if -E option is specified */
 	if (argc > 1 && !strcmp(argv[1], "-E")) {
 	if (argc > 1 && !strcmp(argv[1], "-E")) {
 
 
-#ifdef USE_DUKTAPE
+#if defined(USE_DUKTAPE)
 		if (argc != 3) {
 		if (argc != 3) {
 			show_usage_and_exit(argv[0]);
 			show_usage_and_exit(argv[0]);
 		}
 		}
-#ifdef WIN32
+#if defined(WIN32)
 		(void)MakeConsole();
 		(void)MakeConsole();
 #endif
 #endif
 		exit(run_duktape(argv[2]));
 		exit(run_duktape(argv[2]));
@@ -1388,7 +1387,7 @@ stop_civetweb(void)
 }
 }
 
 
 
 
-#ifdef _WIN32
+#if defined(_WIN32)
 /* Win32 has a small GUI.
 /* Win32 has a small GUI.
  * Define some GUI elements and Windows message handlers. */
  * Define some GUI elements and Windows message handlers. */
 
 

+ 5 - 5
src/md5.inl

@@ -34,7 +34,7 @@
   1999-05-03 lpd Original version.
   1999-05-03 lpd Original version.
  */
  */
 
 
-#ifndef md5_INCLUDED
+#if !defined(md5_INCLUDED)
 #define md5_INCLUDED
 #define md5_INCLUDED
 
 
 /*
 /*
@@ -57,7 +57,7 @@ typedef struct md5_state_s {
 	md5_byte_t buf[64];  /* accumulate block */
 	md5_byte_t buf[64];  /* accumulate block */
 } md5_state_t;
 } md5_state_t;
 
 
-#ifdef __cplusplus
+#if defined(__cplusplus)
 extern "C" {
 extern "C" {
 #endif
 #endif
 
 
@@ -71,7 +71,7 @@ md5_append(md5_state_t *pms, const md5_byte_t *data, size_t nbytes);
 /* Finish the message and return the digest. */
 /* Finish the message and return the digest. */
 MD5_STATIC void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
 MD5_STATIC void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
 
 
-#ifdef __cplusplus
+#if defined(__cplusplus)
 } /* end extern "C" */
 } /* end extern "C" */
 #endif
 #endif
 
 
@@ -130,12 +130,12 @@ MD5_STATIC void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
   1999-05-03 lpd Original version.
   1999-05-03 lpd Original version.
  */
  */
 
 
-#ifndef MD5_STATIC
+#if !defined(MD5_STATIC)
 #include <string.h>
 #include <string.h>
 #endif
 #endif
 
 
 #undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */
 #undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */
-#ifdef ARCH_IS_BIG_ENDIAN
+#if defined(ARCH_IS_BIG_ENDIAN)
 #define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1)
 #define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1)
 #else
 #else
 #define BYTE_ORDER (0)
 #define BYTE_ORDER (0)

+ 10 - 10
src/mod_lua.inl

@@ -5,7 +5,7 @@
 #include "civetweb_lua.h"
 #include "civetweb_lua.h"
 #include "civetweb_private_lua.h"
 #include "civetweb_private_lua.h"
 
 
-#ifdef _WIN32
+#if defined(_WIN32)
 static void *
 static void *
 mmap(void *addr, int64_t len, int prot, int flags, int fd, int offset)
 mmap(void *addr, int64_t len, int prot, int flags, int fd, int offset)
 {
 {
@@ -51,7 +51,7 @@ static const char lua_regkey_connlist = 2;
 static const char lua_regkey_lsp_include_history = 3;
 static const char lua_regkey_lsp_include_history = 3;
 static const char *LUABACKGROUNDPARAMS = "mg";
 static const char *LUABACKGROUNDPARAMS = "mg";
 
 
-#ifndef LSP_INCLUDE_MAX_DEPTH
+#if !defined(LSP_INCLUDE_MAX_DEPTH)
 #define LSP_INCLUDE_MAX_DEPTH (32)
 #define LSP_INCLUDE_MAX_DEPTH (32)
 #endif
 #endif
 
 
@@ -1196,7 +1196,7 @@ lsp_get_info(lua_State *L)
 				/* Lua uses 1 based index, C uses 0 based index */
 				/* Lua uses 1 based index, C uses 0 based index */
 				idx--;
 				idx--;
 
 
-#ifdef MG_EXPERIMENTAL_INTERFACES
+#if defined(MG_EXPERIMENTAL_INTERFACES)
 				len = mg_get_connection_info(ctx, idx, NULL, 0);
 				len = mg_get_connection_info(ctx, idx, NULL, 0);
 				if (len > 0) {
 				if (len > 0) {
 					buf = (char *)mg_malloc(len + 64);
 					buf = (char *)mg_malloc(len + 64);
@@ -1339,7 +1339,7 @@ lsp_uuid(lua_State *L)
 }
 }
 
 
 
 
-#ifdef USE_WEBSOCKET
+#if defined(USE_WEBSOCKET)
 struct lua_websock_data {
 struct lua_websock_data {
 	lua_State *state;
 	lua_State *state;
 	char *script;
 	char *script;
@@ -1354,7 +1354,7 @@ struct lua_websock_data {
 static int
 static int
 lwebsock_write(lua_State *L)
 lwebsock_write(lua_State *L)
 {
 {
-#ifdef USE_WEBSOCKET
+#if defined(USE_WEBSOCKET)
 	int num_args = lua_gettop(L);
 	int num_args = lua_gettop(L);
 	struct lua_websock_data *ws;
 	struct lua_websock_data *ws;
 	const char *str;
 	const char *str;
@@ -1677,19 +1677,19 @@ civetweb_open_lua_libs(lua_State *L)
 		luaL_openlibs(L);
 		luaL_openlibs(L);
 	}
 	}
 
 
-#ifdef USE_LUA_SQLITE3
+#if defined(USE_LUA_SQLITE3)
 	{
 	{
 		extern int luaopen_lsqlite3(lua_State *);
 		extern int luaopen_lsqlite3(lua_State *);
 		luaopen_lsqlite3(L);
 		luaopen_lsqlite3(L);
 	}
 	}
 #endif
 #endif
-#ifdef USE_LUA_LUAXML
+#if defined(USE_LUA_LUAXML)
 	{
 	{
 		extern int luaopen_LuaXML_lib(lua_State *);
 		extern int luaopen_LuaXML_lib(lua_State *);
 		luaopen_LuaXML_lib(L);
 		luaopen_LuaXML_lib(L);
 	}
 	}
 #endif
 #endif
-#ifdef USE_LUA_FILE_SYSTEM
+#if defined(USE_LUA_FILE_SYSTEM)
 	{
 	{
 		extern int luaopen_lfs(lua_State *);
 		extern int luaopen_lfs(lua_State *);
 		luaopen_lfs(L);
 		luaopen_lfs(L);
@@ -1777,7 +1777,7 @@ prepare_lua_environment(struct mg_context *ctx,
 
 
 	if (lua_env_type == LUA_ENV_TYPE_LUA_WEBSOCKET) {
 	if (lua_env_type == LUA_ENV_TYPE_LUA_WEBSOCKET) {
 		reg_function(L, "write", lwebsock_write);
 		reg_function(L, "write", lwebsock_write);
-#ifdef USE_TIMERS
+#if defined(USE_TIMERS)
 		reg_function(L, "set_timeout", lwebsocket_set_timeout);
 		reg_function(L, "set_timeout", lwebsocket_set_timeout);
 		reg_function(L, "set_interval", lwebsocket_set_interval);
 		reg_function(L, "set_interval", lwebsocket_set_interval);
 #endif
 #endif
@@ -2061,7 +2061,7 @@ cleanup_handle_lsp_request:
 }
 }
 
 
 
 
-#ifdef USE_WEBSOCKET
+#if defined(USE_WEBSOCKET)
 struct mg_shared_lua_websocket_list {
 struct mg_shared_lua_websocket_list {
 	struct lua_websock_data ws;
 	struct lua_websock_data ws;
 	struct mg_shared_lua_websocket_list *next;
 	struct mg_shared_lua_websocket_list *next;

+ 2 - 2
src/timer.inl

@@ -158,7 +158,7 @@ timer_thread_run(void *thread_func_param)
  * A faster loop (smaller sleep value) increases CPU load,
  * A faster loop (smaller sleep value) increases CPU load,
  * a slower loop (higher sleep value) decreases timer accuracy.
  * a slower loop (higher sleep value) decreases timer accuracy.
  */
  */
-#ifdef _WIN32
+#if defined(_WIN32)
 		Sleep(10);
 		Sleep(10);
 #else
 #else
 		usleep(10000);
 		usleep(10000);
@@ -173,7 +173,7 @@ timer_thread_run(void *thread_func_param)
 }
 }
 
 
 
 
-#ifdef _WIN32
+#if defined(_WIN32)
 static unsigned __stdcall timer_thread(void *thread_func_param)
 static unsigned __stdcall timer_thread(void *thread_func_param)
 {
 {
 	timer_thread_run(thread_func_param);
 	timer_thread_run(thread_func_param);