Changeset 10858


Ignore:
Timestamp:
Jun 25, 2010, 8:36:10 PM (12 years ago)
Author:
charles
Message:

(trunk libT) #3311 "MingW build of Transmission" -- apply further win32 diffs from rb07

Location:
trunk/libtransmission
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/blocklist.c

    r10816 r10858  
    1919 #define WINVER  WindowsXP
    2020 #include <windows.h>
     21 #define PROT_READ      PAGE_READONLY
     22 #define MAP_PRIVATE    FILE_MAP_COPY
    2123#endif
    2224
  • trunk/libtransmission/net.c

    r10816 r10858  
    6565
    6666#ifdef WIN32
    67 static const char *
    68 inet_ntop( int af, const void *src, char *dst, socklen_t cnt )
     67const char *
     68inet_ntop( int af, const void * src, char * dst, socklen_t cnt )
    6969{
    7070    if (af == AF_INET)
     
    9191}
    9292
    93 static int
    94 inet_pton(int af, const char *src, void *dst)
    95 {
    96     struct addrinfo hints;
    97     struct addrinfo *res;
    98     struct addrinfo *ressave;
    99 
    100     memset(&hints, 0, sizeof(struct addrinfo));
     93int
     94inet_pton( int af, const char * src, void * dst )
     95{
     96    struct addrinfo hints, *res, *ressave;
     97    struct sockaddr_in * s4;
     98    struct sockaddr_in6 * s6;
     99
     100    memset( &hints, 0, sizeof( struct addrinfo ));
    101101    hints.ai_family = af;
    102 
    103     if (getaddrinfo(src, NULL, &hints, &res) != 0)
    104         return -1;
     102    hints.ai_flags = AI_NUMERICHOST;
     103
     104    if( getaddrinfo( src, NULL, &hints, &res ) ) {
     105        if( WSAGetLastError() == WSAHOST_NOT_FOUND )
     106            return 0;
     107        else {
     108            errno = EAFNOSUPPORT;
     109            return -1;
     110        }
     111    }
    105112
    106113    ressave = res;
    107 
    108     while (res)
    109     {
    110         memcpy(dst, res->ai_addr, res->ai_addrlen);
     114    while( res ) {
     115        switch (res->ai_family) {
     116            case AF_INET:
     117                s4 = (struct sockaddr_in *) res->ai_addr;
     118                memcpy( dst, &s4->sin_addr, sizeof( struct in_addr ) );
     119                break;
     120            case AF_INET6:
     121                s6 = (struct sockaddr_in6 *) res->ai_addr;
     122                memcpy( dst, &s6->sin6_addr, sizeof( struct in6_addr ) );
     123                break;
     124            default: /* AF_UNSPEC, AF_NETBIOS */
     125                break;
     126        }
    111127        res = res->ai_next;
    112128    }
    113129
    114130    freeaddrinfo(ressave);
    115     return 0;
    116 }
    117 
    118 #endif
    119 
     131    return 1;
     132}
     133#endif
    120134
    121135void
  • trunk/libtransmission/net.h

    r10816 r10858  
    125125const unsigned char *tr_globalIPv6( void );
    126126
     127#if defined( WIN32) && !defined(QT_DLL)
     128/* The QT exclusion is because something clashes whith the next include */
     129#include <ws2tcpip.h>           /* socklen_t */
     130
     131/** @brief Missing in Windows and Mingw */
     132const char *inet_ntop( int af, const void *src, char *dst, socklen_t cnt );
     133int inet_pton(int af, const char *src, void *dst);
     134#endif
    127135
    128136#endif /* _TR_NET_H_ */
  • trunk/libtransmission/peer-mgr.c

    r10848 r10858  
    1212
    1313#include <assert.h>
     14#include <errno.h> /* error codes ERANGE, ... */
    1415#include <string.h> /* memcpy, memcmp, strstr */
    1516#include <stdlib.h> /* qsort */
  • trunk/libtransmission/trevent.c

    r10816 r10858  
    227227{
    228228    tr_event_handle * eh = veh;
    229     tr_dbg( "Starting libevent thread" );
    230229
    231230#ifndef WIN32
  • trunk/libtransmission/web.c

    r10845 r10858  
    1111 */
    1212
    13 #include <sys/select.h>
     13#ifdef WIN32
     14  #include <ws2tcpip.h>
     15#else
     16  #include <sys/select.h>
     17#endif
    1418
    1519#include <curl/curl.h>
     
    307311#ifdef WIN32
    308312            /* see ticket #3311, comments 16-18 */
    309             if( !r_fd_set.fd_count && !w_fd.set.fd_count && !c_fd_set.fd_count )
    310                 tr_wait( msec );
     313            if( !r_fd_set.fd_count && !w_fd_set.fd_count && !c_fd_set.fd_count )
     314                tr_wait_msec( msec );
    311315            else
    312316                select( 0, r_fd_set.fd_count ? &r_fd_set : NULL,
    313                            w_fd.set.fd_count ? &w_fd_set : NULL,
    314                            c_fd.set.fd_count ? &c_fd_set : NULL, &t );
     317                           w_fd_set.fd_count ? &w_fd_set : NULL,
     318                           c_fd_set.fd_count ? &c_fd_set : NULL, &t );
    315319#else
    316320            select( max_fd+1, &r_fd_set, &w_fd_set, &c_fd_set, &t );
Note: See TracChangeset for help on using the changeset viewer.