From 7abfd02991b34bc61f3f058d815c889bc4e1895d Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 26 Mar 2006 20:53:17 +0000 Subject: [PATCH] Portability --- defines.h | 2 ++ dsock.cc | 6 +++--- dsock.h | 2 +- main.cc | 2 ++ tcp.cc | 6 +++--- wjpeg.cc | 2 ++ wjpeg.h | 4 ++++ 7 files changed, 17 insertions(+), 7 deletions(-) diff --git a/defines.h b/defines.h index 8c3b1ee..f95d286 100644 --- a/defines.h +++ b/defines.h @@ -43,6 +43,7 @@ void MILLISLEEP(ULONG a); #define STRCASECMP stricmp #define STRCASESTR StrStrI #define STRTOULL _strtoui64 + #define CLOSESOCKET closesocket #else @@ -53,6 +54,7 @@ void MILLISLEEP(ULONG a); #define STRCASECMP strcasecmp #define STRCASESTR strcasestr #define STRTOULL strtoull + #define CLOSESOCKET close #endif diff --git a/dsock.cc b/dsock.cc index 4acc89f..2e84bd5 100644 --- a/dsock.cc +++ b/dsock.cc @@ -48,7 +48,7 @@ DatagramSocket::DatagramSocket(short port) DatagramSocket::~DatagramSocket() { - close(socketnum); + CLOSESOCKET(socketnum); } DatagramSocket* DatagramSocket::theInstance = 0; @@ -133,9 +133,9 @@ void DatagramSocket::send(char *ipa, short port, char *message, int length) { printf("%s:%i\tOUT %i\t", ipa, port, length); int k; - uchar l; + UCHAR l; for (k = 0; k < length; k++) - { l = (uchar)message[k]; printf("%u ", l); } + { l = (UCHAR)message[k]; printf("%u ", l); } } int sentLength = 0; diff --git a/dsock.h b/dsock.h index 110c31a..d23fc2f 100644 --- a/dsock.h +++ b/dsock.h @@ -31,9 +31,9 @@ #include #include #include +#include "defines.h" #define MAXBUFLEN 2000 -typedef unsigned char uchar; class DatagramSocket { diff --git a/main.cc b/main.cc index 53c629b..e5c9ae7 100644 --- a/main.cc +++ b/main.cc @@ -22,8 +22,10 @@ #include #include #include +#ifndef WIN32 #include #include +#endif #include "defines.h" #include "log.h" diff --git a/tcp.cc b/tcp.cc index 6f68d4f..7ed0222 100644 --- a/tcp.cc +++ b/tcp.cc @@ -32,7 +32,7 @@ TCP::~TCP() { if (connected) { - close(sock); + CLOSESOCKET(sock); Log::getInstance()->log("TCP", Log::DEBUG, "Have closed"); } } @@ -104,7 +104,7 @@ int TCP::connectTo(char* host, unsigned short port) if (success < 1) { // timeout or error - close(sock); + CLOSESOCKET(sock); return 0; } @@ -123,7 +123,7 @@ int TCP::connectTo(char* host, unsigned short port) } else { - close(sock); + CLOSESOCKET(sock); return 0; } diff --git a/wjpeg.cc b/wjpeg.cc index fb64a6a..361a489 100644 --- a/wjpeg.cc +++ b/wjpeg.cc @@ -28,6 +28,7 @@ int WJpeg::init(char* tfileName) void WJpeg::draw() { +#ifndef WIN32 Log* logger = Log::getInstance(); FILE* infile = fopen(fileName, "r"); @@ -106,5 +107,6 @@ void WJpeg::draw() free(buffer); logger->log("BJpeg", Log::DEBUG, "deleted buffer"); +#endif } diff --git a/wjpeg.h b/wjpeg.h index a647cd1..ec2d78d 100644 --- a/wjpeg.h +++ b/wjpeg.h @@ -23,10 +23,14 @@ #include #include +#ifndef WIN32 extern "C" { #include } +#else +//TODO find a replacement on WIN32 +#endif #include "log.h" #include "widget.h" -- 2.39.5