Sfoglia il codice sorgente

Format code (with clang-format 6.0)

Update clang-format to 6.0.0-1ubuntu2 (Ubuntu 18.04.1 LTS)

New clang version sorts #include directives, indents preprocessor
defines and handles length "if" conditions more effectively.
bel2125 6 anni fa
parent
commit
fc274f5530

+ 4 - 0
.clang-format

@@ -24,9 +24,13 @@ BreakBeforeBraces: Linux
 DerivePointerAlignment: false
 MaxEmptyLinesToKeep: 2
 PenaltyBreakBeforeFirstCallParameter: 100
+ReflowComments: true
 
 SpaceBeforeParens: ControlStatements
 SpaceInEmptyParentheses: false
 SpacesInSquareBrackets: false
 
+IndentPPDirectives: AfterHash
+IncludeBlocks: Regroup
+
 DisableFormat: false

+ 37 - 37
examples/embedded_c/embedded_c.c

@@ -1,36 +1,36 @@
 /*
-* Copyright (c) 2013-2017 the CivetWeb developers
-* Copyright (c) 2013 No Face Press, LLC
-* License http://opensource.org/licenses/mit-license.php MIT License
-*/
+ * Copyright (c) 2013-2017 the CivetWeb developers
+ * Copyright (c) 2013 No Face Press, LLC
+ * License http://opensource.org/licenses/mit-license.php MIT License
+ */
 
 /* Simple example program on how to use CivetWeb embedded into a C program. */
 #ifdef _WIN32
-#include <windows.h>
+#	include <windows.h>
 #else
-#include <unistd.h>
+#	include <unistd.h>
 #endif
 
+#include "civetweb.h"
+
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
 
-#include "civetweb.h"
-
 
 #define DOCUMENT_ROOT "."
 #ifdef NO_SSL
-#ifdef USE_IPV6
-#define PORT "[::]:8888,8884"
-#else
-#define PORT "8888,8884"
-#endif
-#else
-#ifdef USE_IPV6
-#define PORT "[::]:8888r,[::]:8843s,8884"
+#	ifdef USE_IPV6
+#		define PORT "[::]:8888,8884"
+#	else
+#		define PORT "8888,8884"
+#	endif
 #else
-#define PORT "8888r,8843s,8884"
-#endif
+#	ifdef USE_IPV6
+#		define PORT "[::]:8888r,[::]:8843s,8884"
+#	else
+#		define PORT "8888r,8843s,8884"
+#	endif
 #endif
 #define EXAMPLE_URI "/example"
 #define EXIT_URI "/exit"
@@ -648,7 +648,7 @@ WebSocketStartHandler(struct mg_connection *conn, void *cbdata)
  * it can be easily tested to connect more than MAX_WS_CLIENTS clients.
  * A real server should use a much higher number, or better use a dynamic list
  * of currently connected websocket clients. */
-#define MAX_WS_CLIENTS (5)
+#	define MAX_WS_CLIENTS (5)
 
 struct t_ws_client {
 	struct mg_connection *conn;
@@ -656,14 +656,14 @@ struct t_ws_client {
 } static ws_clients[MAX_WS_CLIENTS];
 
 
-#define ASSERT(x)                                                              \
-	{                                                                          \
-		if (!(x)) {                                                            \
-			fprintf(stderr,                                                    \
-			        "Assertion failed in line %u\n",                           \
-			        (unsigned)__LINE__);                                       \
-		}                                                                      \
-	}
+#	define ASSERT(x)                                                          \
+		{                                                                      \
+			if (!(x)) {                                                        \
+				fprintf(stderr,                                                \
+				        "Assertion failed in line %u\n",                       \
+				        (unsigned)__LINE__);                                   \
+			}                                                                  \
+		}
 
 
 int
@@ -793,11 +793,11 @@ InformWebsockets(struct mg_context *ctx)
 
 
 #ifdef USE_SSL_DH
-#include "openssl/ssl.h"
-#include "openssl/dh.h"
-#include "openssl/ec.h"
-#include "openssl/evp.h"
-#include "openssl/ecdsa.h"
+#	include "openssl/dh.h"
+#	include "openssl/ec.h"
+#	include "openssl/ecdsa.h"
+#	include "openssl/evp.h"
+#	include "openssl/ssl.h"
 
 DH *
 get_dh2236()
@@ -853,7 +853,7 @@ init_ssl(void *ssl_context, void *user_data)
 	/* Add application specific SSL initialization */
 	struct ssl_ctx_st *ctx = (struct ssl_ctx_st *)ssl_context;
 
-#ifdef USE_SSL_DH
+#	ifdef USE_SSL_DH
 	/* example from https://github.com/civetweb/civetweb/issues/347 */
 	DH *dh = get_dh2236();
 	if (!dh)
@@ -870,7 +870,7 @@ init_ssl(void *ssl_context, void *user_data)
 	EC_KEY_free(ecdh);
 
 	printf("ECDH ciphers initialized\n");
-#endif
+#	endif
 	return 0;
 }
 #endif
@@ -906,11 +906,11 @@ main(int argc, char *argv[])
 	    "ssl_protocol_version",
 	    "3",
 	    "ssl_cipher_list",
-#ifdef USE_SSL_DH
+#	ifdef USE_SSL_DH
 	    "ECDHE-RSA-AES256-GCM-SHA384:DES-CBC3-SHA:AES128-SHA:AES128-GCM-SHA256",
-#else
+#	else
 	    "DES-CBC3-SHA:AES128-SHA:AES128-GCM-SHA256",
-#endif
+#	endif
 #endif
 	    "enable_auth_domain_check",
 	    "no",

+ 12 - 12
examples/rest/rest.c

@@ -1,29 +1,29 @@
 /*
-* Copyright (c) 2018 the CivetWeb developers
-* MIT License
-*/
+ * Copyright (c) 2018 the CivetWeb developers
+ * MIT License
+ */
 
 /* Simple demo of a REST callback. */
 #ifdef _WIN32
-#include <windows.h>
+#	include <windows.h>
 #else
-#include <unistd.h>
+#	include <unistd.h>
 #endif
 
+#include "cJSON.h"
+#include "civetweb.h"
+
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
 
-#include "civetweb.h"
-#include "cJSON.h"
-
 
 #ifdef NO_SSL
-#define PORT "8089"
-#define HOST_INFO "http://localhost:8089"
+#	define PORT "8089"
+#	define HOST_INFO "http://localhost:8089"
 #else
-#define PORT "8089r,8843s"
-#define HOST_INFO "https://localhost:8843"
+#	define PORT "8089r,8843s"
+#	define HOST_INFO "https://localhost:8843"
 #endif
 
 #define EXAMPLE_URI "/example"

+ 8 - 7
include/CivetServer.h

@@ -8,11 +8,12 @@
 #define _CIVETWEB_SERVER_H_
 #ifdef __cplusplus
 
-#include "civetweb.h"
-#include <map>
-#include <string>
-#include <vector>
-#include <stdexcept>
+#	include "civetweb.h"
+
+#	include <map>
+#	include <stdexcept>
+#	include <string>
+#	include <vector>
 
 // forward declaration
 class CivetServer;
@@ -363,7 +364,7 @@ class CIVETWEB_API CivetServer
 	 * @param cookieName - cookie name to get the value from
 	 * @param cookieValue - cookie value is returned using thiis reference
 	 * @returns the size of the cookie value string read.
-	*/
+	 */
 	static int getCookie(struct mg_connection *conn,
 	                     const std::string &cookieName,
 	                     std::string &cookieValue);
@@ -373,7 +374,7 @@ class CIVETWEB_API CivetServer
 	 * @param conn - the connection information
 	 * @param headerName - header name to get the value from
 	 * @returns a char array which contains the header value as string
-	*/
+	 */
 	static const char *getHeader(struct mg_connection *conn,
 	                             const std::string &headerName);
 

+ 33 - 31
include/civetweb.h

@@ -29,23 +29,23 @@
 #define CIVETWEB_VERSION_PATCH (0)
 
 #ifndef CIVETWEB_API
-#if defined(_WIN32)
-#if defined(CIVETWEB_DLL_EXPORTS)
-#define CIVETWEB_API __declspec(dllexport)
-#elif defined(CIVETWEB_DLL_IMPORTS)
-#define CIVETWEB_API __declspec(dllimport)
-#else
-#define CIVETWEB_API
-#endif
-#elif __GNUC__ >= 4
-#define CIVETWEB_API __attribute__((visibility("default")))
-#else
-#define CIVETWEB_API
-#endif
+#	if defined(_WIN32)
+#		if defined(CIVETWEB_DLL_EXPORTS)
+#			define CIVETWEB_API __declspec(dllexport)
+#		elif defined(CIVETWEB_DLL_IMPORTS)
+#			define CIVETWEB_API __declspec(dllimport)
+#		else
+#			define CIVETWEB_API
+#		endif
+#	elif __GNUC__ >= 4
+#		define CIVETWEB_API __attribute__((visibility("default")))
+#	else
+#		define CIVETWEB_API
+#	endif
 #endif
 
-#include <stdio.h>
 #include <stddef.h>
+#include <stdio.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -705,8 +705,10 @@ CIVETWEB_API int mg_get_server_ports(const struct mg_context *ctx,
 
 #if defined(MG_LEGACY_INTERFACE) /* 2017-04-02 */
 /* Deprecated: Use mg_get_server_ports instead. */
-CIVETWEB_API size_t
-mg_get_ports(const struct mg_context *ctx, size_t size, int *ports, int *ssl);
+CIVETWEB_API size_t mg_get_ports(const struct mg_context *ctx,
+                                 size_t size,
+                                 int *ports,
+                                 int *ssl);
 #endif
 
 
