diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_app/src/netlib.h | 66 | ||||
-rw-r--r-- | src/mir_app/src/netlibhttp.cpp | 4 | ||||
-rw-r--r-- | src/mir_core/src/binbuffer.cpp | 71 | ||||
-rw-r--r-- | src/mir_core/src/mir_core.def | 9 | ||||
-rw-r--r-- | src/mir_core/src/mir_core64.def | 9 |
5 files changed, 92 insertions, 67 deletions
diff --git a/src/mir_app/src/netlib.h b/src/mir_app/src/netlib.h index 0c0ed55d89..2e958498e0 100644 --- a/src/mir_app/src/netlib.h +++ b/src/mir_app/src/netlib.h @@ -65,70 +65,6 @@ union SOCKADDR_INET_M USHORT si_family;
};
-class NetlibBinBuffer
-{
- char *m_buf;
- int m_len;
-
-public:
- NetlibBinBuffer() :
- m_buf(NULL),
- m_len(0)
- {
- }
-
- ~NetlibBinBuffer()
- {
- mir_free(m_buf);
- }
-
- char* data() const { return m_buf; }
- bool isEmpty() const { return m_len == 0; }
- int length() const { return m_len; }
-
- void append(void *pBuf, int bufLen)
- {
- if (pBuf == NULL || bufLen == 0)
- return;
-
- m_buf = (char*)mir_realloc(m_buf, bufLen + m_len);
- if (m_buf) {
- memcpy(m_buf + m_len, pBuf, bufLen);
- m_len += bufLen;
- }
- else m_len = 0;
- }
-
- void appendBefore(void *pBuf, int bufLen)
- {
- if (pBuf == NULL || bufLen == 0)
- return;
-
- m_buf = (char*)mir_realloc(m_buf, bufLen + m_len);
- if (m_buf) {
- memmove(m_buf + bufLen, m_buf, m_len);
- memcpy(m_buf, pBuf, bufLen);
- m_len += bufLen;
- }
- else m_len = 0;
- }
-
- void remove(int sz)
- {
- if (sz > m_len)
- m_len = sz;
-
- if (m_len == sz) {
- m_len = 0;
- mir_free(m_buf); m_buf = NULL;
- }
- else {
- memmove(m_buf, m_buf + sz, m_len - sz);
- m_len -= sz;
- }
- }
-};
-
struct NetlibConnection : public MZeroedObject
{
NetlibConnection();
@@ -154,7 +90,7 @@ struct NetlibConnection : public MZeroedObject // SSL support
HSSL hSsl;
- NetlibBinBuffer foreBuf;
+ MBinBuffer foreBuf;
// proxy support
NETLIBHTTPPROXYINFO nlhpi;
diff --git a/src/mir_app/src/netlibhttp.cpp b/src/mir_app/src/netlibhttp.cpp index a680d26f67..ac8bb5e889 100644 --- a/src/mir_app/src/netlibhttp.cpp +++ b/src/mir_app/src/netlibhttp.cpp @@ -746,7 +746,7 @@ MIR_APP_DLL(NETLIBHTTPREQUEST*) Netlib_RecvHttpHeaders(HNETLIBCONN hConnection, }
// Make sure all headers arrived
- NetlibBinBuffer buf;
+ MBinBuffer buf;
int headersCount = 0;
bytesPeeked = 0;
for (bool headersCompleted = false; !headersCompleted;) {
@@ -966,7 +966,7 @@ char* gzip_decode(char *gzip_data, int *len_ptr, int window) static int NetlibHttpRecvChunkHeader(NetlibConnection *nlc, bool first, DWORD flags)
{
- NetlibBinBuffer buf;
+ MBinBuffer buf;
while (true) {
char data[1000];
diff --git a/src/mir_core/src/binbuffer.cpp b/src/mir_core/src/binbuffer.cpp new file mode 100644 index 0000000000..fe6326077a --- /dev/null +++ b/src/mir_core/src/binbuffer.cpp @@ -0,0 +1,71 @@ +/* +Copyright (C) 2012-17 Miranda NG team (http://miranda-ng.org) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation version 2 +of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "stdafx.h" + +MBinBuffer::MBinBuffer() : + m_buf(NULL), + m_len(0) +{ +} + +MBinBuffer::~MBinBuffer() +{ + mir_free(m_buf); +} + +void MBinBuffer::append(void *pBuf, size_t bufLen) +{ + if (pBuf == NULL || bufLen == 0) + return; + + m_buf = (char*)mir_realloc(m_buf, bufLen + m_len); + if (m_buf) { + memcpy(m_buf + m_len, pBuf, bufLen); + m_len += bufLen; + } + else m_len = 0; +} + +void MBinBuffer::appendBefore(void *pBuf, size_t bufLen) +{ + if (pBuf == NULL || bufLen == 0) + return; + + m_buf = (char*)mir_realloc(m_buf, bufLen + m_len); + if (m_buf) { + memmove(m_buf + bufLen, m_buf, m_len); + memcpy(m_buf, pBuf, bufLen); + m_len += bufLen; + } + else m_len = 0; +} + +void MBinBuffer::remove(size_t sz) +{ + if (sz > m_len) + m_len = sz; + + if (m_len == sz) { + m_len = 0; + mir_free(m_buf); m_buf = NULL; + } + else { + memmove(m_buf, m_buf + sz, m_len - sz); + m_len -= sz; + } +} diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index bb24cd6108..bbe3628c5d 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -1046,3 +1046,12 @@ CallFunctionSync @1170 ?GetNthPage@CCtrlPages@@QAEPAVCDlgBase@@H@Z @1203 NONAME
?GetItemPage@CCtrlPages@@AAEPAUTPageInfo@1@H@Z @1204 NONAME
?RemovePage@CCtrlPages@@QAEXH@Z @1205 NONAME
+??0MBinBuffer@@QAE@XZ @1206 NONAME
+??1MBinBuffer@@QAE@XZ @1207 NONAME
+??4MBinBuffer@@QAEAAV0@ABV0@@Z @1208 NONAME
+?append@MBinBuffer@@QAEXPAXI@Z @1209 NONAME
+?appendBefore@MBinBuffer@@QAEXPAXI@Z @1210 NONAME
+?data@MBinBuffer@@QBEPADXZ @1211 NONAME
+?isEmpty@MBinBuffer@@QBE_NXZ @1212 NONAME
+?length@MBinBuffer@@QBEIXZ @1213 NONAME
+?remove@MBinBuffer@@QAEXI@Z @1214 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index e8a9e2d9cb..7ce3f990e3 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -1046,3 +1046,12 @@ CallFunctionSync @1170 ?GetNthPage@CCtrlPages@@QEAAPEAVCDlgBase@@H@Z @1203 NONAME
?GetItemPage@CCtrlPages@@AEAAPEAUTPageInfo@1@H@Z @1204 NONAME
?RemovePage@CCtrlPages@@QEAAXH@Z @1205 NONAME
+??0MBinBuffer@@QEAA@XZ @1206 NONAME
+??1MBinBuffer@@QEAA@XZ @1207 NONAME
+??4MBinBuffer@@QEAAAEAV0@AEBV0@@Z @1208 NONAME
+?append@MBinBuffer@@QEAAXPEAX_K@Z @1209 NONAME
+?appendBefore@MBinBuffer@@QEAAXPEAX_K@Z @1210 NONAME
+?data@MBinBuffer@@QEBAPEADXZ @1211 NONAME
+?isEmpty@MBinBuffer@@QEBA_NXZ @1212 NONAME
+?length@MBinBuffer@@QEBA_KXZ @1213 NONAME
+?remove@MBinBuffer@@QEAAX_K@Z @1214 NONAME
|