diff options
author | George Hazan <ghazan@miranda.im> | 2020-02-03 18:25:06 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-02-03 18:25:06 +0300 |
commit | d28a5f0ec74910a1ba7c030fc56b61f85d396b1c (patch) | |
tree | 8510f4c43e59947297456df20a85b45597bcfc6c | |
parent | ccda0be02f89020a4c295491663b2d6edcfcc999 (diff) |
Netlib_Dump exported from mir_app
-rw-r--r-- | include/m_netlib.h | 2 | ||||
-rw-r--r-- | libs/win32/mir_app.lib | bin | 201040 -> 201600 bytes | |||
-rw-r--r-- | libs/win64/mir_app.lib | bin | 196642 -> 197188 bytes | |||
-rw-r--r-- | src/mir_app/src/mir_app.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/netlib.h | 1 | ||||
-rw-r--r-- | src/mir_app/src/netlib_http.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/netlib_log.cpp | 12 | ||||
-rw-r--r-- | src/mir_app/src/netlib_sock.cpp | 4 |
9 files changed, 15 insertions, 8 deletions
diff --git a/include/m_netlib.h b/include/m_netlib.h index 1d5be72fd2..c7f7313901 100644 --- a/include/m_netlib.h +++ b/include/m_netlib.h @@ -753,6 +753,8 @@ EXTERN_C MIR_APP_DLL(int) Netlib_LogW(HNETLIBUSER hUser, const wchar_t *pwszStr) EXTERN_C MIR_APP_DLL(int) Netlib_Logf(HNETLIBUSER hUser, _Printf_format_string_ const char *fmt, ...);
EXTERN_C MIR_APP_DLL(int) Netlib_LogfW(HNETLIBUSER hUser, _Printf_format_string_ const wchar_t *fmt, ...);
+EXTERN_C MIR_APP_DLL(void) Netlib_Dump(HNETLIBCONN nlc, const void *buf, size_t len, bool bIsSent, int flags);
+
/////////////////////////////////////////////////////////////////////////////////////////
// Security providers (0.6+)
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex e7ae777699..cbecd7fe9b 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex 64fea1de5c..6cf421c98e 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index bc8f8229f5..c271415c83 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -721,3 +721,4 @@ _WebSocket_Send@12 @808 NONAME _WebSocket_InitHeader@12 @809 NONAME
_WebSocket_Connect@12 @810 NONAME
?log@CSrmmBaseDialog@@QBEPAVCSrmmLogWindow@@XZ @811 NONAME
+Netlib_Dump @812 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index b952ccb7ef..882311a4a0 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -721,3 +721,4 @@ WebSocket_Send @808 NONAME WebSocket_InitHeader @809 NONAME
WebSocket_Connect @810 NONAME
?log@CSrmmBaseDialog@@QEBAPEAVCSrmmLogWindow@@XZ @811 NONAME
+Netlib_Dump @812 NONAME
diff --git a/src/mir_app/src/netlib.h b/src/mir_app/src/netlib.h index 714efc793b..7eed993edf 100644 --- a/src/mir_app/src/netlib.h +++ b/src/mir_app/src/netlib.h @@ -164,7 +164,6 @@ void NetlibConnFromUrl(const char* szUrl, bool secur, NETLIBOPENCONNECTION &nloc // netliblog.c
void NetlibLogShowOptions(void);
-void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int flags);
void NetlibLogInit(void);
void NetlibLogShutdown(void);
diff --git a/src/mir_app/src/netlib_http.cpp b/src/mir_app/src/netlib_http.cpp index 5bd58996dd..dda54725fc 100644 --- a/src/mir_app/src/netlib_http.cpp +++ b/src/mir_app/src/netlib_http.cpp @@ -1124,7 +1124,7 @@ next: } if (bufsz > 0) { - NetlibDumpData(nlc, (PBYTE)szData, bufsz, 0, dflags | MSG_NOTITLE); + Netlib_Dump(nlc, (PBYTE)szData, bufsz, false, dflags | MSG_NOTITLE); mir_free(nlhrReply->pData); nlhrReply->pData = szData; nlhrReply->dataLength = bufsz; diff --git a/src/mir_app/src/netlib_log.cpp b/src/mir_app/src/netlib_log.cpp index 127946259a..07a10d6f4c 100644 --- a/src/mir_app/src/netlib_log.cpp +++ b/src/mir_app/src/netlib_log.cpp @@ -409,7 +409,7 @@ MIR_APP_DLL(int) Netlib_LogW(HNETLIBUSER hUser, const wchar_t *pwszStr) ///////////////////////////////////////////////////////////////////////////////////////// -void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int flags) +MIR_APP_DLL(void) Netlib_Dump(HNETLIBCONN nlc, const void *pBuf, size_t len, bool bIsSent, int flags) { // This section checks a number of conditions and aborts // the dump if the data should not be written to the log @@ -421,7 +421,7 @@ void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int fla // Check user's log settings if (!(logOptions.toOutputDebugString || GetSubscribersCount((THook*)hLogEvent) != 0 || (logOptions.toFile && !logOptions.tszFile.IsEmpty()))) return; - if ((sent && !logOptions.dumpSent) || (!sent && !logOptions.dumpRecv)) + if ((bIsSent && !logOptions.dumpSent) || (!bIsSent && !logOptions.dumpRecv)) return; if ((flags & MSG_DUMPPROXY) && !logOptions.dumpProxy) return; @@ -434,7 +434,7 @@ void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int fla NetlibUser *nlu = nlc ? nlc->nlu : nullptr; if (!(flags & MSG_NOTITLE)) - str.Format("(%p:%u) Data %s%s\r\n", nlc, nlc ? (int)nlc->s : 0, sent ? "sent" : "received", flags & MSG_DUMPPROXY ? " (proxy)" : ""); + str.Format("(%p:%u) Data %s%s\r\n", nlc, nlc ? (int)nlc->s : 0, bIsSent ? "sent" : "received", flags & MSG_DUMPPROXY ? " (proxy)" : ""); ReleaseMutex(hConnectionHeaderMutex); // check filter settings @@ -445,6 +445,8 @@ void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int fla else if (!nlu->toLog) return; + const uint8_t *buf = (const uint8_t *)pBuf; + bool isText = true; if (!logOptions.textDumps) isText = false; @@ -467,7 +469,7 @@ void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int fla // Binary data else { for (int line = 0;; line += 16) { - PBYTE p = buf + line; + auto *p = buf + line; int colsInLine = min(16, len - line); if (colsInLine == 16) str.AppendFormat("%08X: %02X %02X %02X %02X-%02X %02X %02X %02X-%02X %02X %02X %02X-%02X %02X %02X %02X ", @@ -501,6 +503,8 @@ void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int fla NetlibLog_Worker(nlu, str, flags); } +///////////////////////////////////////////////////////////////////////////////////////// + void NetlibLogInit(void) { LARGE_INTEGER li; diff --git a/src/mir_app/src/netlib_sock.cpp b/src/mir_app/src/netlib_sock.cpp index 63c5945430..2c4bfdc82a 100644 --- a/src/mir_app/src/netlib_sock.cpp +++ b/src/mir_app/src/netlib_sock.cpp @@ -35,7 +35,7 @@ MIR_APP_DLL(int) Netlib_Send(HNETLIBCONN nlc, const char *buf, int len, int flag return SOCKET_ERROR; int result; - NetlibDumpData(nlc, (PBYTE)buf, len, 1, flags); + Netlib_Dump(nlc, (PBYTE)buf, len, true, flags); if (nlc->hSsl) result = sslApi.write(nlc->hSsl, buf, len); else @@ -71,7 +71,7 @@ MIR_APP_DLL(int) Netlib_Recv(HNETLIBCONN nlc, char *buf, int len, int flags) if (recvResult <= 0) return recvResult; - NetlibDumpData(nlc, (PBYTE)buf, recvResult, 0, flags); + Netlib_Dump(nlc, (PBYTE)buf, recvResult, false, flags); if ((flags & MSG_PEEK) == 0) { NETLIBNOTIFY nln = { buf, len, flags, recvResult }; |