From 998425b14b5936cdcbfa24a22a60881e385d4f99 Mon Sep 17 00:00:00 2001
From: Sergey Lyubka <valenok@gmail.com>
Date: Mon, 10 Feb 2014 10:21:57 +0000
Subject: [PATCH] Styling changes for hexdump

---
 mongoose.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/mongoose.c b/mongoose.c
index d12d4c2ab..863d25d82 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -2029,12 +2029,15 @@ static void callback_http_client_on_connect(struct connection *conn) {
 #ifdef MONGOOSE_HEXDUMP
 static void hexdump(const struct connection *conn, const void *buf,
                     int len, const char *marker) {
-  if (match_prefix(MONGOOSE_HEXDUMP, strlen(MONGOOSE_HEXDUMP),
-                   conn->mg_conn.remote_ip))  {
   const unsigned char *p = (const unsigned char *) buf;
   char path[MAX_PATH_SIZE], date[100], ascii[17];
   FILE *fp;
 
+  if (!match_prefix(MONGOOSE_HEXDUMP, strlen(MONGOOSE_HEXDUMP),
+                    conn->mg_conn.remote_ip)) {
+    return;
+  }
+
   snprintf(path, sizeof(path), "%s.%hu.txt",
            conn->mg_conn.remote_ip, conn->mg_conn.remote_port);
 
@@ -2062,7 +2065,6 @@ static void hexdump(const struct connection *conn, const void *buf,
     fclose(fp);
   }
 }
-}
 #endif
 
 static void write_to_socket(struct connection *conn) {
@@ -2085,7 +2087,7 @@ static void write_to_socket(struct connection *conn) {
        conn, n, io->len, io->size, io->len < 40 ? io->len : 40, io->buf));
 
 #ifdef MONGOOSE_HEXDUMP
-    hexdump(conn, io->buf, n, "->");
+  hexdump(conn, io->buf, n, "->");
 #endif
 
   if (is_error(n)) {
@@ -3699,7 +3701,7 @@ static void read_from_socket(struct connection *conn) {
   DBG(("%p %d %d (1)", conn, n, conn->flags));
 
 #ifdef MONGOOSE_HEXDUMP
-    hexdump(conn, buf, n, "<-");
+  hexdump(conn, buf, n, "<-");
 #endif
 
   if (is_error(n)) {
-- 
GitLab