@@ -807,8 +809,8 @@ CIVETWEB_API void mg_unlock_connection(struct mg_connection *conn);
 
 
 #if defined(MG_LEGACY_INTERFACE) /* 2014-06-21 */
-#define mg_lock mg_lock_connection
-#define mg_unlock mg_unlock_connection
+#	define mg_lock mg_lock_connection
+#	define mg_unlock mg_unlock_connection
 #endif
 
 
@@ -843,20 +845,20 @@ enum {
 /* Macros for enabling compiler-specific checks for printf-like arguments. */
 #undef PRINTF_FORMAT_STRING
 #if defined(_MSC_VER) && _MSC_VER >= 1400
-#include <sal.h>
-#if defined(_MSC_VER) && _MSC_VER > 1400
-#define PRINTF_FORMAT_STRING(s) _Printf_format_string_ s
-#else
-#define PRINTF_FORMAT_STRING(s) __format_string s
-#endif
+#	include <sal.h>
+#	if defined(_MSC_VER) && _MSC_VER > 1400
+#		define PRINTF_FORMAT_STRING(s) _Printf_format_string_ s
+#	else
+#		define PRINTF_FORMAT_STRING(s) __format_string s
+#	endif
 #else
-#define PRINTF_FORMAT_STRING(s) s
+#	define PRINTF_FORMAT_STRING(s) s
 #endif
 
 #ifdef __GNUC__
-#define PRINTF_ARGS(x, y) __attribute__((format(printf, x, y)))
+#	define PRINTF_ARGS(x, y) __attribute__((format(printf, x, y)))
 #else
-#define PRINTF_ARGS(x, y)
+#	define PRINTF_ARGS(x, y)
 #endif
 
 
@@ -893,7 +895,7 @@ CIVETWEB_API void mg_send_file(struct mg_connection *conn, const char *path);
  *
  * Return:
  *   < 0   Error
-*/
+ */
 CIVETWEB_API int mg_send_file_body(struct mg_connection *conn,
                                    const char *path);
 
@@ -1220,7 +1222,7 @@ struct mg_form_data_handler {
 #if defined(MG_LEGACY_INTERFACE) /* 2017-10-05 */
 enum {
 	/* Skip this field (neither get nor store it). Continue with the
-     * next field. */
+	 * next field. */
 	FORM_FIELD_STORAGE_SKIP = 0x0,
 	/* Get the field value. */
 	FORM_FIELD_STORAGE_GET = 0x1,
@@ -1233,7 +1235,7 @@ enum {
 /* New nomenclature */
 enum {
 	/* Skip this field (neither get nor store it). Continue with the
-     * next field. */
+	 * next field. */
 	MG_FORM_FIELD_STORAGE_SKIP = 0x0,
 	/* Get the field value. */
 	MG_FORM_FIELD_STORAGE_GET = 0x1,
@@ -1246,7 +1248,7 @@ enum {
 /* Return values for "field_get" and "field_store" */
 enum {
 	/* Only "field_get": If there is more data in this field, get the next
-     * chunk. Otherwise: handle the next field. */
+	 * chunk. Otherwise: handle the next field. */
 	MG_FORM_FIELD_HANDLE_GET = 0x1,
 	/* Handle the next field */
 	MG_FORM_FIELD_HANDLE_NEXT = 0x8,

+ 4 - 4
src/CivetServer.cpp

@@ -6,18 +6,18 @@
 
 #include "CivetServer.h"
 
-#include <stdlib.h>
-#include <string.h>
 #include <assert.h>
 #include <stdexcept>
+#include <stdlib.h>
+#include <string.h>
 
 #ifndef UNUSED_PARAMETER
-#define UNUSED_PARAMETER(x) (void)(x)
+#	define UNUSED_PARAMETER(x) (void)(x)
 #endif
 
 #ifndef MAX_PARAM_BODY_LENGTH
 // Set a default limit for parameters in a form body: 2 MB
-#define MAX_PARAM_BODY_LENGTH (1024 * 1024 * 2)
+#	define MAX_PARAM_BODY_LENGTH (1024 * 1024 * 2)
 #endif
 
 bool

File diff suppressed because it is too large
+ 345 - 339
src/civetweb.c


+ 1 - 2
src/civetweb_private_lua.h

@@ -3,9 +3,8 @@
  * mod_lua.inl */
 
 #if !defined(CIVETWEB_PRIVATE_LUA_H)
-#define CIVETWEB_PRIVATE_LUA_H
+#	define CIVETWEB_PRIVATE_LUA_H
 
 int run_lua(const char *file_name);
 
-
 #endif

+ 153 - 148
src/main.c

@@ -18,23 +18,25 @@
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
-*/
+ */
 
 #if defined(_WIN32)
 
-#if !defined(_CRT_SECURE_NO_WARNINGS)
-#define _CRT_SECURE_NO_WARNINGS /* Disable deprecation warning in VS2005 */
-#endif
-#if !defined(_CRT_SECURE_NO_DEPRECATE)
-#define _CRT_SECURE_NO_DEPRECATE
-#endif
-#if defined(WIN32_LEAN_AND_MEAN)
-#undef WIN32_LEAN_AND_MEAN /* Required for some functions (tray icons, ...) */
-#endif
+#	if !defined(_CRT_SECURE_NO_WARNINGS)
+#		define _CRT_SECURE_NO_WARNINGS /* Disable deprecation warning in      \
+		                                    VS2005 */
+#	endif
+#	if !defined(_CRT_SECURE_NO_DEPRECATE)
+#		define _CRT_SECURE_NO_DEPRECATE
+#	endif
+#	if defined(WIN32_LEAN_AND_MEAN)
+#		undef WIN32_LEAN_AND_MEAN /* Required for some functions (tray icons, \
+		                               ...) */
+#	endif
 
 #else
 
-#define _XOPEN_SOURCE 600 /* For PATH_MAX on linux */
+#	define _XOPEN_SOURCE 600 /* For PATH_MAX on linux */
 /* This should also be sufficient for "realpath", according to
  * http://man7.org/linux/man-pages/man3/realpath.3.html, but in
  * reality it does not seem to work. */
@@ -45,118 +47,119 @@
 #endif
 
 #if !defined(IGNORE_UNUSED_RESULT)
-#define IGNORE_UNUSED_RESULT(a) ((void)((a) && 1))
+#	define IGNORE_UNUSED_RESULT(a) ((void)((a) && 1))
 #endif
 
 #if defined(__cplusplus) && (__cplusplus >= 201103L)
-#define NO_RETURN [[noreturn]]
+#	define NO_RETURN [[noreturn]]
 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
-#define NO_RETURN _Noreturn
+#	define NO_RETURN _Noreturn
 #elif defined(__GNUC__)
-#define NO_RETURN __attribute((noreturn))
+#	define NO_RETURN __attribute((noreturn))
 #else
-#define NO_RETURN
+#	define NO_RETURN
 #endif
 
 /* Use same defines as in civetweb.c before including system headers. */
 #if !defined(_LARGEFILE_SOURCE)
-#define _LARGEFILE_SOURCE /* For fseeko(), ftello() */
+#	define _LARGEFILE_SOURCE /* For fseeko(), ftello() */
 #endif
 #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
 #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
 #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
 
-#include <string.h>
+#include "civetweb.h"
+
+#include <ctype.h>
 #include <errno.h>
-#include <sys/stat.h>
-#include <stdio.h>
-#include <stdint.h>
 #include <limits.h>
-#include <stdlib.h>
 #include <signal.h>
-#include <stddef.h>
 #include <stdarg.h>
-#include <ctype.h>
-
-#include "civetweb.h"
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
 
 #undef printf
 #define printf                                                                 \
 	DO_NOT_USE_THIS_FUNCTION__USE_fprintf /* Required for unit testing */
 
 #if defined(_WIN32) && !defined(__SYMBIAN32__) /* WINDOWS include block */
-#if !defined(_WIN32_WINNT)
-#define _WIN32_WINNT 0x0501 /* for tdm-gcc so we can use getconsolewindow */
-#endif
-#undef UNICODE
-#include <windows.h>
-#include <winsvc.h>
-#include <shlobj.h>
-#include <io.h>
-
-#define getcwd(a, b) (_getcwd(a, b))
-#if !defined(__MINGW32__)
+#	if !defined(_WIN32_WINNT)
+#		define _WIN32_WINNT                                                   \
+			0x0501 /* for tdm-gcc so we can use getconsolewindow */
+#	endif
+#	undef UNICODE
+#	include <io.h>
+#	include <shlobj.h>
+#	include <windows.h>
+#	include <winsvc.h>
+
+#	define getcwd(a, b) (_getcwd(a, b))
+#	if !defined(__MINGW32__)
 extern char *_getcwd(char *buf, size_t size);
-#endif
+#	endif
 
-#if !defined(PATH_MAX)
-#define PATH_MAX MAX_PATH
-#endif
+#	if !defined(PATH_MAX)
+#		define PATH_MAX MAX_PATH
+#	endif
 
-#if !defined(S_ISDIR)
-#define S_ISDIR(x) ((x)&_S_IFDIR)
-#endif
+#	if !defined(S_ISDIR)
+#		define S_ISDIR(x) ((x)&_S_IFDIR)
+#	endif
 
-#define DIRSEP '\\'
-#define snprintf _snprintf
-#define vsnprintf _vsnprintf
-#define sleep(x) (Sleep((x)*1000))
-#define WINCDECL __cdecl
-#define abs_path(rel, abs, abs_size) (_fullpath((abs), (rel), (abs_size)))
+#	define DIRSEP '\\'
+#	define snprintf _snprintf
+#	define vsnprintf _vsnprintf
+#	define sleep(x) (Sleep((x)*1000))
+#	define WINCDECL __cdecl
+#	define abs_path(rel, abs, abs_size) (_fullpath((abs), (rel), (abs_size)))
 
 #else /* defined(_WIN32) && !defined(__SYMBIAN32__) - WINDOWS / UNIX include   \
          block */
 
-#include <unistd.h>
-#include <sys/utsname.h>
-#include <sys/wait.h>
+#	include <sys/utsname.h>
+#	include <sys/wait.h>
+#	include <unistd.h>
 
-#define DIRSEP '/'
-#define WINCDECL
-#define abs_path(rel, abs, abs_size) (realpath((rel), (abs)))
+#	define DIRSEP '/'
+#	define WINCDECL
+#	define abs_path(rel, abs, abs_size) (realpath((rel), (abs)))
 
 #endif /* defined(_WIN32) && !defined(__SYMBIAN32__) - WINDOWS / UNIX include  \
           block */
 
 #if !defined(DEBUG_ASSERT)
-#if defined(DEBUG)
+#	if defined(DEBUG)
 
-#if defined(_MSC_VER)
+#		if defined(_MSC_VER)
 /* DEBUG_ASSERT has some const conditions */
-#pragma warning(disable : 4127)
-#endif
-
-#define DEBUG_ASSERT(cond)                                                     \
-	do {                                                                       \
-		if (!(cond)) {                                                         \
-			fprintf(stderr, "ASSERTION FAILED: %s", #cond);                    \
-			exit(2); /* Exit with error */                                     \
-		}                                                                      \
-	} while (0)
-
-#else
-#define DEBUG_ASSERT(cond)
-#endif /* DEBUG */
+#			pragma warning(disable : 4127)
+#		endif
+
+#		define DEBUG_ASSERT(cond)                                             \
+			do {                                                               \
+				if (!(cond)) {                                                 \
+					fprintf(stderr, "ASSERTION FAILED: %s", #cond);            \
+					exit(2); /* Exit with error */                             \
+				}                                                              \
+			} while (0)
+
+#	else
+#		define DEBUG_ASSERT(cond)
+#	endif /* DEBUG */
 #endif
 
 #if !defined(PATH_MAX)
-#define PATH_MAX (1024)
+#	define PATH_MAX (1024)
 #endif
 
 #define MAX_OPTIONS (50)
@@ -182,25 +185,26 @@ static const char **g_add_domain; /* Default from init_server_name,
                                    * updated later from the server config */
 
 
-static char *g_system_info;                    /* Set by init_system_info() */
-static char g_config_file_name[PATH_MAX] = ""; /* Set by
-                                     *  process_command_line_arguments() */
+static char *g_system_info; /* Set by init_system_info() */
+static char g_config_file_name[PATH_MAX] =
+    ""; /* Set by
+         *  process_command_line_arguments() */
 
 static struct mg_context *g_ctx; /* Set by start_civetweb() */
 static struct tuser_data
     g_user_data; /* Passed to mg_start() by start_civetweb() */
 
 #if !defined(CONFIG_FILE)
-#define CONFIG_FILE "civetweb.conf"
+#	define CONFIG_FILE "civetweb.conf"
 #endif /* !CONFIG_FILE */
 
 #if !defined(PASSWORDS_FILE_NAME)
-#define PASSWORDS_FILE_NAME ".htpasswd"
+#	define PASSWORDS_FILE_NAME ".htpasswd"
 #endif
 
 /* backup config file */
 #if !defined(CONFIG_FILE2) && defined(__linux__)
-#define CONFIG_FILE2 "/usr/local/etc/civetweb.conf"
+#	define CONFIG_FILE2 "/usr/local/etc/civetweb.conf"
 #endif
 
 enum {
@@ -356,7 +360,7 @@ get_url_to_first_open_port(const struct mg_context *ctx)
 }
 
 
-#if defined(ENABLE_CREATE_CONFIG_FILE)
+#	if defined(ENABLE_CREATE_CONFIG_FILE)
 static void
 create_config_file(const struct mg_context *ctx, const char *path)
 {
@@ -381,7 +385,7 @@ create_config_file(const struct mg_context *ctx, const char *path)
 		fclose(fp);
 	}
 }
-#endif
+#	endif
 #endif
 
 
@@ -739,7 +743,7 @@ read_config_file(const char *config_file, char **options)
 
 		/* Skip spaces, \r and \n at the end of the line */
 		for (j = strlen(line) - 1; isspace(*(unsigned char *)&line[j])
-		                               || iscntrl(*(unsigned char *)&line[j]);)
+		                           || iscntrl(*(unsigned char *)&line[j]);)
 			line[j--] = 0;
 
 		/* Find the space character between option name and value */
@@ -951,8 +955,9 @@ verify_existence(char **options, const char *option_name, int must_be_dir)
 	}
 #endif
 
-	if (path != NULL && (stat(path, &st) != 0
-	                     || ((S_ISDIR(st.st_mode) ? 1 : 0) != must_be_dir))) {
+	if (path != NULL
+	    && (stat(path, &st) != 0
+	        || ((S_ISDIR(st.st_mode) ? 1 : 0) != must_be_dir))) {
 		die("Invalid path for %s: [%s]: (%s). Make sure that path is either "
 		    "absolute, or it is relative to civetweb executable.",
 		    option_name,
@@ -1003,14 +1008,14 @@ set_absolute_path(char *options[],
 
 #if defined(USE_LUA)
 
-#include "civetweb_private_lua.h"
+#	include "civetweb_private_lua.h"
 
 #endif
 
 
 #if defined(USE_DUKTAPE)
 
-#include "duktape.h"
+#	include "duktape.h"
 
 static int
 run_duktape(const char *file_name)
@@ -1039,7 +1044,7 @@ finished:
 
 #if defined(__MINGW32__) || defined(__MINGW64__)
 /* For __MINGW32/64_MAJOR/MINOR_VERSION define */
-#include <_mingw.h>
+#	include <_mingw.h>
 #endif
 
 
@@ -1276,9 +1281,9 @@ start_civetweb(int argc, char *argv[])
 		if (argc != 3) {
 			show_usage_and_exit(argv[0]);
 		}
-#if defined(WIN32)
+#	if defined(WIN32)
 		(void)MakeConsole();
-#endif
+#	endif
 		exit(run_lua(argv[2]));
 #else
 		show_server_name();
@@ -1294,9 +1299,9 @@ start_civetweb(int argc, char *argv[])
 		if (argc != 3) {
 			show_usage_and_exit(argv[0]);
 		}
-#if defined(WIN32)
+#	if defined(WIN32)
 		(void)MakeConsole();
-#endif
+#	endif
 		exit(run_duktape(argv[2]));
 #else
 		show_server_name();
@@ -1306,8 +1311,9 @@ start_civetweb(int argc, char *argv[])
 	}
 
 	/* Show usage if -h or --help options are specified */
-	if (argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "-H")
-	                  || !strcmp(argv[1], "--help"))) {
+	if (argc == 2
+	    && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "-H")
+	        || !strcmp(argv[1], "--help"))) {
 		show_usage_and_exit(argv[0]);
 	}
 
@@ -1539,11 +1545,11 @@ struct dlg_header_param {
 static struct dlg_header_param
 GetDlgHeader(const short width)
 {
-#if defined(_MSC_VER)
+#	if defined(_MSC_VER)
 /* disable MSVC warning C4204 (non-constant used to initialize structure) */
-#pragma warning(push)
-#pragma warning(disable : 4204)
-#endif /* if defined(_MSC_VER) */
+#		pragma warning(push)
+#		pragma warning(disable : 4204)
+#	endif /* if defined(_MSC_VER) */
 	struct dlg_header_param dialog_header = {{WS_CAPTION | WS_POPUP | WS_SYSMENU
 	                                              | WS_VISIBLE | DS_SETFONT
 	                                              | WS_DLGFRAME,
@@ -1558,9 +1564,9 @@ GetDlgHeader(const short width)
 	                                         L"",
 	                                         8,
 	                                         L"Tahoma"};
-#if defined(_MSC_VER)
-#pragma warning(pop)
-#endif /* if defined(_MSC_VER) */
+#	if defined(_MSC_VER)
+#		pragma warning(pop)
+#	endif /* if defined(_MSC_VER) */
 	return dialog_header;
 }
 
@@ -1855,9 +1861,9 @@ get_password(const char *user,
              char *passwd,
              unsigned passwd_len)
 {
-#define HEIGHT (15)
-#define WIDTH (280)
-#define LABEL_WIDTH (90)
+#	define HEIGHT (15)
+#	define WIDTH (280)
+#	define LABEL_WIDTH (90)
 
 	unsigned char mem[4096], *p;
 	DLGTEMPLATE *dia = (DLGTEMPLATE *)mem;
@@ -1995,18 +2001,18 @@ get_password(const char *user,
 	s_dlg_proc_param.name = "Modify password";
 	s_dlg_proc_param.fRetry = NULL;
 
-	ok =
-	    (IDOK == DialogBoxIndirectParam(
-	                 NULL, dia, NULL, InputDlgProc, (LPARAM)&s_dlg_proc_param));
+	ok = (IDOK
+	      == DialogBoxIndirectParam(
+	             NULL, dia, NULL, InputDlgProc, (LPARAM)&s_dlg_proc_param));
 
 	s_dlg_proc_param.hWnd = NULL;
 	s_dlg_proc_param.guard = 0;
 
 	return ok;
 
-#undef HEIGHT
-#undef WIDTH
-#undef LABEL_WIDTH
+#	undef HEIGHT
+#	undef WIDTH
+#	undef LABEL_WIDTH
 }
 
 
@@ -2130,9 +2136,9 @@ add_control(unsigned char **mem,
 static void
 show_settings_dialog()
 {
-#define HEIGHT (15)
-#define WIDTH (460)
-#define LABEL_WIDTH (90)
+#	define HEIGHT (15)
+#	define WIDTH (460)
+#	define LABEL_WIDTH (90)
 
 	unsigned char mem[16 * 1024], *p;
 	const struct mg_option *options;
@@ -2294,18 +2300,18 @@ show_settings_dialog()
 	s_dlg_proc_param.hWnd = NULL;
 	s_dlg_proc_param.guard = 0;
 
-#undef HEIGHT
-#undef WIDTH
-#undef LABEL_WIDTH
+#	undef HEIGHT
+#	undef WIDTH
+#	undef LABEL_WIDTH
 }
 
 
 static void
 change_password_file()
 {
-#define HEIGHT (15)
-#define WIDTH (320)
-#define LABEL_WIDTH (90)
+#	define HEIGHT (15)
+#	define WIDTH (320)
+#	define LABEL_WIDTH (90)
 
 	OPENFILENAME of;
 	char path[PATH_MAX] = PASSWORDS_FILE_NAME;
@@ -2486,19 +2492,18 @@ change_password_file()
 		s_dlg_proc_param.name = path;
 		s_dlg_proc_param.fRetry = NULL;
 
-	} while ((IDOK == DialogBoxIndirectParam(NULL,
-	                                         dia,
-	                                         NULL,
-	                                         PasswordDlgProc,
-	                                         (LPARAM)&s_dlg_proc_param))
-	         && (!g_exit_flag));
+	} while (
+	    (IDOK
+	     == DialogBoxIndirectParam(
+	            NULL, dia, NULL, PasswordDlgProc, (LPARAM)&s_dlg_proc_param))
+	    && (!g_exit_flag));
 
 	s_dlg_proc_param.hWnd = NULL;
 	s_dlg_proc_param.guard = 0;
 
-#undef HEIGHT
-#undef WIDTH
-#undef LABEL_WIDTH
+#	undef HEIGHT
+#	undef WIDTH
+#	undef LABEL_WIDTH
 }
 
 
@@ -2532,9 +2537,9 @@ sysinfo_reload(struct dlg_proc_param *prm)
 int
 show_system_info()
 {
-#define HEIGHT (15)
-#define WIDTH (320)
-#define LABEL_WIDTH (50)
+#	define HEIGHT (15)
+#	define WIDTH (320)
+#	define LABEL_WIDTH (50)
 
 	unsigned char mem[4096], *p;
 	DLGTEMPLATE *dia = (DLGTEMPLATE *)mem;
@@ -2614,18 +2619,18 @@ show_system_info()
 	s_dlg_proc_param.fRetry = sysinfo_reload;
 	s_dlg_proc_param.idRetry = ID_CONTROLS + 1; /* Reload field with this ID */
 
-	ok =
-	    (IDOK == DialogBoxIndirectParam(
-	                 NULL, dia, NULL, InputDlgProc, (LPARAM)&s_dlg_proc_param));
+	ok = (IDOK
+	      == DialogBoxIndirectParam(
+	             NULL, dia, NULL, InputDlgProc, (LPARAM)&s_dlg_proc_param));
 
 	s_dlg_proc_param.hWnd = NULL;
 	s_dlg_proc_param.guard = 0;
 
 	return ok;
 
-#undef HEIGHT
-#undef WIDTH
-#undef LABEL_WIDTH
+#	undef HEIGHT
+#	undef WIDTH
+#	undef LABEL_WIDTH
 }
 
 
@@ -2871,9 +2876,9 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show)
 	HWND hWnd;
 	MSG msg;
 
-#if defined(DEBUG)
+#	if defined(DEBUG)
 	(void)MakeConsole();
-#endif
+#	endif
 
 	(void)hInst;
 	(void)hPrev;
@@ -2945,7 +2950,7 @@ main(int argc, char *argv[])
 
 
 #elif defined(USE_COCOA)
-#import <Cocoa/Cocoa.h>
+#	import <Cocoa/Cocoa.h>
 
 @interface Civetweb : NSObject <NSApplicationDelegate>
 - (void)openBrowser;
@@ -3004,12 +3009,12 @@ main(int argc, char *argv[])
 
 	/* Add version menu item */
 	[menu
-	    addItem:
-	        [[[NSMenuItem alloc]
-	            /*initWithTitle:[NSString stringWithFormat:@"%s", server_name]*/
-	            initWithTitle:[NSString stringWithUTF8String:g_server_name]
-	                   action:@selector(noexist)
-	            keyEquivalent:@""] autorelease]];
+	    addItem:[[[NSMenuItem alloc]
+	                /*initWithTitle:[NSString stringWithFormat:@"%s",
+	                   server_name]*/
+	                initWithTitle:[NSString stringWithUTF8String:g_server_name]
+	                       action:@selector(noexist)
+	                keyEquivalent:@""] autorelease]];
 
 	/* Add configuration menu item */
 	[menu addItem:[[[NSMenuItem alloc] initWithTitle:@"Edit configuration"

+ 15 - 15
src/md5.inl

@@ -35,7 +35,7 @@
  */
 
 #if !defined(md5_INCLUDED)
-#define md5_INCLUDED
+#	define md5_INCLUDED
 
 /*
  * This package supports both compile-time and run-time determination of CPU
@@ -57,9 +57,9 @@ typedef struct md5_state_s {
 	md5_byte_t buf[64];  /* accumulate block */
 } md5_state_t;
 
-#if defined(__cplusplus)
+#	if defined(__cplusplus)
 extern "C" {
-#endif
+#	endif
 
 /* Initialize the algorithm. */
 MD5_STATIC void md5_init(md5_state_t *pms);
@@ -71,9 +71,9 @@ md5_append(md5_state_t *pms, const md5_byte_t *data, size_t nbytes);
 /* Finish the message and return the digest. */
 MD5_STATIC void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
 
-#if defined(__cplusplus)
+#	if defined(__cplusplus)
 } /* end extern "C" */
-#endif
+#	endif
 
 #endif /* md5_INCLUDED */
 
@@ -131,14 +131,14 @@ MD5_STATIC void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
  */
 
 #if !defined(MD5_STATIC)
-#include <string.h>
+#	include <string.h>
 #endif
 
 #undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */
 #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
-#define BYTE_ORDER (0)
+#	define BYTE_ORDER (0)
 #endif
 
 #define T_MASK ((md5_word_t)~0)
@@ -265,11 +265,11 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
 			const md5_byte_t *xp = data;
 			int i;
 
-#if BYTE_ORDER == 0
+#	if BYTE_ORDER == 0
 			X = xbuf; /* (dynamic only) */
-#else
-#define xbuf X /* (static only) */
-#endif
+#	else
+#		define xbuf X /* (static only) */
+#	endif
 			for (i = 0; i < 16; ++i, xp += 4)
 				xbuf[i] = (md5_word_t)(xp[0]) + (md5_word_t)(xp[1] << 8)
 				          + (md5_word_t)(xp[2] << 16)
@@ -309,7 +309,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
 
 /* Round 2. */
 /* Let [abcd k s i] denote the operation
-     a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
+	 a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
 #define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
 #define SET(a, b, c, d, k, s, Ti)                                              \
 	t = a + G(b, c, d) + X[k] + Ti;                                            \
@@ -336,7 +336,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
 
 /* Round 3. */
 /* Let [abcd k s t] denote the operation
-     a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
+	 a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
 #define H(x, y, z) ((x) ^ (y) ^ (z))
 #define SET(a, b, c, d, k, s, Ti)                                              \
 	t = a + H(b, c, d) + X[k] + Ti;                                            \
@@ -363,7 +363,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
 
 /* Round 4. */
 /* Let [abcd k s t] denote the operation
-     a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
+	 a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
 #define I(x, y, z) ((y) ^ ((x) | ~(z)))
 #define SET(a, b, c, d, k, s, Ti)                                              \
 	t = a + I(b, c, d) + X[k] + Ti;                                            \

+ 1 - 1
src/mod_duktape.inl

@@ -216,7 +216,7 @@ mg_exec_duktape_script(struct mg_connection *conn, const char *script_name)
 #else
 	                          mg_duk_fatal_handler
 #endif
-	                          );
+	);
 	if (!duk_ctx) {
 		mg_cry_internal(conn, "%s", "Failed to create a Duktape heap.");
 		goto exec_duktape_finished;

+ 14 - 13
src/mod_lua.inl

@@ -38,11 +38,11 @@ munmap(void *addr, int64_t length)
 	UnmapViewOfFile(addr);
 }
 
-#define MAP_FAILED (NULL)
-#define MAP_PRIVATE (0)
-#define PROT_READ (0)
+#	define MAP_FAILED (NULL)
+#	define MAP_PRIVATE (0)
+#	define PROT_READ (0)
 #else
-#include <sys/mman.h>
+#	include <sys/mman.h>
 #endif
 
 static const char *LUASOCKET = "luasocket";
@@ -55,7 +55,7 @@ static const char *LUABACKGROUNDPARAMS = "mg";
  * This takes a lot of stack (~10 kB per recursion),
  * so do not use a too high limit. */
 #if !defined(LSP_INCLUDE_MAX_DEPTH)
-#define LSP_INCLUDE_MAX_DEPTH (10)
+#	define LSP_INCLUDE_MAX_DEPTH (10)
 #endif
 
 
@@ -900,10 +900,10 @@ lsp_include(lua_State *L)
 
 			if (handle_lsp_request(conn, file_name_path, &file, L)) {
 				/* handle_lsp_request returned an error code, meaning an error
-				* occurred in the included page and mg.onerror returned
-				* non-zero.
-				* Stop processing.
-				*/
+				 * occurred in the included page and mg.onerror returned
+				 * non-zero.
+				 * Stop processing.
+				 */
 
 				lsp_abort(L);
 			}
@@ -1367,12 +1367,12 @@ lsp_random(lua_State *L)
 	int num_args = lua_gettop(L);
 	if (num_args == 0) {
 		/* The civetweb internal random number generator will generate
-		         * a 64 bit random number. */
+		 * a 64 bit random number. */
 		uint64_t r = get_random();
 		/* Lua "number" is a IEEE 754 double precission float:
- * https://en.wikipedia.org/wiki/Double-precision_floating-point_format
+		 * https://en.wikipedia.org/wiki/Double-precision_floating-point_format
 		 * Thus, mask with 2^53-1 to get an integer with the maximum
- * precission available. */
+		 * precission available. */
 		r &= ((((uint64_t)1) << 53) - 1);
 		lua_pushnumber(L, (double)r);
 		return 1;
@@ -2400,7 +2400,8 @@ handle_lsp_request(struct mg_connection *conn,
 	                 PROT_READ,
 	                 MAP_PRIVATE,
 	                 fileno(filep->access.fp),
-	                 0)) == MAP_FAILED) {
+	                 0))
+	           == MAP_FAILED) {
 
 		/* File was not already in memory, and mmap failed now.
 		 * Since wi have no data, show an error. */

+ 2 - 2
src/mod_zlib.inl

@@ -1,13 +1,13 @@
 /* Experimental implementation for on-the-fly compression */
 #if !defined(USE_ZLIB)
-#error "This file must only be included, if USE_ZLIB is set"
+#	error "This file must only be included, if USE_ZLIB is set"
 #endif
 
 #include "zconf.h"
 #include "zlib.h"
 
 #if !defined(MEM_LEVEL)
-#define MEM_LEVEL (8)
+#	define MEM_LEVEL (8)
 #endif
 
 static void *

+ 1 - 1
src/sha1.inl

@@ -86,8 +86,8 @@ A million repetitions of "a"
   34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
 */
 
-#include <string.h>
 #include <stdint.h>
+#include <string.h>
 
 typedef struct {
 	uint32_t state[5];

+ 25 - 25
src/third_party/civetweb_lua.h

@@ -27,51 +27,51 @@
 #define CIVETWEB_LUA_H
 
 #define LUA_LIB
-#include "lua.h"
 #include "lauxlib.h"
+#include "lua.h"
 #include "lualib.h"
 
 #ifndef LUA_VERSION_NUM
-#error "Unknown Lua version"
+#	error "Unknown Lua version"
 
 #elif LUA_VERSION_NUM == 501
 /* Lua 5.1 detected */
-#define LUA_OK 0
-#define LUA_ERRGCMM 999 /* not supported */
-#define mg_lua_load(a, b, c, d, e) lua_load(a, b, c, d)
-#define lua_rawlen lua_objlen
-#define lua_newstate(a, b)                                                     \
-	luaL_newstate() /* Must use luaL_newstate() for 64 bit target */
-#define lua_pushinteger lua_pushnumber
-#define luaL_newlib(L, t)                                                      \
-	{                                                                          \
-		luaL_Reg const *r = t;                                                 \
-		while (r->name) {                                                      \
-			lua_register(L, r->name, r->func);                                 \
-			r++;                                                               \
-		}                                                                      \
-	}
-#define luaL_setfuncs(L, r, u) lua_register(L, r->name, r->func)
+#	define LUA_OK 0
+#	define LUA_ERRGCMM 999 /* not supported */
+#	define mg_lua_load(a, b, c, d, e) lua_load(a, b, c, d)
+#	define lua_rawlen lua_objlen
+#	define lua_newstate(a, b)                                                 \
+		luaL_newstate() /* Must use luaL_newstate() for 64 bit target */
+#	define lua_pushinteger lua_pushnumber
+#	define luaL_newlib(L, t)                                                  \
+		{                                                                      \
+			luaL_Reg const *r = t;                                             \
+			while (r->name) {                                                  \
+				lua_register(L, r->name, r->func);                             \
+				r++;                                                           \
+			}                                                                  \
+		}
+#	define luaL_setfuncs(L, r, u) lua_register(L, r->name, r->func)
 
 #elif LUA_VERSION_NUM == 502
 /* Lua 5.2 detected */
-#define mg_lua_load lua_load
+#	define mg_lua_load lua_load
 
 #elif LUA_VERSION_NUM == 503
 /* Lua 5.3 detected */
-#define mg_lua_load lua_load
+#	define mg_lua_load lua_load
 
 #elif LUA_VERSION_NUM == 504
 /* Lua 5.4 detected */
-#define mg_lua_load lua_load
+#	define mg_lua_load lua_load
 
 #endif
 
 #ifdef LUA_VERSION_MAKEFILE
-#if LUA_VERSION_MAKEFILE != LUA_VERSION_NUM
-#error                                                                         \
-    "Mismatch between Lua version specified in Makefile and Lua version in lua.h"
-#endif
+#	if LUA_VERSION_MAKEFILE != LUA_VERSION_NUM
+#		error                                                                  \
+		    "Mismatch between Lua version specified in Makefile and Lua version in lua.h"
+#	endif
 #endif
 
 #endif /* #ifndef CIVETWEB_LUA_H */

+ 2 - 2
src/timer.inl

@@ -4,7 +4,7 @@
  */
 
 #if !defined(MAX_TIMERS)
-#define MAX_TIMERS MAX_WORKER_THREADS
+#	define MAX_TIMERS MAX_WORKER_THREADS
 #endif
 
 typedef int (*taction)(void *arg);
@@ -79,7 +79,7 @@ timer_add(struct mg_context *ctx,
 	 *        if next_time < now then we set next_time = now.
 	 *        The first callback will be so fast as possible (now)
 	 *        but the next callback on period
-	*/
+	 */
 	if (is_relative) {
 		next_time += now;
 	}

+ 16 - 16
unittest/civetweb_check.h

@@ -22,14 +22,14 @@
 #define TEST_CIVETWEB_CHECK_H_
 
 #ifdef __clang__
-#pragma clang diagnostic push
+#	pragma clang diagnostic push
 // FIXME: check uses GCC specific variadic macros that are non-standard
-#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#	pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
 #endif
 
 #if defined(__MINGW__) || defined(__GNUC__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wall"
+#	pragma GCC diagnostic push
+#	pragma GCC diagnostic ignored "-Wall"
 /* Disable warnings for defining _CRT_SECURE_NO_* (here) and
  * _CHECK_CHECK_STDINT_H (in check.h)
  */
@@ -41,12 +41,12 @@
 #endif
 
 #ifdef _MSC_VER
-#undef pid_t
-#define pid_t int
+#	undef pid_t
+#	define pid_t int
 /* Unreferenced formal parameter. START_TEST has _i */
-#pragma warning(disable : 4100)
+#	pragma warning(disable : 4100)
 /* conditional expression is constant . asserts use while(0) */
-#pragma warning(disable : 4127)
+#	pragma warning(disable : 4127)
 #endif
 #include <stdint.h>
 
@@ -56,31 +56,31 @@
 #include "check.h"
 
 #if (CHECK_MINOR_VERSION < 11)
-#ifndef LOCAL_TEST
-#error "CivetWeb unit tests require at least check 0.11.0"
-#endif
+#	ifndef LOCAL_TEST
+#		error "CivetWeb unit tests require at least check 0.11.0"
+#	endif
 #endif
 
 #ifdef __clang__
-#pragma clang diagnostic pop
+#	pragma clang diagnostic pop
 #endif
 
 #if !defined(_CRT_SECURE_NO_WARNINGS)
-#define _CRT_SECURE_NO_WARNINGS
+#	define _CRT_SECURE_NO_WARNINGS
 #endif
 #if !defined(_CRT_SECURE_NO_DEPRECATE)
-#define _CRT_SECURE_NO_DEPRECATE
+#	define _CRT_SECURE_NO_DEPRECATE
 #endif
 
 #if defined(__MINGW__) || defined(__GNUC__)
-#pragma GCC diagnostic pop
+#	pragma GCC diagnostic pop
 #endif
 
 #ifdef __clang__
 /* When using -Weverything, clang does not accept it's own headers
  * in a release build configuration. Disable what is too much in
  * -Weverything. */
-#pragma clang diagnostic ignored "-Wdisabled-macro-expansion"
+#	pragma clang diagnostic ignored "-Wdisabled-macro-expansion"
 #endif
 
 /* A minimal timeout used for all tests with the "check" framework. */

+ 5 - 5
unittest/main.c

@@ -20,19 +20,19 @@
  */
 
 #if defined(_MSC_VER)
-#define _CRT_SECURE_NO_WARNINGS /* Microsoft nonsense */
+#	define _CRT_SECURE_NO_WARNINGS /* Microsoft nonsense */
 #endif
 
 #include "civetweb_check.h"
-#include "shared.h"
+#include "private.h"
+#include "private_exe.h"
 #include "public_func.h"
 #include "public_server.h"
-#include "private.h"
+#include "shared.h"
 #include "timertest.h"
-#include "private_exe.h"
 
-#include <stdlib.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 
 /* This unit test file uses the excellent Check unit testing library.

+ 13 - 13
unittest/private.c

@@ -24,23 +24,23 @@
  * static functions
  */
 #ifdef _MSC_VER
-#ifndef _CRT_SECURE_NO_WARNINGS
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#define CIVETWEB_API static
+#	ifndef _CRT_SECURE_NO_WARNINGS
+#		define _CRT_SECURE_NO_WARNINGS
+#	endif
+#	define CIVETWEB_API static
 #endif
 
 #ifdef REPLACE_CHECK_FOR_LOCAL_DEBUGGING
-#undef MEMORY_DEBUGGING
+#	undef MEMORY_DEBUGGING
 #endif
 
+#include "private.h"
+
 #include "../src/civetweb.c"
 
 #include <stdlib.h>
 #include <time.h>
 
-#include "private.h"
-
 
 /* This unit test file uses the excellent Check unit testing library.
  * The API documentation is available here:
@@ -947,8 +947,8 @@ START_TEST(test_config_options)
 	/* Check if the order in
 	 * static struct mg_option config_options[]
 	 * is the same as in the option enum
-	     * This test allows to reorder config_options and the enum,
-	     * and check if the order is still consistent. */
+	 * This test allows to reorder config_options and the enum,
+	 * and check if the order is still consistent. */
 	ck_assert_str_eq("cgi_pattern", config_options[CGI_EXTENSIONS].name);
 	ck_assert_str_eq("cgi_environment", config_options[CGI_ENVIRONMENT].name);
 	ck_assert_str_eq("put_delete_auth_file",
@@ -1169,11 +1169,11 @@ make_private_suite(void)
 void
 MAIN_PRIVATE(void)
 {
-#if defined(_WIN32)
+#	if defined(_WIN32)
 	/* test_parse_port_string requires WSAStartup for IPv6 */
 	WSADATA data;
 	WSAStartup(MAKEWORD(2, 2), &data);
-#endif
+#	endif
 
 	test_alloc_vprintf(0);
 	test_mg_vsnprintf(0);
@@ -1183,9 +1183,9 @@ MAIN_PRIVATE(void)
 	test_parse_http_message(0);
 	test_sha1(0);
 
-#if defined(_WIN32)
+#	if defined(_WIN32)
 	WSACleanup();
-#endif
+#	endif
 }
 
 #endif

+ 3 - 3
unittest/private_exe.c

@@ -24,9 +24,9 @@
  * static functions.
  */
 #ifdef _MSC_VER
-#ifndef _CRT_SECURE_NO_WARNINGS
-#define _CRT_SECURE_NO_WARNINGS
-#endif
+#	ifndef _CRT_SECURE_NO_WARNINGS
+#		define _CRT_SECURE_NO_WARNINGS
+#	endif
 #endif
 
 #include "private_exe.h"

+ 6 - 6
unittest/public_func.c

@@ -20,16 +20,16 @@
  */
 
 #ifdef _MSC_VER
-#ifndef _CRT_SECURE_NO_WARNINGS
-#define _CRT_SECURE_NO_WARNINGS
+#	ifndef _CRT_SECURE_NO_WARNINGS
+#		define _CRT_SECURE_NO_WARNINGS
+#	endif
 #endif
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
 
 #include "public_func.h"
+
 #include <civetweb.h>
+#include <stdio.h>
+#include <stdlib.h>
 
 /* This unit test file uses the excellent Check unit testing library.
  * The API documentation is available here:

+ 108 - 110
unittest/public_server.c

@@ -20,29 +20,29 @@
  */
 
 #ifdef _MSC_VER
-#ifndef _CRT_SECURE_NO_WARNINGS
-#define _CRT_SECURE_NO_WARNINGS
-#endif
+#	ifndef _CRT_SECURE_NO_WARNINGS
+#		define _CRT_SECURE_NO_WARNINGS
+#	endif
 #endif
 
-#include <stdlib.h>
-#include <stdio.h>
+#include "public_server.h"
+
+#include <civetweb.h>
 #include <stdarg.h>
-#include <string.h>
 #include <stdint.h>
-#include <time.h>
-#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <sys/stat.h>
-
-#include "public_server.h"
-#include <civetweb.h>
+#include <sys/types.h>
+#include <time.h>
 
 #if defined(_WIN32)
-#include <windows.h>
-#define test_sleep(x) (Sleep((x)*1000))
+#	include <windows.h>
+#	define test_sleep(x) (Sleep((x)*1000))
 #else
-#include <unistd.h>
-#define test_sleep(x) (sleep(x))
+#	include <unistd.h>
+#	define test_sleep(x) (sleep(x))
 #endif
 
 #define SLEEP_BEFORE_MG_START (1)
@@ -59,7 +59,7 @@
 /* Return codes of the tested functions are evaluated. Checking all other
  * functions, used only to prepare the test environment seems redundant.
  * If they fail, the test fails anyway. */
-#pragma GCC diagnostic ignored "-Wunused-result"
+#	pragma GCC diagnostic ignored "-Wunused-result"
 #endif
 
 static const char *
@@ -68,25 +68,25 @@ locate_path(const char *a_path)
 	static char r_path[256];
 
 #ifdef _WIN32
-#ifdef LOCAL_TEST
+#	ifdef LOCAL_TEST
 	sprintf(r_path, "%s\\", a_path);
-#else
+#	else
 	/* Appveyor */
 	sprintf(r_path, "..\\..\\..\\%s\\", a_path);
 /* TODO: the different paths
  * used in the different test
  * system is an unsolved
  * problem. */
-#endif
+#	endif
 #else
-#ifdef LOCAL_TEST
+#	ifdef LOCAL_TEST
 	sprintf(r_path, "%s/", a_path);
-#else
+#	else
 	/* Travis */
 	sprintf(r_path,
 	        "../../%s/",
 	        a_path); // TODO: fix path in CI test environment
-#endif
+#	endif
 #endif
 
 	return r_path;
@@ -131,9 +131,9 @@ wait_not_null(void *volatile *data)
 	}
 
 #if defined(__MINGW32__) || defined(__GNUC__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunreachable-code"
-#pragma GCC diagnostic ignored "-Wunreachable-code-return"
+#	pragma GCC diagnostic push
+#	pragma GCC diagnostic ignored "-Wunreachable-code"
+#	pragma GCC diagnostic ignored "-Wunreachable-code-return"
 #endif
 
 	ck_abort_msg("wait_not_null failed (%i sec)", i);
@@ -141,7 +141,7 @@ wait_not_null(void *volatile *data)
 	return 0;
 
 #if defined(__MINGW32__) || defined(__GNUC__)
-#pragma GCC diagnostic pop
+#	pragma GCC diagnostic pop
 #endif
 }
 
@@ -205,18 +205,18 @@ START_TEST(test_the_test_environment)
 
 #ifdef _WIN32
 /* Try to copy the files required for AppVeyor */
-#if defined(_WIN64) || defined(__MINGW64__)
+#	if defined(_WIN64) || defined(__MINGW64__)
 	(void)system("cmd /c copy C:\\OpenSSL-Win64\\libeay32.dll libeay32.dll");
 	(void)system("cmd /c copy C:\\OpenSSL-Win64\\libssl32.dll libssl32.dll");
 	(void)system("cmd /c copy C:\\OpenSSL-Win64\\ssleay32.dll ssleay32.dll");
 	(void)system("cmd /c copy C:\\OpenSSL-Win64\\libeay32.dll libeay64.dll");
 	(void)system("cmd /c copy C:\\OpenSSL-Win64\\libssl32.dll libssl64.dll");
 	(void)system("cmd /c copy C:\\OpenSSL-Win64\\ssleay32.dll ssleay64.dll");
-#else
+#	else
 	(void)system("cmd /c copy C:\\OpenSSL-Win32\\libeay32.dll libeay32.dll");
 	(void)system("cmd /c copy C:\\OpenSSL-Win32\\libssl32.dll libssl32.dll");
 	(void)system("cmd /c copy C:\\OpenSSL-Win32\\ssleay32.dll ssleay32.dll");
-#endif
+#	endif
 #endif
 }
 END_TEST
@@ -584,11 +584,11 @@ START_TEST(test_mg_start_stop_https_server)
 
 	struct mg_context *ctx;
 
-#if defined(MG_LEGACY_INTERFACE)
+#	if defined(MG_LEGACY_INTERFACE)
 	size_t ports_cnt;
 	int ports[16];
 	int ssl[16];
-#endif
+#	endif
 	struct mg_callbacks callbacks;
 	char errmsg[256];
 
@@ -605,10 +605,10 @@ START_TEST(test_mg_start_stop_https_server)
 	ck_assert(ssl_cert != NULL);
 
 	memset((void *)OPTIONS, 0, sizeof(OPTIONS));
-#if !defined(NO_FILES)
+#	if !defined(NO_FILES)
 	OPTIONS[opt_idx++] = "document_root";
 	OPTIONS[opt_idx++] = ".";
-#endif
+#	endif
 	OPTIONS[opt_idx++] = "listening_ports";
 	OPTIONS[opt_idx++] = "8080r,8443s";
 	OPTIONS[opt_idx++] = "ssl_certificate";
@@ -618,10 +618,10 @@ START_TEST(test_mg_start_stop_https_server)
 	ck_assert(OPTIONS[sizeof(OPTIONS) / sizeof(OPTIONS[0]) - 1] == NULL);
 	ck_assert(OPTIONS[sizeof(OPTIONS) / sizeof(OPTIONS[0]) - 2] == NULL);
 
-#if defined(MG_LEGACY_INTERFACE)
+#	if defined(MG_LEGACY_INTERFACE)
 	memset(ports, 0, sizeof(ports));
 	memset(ssl, 0, sizeof(ssl));
-#endif
+#	endif
 	memset(portinfo, 0, sizeof(portinfo));
 	memset(&callbacks, 0, sizeof(callbacks));
 	memset(errmsg, 0, sizeof(errmsg));
@@ -633,7 +633,7 @@ START_TEST(test_mg_start_stop_https_server)
 	ck_assert_str_eq(errmsg, "");
 	ck_assert(ctx != NULL);
 
-#if defined(MG_LEGACY_INTERFACE)
+#	if defined(MG_LEGACY_INTERFACE)
 	ports_cnt = mg_get_ports(ctx, 16, ports, ssl);
 	ck_assert_uint_eq(ports_cnt, 2);
 	ck_assert_int_eq(ports[0], 8080);
@@ -642,7 +642,7 @@ START_TEST(test_mg_start_stop_https_server)
 	ck_assert_int_eq(ssl[1], 1);
 	ck_assert_int_eq(ports[2], 0);
 	ck_assert_int_eq(ssl[2], 0);
-#endif
+#	endif
 
 	ret = mg_get_server_ports(ctx, 0, portinfo);
 	ck_assert_int_lt(ret, 0);
@@ -687,15 +687,15 @@ START_TEST(test_mg_start_stop_https_server)
 	client_ri = mg_get_response_info(client_conn);
 	ck_assert(client_ri != NULL);
 
-#if defined(NO_FILES)
+#	if defined(NO_FILES)
 	ck_assert_int_eq(client_ri->status_code, 404);
-#else
+#	else
 	ck_assert_int_eq(client_ri->status_code, 200);
 	/* TODO: ck_assert_str_eq(client_ri->request_method, "HTTP/1.0"); */
 	client_res = (int)mg_read(client_conn, client_err, sizeof(client_err));
 	ck_assert_int_gt(client_res, 0);
 	ck_assert_int_le(client_res, sizeof(client_err));
-#endif
+#	endif
 	mg_close_connection(client_conn);
 
 	test_sleep(1);
@@ -733,19 +733,19 @@ START_TEST(test_mg_server_and_client_tls)
 	ck_assert(res_dir != NULL);
 	strcpy(server_cert, res_dir);
 	strcpy(client_cert, res_dir);
-#ifdef _WIN32
+#	ifdef _WIN32
 	strcat(server_cert, "cert\\server.pem");
 	strcat(client_cert, "cert\\client.pem");
-#else
+#	else
 	strcat(server_cert, "cert/server.pem");
 	strcat(client_cert, "cert/client.pem");
-#endif
+#	endif
 
 	memset((void *)OPTIONS, 0, sizeof(OPTIONS));
-#if !defined(NO_FILES)
+#	if !defined(NO_FILES)
 	OPTIONS[opt_idx++] = "document_root";
 	OPTIONS[opt_idx++] = ".";
-#endif
+#	endif
 	OPTIONS[opt_idx++] = "listening_ports";
 	OPTIONS[opt_idx++] = "8080r,8443s";
 	OPTIONS[opt_idx++] = "ssl_certificate";
@@ -816,15 +816,15 @@ START_TEST(test_mg_server_and_client_tls)
 	client_ri = mg_get_response_info(client_conn);
 	ck_assert(client_ri != NULL);
 
-#if defined(NO_FILES)
+#	if defined(NO_FILES)
 	ck_assert_int_eq(client_ri->status_code, 404);
-#else
+#	else
 	ck_assert_int_eq(client_ri->status_code, 200);
 	/* TODO: ck_assert_str_eq(client_ri->request_method, "HTTP/1.0"); */
 	client_res = (int)mg_read(client_conn, client_err, sizeof(client_err));
 	ck_assert_int_gt(client_res, 0);
 	ck_assert_int_le(client_res, sizeof(client_err));
-#endif
+#	endif
 	mg_close_connection(client_conn);
 
 	/* TODO: A client API using a client certificate is missing */
@@ -934,7 +934,7 @@ static const size_t websocket_goodbye_msg_len =
     14 /* strlen(websocket_goodbye_msg) */;
 
 
-#if defined(DEBUG)
+#	if defined(DEBUG)
 static void
 WS_TEST_TRACE(const char *f, ...)
 {
@@ -943,9 +943,9 @@ WS_TEST_TRACE(const char *f, ...)
 	vprintf(f, l);
 	va_end(l);
 }
-#else
-#define WS_TEST_TRACE(...)
-#endif
+#	else
+#		define WS_TEST_TRACE(...)
+#	endif
 
 
 static int
@@ -981,8 +981,8 @@ websock_server_ready(struct mg_connection *conn, void *udata)
 }
 
 
-#define long_ws_buf_len_16 (500)
-#define long_ws_buf_len_64 (70000)
+#	define long_ws_buf_len_16 (500)
+#	define long_ws_buf_len_64 (70000)
 static char long_ws_buf[long_ws_buf_len_64];
 
 
@@ -1036,26 +1036,26 @@ websock_server_data(struct mg_connection *conn,
 		mg_unlock_connection(conn);
 	} else {
 
-#if defined(__MINGW32__) || defined(__GNUC__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunreachable-code"
-#endif
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunreachable-code"
-#endif
+#	if defined(__MINGW32__) || defined(__GNUC__)
+#		pragma GCC diagnostic push
+#		pragma GCC diagnostic ignored "-Wunreachable-code"
+#	endif
+#	ifdef __clang__
+#		pragma clang diagnostic push
+#		pragma clang diagnostic ignored "-Wunreachable-code"
+#	endif
 
 		ck_abort_msg("Got unexpected message from websocket client");
 
 
 		return 0;
 
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
-#if defined(__MINGW32__) || defined(__GNUC__)
-#pragma GCC diagnostic pop
-#endif
+#	ifdef __clang__
+#		pragma clang diagnostic pop
+#	endif
+#	if defined(__MINGW32__) || defined(__GNUC__)
+#		pragma GCC diagnostic pop
+#	endif
 	}
 	mark_point();
 
@@ -1066,7 +1066,7 @@ websock_server_data(struct mg_connection *conn,
 static void
 websock_server_close(const struct mg_connection *conn, void *udata)
 {
-#ifndef __MACH__
+#	ifndef __MACH__
 	ck_assert_ptr_eq((void *)udata, (void *)(ptrdiff_t)7531);
 	WS_TEST_TRACE("Server: Close connection\n");
 
@@ -1074,7 +1074,7 @@ websock_server_close(const struct mg_connection *conn, void *udata)
 	 * the connection is already closed */
 
 	mark_point();
-#endif
+#	endif
 
 	(void)conn;
 	(void)udata;
@@ -1143,7 +1143,7 @@ websocket_client_close_handler(const struct mg_connection *conn,
 	struct tclient_data *pclient_data =
 	    (struct tclient_data *)mg_get_user_data(ctx);
 
-#ifndef __MACH__
+#	ifndef __MACH__
 	ck_assert_ptr_eq(user_data, (void *)pclient_data);
 
 	ck_assert(pclient_data != NULL);
@@ -1152,12 +1152,12 @@ websocket_client_close_handler(const struct mg_connection *conn,
 	pclient_data->closed++;
 
 	mark_point();
-#else
+#	else
 
 	(void)user_data;
 	pclient_data->closed++;
 
-#endif /* __MACH__ */
+#	endif /* __MACH__ */
 }
 
 #endif /* USE_WEBSOCKET */
@@ -1661,12 +1661,12 @@ START_TEST(test_request_handlers)
 
 	ck_assert(client_ri != NULL);
 
-#if defined(NO_FILES)
+#	if defined(NO_FILES)
 	ck_assert_int_eq(client_ri->status_code, 404);
 
 	(void)expected_cgi_result;
 	(void)cgi_script_content;
-#else
+#	else
 	i = mg_read(client_conn, buf, sizeof(buf));
 	if ((i >= 0) && (i < (int)sizeof(buf))) {
 		while ((i > 0) && ((buf[i - 1] == '\r') || (buf[i - 1] == '\n'))) {
@@ -1678,7 +1678,7 @@ START_TEST(test_request_handlers)
 	ck_assert_str_eq(buf, expected_cgi_result);
 	ck_assert_int_eq(client_ri->status_code, 200);
 	mg_close_connection(client_conn);
-#endif
+#	endif
 
 #else
 	(void)expected_cgi_result;
@@ -1943,9 +1943,8 @@ START_TEST(test_request_handlers)
 	                          "data1",
 	                          5);
 
-	wait_not_null(
-	    &(ws_client1_data
-	          .data)); /* Wait for the websocket acknowledge message */
+	wait_not_null(&(
+	    ws_client1_data.data)); /* Wait for the websocket acknowledge message */
 	ck_assert_int_eq(ws_client1_data.closed, 0);
 	ck_assert_int_eq(ws_client2_data.closed, 0);
 	ck_assert(ws_client2_data.data == NULL);
@@ -1958,7 +1957,7 @@ START_TEST(test_request_handlers)
 	ws_client1_data.len = 0;
 
 /* Now connect a second client */
-#ifdef USE_IPV6
+#	ifdef USE_IPV6
 	ws_client2_conn =
 	    mg_connect_websocket_client("[::1]",
 	                                ipv6_port,
@@ -1970,7 +1969,7 @@ START_TEST(test_request_handlers)
 	                                websocket_client_data_handler,
 	                                websocket_client_close_handler,
 	                                &ws_client2_data);
-#else
+#	else
 	ws_client2_conn =
 	    mg_connect_websocket_client("127.0.0.1",
 	                                ipv4_port,
@@ -1982,7 +1981,7 @@ START_TEST(test_request_handlers)
 	                                websocket_client_data_handler,
 	                                websocket_client_close_handler,
 	                                &ws_client2_data);
-#endif
+#	endif
 	ck_assert(ws_client2_conn != NULL);
 
 	wait_not_null(
@@ -2005,9 +2004,8 @@ START_TEST(test_request_handlers)
 	                          "data2",
 	                          5);
 
-	wait_not_null(
-	    &(ws_client1_data
-	          .data)); /* Wait for the websocket acknowledge message */
+	wait_not_null(&(
+	    ws_client1_data.data)); /* Wait for the websocket acknowledge message */
 
 	ck_assert(ws_client1_data.closed == 0);
 	ck_assert(ws_client2_data.closed == 0);
@@ -2090,13 +2088,13 @@ START_TEST(test_request_handlers)
 	/* Connect client 3 */
 	ws_client3_conn =
 	    mg_connect_websocket_client("localhost",
-#if defined(NO_SSL)
+#	if defined(NO_SSL)
 	                                ipv4_port,
 	                                0,
-#else
+#	else
 	                                ipv4s_port,
 	                                1,
-#endif
+#	endif
 	                                ebuf,
 	                                sizeof(ebuf),
 	                                "/websocket",
@@ -2163,13 +2161,13 @@ START_TEST(test_request_handlers)
 	/* Connect client 4 */
 	ws_client4_conn =
 	    mg_connect_websocket_client("localhost",
-#if defined(NO_SSL)
+#	if defined(NO_SSL)
 	                                ipv4_port,
 	                                0,
-#else
+#	else
 	                                ipv4s_port,
 	                                1,
-#endif
+#	endif
 	                                ebuf,
 	                                sizeof(ebuf),
 	                                "/websocket",
@@ -2195,7 +2193,7 @@ START_TEST(test_request_handlers)
 	ws_client4_data.data = NULL;
 	ws_client4_data.len = 0;
 
-/* stop the server without closing this connection */
+	/* stop the server without closing this connection */
 
 #endif
 
@@ -3148,10 +3146,10 @@ START_TEST(test_http_auth)
 		".",
 		"listening_ports",
 		"8080",
-#if !defined(NO_CACHING)
+#	if !defined(NO_CACHING)
 		"static_file_max_age",
 		"0",
-#endif
+#	endif
 		"put_delete_auth_file",
 		"put_delete_auth_file.csv",
 		NULL,
@@ -4232,16 +4230,16 @@ START_TEST(test_large_file)
 	OPTIONS[opt_cnt++] = "8443s";
 	OPTIONS[opt_cnt++] = "ssl_certificate";
 	OPTIONS[opt_cnt++] = ssl_cert;
-#ifdef __MACH__
+#	ifdef __MACH__
 	/* The Apple builds on Travis CI seem to have problems with TLS1.x
 	 * Allow SSLv3 and TLS */
 	OPTIONS[opt_cnt++] = "ssl_protocol_version";
 	OPTIONS[opt_cnt++] = "2";
-#else
+#	else
 	/* The Linux builds on Travis CI work fine with TLS1.2 */
 	OPTIONS[opt_cnt++] = "ssl_protocol_version";
 	OPTIONS[opt_cnt++] = "4";
-#endif
+#	endif
 	ck_assert(ssl_cert != NULL);
 #endif
 	OPTIONS[opt_cnt] = NULL;
@@ -4507,7 +4505,7 @@ END_TEST
 
 #if defined(MG_USE_OPEN_FILE) && !defined(NO_FILES)
 
-#define FILE_IN_MEM_SIZE (1024 * 100)
+#	define FILE_IN_MEM_SIZE (1024 * 100)
 static char *file_in_mem_data;
 
 static const char *
@@ -4535,9 +4533,9 @@ START_TEST(test_file_in_memory)
 	struct mg_callbacks callbacks;
 	const char *OPTIONS[32];
 	int opt_cnt = 0;
-#if !defined(NO_SSL)
+#	if !defined(NO_SSL)
 	const char *ssl_cert = locate_ssl_cert();
-#endif
+#	endif
 
 	/* Client var */
 	struct mg_connection *client;
@@ -4557,16 +4555,16 @@ START_TEST(test_file_in_memory)
 	/* Set options and start server */
 	OPTIONS[opt_cnt++] = "document_root";
 	OPTIONS[opt_cnt++] = ".";
-#if defined(NO_SSL)
+#	if defined(NO_SSL)
 	OPTIONS[opt_cnt++] = "listening_ports";
 	OPTIONS[opt_cnt++] = "8080";
-#else
+#	else
 	OPTIONS[opt_cnt++] = "listening_ports";
 	OPTIONS[opt_cnt++] = "8443s";
 	OPTIONS[opt_cnt++] = "ssl_certificate";
 	OPTIONS[opt_cnt++] = ssl_cert;
 	ck_assert(ssl_cert != NULL);
-#endif
+#	endif
 	OPTIONS[opt_cnt] = NULL;
 
 
@@ -4582,13 +4580,13 @@ START_TEST(test_file_in_memory)
 
 	client =
 	    mg_download("127.0.0.1",
-#if defined(NO_SSL)
+#	if defined(NO_SSL)
 	                8080,
 	                0,
-#else
+#	else
 	                8443,
 	                1,
-#endif
+#	endif
 	                client_err_buf,
 	                sizeof(client_err_buf),
 	                "GET /file_in_mem HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n");
@@ -4756,7 +4754,7 @@ START_TEST(test_minimal_tls_client)
 
 #if !defined(NO_SSL) /* dont run https test if SSL is not enabled */
 
-#if (!defined(__MACH__) || defined(LOCAL_TEST)) && !defined(OPENSSL_API_1_1)
+#	if (!defined(__MACH__) || defined(LOCAL_TEST)) && !defined(OPENSSL_API_1_1)
 	/* dont run on Travis OSX worker with OpenSSL 1.0 */
 
 	/* Initialize the library */
@@ -4774,7 +4772,7 @@ START_TEST(test_minimal_tls_client)
 	/* Un-initialize the library */
 	mg_exit_library();
 
-#endif
+#	endif
 #endif
 
 	mark_point();
@@ -4885,7 +4883,7 @@ START_TEST(test_minimal_https_server_callback)
 	OPTIONS[opt_idx++] = "ssl_certificate";
 	OPTIONS[opt_idx++] = locate_ssl_cert();
 
-#if defined(LOCAL_TEST) || defined(_WIN32)
+#	if defined(LOCAL_TEST) || defined(_WIN32)
 	/* Do not set this on Travis CI, since the build containers
 	 * contain older SSL libraries */
 
@@ -4896,7 +4894,7 @@ START_TEST(test_minimal_https_server_callback)
 	/* set some modern ciphers - recommended */
 	OPTIONS[opt_idx++] = "ssl_cipher_list";
 	OPTIONS[opt_idx++] = "ECDH+AESGCM+AES256:!aNULL:!MD5:!DSS";
-#endif
+#	endif
 
 	/* set "HTTPS only" header - recommended */
 	OPTIONS[opt_idx++] = "strict_transport_security_max_age";

+ 7 - 6
unittest/shared.c

@@ -20,15 +20,16 @@
  */
 
 #ifdef _MSC_VER
-#if !defined(_CRT_SECURE_NO_WARNINGS)
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#if !defined(_CRT_SECURE_NO_DEPRECATE)
-#define _CRT_SECURE_NO_DEPRECATE
-#endif
+#	if !defined(_CRT_SECURE_NO_WARNINGS)
+#		define _CRT_SECURE_NO_WARNINGS
+#	endif
+#	if !defined(_CRT_SECURE_NO_DEPRECATE)
+#		define _CRT_SECURE_NO_DEPRECATE
+#	endif
 #endif
 
 #include "shared.h"
+
 #include <string.h>
 
 static char s_test_directory[1024] = {'\0'};

+ 11 - 11
unittest/timertest.c

@@ -24,26 +24,26 @@
  * static functions
  */
 #ifdef _MSC_VER
-#ifndef _CRT_SECURE_NO_WARNINGS
-#define _CRT_SECURE_NO_WARNINGS
-#endif
+#	ifndef _CRT_SECURE_NO_WARNINGS
+#		define _CRT_SECURE_NO_WARNINGS
+#	endif
 #endif
 
 #if defined(__GNUC__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-function"
+#	pragma GCC diagnostic push
+#	pragma GCC diagnostic ignored "-Wunused-function"
 #endif
 
 #define CIVETWEB_API static
 #define USE_TIMERS
 
+#include "timertest.h"
+
 #include "../src/civetweb.c"
 
 #include <stdlib.h>
 #include <time.h>
 
-#include "timertest.h"
-
 static int action_dec_ret;
 
 static int
@@ -326,10 +326,10 @@ TIMER_PRIVATE(void)
 	unsigned f_avail;
 	unsigned f_ret;
 
-#if defined(_WIN32)
+#	if defined(_WIN32)
 	WSADATA data;
 	WSAStartup(MAKEWORD(2, 2), &data);
-#endif
+#	endif
 
 	f_avail = mg_check_feature(0xFF);
 	f_ret = mg_init_library(f_avail);
@@ -342,9 +342,9 @@ TIMER_PRIVATE(void)
 
 	mg_exit_library();
 
-#if defined(_WIN32)
+#	if defined(_WIN32)
 	WSACleanup();
-#endif
+#	endif
 }
 
 #endif

Some files were not shown because too many files changed in this diff