wiki:BuildingTransmissionQtWindows/transmission-2.00-Qt-build.diff

Version 2 (modified by rb07, 13 years ago) (diff)

Updated patch (cleanup and fix to inet_pton)

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/libtransmission/JSON_parser.h transmission-2.00/libtransmission/JSON_parser.h --- transmission-2.00-orig/libtransmission/JSON_parser.h 2010-06-15 20:32:58.000000000 -0500 +++ transmission-2.00/libtransmission/JSON_parser.h 2010-06-17 18:52:25.000000000 -0500 @@ -11,7 +11,7 @@

#include <stddef.h>

/* Windows DLL stuff */

-#ifdef _WIN32 +#if defined(WIN32) && !defined(STATICLIB)

# ifdef JSON_PARSER_DLL_EXPORTS # define JSON_PARSER_DLL_API declspec(dllexport) # else

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/libtransmission/Makefile.am transmission-2.00/libtransmission/Makefile.am --- transmission-2.00-orig/libtransmission/Makefile.am 2010-06-15 20:32:58.000000000 -0500 +++ transmission-2.00/libtransmission/Makefile.am 2010-06-18 20:39:57.000000000 -0500 @@ -136,6 +136,7 @@

./libtransmission.a \ $(top_builddir)/third-party/miniupnp/libminiupnp.a \ $(top_builddir)/third-party/libnatpmp/libnatpmp.a \

+ -liphlpapi \

@INTLLIBS@ \ @DHT_LIBS@ \ @LIBCURL_LIBS@ \

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/libtransmission/bencode.c transmission-2.00/libtransmission/bencode.c --- transmission-2.00-orig/libtransmission/bencode.c 2010-06-15 20:32:58.000000000 -0500 +++ transmission-2.00/libtransmission/bencode.c 2010-06-18 20:58:51.000000000 -0500 @@ -17,6 +17,10 @@

#include <stdio.h> #include <stdlib.h> /* realpath() */ #include <string.h>

+#ifdef WIN32 + #include <fcntl.h> + #define fsync _commit +#endif

#include <sys/types.h> /* stat() */ #include <sys/stat.h> /* stat() */

@@ -1625,11 +1629,16 @@

/* follow symlinks to find the "real" file, to make sure the temporary

  • we build with mkstemp() is created on the right partition */
  • if( realpath( filename, buf ) != NULL )

+ if( tr_realpath( filename, buf ) != NULL )

filename = buf;

/* if the file already exists, try to move it out of the way & keep it as a backup */

+#ifdef WIN32 + tmp = tr_strdup_printf( "%s_tmp.XXXXXX", filename ); + #define mkstemp(t) open(mktemp(t), O_CREAT | O_EXCL | O_RDWR | O_BINARY, 0600); +#else

tmp = tr_strdup_printf( "%s.tmp.XXXXXX", filename );

+#endif

fd = mkstemp( tmp ); if( fd >= 0 ) {

@@ -1710,3 +1719,4 @@

tr_free( content ); return err;

}

+ diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/libtransmission/blocklist.c transmission-2.00/libtransmission/blocklist.c --- transmission-2.00-orig/libtransmission/blocklist.c 2010-06-15 20:32:58.000000000 -0500 +++ transmission-2.00/libtransmission/blocklist.c 2010-06-19 18:15:49.000000000 -0500 @@ -15,6 +15,8 @@

#include <string.h>

#ifdef WIN32

+ #include <w32api.h> + #define WINVER WindowsXP

#include <windows.h>

#endif

@@ -80,7 +82,7 @@

if( stat( b->filename, &st ) == -1 )

return;

  • fd = open( b->filename, O_RDONLY );

+ fd = open( b->filename, O_RDONLY | O_BINARY );

if( fd == -1 ) {

tr_err( err_fmt, b->filename, tr_strerror( errno ) );

@@ -105,7 +107,11 @@

{

char * base = tr_basename( b->filename );

+#ifndef WIN32

tr_inf( _( "Blocklist \"%s\" contains %'zu entries" ), base, b->ruleCount );

+#else + tr_inf( _( "Blocklist \"%s\" contains %zu entries" ), base, b->ruleCount ); +#endif

tr_free( base );

}

}

@@ -315,7 +321,7 @@

return 0;

}

  • in = fopen( filename, "r" );

+ in = fopen( filename, "rb" );

