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

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00b1-orig/configure transmission-2.00b1/configure --- transmission-2.00b1-orig/configure 2010-05-22 20:53:18.000000000 -0500 +++ transmission-2.00b1/configure 2010-05-24 13:02:11.000000000 -0500 @@ -19907,6 +19907,11 @@

libevent_extra_libs=""

fi

+case $host_os in + mingw*) + libevent_extra_libs+="-lws2_32" + ;; +esac

{ $as_echo "$as_me:$LINENO: checking for evutil_vsnprintf in -levent" >&5

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00b1-orig/libtransmission/JSON_parser.h transmission-2.00b1/libtransmission/JSON_parser.h --- transmission-2.00b1-orig/libtransmission/JSON_parser.h 2010-05-22 20:49:23.000000000 -0500 +++ transmission-2.00b1/libtransmission/JSON_parser.h 2010-05-24 12:46:36.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.00b1-orig/libtransmission/Makefile.in transmission-2.00b1/libtransmission/Makefile.in --- transmission-2.00b1-orig/libtransmission/Makefile.in 2010-05-22 20:53:20.000000000 -0500 +++ transmission-2.00b1/libtransmission/Makefile.in 2010-05-24 12:46:36.000000000 -0500 @@ -93,7 +93,7 @@

bencode_test_OBJECTS = $(am_bencode_test_OBJECTS) amDEPENDENCIES_1 = ./libtransmission.a \

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

  • $(top_builddir)/third-party/libnatpmp/libnatpmp.a

+ $(top_builddir)/third-party/libnatpmp/libnatpmp.a

bencode_test_DEPENDENCIES = $(amDEPENDENCIES_1) AM_V_lt = $(amv_lt_$(V)) amv_lt_ = $(amv_lt_$(AM_DEFAULT_VERBOSITY))

@@ -507,6 +507,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.00b1-orig/libtransmission/bencode.c transmission-2.00b1/libtransmission/bencode.c --- transmission-2.00b1-orig/libtransmission/bencode.c 2010-05-22 20:49:23.000000000 -0500 +++ transmission-2.00b1/libtransmission/bencode.c 2010-06-01 19:47:41.000000000 -0500 @@ -17,6 +17,11 @@

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

+#ifdef WIN32 + #include <fcntl.h> + #define fsync _commit + static char *realpath(); +#endif

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

@@ -1629,7 +1634,12 @@

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, 0600); +#else

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

+#endif

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

@@ -1653,21 +1663,21 @@

else {

err = errno;

  • tr_err( _( "Couldn't save file \"%1$s\": %2$s" ), filename, tr_strerror( err ) );

+ tr_err( _( "Couldn't save file \"%s\": %s" ), filename, tr_strerror( err ) );

unlink( tmp );

}

} else {

err = errno;

  • tr_err( _( "Couldn't save file \"%1$s\": %2$s" ), filename, tr_strerror( err ) );

+ tr_err( _( "Couldn't save file \"%s\": %s" ), filename, tr_strerror( err ) );

unlink( tmp );

}

} else {

err = errno;

  • tr_err( _( "Couldn't save temporary file \"%1$s\": %2$s" ), tmp, tr_strerror( err ) );

+ tr_err( _( "Couldn't save temporary file \"%s\": %s" ), tmp, tr_strerror( err ) );

close( fd ); unlink( tmp );

}

@@ -1677,7 +1687,7 @@

else {

err = errno;

  • tr_err( _( "Couldn't save temporary file \"%1$s\": %2$s" ), tmp, tr_strerror( err ) );

+ tr_err( _( "Couldn't save temporary file \"%s\": %s" ), tmp, tr_strerror( err ) );

}

tr_free( tmp );

@@ -1710,3 +1720,16 @@

tr_free( content ); return err;

}

+ +#ifdef WIN32 +/* From a message to the Mingw-msys list, circa Jun 2, 2005 + * by Mark Junker. + */ +static +char *realpath(const char *path, char *resolved_path) +{ + if (GetFullPathNameA(path, TR_PATH_MAX, resolved_path, NULL) == 0) + return NULL; + return resolved_path; +} +#endif diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00b1-orig/libtransmission/net.c transmission-2.00b1/libtransmission/net.c --- transmission-2.00b1-orig/libtransmission/net.c 2010-05-22 20:49:23.000000000 -0500 +++ transmission-2.00b1/libtransmission/net.c 2010-05-24 12:46:36.000000000 -0500 @@ -32,8 +32,9 @@

#include <sys/types.h>

#ifdef WIN32

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

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

