From 3a6396a3cb314a10c82e08dccbf27eafd1b714a7 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 10 Jan 2008 18:52:46 +0000 Subject: [PATCH] mingw portability fixes --- libtransmission/crypto.c | 1 - libtransmission/peer-mgr-private.h | 6 ++++++ libtransmission/peer-mgr.c | 3 +-- libtransmission/peer-mgr.h | 5 +++++ libtransmission/peer-msgs.c | 2 -- libtransmission/shared.c | 1 + libtransmission/tracker.c | 1 - libtransmission/trevent.c | 2 -- libtransmission/utils.c | 5 +++++ 9 files changed, 18 insertions(+), 8 deletions(-) diff --git a/libtransmission/crypto.c b/libtransmission/crypto.c index dee56f86f..7806f3f35 100644 --- a/libtransmission/crypto.c +++ b/libtransmission/crypto.c @@ -15,7 +15,6 @@ #include /* uint8_t */ #include /* memcpy */ #include -#include /* struct in_addr */ #include #include diff --git a/libtransmission/peer-mgr-private.h b/libtransmission/peer-mgr-private.h index 2a48050fd..8c0d9167c 100644 --- a/libtransmission/peer-mgr-private.h +++ b/libtransmission/peer-mgr-private.h @@ -14,7 +14,13 @@ #define TR_PEER_MGR_PRIVATE_H #include /* uint16_t */ + +#ifdef WIN32 +#include /* struct in_addr */ +#else #include /* struct in_addr */ +#endif + #include "publish.h" /* tr_publisher_tag */ struct tr_bitfield; diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index eddf520b2..4788184dd 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -17,7 +17,6 @@ #include /* INT_MAX */ #include /* basename */ -#include /* inet_ntoa */ #include @@ -742,7 +741,7 @@ getPreferredBlocks( Torrent * t, uint64_t * setmeCount ) memcpy( walk, req[s], sizeof(uint64_t) * reqCount[s] ); walk += reqCount[s]; } - assert( ( walk - ret ) == blockCount ); + assert( ( walk - ret ) == ( int )blockCount ); *setmeCount = blockCount; /* cleanup */ diff --git a/libtransmission/peer-mgr.h b/libtransmission/peer-mgr.h index b48d5515e..12c60558f 100644 --- a/libtransmission/peer-mgr.h +++ b/libtransmission/peer-mgr.h @@ -14,7 +14,12 @@ #define TR_PEER_MGR_H #include /* uint16_t */ + +#ifdef WIN32 +#include /* struct in_addr */ +#else #include /* struct in_addr */ +#endif struct in_addr; struct tr_handle; diff --git a/libtransmission/peer-msgs.c b/libtransmission/peer-msgs.c index 06c0e3d93..2f826c530 100644 --- a/libtransmission/peer-msgs.c +++ b/libtransmission/peer-msgs.c @@ -17,8 +17,6 @@ #include #include /* basename */ -#include /* struct in_addr */ - #include #include "transmission.h" diff --git a/libtransmission/shared.c b/libtransmission/shared.c index cbdc10198..694dce252 100644 --- a/libtransmission/shared.c +++ b/libtransmission/shared.c @@ -22,6 +22,7 @@ * DEALINGS IN THE SOFTWARE. *****************************************************************************/ +#include #include #include diff --git a/libtransmission/tracker.c b/libtransmission/tracker.c index 2e1306ba4..16bb9304c 100644 --- a/libtransmission/tracker.c +++ b/libtransmission/tracker.c @@ -16,7 +16,6 @@ #include /* strcmp, strchr */ #include /* basename */ -#include /* evhttp.h needs this */ #include #include diff --git a/libtransmission/trevent.c b/libtransmission/trevent.c index 663de6841..5e4045db7 100644 --- a/libtransmission/trevent.c +++ b/libtransmission/trevent.c @@ -17,8 +17,6 @@ #include #include -#include /* for evhttp */ -#include /* for evhttp */ #include #include diff --git a/libtransmission/utils.c b/libtransmission/utils.c index 5a6a38237..eaa85d4e5 100644 --- a/libtransmission/utils.c +++ b/libtransmission/utils.c @@ -94,7 +94,12 @@ tr_getLogTimeStr( char * buf, int buflen ) now = time( NULL ); gettimeofday( &tv, NULL ); +#ifdef WIN32 + now_tm = *localtime( &now ); +#else localtime_r( &now, &now_tm ); +#endif + strftime( tmp, sizeof(tmp), "%H:%M:%S", &now_tm ); milliseconds = (int)(tv.tv_usec / 1000); snprintf( buf, buflen, "%s.%03d", tmp, milliseconds );