Преглед на файлове

Auto-format after merge

bel преди 9 години
родител
ревизия
ce1c8a6095
променени са 4 файла, в които са добавени 51 реда и са изтрити 46 реда
  1. 22 19
      src/civetweb.c
  2. 20 20
      src/mod_lua.inl
  3. 3 3
      test/public_func.c
  4. 6 4
      test/public_server.c

+ 22 - 19
src/civetweb.c

@@ -2106,7 +2106,8 @@ reparse:
 /* A helper function for checking if a comma separated list of values contains
 /* A helper function for checking if a comma separated list of values contains
  * the given option (case insensitvely).
  * the given option (case insensitvely).
  * 'header' can be NULL, in which case false is returned. */
  * 'header' can be NULL, in which case false is returned. */
-static int header_has_option(const char *header, const char *option)
+static int
+header_has_option(const char *header, const char *option)
 {
 {
 	struct vec opt_vec;
 	struct vec opt_vec;
 	struct vec eq_vec;
 	struct vec eq_vec;
@@ -10586,7 +10587,7 @@ ssl_id_callback(void)
 
 
 
 
 static int ssl_use_pem_file(struct mg_context *ctx, const char *pem);
 static int ssl_use_pem_file(struct mg_context *ctx, const char *pem);
-static const char * ssl_error(void);
+static const char *ssl_error(void);
 
 
 
 
 static int
 static int
@@ -10598,37 +10599,39 @@ refresh_trust(struct mg_connection *conn)
 	struct stat cert_buf;
 	struct stat cert_buf;
 	long int t;
 	long int t;
 	char *pem;
 	char *pem;
-    int should_verify_peer;
+	int should_verify_peer;
 
 
 	if ((pem = conn->ctx->config[SSL_CERTIFICATE]) == NULL
 	if ((pem = conn->ctx->config[SSL_CERTIFICATE]) == NULL
-		&& conn->ctx->callbacks.init_ssl == NULL) {
+	    && conn->ctx->callbacks.init_ssl == NULL) {
 		return 0;
 		return 0;
 	}
 	}
 
 
-    t = data_check;
+	t = data_check;
 	if (stat(pem, &cert_buf) != -1) {
 	if (stat(pem, &cert_buf) != -1) {
-		t = (long int) cert_buf.st_mtime;
+		t = (long int)cert_buf.st_mtime;
 	}
 	}
 
 
 	if (data_check != t) {
 	if (data_check != t) {
 		data_check = t;
 		data_check = t;
 
 
 		should_verify_peer =
 		should_verify_peer =
-				(conn->ctx->config[SSL_DO_VERIFY_PEER] != NULL)
-				&& (mg_strcasecmp(conn->ctx->config[SSL_DO_VERIFY_PEER], "yes") == 0);
+		    (conn->ctx->config[SSL_DO_VERIFY_PEER] != NULL)
+		    && (mg_strcasecmp(conn->ctx->config[SSL_DO_VERIFY_PEER], "yes")
+		        == 0);
 
 
 		if (should_verify_peer) {
 		if (should_verify_peer) {
 			char *ca_path = conn->ctx->config[SSL_CA_PATH];
 			char *ca_path = conn->ctx->config[SSL_CA_PATH];
 			char *ca_file = conn->ctx->config[SSL_CA_FILE];
 			char *ca_file = conn->ctx->config[SSL_CA_FILE];
-			if (SSL_CTX_load_verify_locations(conn->ctx->ssl_ctx, ca_file, ca_path)
-				!= 1) {
+			if (SSL_CTX_load_verify_locations(conn->ctx->ssl_ctx,
+			                                  ca_file,
+			                                  ca_path) != 1) {
 				mg_cry(fc(conn->ctx),
 				mg_cry(fc(conn->ctx),
-					   "SSL_CTX_load_verify_locations error: %s "
-							   "ssl_verify_peer requires setting "
-							   "either ssl_ca_path or ssl_ca_file. Is any of them "
-							   "present in "
-							   "the .conf file?",
-					   ssl_error());
+				       "SSL_CTX_load_verify_locations error: %s "
+				       "ssl_verify_peer requires setting "
+				       "either ssl_ca_path or ssl_ca_file. Is any of them "
+				       "present in "
+				       "the .conf file?",
+				       ssl_error());
 				return 0;
 				return 0;
 			}
 			}
 		}
 		}
@@ -10657,15 +10660,15 @@ static int
 sslize(struct mg_connection *conn, SSL_CTX *s, int (*func)(SSL *))
 sslize(struct mg_connection *conn, SSL_CTX *s, int (*func)(SSL *))
 {
 {
 	int ret, err;
 	int ret, err;
-    int short_trust;
+	int short_trust;
 
 
 	if (!conn) {
 	if (!conn) {
 		return 0;
 		return 0;
 	}
 	}
 
 
 	short_trust =
 	short_trust =
-			(conn->ctx->config[SSL_SHORT_TRUST] != NULL)
-			&& (mg_strcasecmp(conn->ctx->config[SSL_SHORT_TRUST], "yes") == 0);
+	    (conn->ctx->config[SSL_SHORT_TRUST] != NULL)
+	    && (mg_strcasecmp(conn->ctx->config[SSL_SHORT_TRUST], "yes") == 0);
 
 
 	if (short_trust) {
 	if (short_trust) {
 		int trust_ret = refresh_trust(conn);
 		int trust_ret = refresh_trust(conn);

+ 20 - 20
src/mod_lua.inl

@@ -852,13 +852,13 @@ lsp_random(lua_State *L)
 	int num_args = lua_gettop(L);
 	int num_args = lua_gettop(L);
 	if (num_args == 0) {
 	if (num_args == 0) {
 		/* The civetweb internal random number generator will generate
 		/* The civetweb internal random number generator will generate
-                 * a 64 bit random number. */
+		         * a 64 bit random number. */
 		uint64_t r = get_random();
 		uint64_t r = get_random();
-                /* Lua "number" is a IEEE 754 double precission float:
-		 * 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. */
-		r &= ((((uint64_t)1)<<53)-1);
+		/* Lua "number" is a IEEE 754 double precission float:
+ * 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. */
+		r &= ((((uint64_t)1) << 53) - 1);
 		lua_pushnumber(L, (double)r);
 		lua_pushnumber(L, (double)r);
 		return 1;
 		return 1;
 	}
 	}
@@ -898,19 +898,20 @@ lsp_uuid(lua_State *L)
 
 
 		pf_uuid_generate.f(uuid.uuid_array);
 		pf_uuid_generate.f(uuid.uuid_array);
 
 
-		sprintf(uuid_str, "{%08lX-%04X-%04X-%02X%02X-"
-			"%02X%02X%02X%02X%02X%02X}",
-			(unsigned long)uuid.uuid_struct.data1, 
-			(unsigned)uuid.uuid_struct.data2,
-			(unsigned)uuid.uuid_struct.data3, 
-			(unsigned)uuid.uuid_struct.data4[0],
-			(unsigned)uuid.uuid_struct.data4[1],
-			(unsigned)uuid.uuid_struct.data4[2],
-			(unsigned)uuid.uuid_struct.data4[3],
-			(unsigned)uuid.uuid_struct.data4[4],
-			(unsigned)uuid.uuid_struct.data4[5],
-			(unsigned)uuid.uuid_struct.data4[6],
-			(unsigned)uuid.uuid_struct.data4[7]);
+		sprintf(uuid_str,
+		        "{%08lX-%04X-%04X-%02X%02X-"
+		        "%02X%02X%02X%02X%02X%02X}",
+		        (unsigned long)uuid.uuid_struct.data1,
+		        (unsigned)uuid.uuid_struct.data2,
+		        (unsigned)uuid.uuid_struct.data3,
+		        (unsigned)uuid.uuid_struct.data4[0],
+		        (unsigned)uuid.uuid_struct.data4[1],
+		        (unsigned)uuid.uuid_struct.data4[2],
+		        (unsigned)uuid.uuid_struct.data4[3],
+		        (unsigned)uuid.uuid_struct.data4[4],
+		        (unsigned)uuid.uuid_struct.data4[5],
+		        (unsigned)uuid.uuid_struct.data4[6],
+		        (unsigned)uuid.uuid_struct.data4[7]);
 
 
 		lua_pushstring(L, uuid_str);
 		lua_pushstring(L, uuid_str);
 		return 1;
 		return 1;
@@ -1837,4 +1838,3 @@ lua_init_optional_libraries(void)
 	pf_uuid_generate.p = 0;
 	pf_uuid_generate.p = 0;
 #endif
 #endif
 }
 }
-

+ 3 - 3
test/public_func.c

@@ -20,9 +20,9 @@
  */
  */
 
 
 #ifdef _MSC_VER
 #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
 #endif
 
 
 #include <stdlib.h>
 #include <stdlib.h>

+ 6 - 4
test/public_server.c

@@ -902,10 +902,13 @@ START_TEST(test_request_handlers)
 	ck_assert(ri != NULL);
 	ck_assert(ri != NULL);
 	ck_assert_str_eq(ri->uri, "200");
 	ck_assert_str_eq(ri->uri, "200");
 	i = mg_read(client_conn, buf, sizeof(buf));
 	i = mg_read(client_conn, buf, sizeof(buf));
-	if ((i>=0) && ((size_t)i<sizeof(buf))) {
+	if ((i >= 0) && ((size_t)i < sizeof(buf))) {
 		buf[i] = 0;
 		buf[i] = 0;
-        } else {
-		ck_abort_msg("ERROR: test_request_handlers: read returned %i (>=0, <%i)", (int)i, (int)sizeof(buf));
+	} else {
+		ck_abort_msg(
+		    "ERROR: test_request_handlers: read returned %i (>=0, <%i)",
+		    (int)i,
+		    (int)sizeof(buf));
 	}
 	}
 	ck_assert((int)i < (int)sizeof(buf));
 	ck_assert((int)i < (int)sizeof(buf));
 	ck_assert(i > 0);
 	ck_assert(i > 0);
@@ -1566,4 +1569,3 @@ suite_create(const char *name)
 void tcase_set_timeout(TCase *tc, double timeout){};
 void tcase_set_timeout(TCase *tc, double timeout){};
 
 
 #endif
 #endif
-