if( !in ) {

tr_err( err_fmt, filename, tr_strerror( errno ) );

@@ -362,7 +368,11 @@

{

char * base = tr_basename( b->filename );

  • tr_inf( _( "Blocklist \"%1$s\" updated with %2$'d entries" ), base, outCount );

+#ifndef WIN32 + tr_inf( _( "Blocklist \"%s\" updated with %'d entries" ), base, outCount ); +#else + tr_inf( _( "Blocklist \"%s\" updated with %d entries" ), base, outCount ); +#endif

tr_free( base );

}

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/libtransmission/fdlimit.c transmission-2.00/libtransmission/fdlimit.c --- transmission-2.00-orig/libtransmission/fdlimit.c 2010-06-15 20:32:58.000000000 -0500 +++ transmission-2.00/libtransmission/fdlimit.c 2010-06-18 21:10:11.000000000 -0500 @@ -125,7 +125,7 @@

#ifdef WIN32

  • HANDLE hFile = CreateFile?( filename, GENERIC_WRITE, 0, 0, CREATE_NEW, 0, 0 );

+ HANDLE hFile = CreateFile?( filename, GENERIC_WRITE, 0, 0, CREATE_NEW, FILE_FLAG_RANDOM_ACCESS, 0 );

if( hFile != INVALID_HANDLE_VALUE ) {

LARGE_INTEGER li;

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/libtransmission/handshake.c transmission-2.00/libtransmission/handshake.c --- transmission-2.00-orig/libtransmission/handshake.c 2010-06-15 20:32:58.000000000 -0500 +++ transmission-2.00/libtransmission/handshake.c 2010-06-17 18:52:25.000000000 -0500 @@ -346,7 +346,7 @@

/* send it */ setReadState( handshake, AWAITING_YB );

  • tr_peerIoWrite( handshake->io, outbuf, walk-outbuf, FALSE );

+ tr_peerIoWrite( handshake->io, outbuf, walk - outbuf, FALSE );

}

static uint32_t

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/libtransmission/net.c transmission-2.00/libtransmission/net.c --- transmission-2.00-orig/libtransmission/net.c 2010-06-15 20:32:58.000000000 -0500 +++ transmission-2.00/libtransmission/net.c 2010-06-20 14:03:25.000000000 -0500 @@ -32,8 +32,8 @@

#include <sys/types.h>

#ifdef WIN32

  • #include <winsock2.h> /* inet_addr */
  • #include <WS2tcpip.h>

+ #define _WIN32_WINNT 0x0501 + #include <ws2tcpip.h>

#else

#include <sys/socket.h> #include <netinet/in.h>

@@ -63,61 +63,6 @@

const tr_address tr_in6addr_any = { TR_AF_INET6, { IN6ADDR_ANY_INIT } }; const tr_address tr_inaddr_any = { TR_AF_INET, { { { { INADDR_ANY, 0x00, 0x00, 0x00 } } } } };

-#ifdef WIN32 -static const char * -inet_ntop( int af, const void *src, char *dst, socklen_t cnt ) -{

  • if (af == AF_INET)
  • {
  • struct sockaddr_in in;
  • memset( &in, 0, sizeof( in ) );
  • in.sin_family = AF_INET;
  • memcpy( &in.sin_addr, src, sizeof( struct in_addr ) );
  • getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in),
  • dst, cnt, NULL, 0, NI_NUMERICHOST);
  • return dst;
  • }
  • else if (af == AF_INET6)
  • {
  • struct sockaddr_in6 in;
  • memset( &in, 0, sizeof( in ) );
  • in.sin6_family = AF_INET6;
  • memcpy( &in.sin6_addr, src, sizeof( struct in_addr6 ) );
  • getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in6),
  • dst, cnt, NULL, 0, NI_NUMERICHOST);
  • return dst;
  • }
  • return NULL;

-} - -static int -inet_pton(int af, const char *src, void *dst) -{

  • struct addrinfo hints;
  • struct addrinfo *res;
  • struct addrinfo *ressave;

-

  • memset(&hints, 0, sizeof(struct addrinfo));
  • hints.ai_family = af;

-

  • if (getaddrinfo(src, NULL, &hints, &res) != 0)
  • return -1;

-

  • ressave = res;

-

  • while (res)
  • {
  • memcpy(dst, res->ai_addr, res->ai_addrlen);
  • res = res->ai_next;
  • }

-

  • freeaddrinfo(ressave);
  • return 0;

-} - -#endif - -