#else

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

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00b1-orig/libtransmission/net.h transmission-2.00b1/libtransmission/net.h --- transmission-2.00b1-orig/libtransmission/net.h 2010-05-22 20:49:23.000000000 -0500 +++ transmission-2.00b1/libtransmission/net.h 2010-05-24 12:46:36.000000000 -0500 @@ -31,8 +31,7 @@

#ifdef WIN32

#include <inttypes.h>

  • #include <winsock2.h>
  • #include <WS2tcpip.h>

+ #include <ws2tcpip.h>

typedef int socklen_t;

#else

#include <sys/types.h>

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00b1-orig/libtransmission/peer-mgr.c transmission-2.00b1/libtransmission/peer-mgr.c --- transmission-2.00b1-orig/libtransmission/peer-mgr.c 2010-05-22 20:49:23.000000000 -0500 +++ transmission-2.00b1/libtransmission/peer-mgr.c 2010-05-24 12:46:36.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.00b1-orig/libtransmission/platform.c transmission-2.00b1/libtransmission/platform.c --- transmission-2.00b1-orig/libtransmission/platform.c 2010-05-22 20:49:23.000000000 -0500 +++ transmission-2.00b1/libtransmission/platform.c 2010-05-24 13:08:18.000000000 -0500 @@ -436,7 +436,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.00b1-orig/libtransmission/platform.h transmission-2.00b1/libtransmission/platform.h --- transmission-2.00b1-orig/libtransmission/platform.h 2010-05-22 20:49:23.000000000 -0500 +++ transmission-2.00b1/libtransmission/platform.h 2010-06-01 17:11:30.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.00b1-orig/libtransmission/torrent.c transmission-2.00b1/libtransmission/torrent.c --- transmission-2.00b1-orig/libtransmission/torrent.c 2010-05-22 20:49:23.000000000 -0500 +++ transmission-2.00b1/libtransmission/torrent.c 2010-05-24 17:17:03.000000000 -0500 @@ -1670,6 +1670,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.00b1-orig/libtransmission/tr-dht.c transmission-2.00b1/libtransmission/tr-dht.c --- transmission-2.00b1-orig/libtransmission/tr-dht.c 2010-05-22 20:49:23.000000000 -0500 +++ transmission-2.00b1/libtransmission/tr-dht.c 2010-05-24 12:46:36.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>

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00b1-orig/libtransmission/tr-lpd.c transmission-2.00b1/libtransmission/tr-lpd.c --- transmission-2.00b1-orig/libtransmission/tr-lpd.c 2010-05-22 20:49:23.000000000 -0500 +++ transmission-2.00b1/libtransmission/tr-lpd.c 2010-05-24 16:39:03.000000000 -0500 @@ -25,14 +25,22 @@

#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>

+#include <fcntl.h> /* fcntl(), O_NONBLOCK */ +#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>

@@ -125,6 +133,59 @@

  • @brief a line-feed, as understood by the LPD protocol */ #define CRLF "\r\n"

+#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 +

/

@@ -242,6 +303,7 @@

  • @} */

+#ifndef WIN32

/

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

@@ -257,6 +319,7 @@

return add;

}

+#endif

/

  • @brief Initializes Local Peer Discovery for this node

@@ -291,7 +354,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 +399,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_socket2, O_NONBLOCK ) < 0 )

+#endif

goto fail;

/* configure outbound multicast TTL */

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00b1-orig/libtransmission/trevent.c transmission-2.00b1/libtransmission/trevent.c --- transmission-2.00b1-orig/libtransmission/trevent.c 2010-05-22 20:49:23.000000000 -0500 +++ transmission-2.00b1/libtransmission/trevent.c 2010-05-24 12:46:36.000000000 -0500 @@ -26,7 +26,7 @@

#ifdef WIN32

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

static int pgpipe( int handles[2] )

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00b1-orig/libtransmission/utils.c transmission-2.00b1/libtransmission/utils.c --- transmission-2.00b1-orig/libtransmission/utils.c 2010-05-22 20:49:23.000000000 -0500 +++ transmission-2.00b1/libtransmission/utils.c 2010-05-24 12:46:36.000000000 -0500 @@ -34,6 +34,9 @@

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

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

#include "event.h"

