Changeset 10816
- Timestamp:
- Jun 22, 2010, 12:12:52 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/configure.ac
r10783 r10816 408 408 CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows" 409 409 CPPFLAGS="$CPPFLAGS -DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN" 410 LIBS="$LIBS -l shell32 -lws2_32"410 LIBS="$LIBS -liphlpapi -lshell32 -lws2_32" 411 411 transmissionlocaledir="locale" 412 412 if test -z "$host_alias"; then -
trunk/libtransmission/bencode.c
r10814 r10816 19 19 #include <string.h> 20 20 21 #ifdef WIN32 21 #ifdef WIN32 /* tr_mkstemp() */ 22 22 #include <fcntl.h> 23 #define fsync(fd) _commit(fd) 23 #define _S_IREAD 256 24 #define _S_IWRITE 128 24 25 #endif 25 26 … … 1634 1635 } 1635 1636 1637 /* portability wrapper for mkstemp(). */ 1638 static int 1639 tr_mkstemp( char * template ) 1640 { 1641 #ifdef WIN32 1642 const int flags = O_RDWR | O_BINARY | O_CREAT | O_EXCL | _O_SHORT_LIVED; 1643 const mode_t mode = _S_IREAD | _S_IWRITE; 1644 mktemp( template ); 1645 return open( template, flags, mode ); 1646 #else 1647 return mkstemp( template ); 1648 #endif 1649 } 1650 1651 /* portability wrapper for fsync(). */ 1652 static void 1653 tr_fsync( int fd ) 1654 { 1655 #ifdef WIN32 1656 _commit( fd ); 1657 #else 1658 fsync( fd ); 1659 #endif 1660 } 1661 1636 1662 int 1637 1663 tr_bencToFile( const tr_benc * top, tr_fmt_mode mode, const char * filename ) … … 1643 1669 1644 1670 /* follow symlinks to find the "real" file, to make sure the temporary 1645 * we build with mkstemp() is created on the right partition */1671 * we build with tr_mkstemp() is created on the right partition */ 1646 1672 if( tr_realpath( filename, buf ) != NULL ) 1647 1673 filename = buf; … … 1649 1675 /* if the file already exists, try to move it out of the way & keep it as a backup */ 1650 1676 tmp = tr_strdup_printf( "%s.tmp.XXXXXX", filename ); 1651 fd = mkstemp( tmp );1677 fd = tr_mkstemp( tmp ); 1652 1678 if( fd >= 0 ) 1653 1679 { … … 1658 1684 if( write( fd, str, len ) == (ssize_t)len ) 1659 1685 { 1660 fsync( fd );1686 tr_fsync( fd ); 1661 1687 close( fd ); 1662 1688 … … 1729 1755 return err; 1730 1756 } 1757 -
trunk/libtransmission/blocklist.c
r10754 r10816 16 16 17 17 #ifdef WIN32 18 #include <w32api.h> 19 #define WINVER WindowsXP 18 20 #include <windows.h> 19 21 #endif … … 34 36 #include "utils.h" 35 37 38 #ifndef O_BINARY 39 #define O_BINARY 0 40 #endif 41 36 42 37 43 /*** … … 81 87 return; 82 88 83 fd = open( b->filename, O_RDONLY );89 fd = open( b->filename, O_RDONLY | O_BINARY ); 84 90 if( fd == -1 ) 85 91 { … … 88 94 } 89 95 90 #ifndef WIN3291 96 b->rules = mmap( NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0 ); 92 #else93 b->rules = mmap( NULL, st.st_size, 0, 0, fd, 0 );94 #endif95 97 if( !b->rules ) 96 98 { … … 316 318 } 317 319 318 in = fopen( filename, "r " );320 in = fopen( filename, "rb" ); 319 321 if( !in ) 320 322 { … … 363 365 { 364 366 char * base = tr_basename( b->filename ); 365 tr_inf( _( "Blocklist \"% 1$s\" updated with %2$'d entries" ), base, outCount );367 tr_inf( _( "Blocklist \"%s\" updated with %'d entries" ), base, outCount ); 366 368 tr_free( base ); 367 369 } -
trunk/libtransmission/net.c
r10753 r10816 33 33 34 34 #ifdef WIN32 35 # include <winsock2.h> /* inet_addr */36 #include < WS2tcpip.h>35 #define _WIN32_WINNT 0x0501 36 #include <ws2tcpip.h> 37 37 #else 38 38 #include <sys/socket.h> -
trunk/libtransmission/net.h
r10508 r10816 32 32 #ifdef WIN32 33 33 #include <inttypes.h> 34 #include <winsock2.h> 35 #include <WS2tcpip.h> 36 typedef int socklen_t; 34 #include <ws2tcpip.h> 37 35 #else 38 36 #include <sys/types.h> … … 43 41 44 42 #ifdef WIN32 43 #define EADDRINUSE WSAEADDRINUSE 45 44 #define ECONNREFUSED WSAECONNREFUSED 46 45 #define ECONNRESET WSAECONNRESET -
trunk/libtransmission/torrent.c
r10800 r10816 1659 1659 } 1660 1660 1661 static void 1662 tr_setenv( const char * name, const char * value, tr_bool override ) 1663 { 1664 #ifdef WIN32 1665 putenv( tr_strdup_printf( "%s=%s", name, value ) ); /* leaks memory... */ 1666 #else 1667 setenv( name, value, override ); 1668 #endif 1669 } 1661 1670 1662 1671 static void … … 1674 1683 #endif 1675 1684 1676 setenv( "TR_APP_VERSION", SHORT_VERSION_STRING, 1 );1685 tr_setenv( "TR_APP_VERSION", SHORT_VERSION_STRING, 1 ); 1677 1686 1678 1687 tr_snprintf( buf, sizeof( buf ), "%d", tr_torrentId( tor ) ); 1679 setenv( "TR_TORRENT_ID", buf, 1 );1680 setenv( "TR_TORRENT_NAME", tr_torrentName( tor ), 1 );1681 setenv( "TR_TORRENT_DIR", tor->currentDir, 1 );1682 setenv( "TR_TORRENT_HASH", tor->info.hashString, 1 );1688 tr_setenv( "TR_TORRENT_ID", buf, 1 ); 1689 tr_setenv( "TR_TORRENT_NAME", tr_torrentName( tor ), 1 ); 1690 tr_setenv( "TR_TORRENT_DIR", tor->currentDir, 1 ); 1691 tr_setenv( "TR_TORRENT_HASH", tor->info.hashString, 1 ); 1683 1692 tr_strlcpy( buf, ctime( &now ), sizeof( buf ) ); 1684 1693 *strchr( buf,'\n' ) = '\0'; 1685 setenv( "TR_TIME_LOCALTIME", buf, 1 );1694 tr_setenv( "TR_TIME_LOCALTIME", buf, 1 ); 1686 1695 tr_torinf( tor, "Calling script \"%s\"", script ); 1687 1696 system( script ); -
trunk/libtransmission/tr-dht.c
r10814 r10816 26 26 27 27 /* posix */ 28 #include <netinet/in.h> /* sockaddr_in */29 28 #include <signal.h> /* sig_atomic_t */ 30 29 #include <sys/time.h> 31 #include <sys/types.h>32 #include <sys/socket.h> /* socket(), bind() */33 #include <netdb.h>34 30 #include <unistd.h> /* close() */ 31 #ifdef WIN32 32 #include <inttypes.h> 33 #define _WIN32_WINNT 0x0501 /* freeaddrinfo(),getaddrinfo(),getnameinfo() */ 34 #include <ws2tcpip.h> 35 #else 36 #include <sys/types.h> 37 #include <sys/socket.h> /* socket(), bind() */ 38 #include <netdb.h> 39 #include <netinet/in.h> /* sockaddr_in */ 40 #endif 35 41 36 42 /* third party */ -
trunk/libtransmission/trevent.c
r9992 r10816 27 27 #ifdef WIN32 28 28 29 #include <WinSock2.h> 29 #include "utils.h" 30 #include <winsock2.h> 30 31 31 32 static int 32 33 pgpipe( int handles[2] ) 33 34 { 34 35 36 37 38 39 40 41 42 /* ereport(LOG, (errmsg_internal("pgpipe failed to create socket: %ui", WSAGetLastError()))); */ 43 44 45 46 47 48 49 50 51 52 /* ereport(LOG, (errmsg_internal("pgpipe failed to bind: %ui", WSAGetLastError()))); */ 53 54 55 56 57 58 /* ereport(LOG, (errmsg_internal("pgpipe failed to listen: %ui", WSAGetLastError()))); */ 59 60 61 62 63 64 /* ereport(LOG, (errmsg_internal("pgpipe failed to getsockname: %ui", WSAGetLastError()))); */ 65 66 67 68 69 70 /* ereport(LOG, (errmsg_internal("pgpipe failed to create socket 2: %ui", WSAGetLastError()))); */ 71 72 73 74 75 76 77 /* ereport(LOG, (errmsg_internal("pgpipe failed to connect socket: %ui", WSAGetLastError()))); */ 78 79 80 81 82 83 /* ereport(LOG, (errmsg_internal("pgpipe failed to accept socket: %ui", WSAGetLastError()))); */ 84 85 86 87 88 89 90 35 SOCKET s; 36 struct sockaddr_in serv_addr; 37 int len = sizeof( serv_addr ); 38 39 handles[0] = handles[1] = INVALID_SOCKET; 40 41 if ( ( s = socket( AF_INET, SOCK_STREAM, 0 ) ) == INVALID_SOCKET ) 42 { 43 tr_dbg("pgpipe failed to create socket: %ui", WSAGetLastError()); 44 return -1; 45 } 46 47 memset( &serv_addr, 0, sizeof( serv_addr ) ); 48 serv_addr.sin_family = AF_INET; 49 serv_addr.sin_port = htons(0); 50 serv_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); 51 if (bind(s, (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR) 52 { 53 tr_dbg("pgpipe failed to bind: %ui", WSAGetLastError()); 54 closesocket(s); 55 return -1; 56 } 57 if (listen(s, 1) == SOCKET_ERROR) 58 { 59 tr_ndbg("event","pgpipe failed to listen: %ui", WSAGetLastError()); 60 closesocket(s); 61 return -1; 62 } 63 if (getsockname(s, (SOCKADDR *) & serv_addr, &len) == SOCKET_ERROR) 64 { 65 tr_dbg("pgpipe failed to getsockname: %ui", WSAGetLastError()); 66 closesocket(s); 67 return -1; 68 } 69 if ((handles[1] = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) 70 { 71 tr_dbg("pgpipe failed to create socket 2: %ui", WSAGetLastError()); 72 closesocket(s); 73 return -1; 74 } 75 76 if (connect(handles[1], (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR) 77 { 78 tr_dbg("pgpipe failed to connect socket: %ui", WSAGetLastError()); 79 closesocket(s); 80 return -1; 81 } 82 if ((handles[0] = accept(s, (SOCKADDR *) & serv_addr, &len)) == INVALID_SOCKET) 83 { 84 tr_dbg("pgpipe failed to accept socket: %ui", WSAGetLastError()); 85 closesocket(handles[1]); 86 handles[1] = INVALID_SOCKET; 87 closesocket(s); 88 return -1; 89 } 90 closesocket(s); 91 return 0; 91 92 } 92 93 … … 94 95 piperead( int s, char *buf, int len ) 95 96 { 96 int ret = recv(s, buf, len, 0); 97 98 if (ret < 0 && WSAGetLastError() == WSAECONNRESET) 99 /* EOF on the pipe! (win32 socket based implementation) */ 100 ret = 0; 101 return ret; 97 int ret = recv(s, buf, len, 0); 98 int werror = 0; 99 100 if (ret < 0) { 101 werror= WSAGetLastError(); 102 switch(werror) { 103 /* simplified error mapping (not valid for connect) */ 104 case WSAEWOULDBLOCK: 105 errno = EAGAIN; 106 break; 107 case WSAECONNRESET: 108 /* EOF on the pipe! (win32 socket based implementation) */ 109 ret = 0; 110 /* fall through */ 111 default: 112 errno = werror; 113 break; 114 } 115 } else 116 errno = 0; 117 return ret; 102 118 } 103 119 -
trunk/qt/qtr.pro
r10815 r10816 10 10 CONFIG += qt qdbus thread debug link_pkgconfig 11 11 QT += network 12 PKGCONFIG = fontconfig libcurl openssl 12 PKGCONFIG = fontconfig libcurl openssl dbus-1 13 13 14 14 TRANSMISSION_TOP = .. … … 18 18 LIBS += $${TRANSMISSION_TOP}/third-party/miniupnp/libminiupnp.a 19 19 LIBS += $${TRANSMISSION_TOP}/third-party/libnatpmp/libnatpmp.a 20 LIBS += -levent 20 unix: LIBS += -levent 21 win32:DEFINES += QT_DBUS 22 win32:LIBS += -levent -lws2_32 -lintl 23 win32:LIBS += -lidn -liconv -lwldap32 -liphlpapi 21 24 22 25 TRANSLATIONS += transmission_en.ts transmission_ru.ts … … 33 36 HEADERS += speed.h types.h 34 37 38 win32:RC_FILE = qtr.rc -
trunk/qt/utils.cc
r10726 r10816 77 77 { 78 78 displayed_size = (double)size / MEGABYTE_FACTOR; 79 str = tr( "%L1 MiB" ).arg( displayed_size, 0, 'f', 1);79 str = tr( "%L1 MiB" ).arg( displayed_size, 0, 'f', 2 ); 80 80 } 81 81 else 82 82 { 83 83 displayed_size = (double) size / GIGABYTE_FACTOR; 84 str = tr( "%L1 GiB" ).arg( displayed_size, 0, 'f', 1);84 str = tr( "%L1 GiB" ).arg( displayed_size, 0, 'f', 3 ); 85 85 } 86 86 }
Note: See TracChangeset
for help on using the changeset viewer.