summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src/jabber_zstream.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-11-15 21:18:48 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-11-15 21:18:48 +0000
commit7ebaebba8520e457bf374ca245f52332fbb008be (patch)
tree55cf960e4981d9413befb1bf275a3fd067bf2534 /protocols/JabberG/src/jabber_zstream.cpp
parent8353de363fc22940685b334cbb38c0378e9c1b71 (diff)
bye-bye old coding style in Jabber
git-svn-id: http://svn.miranda-ng.org/main/trunk@2322 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/src/jabber_zstream.cpp')
-rw-r--r--protocols/JabberG/src/jabber_zstream.cpp84
1 files changed, 42 insertions, 42 deletions
diff --git a/protocols/JabberG/src/jabber_zstream.cpp b/protocols/JabberG/src/jabber_zstream.cpp
index 11829bf401..f5417b2470 100644
--- a/protocols/JabberG/src/jabber_zstream.cpp
+++ b/protocols/JabberG/src/jabber_zstream.cpp
@@ -3,13 +3,13 @@
Jabber Protocol Plugin for Miranda IM
XEP-0138 (Stream Compression) implementation
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Kostya Chukavin, Taras Zackrepa
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Kostya Chukavin, Taras Zackrepa
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; either version 2
-of the License, or ( at your option ) any later version.
+of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -24,9 +24,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "jabber.h"
-BOOL ThreadData::zlibInit( void )
+BOOL ThreadData::zlibInit(void)
{
- proto->Log( "Zlib init..." );
+ proto->Log("Zlib init...");
zStreamIn.zalloc = Z_NULL;
zStreamIn.zfree = Z_NULL;
zStreamIn.opaque = Z_NULL;
@@ -37,92 +37,92 @@ BOOL ThreadData::zlibInit( void )
zStreamOut.zfree = Z_NULL;
zStreamOut.opaque = Z_NULL;
- if ( deflateInit( &zStreamOut, Z_BEST_COMPRESSION) != Z_OK ) return FALSE;
- if ( inflateInit( &zStreamIn ) != Z_OK ) return FALSE;
+ if (deflateInit(&zStreamOut, Z_BEST_COMPRESSION) != Z_OK) return FALSE;
+ if (inflateInit(&zStreamIn) != Z_OK) return FALSE;
zRecvReady = true;
return TRUE;
}
-void ThreadData::zlibUninit( void )
+void ThreadData::zlibUninit(void)
{
- deflateEnd( &zStreamOut );
- inflateEnd( &zStreamIn );
+ deflateEnd(&zStreamOut);
+ inflateEnd(&zStreamIn);
}
-int ThreadData::zlibSend( char* data, int datalen )
+int ThreadData::zlibSend(char* data, int datalen)
{
char send_data[ ZLIB_CHUNK_SIZE ];
int bytesOut = 0;
zStreamOut.avail_in = datalen;
- zStreamOut.next_in = ( unsigned char* )data;
+ zStreamOut.next_in = (unsigned char*)data;
do {
zStreamOut.avail_out = ZLIB_CHUNK_SIZE;
- zStreamOut.next_out = ( unsigned char* )send_data;
+ zStreamOut.next_out = (unsigned char*)send_data;
- switch ( deflate( &zStreamOut, Z_SYNC_FLUSH )) {
- case Z_OK: proto->Log( "Deflate: Z_OK" ); break;
- case Z_BUF_ERROR: proto->Log( "Deflate: Z_BUF_ERROR" ); break;
- case Z_DATA_ERROR: proto->Log( "Deflate: Z_DATA_ERROR" ); break;
- case Z_MEM_ERROR: proto->Log( "Deflate: Z_MEM_ERROR" ); break;
+ switch (deflate(&zStreamOut, Z_SYNC_FLUSH)) {
+ case Z_OK: proto->Log("Deflate: Z_OK"); break;
+ case Z_BUF_ERROR: proto->Log("Deflate: Z_BUF_ERROR"); break;
+ case Z_DATA_ERROR: proto->Log("Deflate: Z_DATA_ERROR"); break;
+ case Z_MEM_ERROR: proto->Log("Deflate: Z_MEM_ERROR"); break;
}
int len, send_datalen = ZLIB_CHUNK_SIZE - zStreamOut.avail_out;
- if (( len = sendws( send_data, send_datalen, MSG_NODUMP )) == SOCKET_ERROR || len != send_datalen ) {
- proto->Log( "Netlib_Send() failed, error=%d", WSAGetLastError());
+ if ((len = sendws(send_data, send_datalen, MSG_NODUMP)) == SOCKET_ERROR || len != send_datalen) {
+ proto->Log("Netlib_Send() failed, error=%d", WSAGetLastError());
return FALSE;
}
bytesOut += len;
}
- while ( zStreamOut.avail_out == 0 );
+ while (zStreamOut.avail_out == 0);
- if ( DBGetContactSettingByte( NULL, "Netlib", "DumpSent", TRUE ) == TRUE )
- proto->Log( "(ZLIB) Data sent\n%s\n===OUT: %d(%d) bytes", data, datalen, bytesOut );
+ if (db_get_b(NULL, "Netlib", "DumpSent", TRUE) == TRUE)
+ proto->Log("(ZLIB) Data sent\n%s\n===OUT: %d(%d) bytes", data, datalen, bytesOut);
return TRUE;
}
-int ThreadData::zlibRecv( char* data, long datalen )
+int ThreadData::zlibRecv(char* data, long datalen)
{
- if ( zRecvReady ) {
+ if (zRecvReady) {
retry:
- zRecvDatalen = recvws( zRecvData, ZLIB_CHUNK_SIZE, MSG_NODUMP );
- if ( zRecvDatalen == SOCKET_ERROR ) {
- proto->Log( "Netlib_Recv() failed, error=%d", WSAGetLastError());
+ zRecvDatalen = recvws(zRecvData, ZLIB_CHUNK_SIZE, MSG_NODUMP);
+ if (zRecvDatalen == SOCKET_ERROR) {
+ proto->Log("Netlib_Recv() failed, error=%d", WSAGetLastError());
return SOCKET_ERROR;
}
- if ( zRecvDatalen == 0 )
+ if (zRecvDatalen == 0)
return 0;
zStreamIn.avail_in = zRecvDatalen;
- zStreamIn.next_in = ( Bytef* )zRecvData;
+ zStreamIn.next_in = (Bytef*)zRecvData;
}
zStreamIn.avail_out = datalen;
- zStreamIn.next_out = ( BYTE* )data;
+ zStreamIn.next_out = (BYTE*)data;
- switch ( inflate( &zStreamIn, Z_NO_FLUSH )) {
- case Z_OK: proto->Log( "Inflate: Z_OK" ); break;
- case Z_BUF_ERROR: proto->Log( "Inflate: Z_BUF_ERROR" ); break;
- case Z_DATA_ERROR: proto->Log( "Inflate: Z_DATA_ERROR" ); break;
- case Z_MEM_ERROR: proto->Log( "Inflate: Z_MEM_ERROR" ); break;
+ switch (inflate(&zStreamIn, Z_NO_FLUSH)) {
+ case Z_OK: proto->Log("Inflate: Z_OK"); break;
+ case Z_BUF_ERROR: proto->Log("Inflate: Z_BUF_ERROR"); break;
+ case Z_DATA_ERROR: proto->Log("Inflate: Z_DATA_ERROR"); break;
+ case Z_MEM_ERROR: proto->Log("Inflate: Z_MEM_ERROR"); break;
}
int len = datalen - zStreamIn.avail_out;
- if ( DBGetContactSettingByte( NULL, "Netlib", "DumpRecv", TRUE ) == TRUE ) {
- char* szLogBuffer = ( char* )alloca( len+32 );
- memcpy( szLogBuffer, data, len );
+ if (db_get_b(NULL, "Netlib", "DumpRecv", TRUE) == TRUE) {
+ char* szLogBuffer = (char*)alloca(len+32);
+ memcpy(szLogBuffer, data, len);
szLogBuffer[ len ]='\0';
- proto->Log( "(ZLIB) Data received\n%s\n===IN: %d(%d) bytes", szLogBuffer, len, zRecvDatalen );
+ proto->Log("(ZLIB) Data received\n%s\n===IN: %d(%d) bytes", szLogBuffer, len, zRecvDatalen);
}
- if ( len == 0 )
+ if (len == 0)
goto retry;
- zRecvReady = ( zStreamIn.avail_out != 0 );
+ zRecvReady = (zStreamIn.avail_out != 0);
return len;
}