diff options
author | George Hazan <ghazan@miranda.im> | 2017-02-14 18:08:41 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-02-14 18:08:41 +0300 |
commit | b8e0ee2bea6aac0a1bdf43575585ed78263bbe16 (patch) | |
tree | 281debed38d4e98275db6fa91cd8511a0dc0e08f /src/mir_app | |
parent | 43ab22c6b58eccb328b1c738e6d7aa8e171e9d3f (diff) |
handy little class for managing buffers moved to mir_core
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/netlib.h | 66 | ||||
-rw-r--r-- | src/mir_app/src/netlibhttp.cpp | 4 |
2 files changed, 3 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];
|