mirror of
https://github.com/transmission/transmission
synced 2025-03-02 17:55:22 +00:00
(trunk libT) #3311 "MingW build of Transmission" -- apply further win32 diffs from rb07
This commit is contained in:
parent
e2b4933777
commit
98cec85e46
6 changed files with 51 additions and 23 deletions
|
@ -18,6 +18,8 @@
|
|||
#include <w32api.h>
|
||||
#define WINVER WindowsXP
|
||||
#include <windows.h>
|
||||
#define PROT_READ PAGE_READONLY
|
||||
#define MAP_PRIVATE FILE_MAP_COPY
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
|
|
|
@ -64,8 +64,8 @@ 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 )
|
||||
const char *
|
||||
inet_ntop( int af, const void * src, char * dst, socklen_t cnt )
|
||||
{
|
||||
if (af == AF_INET)
|
||||
{
|
||||
|
@ -90,34 +90,48 @@ inet_ntop( int af, const void *src, char *dst, socklen_t cnt )
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
inet_pton(int af, const char *src, void *dst)
|
||||
int
|
||||
inet_pton( int af, const char * src, void * dst )
|
||||
{
|
||||
struct addrinfo hints;
|
||||
struct addrinfo *res;
|
||||
struct addrinfo *ressave;
|
||||
struct addrinfo hints, *res, *ressave;
|
||||
struct sockaddr_in * s4;
|
||||
struct sockaddr_in6 * s6;
|
||||
|
||||
memset(&hints, 0, sizeof(struct addrinfo));
|
||||
memset( &hints, 0, sizeof( struct addrinfo ));
|
||||
hints.ai_family = af;
|
||||
hints.ai_flags = AI_NUMERICHOST;
|
||||
|
||||
if (getaddrinfo(src, NULL, &hints, &res) != 0)
|
||||
return -1;
|
||||
if( getaddrinfo( src, NULL, &hints, &res ) ) {
|
||||
if( WSAGetLastError() == WSAHOST_NOT_FOUND )
|
||||
return 0;
|
||||
else {
|
||||
errno = EAFNOSUPPORT;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
ressave = res;
|
||||
|
||||
while (res)
|
||||
{
|
||||
memcpy(dst, res->ai_addr, res->ai_addrlen);
|
||||
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 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
tr_netInit( void )
|
||||
{
|
||||
|
|
|
@ -124,5 +124,13 @@ void tr_netInit( void );
|
|||
|
||||
const unsigned char *tr_globalIPv6( void );
|
||||
|
||||
#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
|
||||
|
||||
#endif /* _TR_NET_H_ */
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h> /* error codes ERANGE, ... */
|
||||
#include <string.h> /* memcpy, memcmp, strstr */
|
||||
#include <stdlib.h> /* qsort */
|
||||
|
||||
|
|
|
@ -226,7 +226,6 @@ static void
|
|||
libeventThreadFunc( void * veh )
|
||||
{
|
||||
tr_event_handle * eh = veh;
|
||||
tr_dbg( "Starting libevent thread" );
|
||||
|
||||
#ifndef WIN32
|
||||
/* Don't exit when writing on a broken socket */
|
||||
|
|
|
@ -10,7 +10,11 @@
|
|||
* $Id$
|
||||
*/
|
||||
|
||||
#include <sys/select.h>
|
||||
#ifdef WIN32
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <event.h>
|
||||
|
@ -306,12 +310,12 @@ tr_webThreadFunc( void * vsession )
|
|||
|
||||
#ifdef WIN32
|
||||
/* see ticket #3311, comments 16-18 */
|
||||
if( !r_fd_set.fd_count && !w_fd.set.fd_count && !c_fd_set.fd_count )
|
||||
tr_wait( msec );
|
||||
if( !r_fd_set.fd_count && !w_fd_set.fd_count && !c_fd_set.fd_count )
|
||||
tr_wait_msec( msec );
|
||||
else
|
||||
select( 0, r_fd_set.fd_count ? &r_fd_set : NULL,
|
||||
w_fd.set.fd_count ? &w_fd_set : NULL,
|
||||
c_fd.set.fd_count ? &c_fd_set : NULL, &t );
|
||||
w_fd_set.fd_count ? &w_fd_set : NULL,
|
||||
c_fd_set.fd_count ? &c_fd_set : NULL, &t );
|
||||
#else
|
||||
select( max_fd+1, &r_fd_set, &w_fd_set, &c_fd_set, &t );
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue