summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-01-17 12:38:25 +0100
committermadmaxoft <github@xoft.cz>2014-01-17 12:38:25 +0100
commitc4f4eda3474bceff61fa275c416e57fe8a3de7fa (patch)
treebf8d619d6ed27c2ba2dc954301bf548b48d0ab90
parentProtoProxy: Fixed #include filename case. (diff)
downloadcuberite-c4f4eda3474bceff61fa275c416e57fe8a3de7fa.tar
cuberite-c4f4eda3474bceff61fa275c416e57fe8a3de7fa.tar.gz
cuberite-c4f4eda3474bceff61fa275c416e57fe8a3de7fa.tar.bz2
cuberite-c4f4eda3474bceff61fa275c416e57fe8a3de7fa.tar.lz
cuberite-c4f4eda3474bceff61fa275c416e57fe8a3de7fa.tar.xz
cuberite-c4f4eda3474bceff61fa275c416e57fe8a3de7fa.tar.zst
cuberite-c4f4eda3474bceff61fa275c416e57fe8a3de7fa.zip
-rw-r--r--Tools/ProtoProxy/Connection.cpp12
-rw-r--r--Tools/ProtoProxy/Globals.h6
-rw-r--r--Tools/ProtoProxy/Server.cpp19
3 files changed, 21 insertions, 16 deletions
diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp
index e91b9935e..de67c6e43 100644
--- a/Tools/ProtoProxy/Connection.cpp
+++ b/Tools/ProtoProxy/Connection.cpp
@@ -249,12 +249,10 @@ void cConnection::Run(void)
void cConnection::Log(const char * a_Format, ...)
{
- va_list args, argsCopy;
+ va_list args;
va_start(args, a_Format);
- va_start(argsCopy, a_Format);
AString msg;
- AppendVPrintf(msg, a_Format, args, argsCopy);
- va_end(argsCopy);
+ AppendVPrintf(msg, a_Format, args);
va_end(args);
AString FullMsg;
Printf(FullMsg, "[%5.3f] %s\n", GetRelativeTime(), msg.c_str());
@@ -276,12 +274,10 @@ void cConnection::Log(const char * a_Format, ...)
void cConnection::DataLog(const void * a_Data, int a_Size, const char * a_Format, ...)
{
- va_list args, argsCopy;
+ va_list args;
va_start(args, a_Format);
- va_start(argsCopy, a_Format);
AString msg;
- AppendVPrintf(msg, a_Format, args, argsCopy);
- va_end(argsCopy);
+ AppendVPrintf(msg, a_Format, args);
va_end(args);
AString FullMsg;
AString Hex;
diff --git a/Tools/ProtoProxy/Globals.h b/Tools/ProtoProxy/Globals.h
index ad81e6810..2b39bfae3 100644
--- a/Tools/ProtoProxy/Globals.h
+++ b/Tools/ProtoProxy/Globals.h
@@ -123,6 +123,12 @@ typedef unsigned short UInt16;
#include <semaphore.h>
#include <errno.h>
#include <fcntl.h>
+
+ typedef SOCKET int;
+ enum
+ {
+ INVALID_SOCKET = -1,
+ };
#if !defined(ANDROID_NDK)
#include <tr1/memory>
#endif
diff --git a/Tools/ProtoProxy/Server.cpp b/Tools/ProtoProxy/Server.cpp
index 35732764c..aa5b74a2a 100644
--- a/Tools/ProtoProxy/Server.cpp
+++ b/Tools/ProtoProxy/Server.cpp
@@ -22,13 +22,16 @@ cServer::cServer(void)
int cServer::Init(short a_ListenPort, short a_ConnectPort)
{
m_ConnectPort = a_ConnectPort;
- WSAData wsa;
- int res = WSAStartup(0x0202, &wsa);
- if (res != 0)
- {
- printf("Cannot initialize WinSock: %d\n", res);
- return res;
- }
+
+ #ifdef _WIN32
+ WSAData wsa;
+ int res = WSAStartup(0x0202, &wsa);
+ if (res != 0)
+ {
+ printf("Cannot initialize WinSock: %d\n", res);
+ return res;
+ }
+ #endif // _WIN32
printf("Generating protocol encryption keypair...\n");
time_t CurTime = time(NULL);
@@ -62,7 +65,7 @@ void cServer::Run(void)
while (true)
{
sockaddr_in Addr;
- ZeroMemory(&Addr, sizeof(Addr));
+ memset(&Addr, 0, sizeof(Addr));
int AddrSize = sizeof(Addr);
SOCKET client = accept(m_ListenSocket, (sockaddr *)&Addr, &AddrSize);
if (client == INVALID_SOCKET)