void tr_netInit( void ) {

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/libtransmission/net.h transmission-2.00/libtransmission/net.h --- transmission-2.00-orig/libtransmission/net.h 2010-06-15 20:32:58.000000000 -0500 +++ transmission-2.00/libtransmission/net.h 2010-06-19 12:37:12.000000000 -0500 @@ -31,9 +31,7 @@

#ifdef WIN32

#include <inttypes.h>

  • #include <winsock2.h>
  • #include <WS2tcpip.h>
  • typedef int socklen_t;

+ #include <ws2tcpip.h>

#else

#include <sys/types.h> #include <sys/socket.h>

@@ -42,6 +40,7 @@

#endif

#ifdef WIN32

+ #define EADDRINUSE WSAEADDRINUSE

#define ECONNREFUSED WSAECONNREFUSED #define ECONNRESET WSAECONNRESET #define EHOSTUNREACH WSAEHOSTUNREACH

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/libtransmission/peer-io.c transmission-2.00/libtransmission/peer-io.c --- transmission-2.00-orig/libtransmission/peer-io.c 2010-06-15 20:32:58.000000000 -0500 +++ transmission-2.00/libtransmission/peer-io.c 2010-06-18 21:18:33.000000000 -0500 @@ -19,8 +19,52 @@

#ifdef WIN32

#include <winsock2.h>

+ #define WINDOWS_SUCKS 1 + int fix_errno () { + int werror= WSAGetLastError(); + switch(werror) { + case WSAEWOULDBLOCK: errno = EAGAIN; break; + case WSAEINTR: errno = EINTR; break; + case WSAEBADF: errno = EBADF; break; + case WSAEACCES: errno = EACCES; break; + case WSAEFAULT: errno = EFAULT; break; + case WSAEINVAL: errno = EINVAL; break; + case WSAEMFILE: errno = EMFILE; break; + case WSAEINPROGRESS: errno = werror; break; /* net.h has these */ + case WSAEALREADY: errno = 120; break; + case WSAENOTSOCK: errno = 108; break; + case WSAEDESTADDRREQ: errno = 121; break; + case WSAEMSGSIZE: errno = 122; break; + case WSAEPROTOTYPE: errno = 107; break; + case WSAENOPROTOOPT: errno = 109; break; + case WSAEAFNOSUPPORT: errno = werror; break; + case WSAEADDRINUSE: errno = werror; break; + case WSAEADDRNOTAVAIL: errno = 125; break; + case WSAENETDOWN: errno = 115; break; + case WSAENETUNREACH: errno = werror; break; + case WSAENETRESET: errno = 126; break; + case WSAECONNABORTED: errno = 113; break; + case WSAECONNRESET: errno = werror; break; + case WSAENOBUFS: errno = 105; break; + case WSAEISCONN: errno = 127; break; + case WSAENOTCONN: errno = werror; break; + case WSAESHUTDOWN: errno = 110; break; + case WSAETOOMANYREFS: errno = 129; break; + case WSAETIMEDOUT: errno = 116; break; + case WSAECONNREFUSED: errno = werror; break; + case WSAELOOP: errno = 92; break; + case WSAENAMETOOLONG: errno = ENAMETOOLONG; break; + case WSAEHOSTDOWN: errno = 117; break; + case WSAEHOSTUNREACH: break; + default: + errno = werror; + break; + } + return errno; + }

#else

#include <arpa/inet.h> /* inet_ntoa */

+ #define WINDOWS_SUCKS 0

#endif

#include <event.h>

@@ -223,7 +267,7 @@

errno = 0; res = evbuffer_read( io->inbuf, fd, howmuch );

  • e = errno;

+ e = WINDOWS_SUCKS? fix_errno() : errno;

if( res > 0 ) {

@@ -268,8 +312,8 @@

#else

n = (int) write(fd, buffer->buffer, howmuch );

#endif

  • e = errno;
  • dbgmsg( io, "wrote %d to peer (%s)", n, (n==-1?strerror(e):"") );

+ e = WINDOWS_SUCKS? fix_errno() : errno; + dbgmsg(io, "wrote %d to peer (%d, %s)", n, e, (n == -1? strerror(e):"no error"));

if( n > 0 )

evbuffer_drain( buffer, n );

@@ -315,18 +359,11 @@

e = errno;

if (res == -1) {

-#ifndef WIN32 -/*todo. evbuffer uses WriteFile? when WIN32 is set. WIN32 system calls do not

  • * *set errno. thus this error checking is not portable*/
if (e == EAGAIN
e == EINTR e == EINPROGRESS)

goto reschedule;

/* error case */ what |= EVBUFFER_ERROR;

-#else

  • goto reschedule;

-#endif -

} else if (res == 0) {

/* eof case */ what |= EVBUFFER_EOF;

@@ -881,7 +918,7 @@

int e; errno = 0; res = evbuffer_read( io->inbuf, io->socket, howmuch );

  • e = errno;

+ e = WINDOWS_SUCKS? fix_errno() : errno;

dbgmsg( io, "read %d from peer (%s)", res, (res==-1?strerror(e):"") );

@@ -945,7 +982,7 @@

bytesUsed = tr_peerIoTryWrite( io, limit );

}

  • dbgmsg( io, "flushing peer-io, hasFinishedConnecting %d, direction %d, limit %zu, bytesUsed %d", (int)io->hasFinishedConnecting, (int)dir, limit, bytesUsed );

+ dbgmsg( io, "flushing peer-io, hasFinishedConnecting %d, direction %s, limit %u, bytesUsed %d", (int)io->hasFinishedConnecting, (dir == TR_DOWN)? "DOWN":"UP", limit, bytesUsed );

return bytesUsed;

}

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/libtransmission/peer-mgr.c transmission-2.00/libtransmission/peer-mgr.c --- transmission-2.00-orig/libtransmission/peer-mgr.c 2010-06-15 20:32:58.000000000 -0500 +++ transmission-2.00/libtransmission/peer-mgr.c 2010-06-17 18:52:25.000000000 -0500 @@ -15,6 +15,9 @@

#include <stdlib.h> /* qsort */

#include <event.h>

+#ifdef WIN32 + #include <errno.h> +#endif

#include "transmission.h" #include "announcer.h"

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/libtransmission/platform.c transmission-2.00/libtransmission/platform.c --- transmission-2.00-orig/libtransmission/platform.c 2010-06-15 20:32:58.000000000 -0500 +++ transmission-2.00/libtransmission/platform.c 2010-06-19 18:25:43.000000000 -0500 @@ -11,6 +11,8 @@

*/

#ifdef WIN32

+ #include <w32api.h> + #define WINVER WindowsXP

#include <windows.h> #include <shlobj.h> /* for CSIDL_APPDATA, CSIDL_MYDOCUMENTS */

#else

@@ -436,7 +438,7 @@

s = tr_buildPath( getHomeDir( ), "Library", "Application Support",

appname, NULL );

#elif defined( WIN32 )

  • char appdata[TR_MAX_PATH]; /* SHGetFolderPath() requires MAX_PATH */

+ char appdata[TR_PATH_MAX]; /* SHGetFolderPath() requires MAX_PATH */

SHGetFolderPath( NULL, CSIDL_APPDATA, NULL, 0, appdata ); s = tr_buildPath( appdata, appname, NULL );

#elif defined( HAIKU )

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/libtransmission/platform.h transmission-2.00/libtransmission/platform.h --- transmission-2.00-orig/libtransmission/platform.h 2010-06-15 20:32:58.000000000 -0500 +++ transmission-2.00/libtransmission/platform.h 2010-06-17 18:52:25.000000000 -0500 @@ -26,8 +26,8 @@

#endif

#ifdef WIN32

  • #include <windows.h> /* MAX_PATH */
  • #define TR_PATH_MAX MAX_PATH

+ #include <windef.h> /* MAX_PATH */ + #define TR_PATH_MAX (MAX_PATH + 1)

#else

#include <limits.h> /* PATH_MAX */ #ifdef PATH_MAX

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/libtransmission/rpcimpl.c transmission-2.00/libtransmission/rpcimpl.c --- transmission-2.00-orig/libtransmission/rpcimpl.c 2010-06-15 20:32:58.000000000 -0500 +++ transmission-2.00/libtransmission/rpcimpl.c 2010-06-18 21:23:51.000000000 -0500 @@ -859,7 +859,7 @@

if( response_code != 200 ) {

  • tr_snprintf( result, sizeof( result ), "http error %ld: %s",

+ tr_snprintf( result, sizeof( result ), "portTested: http error %ld: %s",

response_code, tr_webGetResponseStr( response_code ) );

} else /* success */

@@ -901,14 +901,14 @@

if( response_code != 200 ) {

  • tr_snprintf( result, sizeof( result ), "http error %ld: %s",

+ tr_snprintf( result, sizeof( result ), "gotNewBlocklist: http error %ld: %s",

response_code, tr_webGetResponseStr( response_code ) );

} else /* successfully fetched the blocklist... */ {

const char * configDir = tr_sessionGetConfigDir( session ); char * filename = tr_buildPath( configDir, "blocklist.tmp", NULL );

  • FILE * fp = fopen( filename, "w+" );

+ FILE * fp = fopen( filename, "wb+" );

if( fp == NULL ) {

@@ -1022,7 +1022,7 @@

else {

char result[1024];

  • tr_snprintf( result, sizeof( result ), "http error %ld: %s",

+ tr_snprintf( result, sizeof( result ), "gotMetadataFromURL: http error %ld: %s",

response_code, tr_webGetResponseStr( response_code ) );

tr_idle_function_done( data->data, result );

}

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/libtransmission/torrent.c transmission-2.00/libtransmission/torrent.c --- transmission-2.00-orig/libtransmission/torrent.c 2010-06-15 20:32:58.000000000 -0500 +++ transmission-2.00/libtransmission/torrent.c 2010-06-18 21:25:12.000000000 -0500 @@ -1666,6 +1666,19 @@

tr_torrentSetRatioLimitHitCallback( torrent, NULL, NULL );

}

+#ifdef WIN32 +#include <pthread.h> /* asctime_r(), ctime_r(), localtime_r() */ + +static void +setenv (const char *name, const char *value, int override) +{ + int len = strlen(name) + strlen(value) + 2; + char *str = malloc(len); + sprintf(str, "%s=%s", name, value); + putenv(str); + /* leaks memory on purpose (i.e. Windows semantics) */ +} +#endif

static void torrentCallScript( tr_torrent * tor, const char * script )

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/libtransmission/tr-dht.c transmission-2.00/libtransmission/tr-dht.c --- transmission-2.00-orig/libtransmission/tr-dht.c 2010-06-15 20:32:58.000000000 -0500 +++ transmission-2.00/libtransmission/tr-dht.c 2010-06-17 18:52:25.000000000 -0500 @@ -25,13 +25,19 @@

#include <stdio.h>

/* posix */

-#include <netinet/in.h> /* sockaddr_in */

#include <signal.h> /* sig_atomic_t */ #include <sys/time.h>

-#include <sys/types.h> -#include <sys/socket.h> /* socket(), bind() */ -#include <netdb.h>

#include <unistd.h> /* close() */

+#ifdef WIN32 + #include <inttypes.h> + #define _WIN32_WINNT 0x0501 /* freeaddrinfo(),getaddrinfo(),getnameinfo() */ + #include <ws2tcpip.h> +#else + #include <sys/types.h> + #include <sys/socket.h> /* socket(), bind() */ + #include <netdb.h> + #include <netinet/in.h> /* sockaddr_in */ +#endif

/* third party */ #include <event.h>

@@ -193,7 +199,7 @@

tr_buildPath(cl->session->configDir, "dht.bootstrap", NULL);

if(bootstrap_file)

  • f = fopen(bootstrap_file, "r");

+ f = fopen(bootstrap_file, "rb");

if(f != NULL) {

tr_ninf("DHT", "Attempting manual bootstrap"); for(;;) {

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/libtransmission/tr-lpd.c transmission-2.00/libtransmission/tr-lpd.c --- transmission-2.00-orig/libtransmission/tr-lpd.c 2010-06-15 20:32:58.000000000 -0500 +++ transmission-2.00/libtransmission/tr-lpd.c 2010-06-19 12:25:33.000000000 -0500 @@ -25,14 +25,21 @@

#include <stdio.h>

/* posix */

-#include <netinet/in.h> /* sockaddr_in */

#include <signal.h> /* sig_atomic_t */ #include <sys/time.h>

-#include <sys/types.h> -#include <sys/socket.h> /* socket(), bind() */

#include <unistd.h> /* close() */ #include <fcntl.h> /* fcntl(), O_NONBLOCK */ #include <ctype.h> /* toupper() */

+#ifdef WIN32 + #include <inttypes.h> + #define _WIN32_WINNT 0x0501 /* freeaddrinfo(),getaddrinfo(),getnameinfo() */ + #include <ws2tcpip.h> + typedef unsigned short in_port_t; +#else + #include <sys/types.h> + #include <sys/socket.h> /* socket(), bind() */ + #include <netinet/in.h> /* sockaddr_in */ +#endif

/* third party */ #include <event.h>

@@ -242,6 +249,7 @@

  • @} */

+#ifndef WIN32

/

  • @brief Configures additional capabilities for a socket */ static inline int lpd_configureSocket( int sock, int add )

@@ -257,6 +265,7 @@

return add;

}

+#endif

/

  • @brief Initializes Local Peer Discovery for this node

@@ -291,7 +300,12 @@

goto fail;

/* enable non-blocking operation */

+#ifdef WIN32 + unsigned long flags= 1; + if (ioctlsocket(lpd_socket, FIONBIO, &flags) == SOCKET_ERROR) +#else

if( lpd_configureSocket( lpd_socket, O_NONBLOCK ) < 0 )

+#endif

goto fail;

if( setsockopt( lpd_socket, SOL_SOCKET, SO_REUSEADDR,

@@ -331,7 +345,12 @@

goto fail;

/* enable non-blocking operation */

+#ifdef WIN32 + unsigned long flags= 1; + if (ioctlsocket(lpd_socket2, FIONBIO, &flags) == SOCKET_ERROR) +#else

if( lpd_configureSocket( lpd_socket2, O_NONBLOCK ) < 0 )

+#endif

goto fail;

/* configure outbound multicast TTL */

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/libtransmission/trevent.c transmission-2.00/libtransmission/trevent.c --- transmission-2.00-orig/libtransmission/trevent.c 2010-06-15 20:32:58.000000000 -0500 +++ transmission-2.00/libtransmission/trevent.c 2010-06-17 18:52:25.000000000 -0500 @@ -26,79 +26,95 @@

#ifdef WIN32

-#include <WinSock2.h> +#include "utils.h" +#include <winsock2.h>

static int pgpipe( int handles[2] ) {

  • SOCKET s;
  • struct sockaddr_in serv_addr;
  • int len = sizeof( serv_addr );

+ SOCKET s; + struct sockaddr_in serv_addr; + int len = sizeof( serv_addr );

  • handles[0] = handles[1] = INVALID_SOCKET;

+ handles[0] = handles[1] = INVALID_SOCKET;

  • if ( ( s = socket( AF_INET, SOCK_STREAM, 0 ) ) == INVALID_SOCKET )
  • {

-/* ereport(LOG, (errmsg_internal("pgpipe failed to create socket: %ui", WSAGetLastError()))); */

  • return -1;
  • }

+ if ( ( s = socket( AF_INET, SOCK_STREAM, 0 ) ) == INVALID_SOCKET ) + { + tr_dbg("pgpipe failed to create socket: %ui", WSAGetLastError()); + return -1; + }

  • memset( &serv_addr, 0, sizeof( serv_addr ) );
  • serv_addr.sin_family = AF_INET;
  • serv_addr.sin_port = htons(0);
  • serv_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
  • if (bind(s, (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR)
  • {

-/* ereport(LOG, (errmsg_internal("pgpipe failed to bind: %ui", WSAGetLastError()))); */

  • closesocket(s);
  • return -1;
  • }
  • if (listen(s, 1) == SOCKET_ERROR)
  • {

-/* ereport(LOG, (errmsg_internal("pgpipe failed to listen: %ui", WSAGetLastError()))); */

  • closesocket(s);
  • return -1;
  • }
  • if (getsockname(s, (SOCKADDR *) & serv_addr, &len) == SOCKET_ERROR)
  • {

-/* ereport(LOG, (errmsg_internal("pgpipe failed to getsockname: %ui", WSAGetLastError()))); */

  • closesocket(s);
  • return -1;
  • }
  • if ((handles[1] = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
  • {

-/* ereport(LOG, (errmsg_internal("pgpipe failed to create socket 2: %ui", WSAGetLastError()))); */

  • closesocket(s);
  • return -1;
  • }

+ memset( &serv_addr, 0, sizeof( serv_addr ) ); + serv_addr.sin_family = AF_INET; + serv_addr.sin_port = htons(0); + serv_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + if (bind(s, (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR) + { + tr_dbg("pgpipe failed to bind: %ui", WSAGetLastError()); + closesocket(s); + return -1; + } + if (listen(s, 1) == SOCKET_ERROR) + { + tr_ndbg("event","pgpipe failed to listen: %ui", WSAGetLastError()); + closesocket(s); + return -1; + } + if (getsockname(s, (SOCKADDR *) & serv_addr, &len) == SOCKET_ERROR) + { + tr_dbg("pgpipe failed to getsockname: %ui", WSAGetLastError()); + closesocket(s); + return -1; + } + if ((handles[1] = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) + { + tr_dbg("pgpipe failed to create socket 2: %ui", WSAGetLastError()); + closesocket(s); + return -1; + }

  • if (connect(handles[1], (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR)
  • {

-/* ereport(LOG, (errmsg_internal("pgpipe failed to connect socket: %ui", WSAGetLastError()))); */

  • closesocket(s);
  • return -1;
  • }
  • if ((handles[0] = accept(s, (SOCKADDR *) & serv_addr, &len)) == INVALID_SOCKET)
  • {

-/* ereport(LOG, (errmsg_internal("pgpipe failed to accept socket: %ui", WSAGetLastError()))); */

  • closesocket(handles[1]);
  • handles[1] = INVALID_SOCKET;
  • closesocket(s);
  • return -1;
  • }

+ if (connect(handles[1], (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR) + { + tr_dbg("pgpipe failed to connect socket: %ui", WSAGetLastError()); + closesocket(s); + return -1; + } + if ((handles[0] = accept(s, (SOCKADDR *) & serv_addr, &len)) == INVALID_SOCKET) + { + tr_dbg("pgpipe failed to accept socket: %ui", WSAGetLastError()); + closesocket(handles[1]); + handles[1] = INVALID_SOCKET;

closesocket(s);

  • return 0;

+ return -1; + } + closesocket(s); + return 0;

}

static int piperead( int s, char *buf, int len ) {

  • int ret = recv(s, buf, len, 0);

+ int ret = recv(s, buf, len, 0); + int werror = 0;

  • if (ret < 0 && WSAGetLastError() == WSAECONNRESET)
  • /* EOF on the pipe! (win32 socket based implementation) */
  • ret = 0;
  • return ret;

+ if (ret < 0) { + werror= WSAGetLastError(); + switch(werror) { + /* simplified error mapping (not valid for connect) */ + case WSAEWOULDBLOCK: + errno = EAGAIN; + break; + case WSAECONNRESET: + /* EOF on the pipe! (win32 socket based implementation) */ + ret = 0; + /* fall through */ + default: + errno = werror; + break; + } + } else + errno = 0; + return ret;

}

#define pipe(a) pgpipe(a)

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/libtransmission/utils.c transmission-2.00/libtransmission/utils.c --- transmission-2.00-orig/libtransmission/utils.c 2010-06-15 20:32:58.000000000 -0500 +++ transmission-2.00/libtransmission/utils.c 2010-06-20 14:59:51.000000000 -0500 @@ -34,10 +34,15 @@

#include <sys/types.h> #include <sys/stat.h> #include <unistd.h> /* usleep, stat, getcwd, getpagesize */

+#ifdef WIN32 +#define getpagesize() 65536 +#endif

#include "event.h"

#ifdef WIN32

+ #include <w32api.h> + #define WINVER WindowsXP /* freeaddrinfo(),getaddrinfo(),getnameinfo() */

#include <direct.h> /* _getcwd */ #include <windows.h> /* Sleep */

#endif

@@ -1429,7 +1434,11 @@

/* copy the file */ in = tr_open_file_for_scanning( oldpath ); out = tr_open_file_for_writing( newpath );

+#ifdef WIN32 + buflen = 4096; +#else

buflen = stat( newpath, &st ) ? 4096 : st.st_blksize;

+#endif

buf = tr_valloc( buflen ); while( bytesLeft > 0 ) {

@@ -1492,3 +1501,87 @@

tr_dbg( "tr_valloc(%zu) allocating %zu bytes", bufLen, allocLen ); return buf;

}

+ +char *tr_realpath(const char *path, char *resolved_path) +{ +#ifdef WIN32 +/* From a message to the Mingw-msys list, circa Jun 2, 2005 + * by Mark Junker. + */ + if (GetFullPathNameA(path, TR_PATH_MAX, resolved_path, NULL) == 0) + return NULL; + return resolved_path; +#else + return realpath(path, resolved_path); +#endif +} + +#ifdef WIN32 +const char * +inet_ntop( int af, const void *src, char *dst, socklen_t cnt ) +{ + if (af == AF_INET) + { + struct sockaddr_in in; + memset( &in, 0, sizeof( in ) ); + in.sin_family = AF_INET; + memcpy( &in.sin_addr, src, sizeof( struct in_addr ) ); + getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in), + dst, cnt, NULL, 0, NI_NUMERICHOST); + return dst; + } + else if (af == AF_INET6) + { + struct sockaddr_in6 in; + memset( &in, 0, sizeof( in ) ); + in.sin6_family = AF_INET6; + memcpy( &in.sin6_addr, src, sizeof( struct in_addr6 ) ); + getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in6), + dst, cnt, NULL, 0, NI_NUMERICHOST); + return dst; + } + return NULL; +} + +int +inet_pton(int af, const char *src, void *dst) +{ + struct addrinfo hints, *res, *ressave; + struct sockaddr_in *s4; + struct sockaddr_in6 *s6; + + memset(&hints, 0, sizeof(struct addrinfo)); + hints.ai_family = af; + hints.ai_flags = AI_NUMERICHOST; + + if (getaddrinfo(src, NULL, &hints, &res) != 0) { + if (WSAGetLastError() == WSAHOST_NOT_FOUND) + return 0; + else { + errno = EAFNOSUPPORT; + return -1; + } + } + + ressave = res; + while (res) { + switch (res->ai_family) { + case AF_INET: + s4 = (struct sockaddr_in *) res->ai_addr; + memcpy(dst, &s4->sin_addr, sizeof(struct in_addr)); + break; + case AF_INET6: + s6 = (struct sockaddr_in6 *) res->ai_addr; + memcpy(dst, &s6->sin6_addr, sizeof(struct in6_addr)); + break; + default: /* AF_UNSPEC, AF_NETBIOS */ + break; + } + res = res->ai_next; + } + + freeaddrinfo(ressave); + return 1; +} + +#endif diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/libtransmission/utils.h transmission-2.00/libtransmission/utils.h --- transmission-2.00-orig/libtransmission/utils.h 2010-06-15 20:32:58.000000000 -0500 +++ transmission-2.00/libtransmission/utils.h 2010-06-19 14:31:09.000000000 -0500 @@ -98,6 +98,9 @@

#endif

/* #define DISABLE_GETTEXT */

+#ifdef WIN32 + #define DISABLE_GETTEXT +#endif

#if defined(TR_EMBEDDED) && !defined(DISABLE_GETTEXT)

#define DISABLE_GETTEXT

#endif

@@ -546,6 +549,18 @@

/ @brief Private libtransmission function to update tr_time()'s counter */ static inline void tr_timeUpdate( time_t now ) { transmission_now = now; }

+/ @brief Portability wrapper for realpath() that uses the system implementation if available */ +char *tr_realpath(const char *path, char *resolved_path); + +#if defined( WIN32) && !defined(QT_DLL) +/* The QT exclusion is because something clashes whith the next include */ +#include <ws2tcpip.h> /* socklen_t */ + +/ @brief Missing in Windows and Mingw */ +const char *inet_ntop( int af, const void *src, char *dst, socklen_t cnt ); +int inet_pton(int af, const char *src, void *dst); +#endif +

/* */

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/libtransmission/web.c transmission-2.00/libtransmission/web.c --- transmission-2.00-orig/libtransmission/web.c 2010-06-15 20:32:58.000000000 -0500 +++ transmission-2.00/libtransmission/web.c 2010-06-19 10:54:42.000000000 -0500 @@ -10,7 +10,9 @@

  • $Id: web.c 10535 2010-04-28 00:32:43Z charles $ */

+#ifndef WIN32

#include <sys/select.h>

+#endif

#include <curl/curl.h> #include <event.h>

@@ -304,6 +306,9 @@

t.tv_sec = usec / 1000000; t.tv_usec = usec % 1000000;

+#ifdef WIN32 + Sleep(msec); /* Windows' select() doesn't like the parameters below... */ +#endif

select( max_fd+1, &r_fd_set, &w_fd_set, &c_fd_set, &t );

}

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/qt/qtr.pro transmission-2.00/qt/qtr.pro --- transmission-2.00-orig/qt/qtr.pro 2010-06-15 20:32:59.000000000 -0500 +++ transmission-2.00/qt/qtr.pro 2010-06-17 19:06:14.000000000 -0500 @@ -1,7 +1,7 @@

TARGET = qtr NAME = "Transmission" DESCRIPTION = "Transmission: a fast, easy, and free BitTorrent? client"

-VERSION = 1.60 +VERSION = 2.00

LICENSE = "GPL"

target.path = /bin

@@ -9,7 +9,7 @@

CONFIG += qt qdbus thread debug link_pkgconfig QT += network

-PKGCONFIG = fontconfig libcurl openssl +PKGCONFIG = fontconfig libcurl openssl dbus-1

TRANSMISSION_TOP = .. INCLUDEPATH += $${TRANSMISSION_TOP}

@@ -17,7 +17,10 @@

LIBS += $${TRANSMISSION_TOP}/third-party/dht/libdht.a LIBS += $${TRANSMISSION_TOP}/third-party/miniupnp/libminiupnp.a LIBS += $${TRANSMISSION_TOP}/third-party/libnatpmp/libnatpmp.a

-LIBS += -levent +unix: LIBS += -levent +win32:DEFINES += QT_DBUS +win32:LIBS += -levent -lws2_32 -lintl +win32:LIBS += -lidn -liconv -lwldap32 -liphlpapi

TRANSLATIONS += transmission_en.ts transmission_ru.ts

@@ -31,4 +34,4 @@

torrent-model.cc triconpushbutton.cc utils.cc watchdir.cc

HEADERS += $$replace(SOURCES, .cc, .h) HEADERS += speed.h types.h

- +win32:RC_FILE = qtr.rc diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/qt/qtr.rc transmission-2.00/qt/qtr.rc --- transmission-2.00-orig/qt/qtr.rc 1969-12-31 18:00:00.000000000 -0600 +++ transmission-2.00/qt/qtr.rc 2010-06-17 18:52:25.000000000 -0500 @@ -0,0 +1 @@ +IDI_ICON1 ICON DISCARDABLE "qtr.ico" diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/qt/session.cc transmission-2.00/qt/session.cc --- transmission-2.00-orig/qt/session.cc 2010-06-15 20:32:59.000000000 -0500 +++ transmission-2.00/qt/session.cc 2010-06-17 18:52:25.000000000 -0500 @@ -142,6 +142,7 @@

case Prefs
DOWNLOAD_DIR:
case Prefs
DSPEED:
case Prefs
DSPEED_ENABLED:
+ case Prefs :: ENCRYPTION:
case Prefs
INCOMPLETE_DIR:
case Prefs
INCOMPLETE_DIR_ENABLED:
case Prefs
LPD_ENABLED:
diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/qt/utils.cc transmission-2.00/qt/utils.cc --- transmission-2.00-orig/qt/utils.cc 2010-06-15 20:32:59.000000000 -0500 +++ transmission-2.00/qt/utils.cc 2010-06-17 18:52:25.000000000 -0500 @@ -76,12 +76,12 @@

else if( size < (int64_t)GIGABYTE_FACTOR ) {

displayed_size = (double)size / MEGABYTE_FACTOR;

  • str = tr( "%L1 MiB" ).arg( displayed_size, 0, 'f', 1 );

+ str = tr( "%L1 MiB" ).arg( displayed_size, 0, 'f', 2 );

} else {

displayed_size = (double) size / GIGABYTE_FACTOR;

  • str = tr( "%L1 GiB" ).arg( displayed_size, 0, 'f', 1 );

+ str = tr( "%L1 GiB" ).arg( displayed_size, 0, 'f', 3 );

}

}

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/third-party/dht/dht.c transmission-2.00/third-party/dht/dht.c --- transmission-2.00-orig/third-party/dht/dht.c 2010-06-15 20:33:16.000000000 -0500 +++ transmission-2.00/third-party/dht/dht.c 2010-06-19 18:32:13.000000000 -0500 @@ -39,10 +39,19 @@

#include <unistd.h> #include <fcntl.h> #include <sys/time.h>

+#ifndef WIN32

#include <arpa/inet.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h>

+#else +#include <w32api.h> +#define WINVER WindowsXP /* freeaddrinfo(),getaddrinfo(),getnameinfo() */ +#include <ws2tcpip.h> +#define random rand /* int rand() since no long random() */ +extern const char *inet_ntop(int, const void *, char *, socklen_t); /* from libtransmission (utils.c) */ +#define EAFNOSUPPORT WSAEAFNOSUPPORT +#endif

#include "dht.h"

@@ -1530,6 +1539,10 @@

dht_init(int s, int s6, const unsigned char *id, const unsigned char *v) {

int rc;

+#ifdef WIN32 + unsigned long flags = 1; +#endif +

if(dht_socket >= 0
dht_socket6 >= 0 buckets buckets6) {

errno = EBUSY;

@@ -1548,11 +1561,15 @@

return -1;

buckets->af = AF_INET;

+#ifndef WIN32

rc = fcntl(s, F_GETFL, 0); if(rc < 0)

goto fail;

rc = fcntl(s, F_SETFL, (rc | O_NONBLOCK));

+#else + rc = ioctlsocket(s, FIONBIO, &flags); +#endif

if(rc < 0)

goto fail;

}

@@ -1563,11 +1580,15 @@

return -1;

buckets6->af = AF_INET6;

+#ifndef WIN32

rc = fcntl(s6, F_GETFL, 0); if(rc < 0)

goto fail;

rc = fcntl(s6, F_SETFL, (rc | O_NONBLOCK));

+#else + rc = ioctlsocket(s6, FIONBIO, &flags); +#endif

if(rc < 0)

goto fail;

}

@@ -2877,3 +2898,4 @@

debugf("Truncated message.\n"); return -1;

}

+ diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00-orig/third-party/miniupnp/miniupnpc.c transmission-2.00/third-party/miniupnp/miniupnpc.c --- transmission-2.00-orig/third-party/miniupnp/miniupnpc.c 2010-06-15 20:33:16.000000000 -0500 +++ transmission-2.00/third-party/miniupnp/miniupnpc.c 2010-06-17 19:15:56.000000000 -0500 @@ -24,7 +24,7 @@

#include <winsock2.h> #include <ws2tcpip.h> #include <io.h>

-#include <IPHlpApi.h> +#include <iphlpapi.h>

#define snprintf _snprintf #if defined(_MSC_VER) && (_MSC_VER >= 1400) #define strncasecmp _memicmp