Changeset 14382
- Timestamp:
- Dec 13, 2014, 3:22:39 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/configure.ac
r14363 r14382 452 452 have_msw="yes" 453 453 CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows" 454 CPPFLAGS="$CPPFLAGS -DWIN32_LEAN_AND_MEAN" 454 CPPFLAGS="$CPPFLAGS -DWINVER=0x0600 -D_WIN32_WINNT=0x0600 -DWIN32_LEAN_AND_MEAN" 455 CPPFLAGS="$CPPFLAGS -D__USE_MINGW_ANSI_STDIO=1 -D__STDC_FORMAT_MACROS=1" 455 456 LIBS="$LIBS -liphlpapi -lshell32 -lws2_32" 456 457 transmissionlocaledir="locale" -
trunk/daemon/daemon.c
r14337 r14382 12 12 #include <stdlib.h> /* exit, atoi */ 13 13 14 #include <fcntl.h> /* open */15 14 #include <signal.h> 16 15 #ifdef HAVE_SYSLOG 17 16 #include <syslog.h> 18 17 #endif 19 #include <unistd.h> /* daemon */ 18 19 #ifdef _WIN32 20 #include <process.h> /* getpid */ 21 #else 22 #include <fcntl.h> /* open */ 23 #include <unistd.h> /* daemon */ 24 #endif 20 25 21 26 #include <event2/buffer.h> … … 172 177 switch (sig) 173 178 { 179 #ifdef SIGHUP 174 180 case SIGHUP: 175 181 { … … 201 207 break; 202 208 } 209 #endif 203 210 204 211 default: … … 434 441 signal (SIGINT, gotsig); 435 442 signal (SIGTERM, gotsig); 436 #if ndef _WIN32443 #ifdef SIGHUP 437 444 signal (SIGHUP, gotsig); 438 445 #endif … … 616 623 mySession = session; 617 624 625 #ifdef SIGHUP 618 626 /* If we got a SIGHUP during startup, process that now. */ 619 627 if (seenHUP) 620 628 gotsig (SIGHUP); 629 #endif 621 630 622 631 /* maybe add a watchdir */ … … 694 703 695 704 /* shutdown */ 696 #if HAVE_SYSLOG705 #ifdef HAVE_SYSLOG 697 706 if (!foreground) 698 707 { -
trunk/libtransmission/blocklist-test.c
r14331 r14382 11 11 #include <stdio.h> 12 12 #include <string.h> /* strlen () */ 13 #include <unistd.h> /* sync() */14 13 15 14 #include "transmission.h" … … 49 48 tr_sys_file_close (fd, NULL); 50 49 51 sync ();50 libttest_sync (); 52 51 } 53 52 -
trunk/libtransmission/fdlimit.c
r14367 r14382 13 13 #include <string.h> 14 14 15 #include <sys/time.h> /* getrlimit */ 16 #include <sys/resource.h> /* getrlimit */ 15 #ifndef _WIN32 16 #include <sys/time.h> /* getrlimit */ 17 #include <sys/resource.h> /* getrlimit */ 18 #endif 17 19 18 20 #include "transmission.h" … … 356 358 if (session->fdInfo == NULL) 357 359 { 358 struct rlimit limit;359 360 struct tr_fdInfo * i; 360 361 const int FILE_CACHE_SIZE = 32; … … 365 366 session->fdInfo = i; 366 367 368 #ifndef _WIN32 367 369 /* set the open-file limit to the largest safe size wrt FD_SETSIZE */ 370 struct rlimit limit; 368 371 if (!getrlimit (RLIMIT_NOFILE, &limit)) 369 372 { … … 378 381 } 379 382 } 383 #endif 380 384 } 381 385 } … … 542 546 { 543 547 int fd; 544 unsigned int len;548 socklen_t len; 545 549 struct tr_fdInfo * gFd; 546 550 struct sockaddr_storage sock; -
trunk/libtransmission/file-win32.c
r14369 r14382 393 393 wchar_t * wide_path; 394 394 wchar_t * wide_ret = NULL; 395 HANDLE handle ;395 HANDLE handle = INVALID_HANDLE_VALUE; 396 396 DWORD wide_ret_size; 397 397 -
trunk/libtransmission/libtransmission-test.c
r14359 r14382 9 9 10 10 #include <assert.h> 11 #include <errno.h> 11 12 #include <stdio.h> 12 13 #include <stdlib.h> /* mkstemp() */ 13 14 #include <unistd.h> 14 #include <string.h> /* strcmp() */ 15 16 #ifndef _WIN32 17 #include <unistd.h> /* sync() */ 18 #endif 15 19 16 20 #include "transmission.h" … … 21 25 #include "torrent.h" 22 26 #include "trevent.h" 27 #include "variant.h" 23 28 #include "libtransmission-test.h" 24 29 … … 114 119 return 0; /* All tests passed */ 115 120 } 116 117 /***118 ****119 ***/120 121 #include <unistd.h> /* sync() */122 123 #include <errno.h>124 #include <string.h> /* strcmp() */125 126 #include "variant.h"127 121 128 122 /*** … … 399 393 } 400 394 401 sync ();395 libttest_sync (); 402 396 libttest_blockingTorrentVerify (tor); 403 397 … … 458 452 tr_sys_file_close (fd, NULL); 459 453 460 sync ();454 libttest_sync (); 461 455 462 456 errno = tmperr; … … 493 487 tr_sys_file_close (fd, NULL); 494 488 489 libttest_sync (); 490 491 errno = tmperr; 492 } 493 494 void 495 libttest_sync (void) 496 { 497 #ifndef _WIN32 495 498 sync (); 496 497 errno = tmperr; 498 } 499 #endif 500 } -
trunk/libtransmission/libtransmission-test.h
r14289 r14382 92 92 void libtest_sandbox_destroy (const char * sandbox); 93 93 94 void libttest_sync (void); 94 95 95 96 #endif /* !LIBTRANSMISSION_TEST_H */ -
trunk/libtransmission/makemeta-test.c
r14369 r14382 14 14 #include "file.h" 15 15 #include "makemeta.h" 16 17 #include <unistd.h> /* sync() */18 16 19 17 #include <stdlib.h> /* mktemp() */ … … 64 62 /* now let's check our work: parse the .torrent file */ 65 63 ctor = tr_ctorNew (NULL); 66 sync ();64 libttest_sync (); 67 65 tr_ctorSetMetainfoFromFile (ctor, torrent_file); 68 66 parse_result = tr_torrentParse (ctor, &inf); … … 158 156 totalSize += payloadSizes[i]; 159 157 } 160 sync ();158 libttest_sync (); 161 159 162 160 /* init the builder */ … … 185 183 /* now let's check our work: parse the .torrent file */ 186 184 ctor = tr_ctorNew (NULL); 187 sync ();185 libttest_sync (); 188 186 tr_ctorSetMetainfoFromFile (ctor, torrent_file); 189 187 parse_result = tr_torrentParse (ctor, &inf); -
trunk/libtransmission/move-test.c
r14365 r14382 12 12 #include <string.h> /* strcmp() */ 13 13 #include <stdio.h> 14 15 #include <unistd.h> /* sync() */16 14 17 15 #include <event2/buffer.h> … … 201 199 202 200 /* confirm the filest really got moved */ 203 sync ();201 libttest_sync (); 204 202 for (i=0; i<tor->info.fileCount; ++i) 205 203 check_file_location (tor, i, tr_buildPath (target_dir, tor->info.files[i].name, NULL)); -
trunk/libtransmission/net.c
r14347 r14382 31 31 32 32 #ifdef _WIN32 33 #define _WIN32_WINNT 0x050134 33 #include <ws2tcpip.h> 35 34 #else -
trunk/libtransmission/net.h
r14316 r14382 39 39 40 40 #ifdef _WIN32 41 #undef EADDRINUSE 41 42 #define EADDRINUSE WSAEADDRINUSE 43 #undef ECONNREFUSED 42 44 #define ECONNREFUSED WSAECONNREFUSED 45 #undef ECONNRESET 43 46 #define ECONNRESET WSAECONNRESET 47 #undef EHOSTUNREACH 44 48 #define EHOSTUNREACH WSAEHOSTUNREACH 49 #undef EINPROGRESS 45 50 #define EINPROGRESS WSAEINPROGRESS 51 #undef ENOTCONN 46 52 #define ENOTCONN WSAENOTCONN 53 #undef EWOULDBLOCK 47 54 #define EWOULDBLOCK WSAEWOULDBLOCK 55 #undef EAFNOSUPPORT 48 56 #define EAFNOSUPPORT WSAEAFNOSUPPORT 57 #undef ENETUNREACH 49 58 #define ENETUNREACH WSAENETUNREACH 50 59 #define sockerrno WSAGetLastError () -
trunk/libtransmission/peer-common.h
r14316 r14382 175 175 176 176 #ifdef _WIN32 177 #undef EMSGSIZE 177 178 #define EMSGSIZE WSAEMSGSIZE 178 179 #endif -
trunk/libtransmission/peer-io.c
r14354 r14382 31 31 32 32 #ifdef _WIN32 33 #undef EAGAIN 33 34 #define EAGAIN WSAEWOULDBLOCK 35 #undef EINTR 34 36 #define EINTR WSAEINTR 37 #undef EINPROGRESS 35 38 #define EINPROGRESS WSAEINPROGRESS 39 #undef EPIPE 36 40 #define EPIPE WSAECONNRESET 37 41 #endif -
trunk/libtransmission/peer-mgr.c
r14372 r14382 2896 2896 const int inc = maxIncrease * mult; 2897 2897 maxPeers = s->maxPeers + inc; 2898 tordbg (s, "time since last cancel is % lli-- increasing the "2898 tordbg (s, "time since last cancel is %"PRId64" -- increasing the " 2899 2899 "number of peers we're interested in by %d", 2900 2900 (long long)timeSinceCancel, inc); -
trunk/libtransmission/platform-quota.c
r14373 r14382 11 11 #include <stdlib.h> 12 12 #include <string.h> 13 #include <unistd.h> /* getuid() */ 13 14 14 #include <event2/util.h> /* evutil_ascii_strcasecmp () */ 15 15 16 16 #ifndef _WIN32 17 #include <unistd.h> /* getuid() */ 17 18 #include <sys/types.h> /* types needed by quota.h */ 18 19 #if defined(__FreeBSD__) || defined(__OpenBSD__) -
trunk/libtransmission/platform.c
r14348 r14382 16 16 #include <stdlib.h> 17 17 #include <string.h> 18 #include <unistd.h> /* getuid() */19 18 20 19 #ifdef __HAIKU__ … … 23 22 24 23 #ifdef _WIN32 25 #include <w32api.h> 26 #define WINVER WindowsXP 24 #include <process.h> /* _beginthreadex (), _endthreadex () */ 27 25 #include <windows.h> 28 26 #include <shlobj.h> /* for CSIDL_APPDATA, CSIDL_MYDOCUMENTS */ 29 27 #else 28 #include <unistd.h> /* getuid() */ 30 29 #ifdef BUILD_MAC_CLIENT 31 30 #include <CoreFoundation/CoreFoundation.h> … … 37 36 #endif 38 37 39 #ifdef _WIN3240 #include <libgen.h> /* dirname() */41 #endif42 43 38 #include "transmission.h" 44 39 #include "file.h" … … 230 225 #ifdef _WIN32 231 226 232 char *227 static char * 233 228 win32_get_special_folder (int folder_id) 234 229 { -
trunk/libtransmission/rename-test.c
r14366 r14382 12 12 #include <stdio.h> /* fopen() */ 13 13 #include <string.h> /* strcmp() */ 14 15 #include <unistd.h> /* sync() */16 14 17 15 #include "transmission.h" … … 203 201 /* (while it's renamed: confirm that the .resume file remembers the changes) */ 204 202 tr_torrentSaveResume (tor); 205 sync ();203 libttest_sync (); 206 204 loaded = tr_torrentLoadResume (tor, ~0, ctor); 207 205 check_streq ("foobar", tr_torrentName(tor)); … … 255 253 tr_free (path); 256 254 257 sync ();255 libttest_sync (); 258 256 } 259 257 … … 390 388 tr_free (tmp); 391 389 tr_free (str); 392 sync ();390 libttest_sync (); 393 391 libttest_blockingTorrentVerify (tor); 394 392 testFileExistsAndConsistsOfThisString (tor, 0, expected_contents[0]); -
trunk/libtransmission/session.c
r14354 r14382 15 15 16 16 #include <signal.h> 17 #include <sys/types.h> /* umask () */ 18 #include <sys/stat.h> /* umask () */ 17 18 #ifndef _WIN32 19 #include <sys/types.h> /* umask () */ 20 #include <sys/stat.h> /* umask () */ 21 #endif 19 22 20 23 #include <event2/dns.h> /* evdns_base_free () */ … … 772 775 tr_logSetLevel (i); 773 776 777 #ifndef _WIN32 774 778 if (tr_variantDictFindInt (settings, TR_KEY_umask, &i)) 775 779 { … … 777 781 umask (session->umask); 778 782 } 783 #endif 779 784 780 785 /* misc features */ -
trunk/libtransmission/torrent.c
r14368 r14382 10 10 #include <errno.h> /* EINVAL */ 11 11 #include <signal.h> /* signal () */ 12 12 13 #ifndef _WIN32 13 14 #include <sys/wait.h> /* wait () */ 15 #include <unistd.h> /* fork (), execvp (), _exit () */ 14 16 #else 15 #include <process.h> 17 #include <process.h> /* _spawnvpe () */ 16 18 #endif 17 #include <unistd.h> /* fork (), execvp (), _exit () */18 19 19 20 #include <assert.h> … … 2077 2078 } 2078 2079 2080 #ifndef _WIN32 2081 2079 2082 static void 2080 2083 onSigCHLD (int i UNUSED) 2081 2084 { 2082 #ifdef _WIN322083 2084 _cwait (NULL, -1, WAIT_CHILD);2085 2086 #else2087 2088 2085 int rc; 2089 2086 do 2090 2087 rc = waitpid (-1, NULL, WNOHANG); 2091 2088 while (rc>0 || (rc==-1 && errno==EINTR)); 2089 } 2092 2090 2093 2091 #endif 2094 }2095 2092 2096 2093 static void -
trunk/libtransmission/tr-dht.c
r14355 r14382 32 32 /* posix */ 33 33 #include <signal.h> /* sig_atomic_t */ 34 #include <sys/time.h> 34 35 35 #ifdef _WIN32 36 36 #include <inttypes.h> 37 #define _WIN32_WINNT 0x0501 /* freeaddrinfo (),getaddrinfo (),getnameinfo () */38 37 #include <ws2tcpip.h> 39 38 #else 39 #include <sys/time.h> 40 40 #include <sys/types.h> 41 41 #include <sys/socket.h> /* socket (), bind () */ -
trunk/libtransmission/tr-lpd.c
r14321 r14382 28 28 /* posix */ 29 29 #include <signal.h> /* sig_atomic_t */ 30 #include <sys/time.h>31 #include <unistd.h> /* close () */32 30 #include <ctype.h> /* toupper () */ 31 33 32 #ifdef _WIN32 34 #include <w32api.h>35 #define WINDOWS WindowsXP /* freeaddrinfo (),getaddrinfo (),getnameinfo () */36 33 #include <inttypes.h> 37 34 #include <ws2tcpip.h> 38 35 typedef uint16_t in_port_t; /* all missing */ 39 36 #else 37 #include <sys/time.h> 38 #include <unistd.h> /* close () */ 40 39 #include <sys/types.h> 41 40 #include <sys/socket.h> /* socket (), bind () */ … … 360 359 { 361 360 const int save = errno; 362 close(lpd_socket);363 close(lpd_socket2);361 evutil_closesocket (lpd_socket); 362 evutil_closesocket (lpd_socket2); 364 363 lpd_socket = lpd_socket2 = -1; 365 364 session = NULL; -
trunk/libtransmission/tr-udp.c
r14187 r14382 26 26 #include <stdlib.h> /* malloc (), free () */ 27 27 28 #include <unistd.h> /* close () */ 28 #ifdef _WIN32 29 #include <io.h> /* dup2 () */ 30 #else 31 #include <unistd.h> /* dup2 () */ 32 #endif 29 33 30 34 #include <event2/event.h> … … 163 167 ss->udp6_socket = s; 164 168 } else { 169 /* FIXME: dup2 doesn't work for sockets on Windows */ 165 170 rc = dup2 (s, ss->udp6_socket); 166 171 if (rc < 0) 167 172 goto fail; 168 close(s);173 tr_netCloseSocket (s); 169 174 } 170 175 … … 181 186 tr_logAddNamedError ("UDP", "Couldn't rebind IPv6 socket"); 182 187 if (s >= 0) 183 close(s);188 tr_netCloseSocket (s); 184 189 if (ss->udp6_bound) { 185 190 free (ss->udp6_bound); … … 262 267 if (rc < 0) { 263 268 tr_logAddNamedError ("UDP", "Couldn't bind IPv4 socket"); 264 close(ss->udp_socket);269 tr_netCloseSocket (ss->udp_socket); 265 270 ss->udp_socket = -1; 266 271 goto ipv6; -
trunk/libtransmission/tr-utp.c
r14354 r14382 158 158 159 159 static void 160 timer_callback ( int s UNUSED, short type UNUSED, void *closure)160 timer_callback (evutil_socket_t s UNUSED, short type UNUSED, void *closure) 161 161 { 162 162 tr_session *ss = closure; -
trunk/libtransmission/transmission.h
r14316 r14382 30 30 #include <time.h> /* time_t */ 31 31 32 #ifdef _WIN32 33 #define __USE_MINGW_ANSI_STDIO 1 34 #define __STDC_FORMAT_MACROS 1 32 #ifdef _MSC_VER 33 typedef intptr_t ssize_t; 35 34 #endif 36 35 … … 46 45 47 46 #ifndef PRId64 48 #if def _WIN3247 #if defined (_MSC_VER) || (defined (__MINGW32__) && !defined (__USE_MINGW_ANSI_STDIO)) 49 48 #define PRId64 "I64" 50 49 #else … … 54 53 55 54 #ifndef PRIu64 56 #if def _WIN3255 #if defined (_MSC_VER) || (defined (__MINGW32__) && !defined (__USE_MINGW_ANSI_STDIO)) 57 56 #define PRIu64 "I64u" 58 57 #else … … 62 61 63 62 #ifndef PRIu32 64 #if def _WIN3263 #if defined (_MSC_VER) || (defined (__MINGW32__) && !defined (__USE_MINGW_ANSI_STDIO)) 65 64 #define PRIu32 "u" 66 65 #else … … 70 69 71 70 #ifndef TR_PRIuSIZE 72 #if def _MSC_VER71 #if defined (_MSC_VER) || (defined (__MINGW32__) && !defined (__USE_MINGW_ANSI_STDIO)) 73 72 #define TR_PRIuSIZE "Iu" 74 73 #else … … 77 76 #endif 78 77 79 #if defined (_ WIN32) && defined (_MSC_VER)78 #if defined (_MSC_VER) && !defined (__cplusplus) 80 79 #define inline __inline 81 80 #endif -
trunk/libtransmission/trevent.c
r14316 r14382 14 14 #include <signal.h> 15 15 16 #ifdef _WIN32 17 #include <winsock2.h> 18 #else 19 #include <unistd.h> /* read (), write (), pipe () */ 20 #endif 21 16 22 #include <event2/dns.h> 17 23 #include <event2/event.h> … … 22 28 #include "session.h" 23 29 30 #include "transmission.h" 31 #include "platform.h" /* tr_lockLock () */ 32 #include "trevent.h" 33 #include "utils.h" 34 35 24 36 #ifdef _WIN32 25 26 #include "utils.h"27 #include <winsock2.h>28 37 29 38 static int … … 122 131 #endif 123 132 124 #include <unistd.h> /* read (), write (), pipe () */125 126 #include "transmission.h"127 #include "platform.h" /* tr_lockLock () */128 #include "trevent.h"129 #include "utils.h"130 131 133 /*** 132 134 **** -
trunk/libtransmission/utils-test.c
r14371 r14382 385 385 check_streq ("3", buf); 386 386 387 #if !(defined (_MSC_VER) || (defined (__MINGW32__) && defined (__MSVCRT__))) 388 /* FIXME: MSCVRT behaves differently in case of nan */ 387 389 tr_snprintf (buf, sizeof (buf), "%.2f", tr_truncd (nan, 2)); 388 390 check (strstr (buf, "nan") != NULL); 391 #endif 389 392 390 393 return 0; -
trunk/libtransmission/utils.c
r14368 r14382 29 29 #include <time.h> /* nanosleep () */ 30 30 31 #ifdef _WIN32 32 #include <windows.h> /* Sleep (), GetSystemTimeAsFileTime (), GetEnvironmentVariable () */ 33 #include <shellapi.h> /* CommandLineToArgv () */ 34 #else 35 #include <sys/time.h> 36 #include <unistd.h> /* getpagesize () */ 37 #endif 38 31 39 #ifdef HAVE_ICONV_OPEN 32 40 #include <iconv.h> 33 41 #endif 34 #include <sys/time.h>35 #include <unistd.h> /* getpagesize () */36 42 37 43 #include <event2/buffer.h> 38 44 #include <event2/event.h> 39 40 #ifdef _WIN3241 #include <w32api.h>42 #define WINVER WindowsXP /* freeaddrinfo (), getaddrinfo (), getnameinfo () */43 #include <windows.h> /* Sleep (), GetSystemTimeAsFileTime (), GetEnvironmentVariable () */44 #include <shellapi.h> /* CommandLineToArgv () */45 #endif46 45 47 46 #include "transmission.h" … … 82 81 tr_gettimeofday (struct timeval * tv) 83 82 { 84 #ifdef _ MSC_VER85 #define DELTA_EPOCH_IN_MICROSECS 11644473600000000U i6483 #ifdef _WIN32 84 #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL 86 85 87 86 FILETIME ft; … … 1517 1516 if (!pageSize) 1518 1517 { 1519 #if def HAVE_GETPAGESIZE1518 #if defined (HAVE_GETPAGESIZE) && !defined (_WIN32) 1520 1519 pageSize = (size_t) getpagesize (); 1521 1520 #else /* guess */ -
trunk/libtransmission/variant-test.c
r14316 r14382 101 101 102 102 /* string len is designed to overflow */ 103 n = tr_snprintf ((char*)buf, sizeof (buf), "% zu:boat", (size_t)(SIZE_MAX-2));103 n = tr_snprintf ((char*)buf, sizeof (buf), "%"TR_PRIuSIZE":boat", (size_t)(SIZE_MAX-2)); 104 104 err = tr_bencParseStr (buf, buf+n, &end, &str, &len); 105 105 check_int_eq (EILSEQ, err);
Note: See TracChangeset
for help on using the changeset viewer.