@@ -1411,7 +1414,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 ) {

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00b1-orig/libtransmission/web.c transmission-2.00b1/libtransmission/web.c --- transmission-2.00b1-orig/libtransmission/web.c 2010-05-22 20:49:23.000000000 -0500 +++ transmission-2.00b1/libtransmission/web.c 2010-05-24 12:46:36.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>

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00b1-orig/qt/app.cc transmission-2.00b1/qt/app.cc --- transmission-2.00b1-orig/qt/app.cc 2010-05-22 20:49:25.000000000 -0500 +++ transmission-2.00b1/qt/app.cc 2010-05-26 12:10:07.000000000 -0500 @@ -14,6 +14,9 @@

#include <ctime> #include <iostream>

+#ifdef WIN32 + #define QT_DBUS +#endif

#include <QDBusConnection> #include <QDBusError> #include <QDBusMessage>

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00b1-orig/qt/dbus-adaptor.cc transmission-2.00b1/qt/dbus-adaptor.cc --- transmission-2.00b1-orig/qt/dbus-adaptor.cc 2010-05-22 20:49:25.000000000 -0500 +++ transmission-2.00b1/qt/dbus-adaptor.cc 2010-05-26 12:17:26.000000000 -0500 @@ -10,6 +10,10 @@

  • $Id:$ */

+#ifdef WIN32 + #define QT_DBUS +#endif +

#include "app.h" #include "dbus-adaptor.h"

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00b1-orig/qt/dbus-adaptor.h transmission-2.00b1/qt/dbus-adaptor.h --- transmission-2.00b1-orig/qt/dbus-adaptor.h 2010-05-22 20:49:25.000000000 -0500 +++ transmission-2.00b1/qt/dbus-adaptor.h 2010-05-26 12:13:23.000000000 -0500 @@ -13,6 +13,10 @@

#ifndef QTR_DBUS_ADAPTOR_H #define QTR_DBUS_ADAPTOR_H

+#ifdef WIN32 + #define QT_DBUS +#endif +

class MyApp?;

#include <QDBusAbstractAdaptor>

diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00b1-orig/qt/qtr.pro transmission-2.00b1/qt/qtr.pro --- transmission-2.00b1-orig/qt/qtr.pro 2010-05-22 20:49:25.000000000 -0500 +++ transmission-2.00b1/qt/qtr.pro 2010-05-27 12:57: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.00b1

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,8 @@

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 += $${TRANSMISSION_TOP}/third-party/libevent/.libs/libevent.a +win32:LIBS += -levent -lws2_32 -lintl +win32:LIBS += -lidn -liconv -lwldap32 -liphlpapi

TRANSLATIONS += transmission_en.ts transmission_ru.ts

@@ -32,3 +33,4 @@

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

+win32:RC_FILE = qtr.rc diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00b1-orig/qt/qtr.rc transmission-2.00b1/qt/qtr.rc --- transmission-2.00b1-orig/qt/qtr.rc 1969-12-31 18:00:00.000000000 -0600 +++ transmission-2.00b1/qt/qtr.rc 2010-05-24 12:46:36.000000000 -0500 @@ -0,0 +1 @@ +IDI_ICON1 ICON DISCARDABLE "qtr.ico" diff -NaurX /home/rberber/diff-excludes.txt transmission-2.00b1-orig/qt/session.cc transmission-2.00b1/qt/session.cc --- transmission-2.00b1-orig/qt/session.cc 2010-05-22 20:49:25.000000000 -0500 +++ transmission-2.00b1/qt/session.cc 2010-06-01 16:49:14.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.00b1-orig/qt/utils.cc transmission-2.00b1/qt/utils.cc --- transmission-2.00b1-orig/qt/utils.cc 2010-05-22 20:49:25.000000000 -0500 +++ transmission-2.00b1/qt/utils.cc 2010-05-24 12:50:47.000000000 -0500 @@ -56,12 +56,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.00b1-orig/third-party/dht/dht.c transmission-2.00b1/third-party/dht/dht.c --- transmission-2.00b1-orig/third-party/dht/dht.c 2010-05-22 20:50:10.000000000 -0500 +++ transmission-2.00b1/third-party/dht/dht.c 2010-05-24 12:46:36.000000000 -0500 @@ -39,10 +39,18 @@

#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 +#define WINVER WindowsXP /* freeaddrinfo(),getaddrinfo(),getnameinfo() */ +#include <ws2tcpip.h> +#define random rand /* int rand() since no long random() */ +const char *inet_ntop(int, const void *, char *, socklen_t); +#define EAFNOSUPPORT WSAEAFNOSUPPORT +#endif

#include "dht.h"

@@ -1530,6 +1538,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 +1560,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 +1579,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 +2897,29 @@

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

}

+ +#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; +} +#endif

Last modified 11 years ago Last modified on Jun 4, 2010, 1:25:30 AM