mirror of https://github.com/aria2/aria2
				
				
				
			2007-07-23 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Merged Ross's win32 patch(manually)
	In the course of merging, following files are added.
	* src/strptime.{h,c}
	* src/libgen.{h,c}
	* src/inet_aton.{h,c}
	* src/Platform.{h,cc}
	* src/localtime_r.{h,c}
	* src/getaddrinfo.{h,c}
	I've gethered network related things, and put them to following 
file:
	* src/a2netcompat.h
	Also io related things are put to following file:
	* src/a2io.h
	
	Changed %lld to %s because mingw32 doesn't recognize %lld.
	* src/message.h
	(MSG_ALLOCATION_COMPLETED)
	(EX_TOO_LARGE_FILE)
	(EX_SIZE_MISMATCH)
	(EX_FILE_OFFSET_OUT_OF_RANGE)
	(EX_INVALID_CHUNK_CHECKSUM)
	(EX_INVALID_RANGE_HEADER)
	* src/FileAllocationCommand.cc
	* src/HttpResponse.cc
	* src/RequestGroup.cc
	* src/MultiDiskAdaptor.cc
	* src/OptionHandlerImpl.h
	* src/HttpResponseCommand.cc
	* src/FtpNegotiateCommand.cc
	* src/IteratableChecksumValidator.cc
	* src/SegmentMan.cc
	* src/ChunkChecksumValidator.cc
	
	Added Randomizer::getRandomNumber(long int)
	* src/Randomizer.h (getRandomNumber)
	* src/SimpleRandomizer.h (getRandomNumber)
	* src/BitfieldMan.cc (getMissingIndexRandomly): Use this new 
function.
	* src/Util.cc (randomAlpha): Use this new function.
			
			
				pull/1/head
			
			
		
							parent
							
								
									6574e44f88
								
							
						
					
					
						commit
						380e3f0187
					
				
							
								
								
									
										40
									
								
								ChangeLog
								
								
								
								
							
							
						
						
									
										40
									
								
								ChangeLog
								
								
								
								
							| 
						 | 
					@ -1,3 +1,43 @@
 | 
				
			||||||
 | 
					2007-07-23  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Merged Ross's win32 patch(manually)
 | 
				
			||||||
 | 
						In the course of merging, following files are added.
 | 
				
			||||||
 | 
						* src/strptime.{h,c}
 | 
				
			||||||
 | 
						* src/libgen.{h,c}
 | 
				
			||||||
 | 
						* src/inet_aton.{h,c}
 | 
				
			||||||
 | 
						* src/Platform.{h,cc}
 | 
				
			||||||
 | 
						* src/localtime_r.{h,c}
 | 
				
			||||||
 | 
						* src/getaddrinfo.{h,c}
 | 
				
			||||||
 | 
						I've gethered network related things, and put them to following file:
 | 
				
			||||||
 | 
						* src/a2netcompat.h
 | 
				
			||||||
 | 
						Also io related things are put to following file:
 | 
				
			||||||
 | 
						* src/a2io.h
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						Changed %lld to %s because mingw32 doesn't recognize %lld.
 | 
				
			||||||
 | 
						* src/message.h
 | 
				
			||||||
 | 
						(MSG_ALLOCATION_COMPLETED)
 | 
				
			||||||
 | 
						(EX_TOO_LARGE_FILE)
 | 
				
			||||||
 | 
						(EX_SIZE_MISMATCH)
 | 
				
			||||||
 | 
						(EX_FILE_OFFSET_OUT_OF_RANGE)
 | 
				
			||||||
 | 
						(EX_INVALID_CHUNK_CHECKSUM)
 | 
				
			||||||
 | 
						(EX_INVALID_RANGE_HEADER)
 | 
				
			||||||
 | 
						* src/FileAllocationCommand.cc
 | 
				
			||||||
 | 
						* src/HttpResponse.cc
 | 
				
			||||||
 | 
						* src/RequestGroup.cc
 | 
				
			||||||
 | 
						* src/MultiDiskAdaptor.cc
 | 
				
			||||||
 | 
						* src/OptionHandlerImpl.h
 | 
				
			||||||
 | 
						* src/HttpResponseCommand.cc
 | 
				
			||||||
 | 
						* src/FtpNegotiateCommand.cc
 | 
				
			||||||
 | 
						* src/IteratableChecksumValidator.cc
 | 
				
			||||||
 | 
						* src/SegmentMan.cc
 | 
				
			||||||
 | 
						* src/ChunkChecksumValidator.cc
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						Added Randomizer::getRandomNumber(long int)
 | 
				
			||||||
 | 
						* src/Randomizer.h (getRandomNumber)
 | 
				
			||||||
 | 
						* src/SimpleRandomizer.h (getRandomNumber)
 | 
				
			||||||
 | 
						* src/BitfieldMan.cc (getMissingIndexRandomly): Use this new function.
 | 
				
			||||||
 | 
						* src/Util.cc (randomAlpha): Use this new function.
 | 
				
			||||||
 | 
						
 | 
				
			||||||
2007-07-21  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 | 
					2007-07-21  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Converted int's to in32_t. long long int's are also converted to
 | 
						Converted int's to in32_t. long long int's are also converted to
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										16
									
								
								Makefile.in
								
								
								
								
							
							
						
						
									
										16
									
								
								Makefile.in
								
								
								
								
							| 
						 | 
					@ -35,6 +35,7 @@ PRE_UNINSTALL = :
 | 
				
			||||||
POST_UNINSTALL = :
 | 
					POST_UNINSTALL = :
 | 
				
			||||||
build_triplet = @build@
 | 
					build_triplet = @build@
 | 
				
			||||||
host_triplet = @host@
 | 
					host_triplet = @host@
 | 
				
			||||||
 | 
					target_triplet = @target@
 | 
				
			||||||
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
 | 
					DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
 | 
				
			||||||
	$(srcdir)/Makefile.in $(srcdir)/config.h.in \
 | 
						$(srcdir)/Makefile.in $(srcdir)/config.h.in \
 | 
				
			||||||
	$(top_srcdir)/configure $(top_srcdir)/intl/Makefile.in \
 | 
						$(top_srcdir)/configure $(top_srcdir)/intl/Makefile.in \
 | 
				
			||||||
| 
						 | 
					@ -127,6 +128,16 @@ GENCAT = @GENCAT@
 | 
				
			||||||
GLIBC21 = @GLIBC21@
 | 
					GLIBC21 = @GLIBC21@
 | 
				
			||||||
GMSGFMT = @GMSGFMT@
 | 
					GMSGFMT = @GMSGFMT@
 | 
				
			||||||
GREP = @GREP@
 | 
					GREP = @GREP@
 | 
				
			||||||
 | 
					HAVE_BASENAME_FALSE = @HAVE_BASENAME_FALSE@
 | 
				
			||||||
 | 
					HAVE_BASENAME_TRUE = @HAVE_BASENAME_TRUE@
 | 
				
			||||||
 | 
					HAVE_GETADDRINFO_FALSE = @HAVE_GETADDRINFO_FALSE@
 | 
				
			||||||
 | 
					HAVE_GETADDRINFO_TRUE = @HAVE_GETADDRINFO_TRUE@
 | 
				
			||||||
 | 
					HAVE_INET_ATON_FALSE = @HAVE_INET_ATON_FALSE@
 | 
				
			||||||
 | 
					HAVE_INET_ATON_TRUE = @HAVE_INET_ATON_TRUE@
 | 
				
			||||||
 | 
					HAVE_LOCALTIME_R_FALSE = @HAVE_LOCALTIME_R_FALSE@
 | 
				
			||||||
 | 
					HAVE_LOCALTIME_R_TRUE = @HAVE_LOCALTIME_R_TRUE@
 | 
				
			||||||
 | 
					HAVE_STRPTIME_FALSE = @HAVE_STRPTIME_FALSE@
 | 
				
			||||||
 | 
					HAVE_STRPTIME_TRUE = @HAVE_STRPTIME_TRUE@
 | 
				
			||||||
INSTALL_DATA = @INSTALL_DATA@
 | 
					INSTALL_DATA = @INSTALL_DATA@
 | 
				
			||||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
 | 
					INSTALL_PROGRAM = @INSTALL_PROGRAM@
 | 
				
			||||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
 | 
					INSTALL_SCRIPT = @INSTALL_SCRIPT@
 | 
				
			||||||
| 
						 | 
					@ -176,6 +187,7 @@ STRIP = @STRIP@
 | 
				
			||||||
USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
 | 
					USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
 | 
				
			||||||
USE_NLS = @USE_NLS@
 | 
					USE_NLS = @USE_NLS@
 | 
				
			||||||
VERSION = @VERSION@
 | 
					VERSION = @VERSION@
 | 
				
			||||||
 | 
					WINSOCK_LIBS = @WINSOCK_LIBS@
 | 
				
			||||||
XGETTEXT = @XGETTEXT@
 | 
					XGETTEXT = @XGETTEXT@
 | 
				
			||||||
XML2_CONFIG = @XML2_CONFIG@
 | 
					XML2_CONFIG = @XML2_CONFIG@
 | 
				
			||||||
XML_CPPFLAGS = @XML_CPPFLAGS@
 | 
					XML_CPPFLAGS = @XML_CPPFLAGS@
 | 
				
			||||||
| 
						 | 
					@ -227,7 +239,11 @@ psdir = @psdir@
 | 
				
			||||||
sbindir = @sbindir@
 | 
					sbindir = @sbindir@
 | 
				
			||||||
sharedstatedir = @sharedstatedir@
 | 
					sharedstatedir = @sharedstatedir@
 | 
				
			||||||
sysconfdir = @sysconfdir@
 | 
					sysconfdir = @sysconfdir@
 | 
				
			||||||
 | 
					target = @target@
 | 
				
			||||||
target_alias = @target_alias@
 | 
					target_alias = @target_alias@
 | 
				
			||||||
 | 
					target_cpu = @target_cpu@
 | 
				
			||||||
 | 
					target_os = @target_os@
 | 
				
			||||||
 | 
					target_vendor = @target_vendor@
 | 
				
			||||||
SUBDIRS = intl  m4 po src test doc
 | 
					SUBDIRS = intl  m4 po src test doc
 | 
				
			||||||
ACLOCAL_AMFLAGS = -I m4
 | 
					ACLOCAL_AMFLAGS = -I m4
 | 
				
			||||||
EXTRA_DIST = config.rpath
 | 
					EXTRA_DIST = config.rpath
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										18
									
								
								TODO
								
								
								
								
							
							
						
						
									
										18
									
								
								TODO
								
								
								
								
							| 
						 | 
					@ -28,8 +28,22 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* Fix log and stdout message in Metalink related class.
 | 
					* Fix log and stdout message in Metalink related class.
 | 
				
			||||||
* Fix Cookie header's value. ';' is not necessary at the end of it.
 | 
					* Fix Cookie header's value. ';' is not necessary at the end of it.
 | 
				
			||||||
* It is possible to replace all %lld to %s, using Util::llitos(...) ?.
 | 
					 | 
				
			||||||
* Time::getTimeInMillis() returns int64_t.
 | 
					* Time::getTimeInMillis() returns int64_t.
 | 
				
			||||||
* Util::secfmt, What happens if sec is less than 0?
 | 
					* Util::secfmt, What happens if sec is less than 0?
 | 
				
			||||||
* Rewrite ChunkedEncoding
 | 
					* Rewrite ChunkedEncoding
 | 
				
			||||||
* typedef int32_t CUID in common.h or a2types.h
 | 
					* typedef int32_t CUID in common.h or a2types.h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* tempdir in HttpResponseCommand is not patched yet.
 | 
				
			||||||
 | 
					* Is localtime.cc not needed?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* io related headers and compatible macros and definition -> a2io.h
 | 
				
			||||||
 | 
					* net related headers and compatible macros and definition -> a2netcompat.h
 | 
				
			||||||
 | 
					* used globally -> common.h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* Following files have copyright issue
 | 
				
			||||||
 | 
						libgen.c
 | 
				
			||||||
 | 
						libgen.h
 | 
				
			||||||
 | 
						inet_aton.c
 | 
				
			||||||
 | 
						inet_aton.h
 | 
				
			||||||
 | 
						localtime_r.{h,c}
 | 
				
			||||||
 | 
						strptime.h
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										51
									
								
								config.h.in
								
								
								
								
							
							
						
						
									
										51
									
								
								config.h.in
								
								
								
								
							| 
						 | 
					@ -40,6 +40,12 @@
 | 
				
			||||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
 | 
					/* Define to 1 if you have the <arpa/inet.h> header file. */
 | 
				
			||||||
#undef HAVE_ARPA_INET_H
 | 
					#undef HAVE_ARPA_INET_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `basename' function. */
 | 
				
			||||||
 | 
					#undef HAVE_BASENAME
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `daemon' function. */
 | 
				
			||||||
 | 
					#undef HAVE_DAEMON
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Define if the GNU dcgettext() function is already present or preinstalled.
 | 
					/* Define if the GNU dcgettext() function is already present or preinstalled.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
#undef HAVE_DCGETTEXT
 | 
					#undef HAVE_DCGETTEXT
 | 
				
			||||||
| 
						 | 
					@ -59,6 +65,9 @@
 | 
				
			||||||
/* Define to 1 if you have the `ftruncate' function. */
 | 
					/* Define to 1 if you have the `ftruncate' function. */
 | 
				
			||||||
#undef HAVE_FTRUNCATE
 | 
					#undef HAVE_FTRUNCATE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `getaddrinfo' function. */
 | 
				
			||||||
 | 
					#undef HAVE_GETADDRINFO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Define to 1 if you have the `getcwd' function. */
 | 
					/* Define to 1 if you have the `getcwd' function. */
 | 
				
			||||||
#undef HAVE_GETCWD
 | 
					#undef HAVE_GETCWD
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -89,6 +98,9 @@
 | 
				
			||||||
/* Define if you have the iconv() function. */
 | 
					/* Define if you have the iconv() function. */
 | 
				
			||||||
#undef HAVE_ICONV
 | 
					#undef HAVE_ICONV
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `inet_aton' function. */
 | 
				
			||||||
 | 
					#undef HAVE_INET_ATON
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Define to 1 if you have the `inet_ntoa' function. */
 | 
					/* Define to 1 if you have the `inet_ntoa' function. */
 | 
				
			||||||
#undef HAVE_INET_NTOA
 | 
					#undef HAVE_INET_NTOA
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -99,6 +111,9 @@
 | 
				
			||||||
   declares uintmax_t. */
 | 
					   declares uintmax_t. */
 | 
				
			||||||
#undef HAVE_INTTYPES_H_WITH_UINTMAX
 | 
					#undef HAVE_INTTYPES_H_WITH_UINTMAX
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the <io.h> header file. */
 | 
				
			||||||
 | 
					#undef HAVE_IO_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
 | 
					/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
 | 
				
			||||||
#undef HAVE_LANGINFO_CODESET
 | 
					#undef HAVE_LANGINFO_CODESET
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -117,6 +132,9 @@
 | 
				
			||||||
/* Define to 1 if you have libgcrypt. */
 | 
					/* Define to 1 if you have libgcrypt. */
 | 
				
			||||||
#undef HAVE_LIBGCRYPT
 | 
					#undef HAVE_LIBGCRYPT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the <libgen.h> header file. */
 | 
				
			||||||
 | 
					#undef HAVE_LIBGEN_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Define to 1 if you have libgnutls. */
 | 
					/* Define to 1 if you have libgnutls. */
 | 
				
			||||||
#undef HAVE_LIBGNUTLS
 | 
					#undef HAVE_LIBGNUTLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -135,6 +153,9 @@
 | 
				
			||||||
/* Define to 1 if you have the <locale.h> header file. */
 | 
					/* Define to 1 if you have the <locale.h> header file. */
 | 
				
			||||||
#undef HAVE_LOCALE_H
 | 
					#undef HAVE_LOCALE_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `localtime_r' function. */
 | 
				
			||||||
 | 
					#undef HAVE_LOCALTIME_R
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
 | 
					/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
 | 
				
			||||||
   to 0 otherwise. */
 | 
					   to 0 otherwise. */
 | 
				
			||||||
#undef HAVE_MALLOC
 | 
					#undef HAVE_MALLOC
 | 
				
			||||||
| 
						 | 
					@ -178,6 +199,9 @@
 | 
				
			||||||
/* Define to 1 if you have the `putenv' function. */
 | 
					/* Define to 1 if you have the `putenv' function. */
 | 
				
			||||||
#undef HAVE_PUTENV
 | 
					#undef HAVE_PUTENV
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `random' function. */
 | 
				
			||||||
 | 
					#undef HAVE_RANDOM
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Define to 1 if your system has a GNU libc compatible `realloc' function,
 | 
					/* Define to 1 if your system has a GNU libc compatible `realloc' function,
 | 
				
			||||||
   and to 0 otherwise. */
 | 
					   and to 0 otherwise. */
 | 
				
			||||||
#undef HAVE_REALLOC
 | 
					#undef HAVE_REALLOC
 | 
				
			||||||
| 
						 | 
					@ -194,9 +218,21 @@
 | 
				
			||||||
/* Define to 1 if you have the `setlocale' function. */
 | 
					/* Define to 1 if you have the `setlocale' function. */
 | 
				
			||||||
#undef HAVE_SETLOCALE
 | 
					#undef HAVE_SETLOCALE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `setmode' function. */
 | 
				
			||||||
 | 
					#undef HAVE_SETMODE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `sigaction' function. */
 | 
				
			||||||
 | 
					#undef HAVE_SIGACTION
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `sleep' function. */
 | 
				
			||||||
 | 
					#undef HAVE_SLEEP
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Define to 1 if you have the `socket' function. */
 | 
					/* Define to 1 if you have the `socket' function. */
 | 
				
			||||||
#undef HAVE_SOCKET
 | 
					#undef HAVE_SOCKET
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `srandom' function. */
 | 
				
			||||||
 | 
					#undef HAVE_SRANDOM
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Define to 1 if `stat' has the bug that it succeeds when given the
 | 
					/* Define to 1 if `stat' has the bug that it succeeds when given the
 | 
				
			||||||
   zero-length file name argument. */
 | 
					   zero-length file name argument. */
 | 
				
			||||||
#undef HAVE_STAT_EMPTY_STRING_BUG
 | 
					#undef HAVE_STAT_EMPTY_STRING_BUG
 | 
				
			||||||
| 
						 | 
					@ -244,6 +280,9 @@
 | 
				
			||||||
/* Define to 1 if you have the <string.h> header file. */
 | 
					/* Define to 1 if you have the <string.h> header file. */
 | 
				
			||||||
#undef HAVE_STRING_H
 | 
					#undef HAVE_STRING_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `strptime' function. */
 | 
				
			||||||
 | 
					#undef HAVE_STRPTIME
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Define to 1 if you have the `strstr' function. */
 | 
					/* Define to 1 if you have the `strstr' function. */
 | 
				
			||||||
#undef HAVE_STRSTR
 | 
					#undef HAVE_STRSTR
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -271,6 +310,9 @@
 | 
				
			||||||
/* Define to 1 if you have the <sys/types.h> header file. */
 | 
					/* Define to 1 if you have the <sys/types.h> header file. */
 | 
				
			||||||
#undef HAVE_SYS_TYPES_H
 | 
					#undef HAVE_SYS_TYPES_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `timegm' function. */
 | 
				
			||||||
 | 
					#undef HAVE_TIMEGM
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Define to 1 if you have the `tsearch' function. */
 | 
					/* Define to 1 if you have the `tsearch' function. */
 | 
				
			||||||
#undef HAVE_TSEARCH
 | 
					#undef HAVE_TSEARCH
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -283,9 +325,18 @@
 | 
				
			||||||
/* Define if you have the unsigned long long type. */
 | 
					/* Define if you have the unsigned long long type. */
 | 
				
			||||||
#undef HAVE_UNSIGNED_LONG_LONG
 | 
					#undef HAVE_UNSIGNED_LONG_LONG
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `usleep' function. */
 | 
				
			||||||
 | 
					#undef HAVE_USLEEP
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Define to 1 if you have the `vprintf' function. */
 | 
					/* Define to 1 if you have the `vprintf' function. */
 | 
				
			||||||
#undef HAVE_VPRINTF
 | 
					#undef HAVE_VPRINTF
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the <winsock2.h> header file. */
 | 
				
			||||||
 | 
					#undef HAVE_WINSOCK2_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the <ws2tcpip.h> header file. */
 | 
				
			||||||
 | 
					#undef HAVE_WS2TCPIP_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Define to 1 if the system has the type `_Bool'. */
 | 
					/* Define to 1 if the system has the type `_Bool'. */
 | 
				
			||||||
#undef HAVE__BOOL
 | 
					#undef HAVE__BOOL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										37
									
								
								configure.ac
								
								
								
								
							
							
						
						
									
										37
									
								
								configure.ac
								
								
								
								
							| 
						 | 
					@ -3,11 +3,20 @@
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
AC_PREREQ(2.59)
 | 
					AC_PREREQ(2.59)
 | 
				
			||||||
AC_INIT(aria2c, 0.11.1+1, t-tujikawa@users.sourceforge.net)
 | 
					AC_INIT(aria2c, 0.11.1+1, t-tujikawa@users.sourceforge.net)
 | 
				
			||||||
 | 
					AC_CANONICAL_HOST
 | 
				
			||||||
 | 
					AC_CANONICAL_SYSTEM
 | 
				
			||||||
AM_INIT_AUTOMAKE()
 | 
					AM_INIT_AUTOMAKE()
 | 
				
			||||||
AM_PATH_CPPUNIT(1.10.2)
 | 
					AM_PATH_CPPUNIT(1.10.2)
 | 
				
			||||||
AC_CONFIG_SRCDIR([src/Socket.h])
 | 
					AC_CONFIG_SRCDIR([src/Socket.h])
 | 
				
			||||||
AC_CONFIG_HEADERS([config.h])
 | 
					AC_CONFIG_HEADERS([config.h])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					case "$target" in
 | 
				
			||||||
 | 
						*mingw*|*cygwin*)
 | 
				
			||||||
 | 
							WINSOCK_LIBS="-lws2_32"
 | 
				
			||||||
 | 
							AC_SUBST(WINSOCK_LIBS)
 | 
				
			||||||
 | 
							;;
 | 
				
			||||||
 | 
					esac
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Set localedir
 | 
					# Set localedir
 | 
				
			||||||
localedir=${datadir}/locale
 | 
					localedir=${datadir}/locale
 | 
				
			||||||
AC_SUBST(localedir)
 | 
					AC_SUBST(localedir)
 | 
				
			||||||
| 
						 | 
					@ -102,7 +111,7 @@ fi
 | 
				
			||||||
# Checks for header files.
 | 
					# Checks for header files.
 | 
				
			||||||
AC_FUNC_ALLOCA
 | 
					AC_FUNC_ALLOCA
 | 
				
			||||||
#AC_HEADER_STDC
 | 
					#AC_HEADER_STDC
 | 
				
			||||||
AC_CHECK_HEADERS([argz.h arpa/inet.h fcntl.h inttypes.h langinfo.h libintl.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdio_ext.h stdlib.h string.h strings.h sys/param.h sys/socket.h sys/time.h unistd.h])
 | 
					AC_CHECK_HEADERS([winsock2.h ws2tcpip.h argz.h arpa/inet.h fcntl.h inttypes.h io.h langinfo.h libgen.h libintl.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdio_ext.h stdlib.h string.h strings.h sys/param.h sys/socket.h sys/time.h unistd.h])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Checks for typedefs, structures, and compiler characteristics.
 | 
					# Checks for typedefs, structures, and compiler characteristics.
 | 
				
			||||||
AC_HEADER_STDBOOL
 | 
					AC_HEADER_STDBOOL
 | 
				
			||||||
| 
						 | 
					@ -125,7 +134,31 @@ AC_FUNC_REALLOC
 | 
				
			||||||
AC_FUNC_SELECT_ARGTYPES
 | 
					AC_FUNC_SELECT_ARGTYPES
 | 
				
			||||||
AC_FUNC_STAT
 | 
					AC_FUNC_STAT
 | 
				
			||||||
AC_FUNC_VPRINTF
 | 
					AC_FUNC_VPRINTF
 | 
				
			||||||
AC_CHECK_FUNCS([__argz_count __argz_next __argz_stringify ftruncate getcwd getpagesize gettimeofday inet_ntoa memchr mempcpy memset mkdir munmap nl_langinfo rmdir select setlocale socket stpcpy strcasecmp strchr strcspn strdup strerror strstr strtol strtoul])
 | 
					AC_CHECK_FUNCS([__argz_count __argz_next __argz_stringify daemon ftruncate getcwd getpagesize gettimeofday inet_ntoa memchr mempcpy memset mkdir munmap nl_langinfo random rmdir select setlocale setmode sigaction sleep socket srandom stpcpy strcasecmp strchr strcspn strdup strerror strstr strtol strtoul timegm usleep])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					AC_CHECK_FUNCS([basename],
 | 
				
			||||||
 | 
						[AM_CONDITIONAL([HAVE_BASENAME], true)],
 | 
				
			||||||
 | 
						[AM_CONDITIONAL([HAVE_BASENAME], false)])
 | 
				
			||||||
 | 
					AC_CHECK_FUNCS([getaddrinfo],
 | 
				
			||||||
 | 
						[AM_CONDITIONAL([HAVE_GETADDRINFO], true)],
 | 
				
			||||||
 | 
						[AM_CONDITIONAL([HAVE_GETADDRINFO], false)])
 | 
				
			||||||
 | 
					AC_CHECK_FUNCS([inet_aton],
 | 
				
			||||||
 | 
						[AM_CONDITIONAL([HAVE_INET_ATON], true)],
 | 
				
			||||||
 | 
						[AM_CONDITIONAL([HAVE_INET_ATON], false)])
 | 
				
			||||||
 | 
					AC_CHECK_FUNCS([localtime_r],
 | 
				
			||||||
 | 
						[AM_CONDITIONAL([HAVE_LOCALTIME_R], true)],
 | 
				
			||||||
 | 
						[AM_CONDITIONAL([HAVE_LOCALTIME_R], false)])
 | 
				
			||||||
 | 
					AC_CHECK_FUNCS([strptime],
 | 
				
			||||||
 | 
						[AM_CONDITIONAL([HAVE_STRPTIME], true)],
 | 
				
			||||||
 | 
						[AM_CONDITIONAL([HAVE_STRPTIME], false)])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					case "$target" in
 | 
				
			||||||
 | 
						*mingw*)
 | 
				
			||||||
 | 
							dnl true if _WIN32_WINNT >= 0x0501
 | 
				
			||||||
 | 
							AM_CONDITIONAL([HAVE_GETADDRINFO], true)
 | 
				
			||||||
 | 
							;;
 | 
				
			||||||
 | 
					esac
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AC_CONFIG_FILES([Makefile
 | 
					AC_CONFIG_FILES([Makefile
 | 
				
			||||||
		src/Makefile
 | 
							src/Makefile
 | 
				
			||||||
		test/Makefile
 | 
							test/Makefile
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,6 +35,7 @@ PRE_UNINSTALL = :
 | 
				
			||||||
POST_UNINSTALL = :
 | 
					POST_UNINSTALL = :
 | 
				
			||||||
build_triplet = @build@
 | 
					build_triplet = @build@
 | 
				
			||||||
host_triplet = @host@
 | 
					host_triplet = @host@
 | 
				
			||||||
 | 
					target_triplet = @target@
 | 
				
			||||||
subdir = doc
 | 
					subdir = doc
 | 
				
			||||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 | 
					DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 | 
				
			||||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 | 
					ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 | 
				
			||||||
| 
						 | 
					@ -105,6 +106,16 @@ GENCAT = @GENCAT@
 | 
				
			||||||
GLIBC21 = @GLIBC21@
 | 
					GLIBC21 = @GLIBC21@
 | 
				
			||||||
GMSGFMT = @GMSGFMT@
 | 
					GMSGFMT = @GMSGFMT@
 | 
				
			||||||
GREP = @GREP@
 | 
					GREP = @GREP@
 | 
				
			||||||
 | 
					HAVE_BASENAME_FALSE = @HAVE_BASENAME_FALSE@
 | 
				
			||||||
 | 
					HAVE_BASENAME_TRUE = @HAVE_BASENAME_TRUE@
 | 
				
			||||||
 | 
					HAVE_GETADDRINFO_FALSE = @HAVE_GETADDRINFO_FALSE@
 | 
				
			||||||
 | 
					HAVE_GETADDRINFO_TRUE = @HAVE_GETADDRINFO_TRUE@
 | 
				
			||||||
 | 
					HAVE_INET_ATON_FALSE = @HAVE_INET_ATON_FALSE@
 | 
				
			||||||
 | 
					HAVE_INET_ATON_TRUE = @HAVE_INET_ATON_TRUE@
 | 
				
			||||||
 | 
					HAVE_LOCALTIME_R_FALSE = @HAVE_LOCALTIME_R_FALSE@
 | 
				
			||||||
 | 
					HAVE_LOCALTIME_R_TRUE = @HAVE_LOCALTIME_R_TRUE@
 | 
				
			||||||
 | 
					HAVE_STRPTIME_FALSE = @HAVE_STRPTIME_FALSE@
 | 
				
			||||||
 | 
					HAVE_STRPTIME_TRUE = @HAVE_STRPTIME_TRUE@
 | 
				
			||||||
INSTALL_DATA = @INSTALL_DATA@
 | 
					INSTALL_DATA = @INSTALL_DATA@
 | 
				
			||||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
 | 
					INSTALL_PROGRAM = @INSTALL_PROGRAM@
 | 
				
			||||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
 | 
					INSTALL_SCRIPT = @INSTALL_SCRIPT@
 | 
				
			||||||
| 
						 | 
					@ -154,6 +165,7 @@ STRIP = @STRIP@
 | 
				
			||||||
USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
 | 
					USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
 | 
				
			||||||
USE_NLS = @USE_NLS@
 | 
					USE_NLS = @USE_NLS@
 | 
				
			||||||
VERSION = @VERSION@
 | 
					VERSION = @VERSION@
 | 
				
			||||||
 | 
					WINSOCK_LIBS = @WINSOCK_LIBS@
 | 
				
			||||||
XGETTEXT = @XGETTEXT@
 | 
					XGETTEXT = @XGETTEXT@
 | 
				
			||||||
XML2_CONFIG = @XML2_CONFIG@
 | 
					XML2_CONFIG = @XML2_CONFIG@
 | 
				
			||||||
XML_CPPFLAGS = @XML_CPPFLAGS@
 | 
					XML_CPPFLAGS = @XML_CPPFLAGS@
 | 
				
			||||||
| 
						 | 
					@ -205,7 +217,11 @@ psdir = @psdir@
 | 
				
			||||||
sbindir = @sbindir@
 | 
					sbindir = @sbindir@
 | 
				
			||||||
sharedstatedir = @sharedstatedir@
 | 
					sharedstatedir = @sharedstatedir@
 | 
				
			||||||
sysconfdir = @sysconfdir@
 | 
					sysconfdir = @sysconfdir@
 | 
				
			||||||
 | 
					target = @target@
 | 
				
			||||||
target_alias = @target_alias@
 | 
					target_alias = @target_alias@
 | 
				
			||||||
 | 
					target_cpu = @target_cpu@
 | 
				
			||||||
 | 
					target_os = @target_os@
 | 
				
			||||||
 | 
					target_vendor = @target_vendor@
 | 
				
			||||||
man_MANS = aria2c.1
 | 
					man_MANS = aria2c.1
 | 
				
			||||||
EXTRA_DIST = $(man_MANS)
 | 
					EXTRA_DIST = $(man_MANS)
 | 
				
			||||||
all: all-am
 | 
					all: all-am
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,6 +35,7 @@ PRE_UNINSTALL = :
 | 
				
			||||||
POST_UNINSTALL = :
 | 
					POST_UNINSTALL = :
 | 
				
			||||||
build_triplet = @build@
 | 
					build_triplet = @build@
 | 
				
			||||||
host_triplet = @host@
 | 
					host_triplet = @host@
 | 
				
			||||||
 | 
					target_triplet = @target@
 | 
				
			||||||
subdir = m4
 | 
					subdir = m4
 | 
				
			||||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
 | 
					DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
 | 
				
			||||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 | 
					ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 | 
				
			||||||
| 
						 | 
					@ -101,6 +102,16 @@ GENCAT = @GENCAT@
 | 
				
			||||||
GLIBC21 = @GLIBC21@
 | 
					GLIBC21 = @GLIBC21@
 | 
				
			||||||
GMSGFMT = @GMSGFMT@
 | 
					GMSGFMT = @GMSGFMT@
 | 
				
			||||||
GREP = @GREP@
 | 
					GREP = @GREP@
 | 
				
			||||||
 | 
					HAVE_BASENAME_FALSE = @HAVE_BASENAME_FALSE@
 | 
				
			||||||
 | 
					HAVE_BASENAME_TRUE = @HAVE_BASENAME_TRUE@
 | 
				
			||||||
 | 
					HAVE_GETADDRINFO_FALSE = @HAVE_GETADDRINFO_FALSE@
 | 
				
			||||||
 | 
					HAVE_GETADDRINFO_TRUE = @HAVE_GETADDRINFO_TRUE@
 | 
				
			||||||
 | 
					HAVE_INET_ATON_FALSE = @HAVE_INET_ATON_FALSE@
 | 
				
			||||||
 | 
					HAVE_INET_ATON_TRUE = @HAVE_INET_ATON_TRUE@
 | 
				
			||||||
 | 
					HAVE_LOCALTIME_R_FALSE = @HAVE_LOCALTIME_R_FALSE@
 | 
				
			||||||
 | 
					HAVE_LOCALTIME_R_TRUE = @HAVE_LOCALTIME_R_TRUE@
 | 
				
			||||||
 | 
					HAVE_STRPTIME_FALSE = @HAVE_STRPTIME_FALSE@
 | 
				
			||||||
 | 
					HAVE_STRPTIME_TRUE = @HAVE_STRPTIME_TRUE@
 | 
				
			||||||
INSTALL_DATA = @INSTALL_DATA@
 | 
					INSTALL_DATA = @INSTALL_DATA@
 | 
				
			||||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
 | 
					INSTALL_PROGRAM = @INSTALL_PROGRAM@
 | 
				
			||||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
 | 
					INSTALL_SCRIPT = @INSTALL_SCRIPT@
 | 
				
			||||||
| 
						 | 
					@ -150,6 +161,7 @@ STRIP = @STRIP@
 | 
				
			||||||
USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
 | 
					USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
 | 
				
			||||||
USE_NLS = @USE_NLS@
 | 
					USE_NLS = @USE_NLS@
 | 
				
			||||||
VERSION = @VERSION@
 | 
					VERSION = @VERSION@
 | 
				
			||||||
 | 
					WINSOCK_LIBS = @WINSOCK_LIBS@
 | 
				
			||||||
XGETTEXT = @XGETTEXT@
 | 
					XGETTEXT = @XGETTEXT@
 | 
				
			||||||
XML2_CONFIG = @XML2_CONFIG@
 | 
					XML2_CONFIG = @XML2_CONFIG@
 | 
				
			||||||
XML_CPPFLAGS = @XML_CPPFLAGS@
 | 
					XML_CPPFLAGS = @XML_CPPFLAGS@
 | 
				
			||||||
| 
						 | 
					@ -201,7 +213,11 @@ psdir = @psdir@
 | 
				
			||||||
sbindir = @sbindir@
 | 
					sbindir = @sbindir@
 | 
				
			||||||
sharedstatedir = @sharedstatedir@
 | 
					sharedstatedir = @sharedstatedir@
 | 
				
			||||||
sysconfdir = @sysconfdir@
 | 
					sysconfdir = @sysconfdir@
 | 
				
			||||||
 | 
					target = @target@
 | 
				
			||||||
target_alias = @target_alias@
 | 
					target_alias = @target_alias@
 | 
				
			||||||
 | 
					target_cpu = @target_cpu@
 | 
				
			||||||
 | 
					target_os = @target_os@
 | 
				
			||||||
 | 
					target_vendor = @target_vendor@
 | 
				
			||||||
EXTRA_DIST = codeset.m4 gettext.m4 glibc21.m4 iconv.m4 intdiv0.m4 inttypes.m4 inttypes_h.m4 inttypes-pri.m4 isc-posix.m4 lcmessage.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 nls.m4 po.m4 progtest.m4 stdint_h.m4 uintmax_t.m4 ulonglong.m4
 | 
					EXTRA_DIST = codeset.m4 gettext.m4 glibc21.m4 iconv.m4 intdiv0.m4 inttypes.m4 inttypes_h.m4 inttypes-pri.m4 isc-posix.m4 lcmessage.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 nls.m4 po.m4 progtest.m4 stdint_h.m4 uintmax_t.m4 ulonglong.m4
 | 
				
			||||||
all: all-am
 | 
					all: all-am
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,6 +38,7 @@
 | 
				
			||||||
#include "Util.h"
 | 
					#include "Util.h"
 | 
				
			||||||
#include "message.h"
 | 
					#include "message.h"
 | 
				
			||||||
#include "LogFactory.h"
 | 
					#include "LogFactory.h"
 | 
				
			||||||
 | 
					#include "a2io.h"
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
#include <sys/types.h>
 | 
					#include <sys/types.h>
 | 
				
			||||||
#include <sys/stat.h>
 | 
					#include <sys/stat.h>
 | 
				
			||||||
| 
						 | 
					@ -79,7 +80,7 @@ void AbstractDiskWriter::openExistingFile(const string& filename, int64_t totalL
 | 
				
			||||||
    throw new DlAbortEx(EX_FILE_OPEN, filename.c_str(), MSG_FILE_NOT_FOUND);
 | 
					    throw new DlAbortEx(EX_FILE_OPEN, filename.c_str(), MSG_FILE_NOT_FOUND);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if((fd = open(filename.c_str(), O_RDWR, OPEN_MODE)) < 0) {
 | 
					  if((fd = open(filename.c_str(), O_RDWR|O_BINARY, OPEN_MODE)) < 0) {
 | 
				
			||||||
    throw new DlAbortEx(EX_FILE_OPEN, filename.c_str(), strerror(errno));
 | 
					    throw new DlAbortEx(EX_FILE_OPEN, filename.c_str(), strerror(errno));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if(f.size() < totalLength) {
 | 
					  if(f.size() < totalLength) {
 | 
				
			||||||
| 
						 | 
					@ -99,7 +100,7 @@ void AbstractDiskWriter::createFile(const string& filename, int32_t addFlags) {
 | 
				
			||||||
//   if(filename.empty()) {
 | 
					//   if(filename.empty()) {
 | 
				
			||||||
//     filename = "index.html";
 | 
					//     filename = "index.html";
 | 
				
			||||||
//   }
 | 
					//   }
 | 
				
			||||||
  if((fd = open(filename.c_str(), O_CREAT|O_RDWR|O_TRUNC|addFlags, OPEN_MODE)) < 0) {
 | 
					  if((fd = open(filename.c_str(), O_CREAT|O_RDWR|O_TRUNC|O_BINARY|addFlags, OPEN_MODE)) < 0) {
 | 
				
			||||||
    throw new DlAbortEx(EX_FILE_OPEN, filename.c_str(), strerror(errno));
 | 
					    throw new DlAbortEx(EX_FILE_OPEN, filename.c_str(), strerror(errno));
 | 
				
			||||||
  }  
 | 
					  }  
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -135,9 +135,12 @@ int32_t
 | 
				
			||||||
BitfieldMan::getMissingIndexRandomly(const unsigned char* bitfield,
 | 
					BitfieldMan::getMissingIndexRandomly(const unsigned char* bitfield,
 | 
				
			||||||
				     int32_t bitfieldLength) const
 | 
									     int32_t bitfieldLength) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					  /*
 | 
				
			||||||
  int32_t byte = (int32_t)(((double)bitfieldLength)*
 | 
					  int32_t byte = (int32_t)(((double)bitfieldLength)*
 | 
				
			||||||
			   randomizer->getRandomNumber()/
 | 
								   randomizer->getRandomNumber()/
 | 
				
			||||||
			   (randomizer->getMaxRandomNumber()+1.0));
 | 
								   (randomizer->getMaxRandomNumber()+1.0));
 | 
				
			||||||
 | 
					  */
 | 
				
			||||||
 | 
					  int32_t byte = randomizer->getRandomNumber(bitfieldLength);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  unsigned char lastMask = 0;
 | 
					  unsigned char lastMask = 0;
 | 
				
			||||||
  // the number of bytes in the last byte of bitfield
 | 
					  // the number of bytes in the last byte of bitfield
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,7 +49,7 @@ void ChunkChecksumValidator::validateSameLengthChecksum(BitfieldMan* bitfieldMan
 | 
				
			||||||
  string actualChecksum = diskWriter->messageDigest(offset, dataLength, algo);
 | 
					  string actualChecksum = diskWriter->messageDigest(offset, dataLength, algo);
 | 
				
			||||||
  if(actualChecksum != expectedChecksum) {
 | 
					  if(actualChecksum != expectedChecksum) {
 | 
				
			||||||
    logger->info(EX_INVALID_CHUNK_CHECKSUM,
 | 
					    logger->info(EX_INVALID_CHUNK_CHECKSUM,
 | 
				
			||||||
		 index, offset,
 | 
							 index, Util::llitos(offset, true).c_str(),
 | 
				
			||||||
		 expectedChecksum.c_str(), actualChecksum.c_str());
 | 
							 expectedChecksum.c_str(), actualChecksum.c_str());
 | 
				
			||||||
    bitfieldMan->unsetBit(index);
 | 
					    bitfieldMan->unsetBit(index);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					@ -71,7 +71,7 @@ void ChunkChecksumValidator::validateDifferentLengthChecksum(BitfieldMan* bitfie
 | 
				
			||||||
    if(expectedChecksum != actualChecksum) {
 | 
					    if(expectedChecksum != actualChecksum) {
 | 
				
			||||||
      // wrong checksum
 | 
					      // wrong checksum
 | 
				
			||||||
      logger->info(EX_INVALID_CHUNK_CHECKSUM,
 | 
					      logger->info(EX_INVALID_CHUNK_CHECKSUM,
 | 
				
			||||||
		   index, offset,
 | 
							   index, Util::llitos(offset, true).c_str(),
 | 
				
			||||||
		   expectedChecksum.c_str(), actualChecksum.c_str());
 | 
							   expectedChecksum.c_str(), actualChecksum.c_str());
 | 
				
			||||||
      bitfieldMan->unsetBitRange(startIndex, endIndex);
 | 
					      bitfieldMan->unsetBitRange(startIndex, endIndex);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,7 +33,7 @@
 | 
				
			||||||
/* copyright --> */
 | 
					/* copyright --> */
 | 
				
			||||||
#include "CompactPeerListProcessor.h"
 | 
					#include "CompactPeerListProcessor.h"
 | 
				
			||||||
#include "Data.h"
 | 
					#include "Data.h"
 | 
				
			||||||
#include <netinet/in.h>
 | 
					#include "a2netcompat.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool CompactPeerListProcessor::canHandle(const MetaEntry* peersEntry) const {
 | 
					bool CompactPeerListProcessor::canHandle(const MetaEntry* peersEntry) const {
 | 
				
			||||||
  return dynamic_cast<const Data*>(peersEntry) != 0;
 | 
					  return dynamic_cast<const Data*>(peersEntry) != 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,6 +40,7 @@
 | 
				
			||||||
#include "message.h"
 | 
					#include "message.h"
 | 
				
			||||||
#include "File.h"
 | 
					#include "File.h"
 | 
				
			||||||
#include "Util.h"
 | 
					#include "Util.h"
 | 
				
			||||||
 | 
					#include "a2io.h"
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DefaultBtProgressInfoFile::DefaultBtProgressInfoFile(const BtContextHandle& btContext,
 | 
					DefaultBtProgressInfoFile::DefaultBtProgressInfoFile(const BtContextHandle& btContext,
 | 
				
			||||||
| 
						 | 
					@ -59,7 +60,7 @@ DefaultBtProgressInfoFile::~DefaultBtProgressInfoFile() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DefaultBtProgressInfoFile::save() {
 | 
					void DefaultBtProgressInfoFile::save() {
 | 
				
			||||||
  logger->info(MSG_SAVING_SEGMENT_FILE, filename.c_str());
 | 
					  logger->info(MSG_SAVING_SEGMENT_FILE, filename.c_str());
 | 
				
			||||||
  FILE* file = openFile(filename, "w");
 | 
					  FILE* file = openFile(filename, "wb");
 | 
				
			||||||
  try {
 | 
					  try {
 | 
				
			||||||
    if(fwrite(btContext->getInfoHash(),
 | 
					    if(fwrite(btContext->getInfoHash(),
 | 
				
			||||||
	      btContext->getInfoHashLength(), 1, file) < 1) {
 | 
						      btContext->getInfoHashLength(), 1, file) < 1) {
 | 
				
			||||||
| 
						 | 
					@ -93,7 +94,7 @@ void DefaultBtProgressInfoFile::save() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DefaultBtProgressInfoFile::load() {
 | 
					void DefaultBtProgressInfoFile::load() {
 | 
				
			||||||
  logger->info(MSG_LOADING_SEGMENT_FILE, filename.c_str());
 | 
					  logger->info(MSG_LOADING_SEGMENT_FILE, filename.c_str());
 | 
				
			||||||
  FILE* file = openFile(filename, "r+");
 | 
					  FILE* file = openFile(filename, "r+b");
 | 
				
			||||||
  unsigned char* savedInfoHash = 0;
 | 
					  unsigned char* savedInfoHash = 0;
 | 
				
			||||||
  unsigned char* savedBitfield = 0;
 | 
					  unsigned char* savedBitfield = 0;
 | 
				
			||||||
  try {
 | 
					  try {
 | 
				
			||||||
| 
						 | 
					@ -161,6 +162,9 @@ FILE* DefaultBtProgressInfoFile::openFile(const string& filename,
 | 
				
			||||||
    throw new DlAbortEx(EX_SEGMENT_FILE_OPEN,
 | 
					    throw new DlAbortEx(EX_SEGMENT_FILE_OPEN,
 | 
				
			||||||
			filename.c_str(), strerror(errno));
 | 
								filename.c_str(), strerror(errno));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					#ifdef HAVE_SETMODE
 | 
				
			||||||
 | 
					  setmode(fileno(file), O_BINARY);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
  return file;
 | 
					  return file;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,9 +36,11 @@
 | 
				
			||||||
#include "File.h"
 | 
					#include "File.h"
 | 
				
			||||||
#include "DlAbortEx.h"
 | 
					#include "DlAbortEx.h"
 | 
				
			||||||
#include "message.h"
 | 
					#include "message.h"
 | 
				
			||||||
 | 
					#include "a2io.h"
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <sys/stat.h>
 | 
					#include <sys/stat.h>
 | 
				
			||||||
#include <sys/types.h>
 | 
					#include <sys/types.h>
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Directory::Directory(const string& name):name(name) {}
 | 
					Directory::Directory(const string& name):name(name) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,7 +63,7 @@ void Directory::createDir(const string& parentDir, bool recursive) const {
 | 
				
			||||||
      throw new DlAbortEx(EX_NOT_DIRECTORY, path.c_str());
 | 
					      throw new DlAbortEx(EX_NOT_DIRECTORY, path.c_str());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    if(mkdir(path.c_str(), OPEN_MODE) == -1) {
 | 
					    if(a2mkdir(path.c_str(), OPEN_MODE) == -1) {
 | 
				
			||||||
      throw new DlAbortEx(EX_MAKE_DIR, path.c_str(), strerror(errno));
 | 
					      throw new DlAbortEx(EX_MAKE_DIR, path.c_str(), strerror(errno));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,6 +44,7 @@
 | 
				
			||||||
# include "ChecksumCommand.h"
 | 
					# include "ChecksumCommand.h"
 | 
				
			||||||
#endif // ENABLE_MESSAGE_DIGEST
 | 
					#endif // ENABLE_MESSAGE_DIGEST
 | 
				
			||||||
#include <sys/time.h>
 | 
					#include <sys/time.h>
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DownloadCommand::DownloadCommand(int cuid,
 | 
					DownloadCommand::DownloadCommand(int cuid,
 | 
				
			||||||
				 const RequestHandle req,
 | 
									 const RequestHandle req,
 | 
				
			||||||
| 
						 | 
					@ -71,7 +72,11 @@ bool DownloadCommand::executeInternal() {
 | 
				
			||||||
  // TODO we need to specify the sum of all segmentMan's download speed here.
 | 
					  // TODO we need to specify the sum of all segmentMan's download speed here.
 | 
				
			||||||
  if(maxDownloadSpeedLimit > 0 &&
 | 
					  if(maxDownloadSpeedLimit > 0 &&
 | 
				
			||||||
     maxDownloadSpeedLimit < _requestGroup->getSegmentMan()->calculateDownloadSpeed()) {
 | 
					     maxDownloadSpeedLimit < _requestGroup->getSegmentMan()->calculateDownloadSpeed()) {
 | 
				
			||||||
 | 
					#ifdef HAVE_USLEEP
 | 
				
			||||||
    usleep(1);
 | 
					    usleep(1);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					    _sleep(1);
 | 
				
			||||||
 | 
					#endif // HAVE_USLEEP
 | 
				
			||||||
    e->commands.push_back(this);
 | 
					    e->commands.push_back(this);
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										11
									
								
								src/File.cc
								
								
								
								
							
							
						
						
									
										11
									
								
								src/File.cc
								
								
								
								
							| 
						 | 
					@ -34,9 +34,7 @@
 | 
				
			||||||
/* copyright --> */
 | 
					/* copyright --> */
 | 
				
			||||||
#include "File.h"
 | 
					#include "File.h"
 | 
				
			||||||
#include "Util.h"
 | 
					#include "Util.h"
 | 
				
			||||||
#include <sys/types.h>
 | 
					#include "a2io.h"
 | 
				
			||||||
#include <sys/stat.h>
 | 
					 | 
				
			||||||
#include <unistd.h>
 | 
					 | 
				
			||||||
#include <libgen.h>
 | 
					#include <libgen.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
File::File(const string& name):name(name) {}
 | 
					File::File(const string& name):name(name) {}
 | 
				
			||||||
| 
						 | 
					@ -106,7 +104,7 @@ bool File::mkdirs() {
 | 
				
			||||||
    if(File(accDir).isDir()) {
 | 
					    if(File(accDir).isDir()) {
 | 
				
			||||||
      continue;
 | 
					      continue;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if(mkdir(accDir.c_str(), DIR_OPEN_MODE) == -1) {
 | 
					    if(a2mkdir(accDir.c_str(), DIR_OPEN_MODE) == -1) {
 | 
				
			||||||
      return false;
 | 
					      return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					@ -137,3 +135,8 @@ string File::getDirname() const
 | 
				
			||||||
  free(s);
 | 
					  free(s);
 | 
				
			||||||
  return dname;
 | 
					  return dname;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool File::isDir(const string& filename)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  return File(filename).isDir();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -94,6 +94,8 @@ public:
 | 
				
			||||||
  string getBasename() const;
 | 
					  string getBasename() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  string getDirname() const;
 | 
					  string getDirname() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  static bool isDir(const string& filename);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // _D_FILE_H_
 | 
					#endif // _D_FILE_H_
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,6 +37,7 @@
 | 
				
			||||||
#include "message.h"
 | 
					#include "message.h"
 | 
				
			||||||
#include "DownloadCommand.h"
 | 
					#include "DownloadCommand.h"
 | 
				
			||||||
#include "prefs.h"
 | 
					#include "prefs.h"
 | 
				
			||||||
 | 
					#include "Util.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool FileAllocationCommand::executeInternal()
 | 
					bool FileAllocationCommand::executeInternal()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -44,7 +45,8 @@ bool FileAllocationCommand::executeInternal()
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  if(_fileAllocationEntry->finished()) {
 | 
					  if(_fileAllocationEntry->finished()) {
 | 
				
			||||||
    logger->debug(MSG_ALLOCATION_COMPLETED,
 | 
					    logger->debug(MSG_ALLOCATION_COMPLETED,
 | 
				
			||||||
		  _timer.difference(), _requestGroup->getTotalLength());
 | 
							  _timer.difference(),
 | 
				
			||||||
 | 
							  Util::llitos(_requestGroup->getTotalLength(), true).c_str());
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    _e->_fileAllocationMan->markCurrentFileAllocationEntryDone();
 | 
					    _e->_fileAllocationMan->markCurrentFileAllocationEntryDone();
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -201,7 +201,7 @@ int32_t FtpConnection::receiveSizeResponse(int64_t& size) {
 | 
				
			||||||
  pair<int32_t, string> response;
 | 
					  pair<int32_t, string> response;
 | 
				
			||||||
  if(bulkReceiveResponse(response)) {
 | 
					  if(bulkReceiveResponse(response)) {
 | 
				
			||||||
    if(response.first == 213) {
 | 
					    if(response.first == 213) {
 | 
				
			||||||
      sscanf(response.second.c_str(), "%*d %Ld", &size);
 | 
					      sscanf(response.second.c_str(), "%*d " LONGLONG_SCANF, &size);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return response.first;
 | 
					    return response.first;
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -187,7 +187,7 @@ bool FtpNegotiationCommand::recvSize() {
 | 
				
			||||||
    throw new DlRetryEx(EX_BAD_STATUS, status);
 | 
					    throw new DlRetryEx(EX_BAD_STATUS, status);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if(size == INT64_MAX || size < 0) {
 | 
					  if(size == INT64_MAX || size < 0) {
 | 
				
			||||||
    throw new DlAbortEx(EX_TOO_LARGE_FILE, size);
 | 
					    throw new DlAbortEx(EX_TOO_LARGE_FILE, Util::llitos(size, true).c_str());
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if(!_requestGroup->getSegmentMan()->downloadStarted) {
 | 
					  if(!_requestGroup->getSegmentMan()->downloadStarted) {
 | 
				
			||||||
    _requestGroup->getSegmentMan()->downloadStarted = true;
 | 
					    _requestGroup->getSegmentMan()->downloadStarted = true;
 | 
				
			||||||
| 
						 | 
					@ -220,23 +220,8 @@ bool FtpNegotiationCommand::recvSize() {
 | 
				
			||||||
    sequence = SEQ_FILE_PREPARATION;
 | 
					    sequence = SEQ_FILE_PREPARATION;
 | 
				
			||||||
    e->noWait = true;
 | 
					    e->noWait = true;
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    /*
 | 
					 | 
				
			||||||
    _requestGroup->getSegmentMan()->initBitfield(e->option->getAsInt(PREF_SEGMENT_SIZE),
 | 
					 | 
				
			||||||
						 _requestGroup->getSegmentMan()->totalSize);
 | 
					 | 
				
			||||||
    bool segFileExists = _requestGroup->getSegmentMan()->segmentFileExists();
 | 
					 | 
				
			||||||
    if(segFileExists) {
 | 
					 | 
				
			||||||
      _requestGroup->getSegmentMan()->load();
 | 
					 | 
				
			||||||
      _requestGroup->getSegmentMan()->diskWriter->openExistingFile(_requestGroup->getSegmentMan()->getFilePath());
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
      _requestGroup->getSegmentMan()->diskWriter->initAndOpenFile(_requestGroup->getSegmentMan()->getFilePath(), size);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    _requestGroup->validateTotalLength(size);
 | 
					    _requestGroup->validateTotalLength(size);
 | 
				
			||||||
    //if(_requestGroup->getSegmentMan()->totalSize != size) {
 | 
					 | 
				
			||||||
    //throw new DlAbortEx(EX_SIZE_MISMATCH, _requestGroup->getSegmentMan()->totalSize, size);
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if(e->option->get(PREF_FTP_PASV) == V_TRUE) {
 | 
					  if(e->option->get(PREF_FTP_PASV) == V_TRUE) {
 | 
				
			||||||
    sequence = SEQ_SEND_PASV;
 | 
					    sequence = SEQ_SEND_PASV;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,8 +44,6 @@
 | 
				
			||||||
#include "Logger.h"
 | 
					#include "Logger.h"
 | 
				
			||||||
#include "HttpResponse.h"
 | 
					#include "HttpResponse.h"
 | 
				
			||||||
#include "HttpHeaderProcessor.h"
 | 
					#include "HttpHeaderProcessor.h"
 | 
				
			||||||
#include <netinet/in.h>
 | 
					 | 
				
			||||||
#include <string>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class HttpRequestEntry {
 | 
					class HttpRequestEntry {
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,7 +40,6 @@
 | 
				
			||||||
#include "Range.h"
 | 
					#include "Range.h"
 | 
				
			||||||
#include "Request.h"
 | 
					#include "Request.h"
 | 
				
			||||||
#include "Option.h"
 | 
					#include "Option.h"
 | 
				
			||||||
#include <netinet/in.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class HttpRequest {
 | 
					class HttpRequest {
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,12 +58,12 @@ void HttpResponse::validateResponse() const
 | 
				
			||||||
      RangeHandle responseRange = httpHeader->getRange();
 | 
					      RangeHandle responseRange = httpHeader->getRange();
 | 
				
			||||||
      if(!httpRequest->isRangeSatisfied(responseRange)) {
 | 
					      if(!httpRequest->isRangeSatisfied(responseRange)) {
 | 
				
			||||||
	throw new DlRetryEx(EX_INVALID_RANGE_HEADER,
 | 
						throw new DlRetryEx(EX_INVALID_RANGE_HEADER,
 | 
				
			||||||
			    httpRequest->getStartByte(),
 | 
								    Util::llitos(httpRequest->getStartByte(), true).c_str(),
 | 
				
			||||||
			    httpRequest->getEndByte(),
 | 
								    Util::llitos(httpRequest->getEndByte(), true).c_str(),
 | 
				
			||||||
			    httpRequest->getEntityLength(),
 | 
								    Util::llitos(httpRequest->getEntityLength(), true).c_str(),
 | 
				
			||||||
			    responseRange->getStartByte(),
 | 
								    Util::llitos(responseRange->getStartByte(), true).c_str(),
 | 
				
			||||||
			    responseRange->getEndByte(),
 | 
								    Util::llitos(responseRange->getEndByte(), true).c_str(),
 | 
				
			||||||
			    responseRange->getEntityLength());
 | 
								    Util::llitos(responseRange->getEntityLength(), true).c_str());
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -121,7 +121,7 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpResponseHandle& httpRe
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  int64_t size = httpResponse->getEntityLength();
 | 
					  int64_t size = httpResponse->getEntityLength();
 | 
				
			||||||
  if(size == INT64_MAX || size < 0) {
 | 
					  if(size == INT64_MAX || size < 0) {
 | 
				
			||||||
    throw new DlAbortEx(EX_TOO_LARGE_FILE, size);
 | 
					    throw new DlAbortEx(EX_TOO_LARGE_FILE, Util::llitos(size, true).c_str());
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  _requestGroup->getSegmentMan()->isSplittable = !(size == 0);
 | 
					  _requestGroup->getSegmentMan()->isSplittable = !(size == 0);
 | 
				
			||||||
  _requestGroup->getSegmentMan()->downloadStarted = true;
 | 
					  _requestGroup->getSegmentMan()->downloadStarted = true;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,7 +47,7 @@ void IteratableChunkChecksumValidator::validateChunk()
 | 
				
			||||||
      // wrong checksum
 | 
					      // wrong checksum
 | 
				
			||||||
      logger->info(EX_INVALID_CHUNK_CHECKSUM,
 | 
					      logger->info(EX_INVALID_CHUNK_CHECKSUM,
 | 
				
			||||||
		   _currentIndex,
 | 
							   _currentIndex,
 | 
				
			||||||
		   offset,
 | 
							   Util::llitos(offset, true).c_str(),
 | 
				
			||||||
		   _chunkChecksum->getChecksum(_currentIndex).c_str(),
 | 
							   _chunkChecksum->getChecksum(_currentIndex).c_str(),
 | 
				
			||||||
		   actualChecksum.c_str());
 | 
							   actualChecksum.c_str());
 | 
				
			||||||
      int32_t startIndex;
 | 
					      int32_t startIndex;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,8 +34,9 @@
 | 
				
			||||||
/* copyright --> */
 | 
					/* copyright --> */
 | 
				
			||||||
#include "LogFactory.h"
 | 
					#include "LogFactory.h"
 | 
				
			||||||
#include "SimpleLogger.h"
 | 
					#include "SimpleLogger.h"
 | 
				
			||||||
 | 
					#include "a2io.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
string LogFactory::filename = "/dev/null";
 | 
					string LogFactory::filename = DEV_NULL;
 | 
				
			||||||
Logger* LogFactory::logger = NULL;
 | 
					Logger* LogFactory::logger = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Logger* LogFactory::getInstance() {
 | 
					Logger* LogFactory::getInstance() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -98,7 +98,8 @@ SRCS =  Socket.h\
 | 
				
			||||||
	CookieParser.cc CookieParser.h\
 | 
						CookieParser.cc CookieParser.h\
 | 
				
			||||||
	CookieBoxFactory.cc CookieBoxFactory.h\
 | 
						CookieBoxFactory.cc CookieBoxFactory.h\
 | 
				
			||||||
	HttpHeaderProcessor.cc HttpHeaderProcessor.h\
 | 
						HttpHeaderProcessor.cc HttpHeaderProcessor.h\
 | 
				
			||||||
	FileEntry.cc FileEntry.h
 | 
						FileEntry.cc FileEntry.h\
 | 
				
			||||||
 | 
						Platform.cc Platform.h
 | 
				
			||||||
#	debug_new.cpp
 | 
					#	debug_new.cpp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if ENABLE_MESSAGE_DIGEST
 | 
					if ENABLE_MESSAGE_DIGEST
 | 
				
			||||||
| 
						 | 
					@ -226,11 +227,31 @@ SRCS += Metalinker.cc Metalinker.h\
 | 
				
			||||||
	MetalinkRequestInfo.cc MetalinkRequestInfo.h
 | 
						MetalinkRequestInfo.cc MetalinkRequestInfo.h
 | 
				
			||||||
endif # ENABLE_METALINK
 | 
					endif # ENABLE_METALINK
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if !HAVE_BASENAME
 | 
				
			||||||
 | 
					SRCS += libgen.c libgen.h
 | 
				
			||||||
 | 
					endif # !HAVE_BASENAME
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if !HAVE_GETADDRINFO
 | 
				
			||||||
 | 
					SRCS += getaddrinfo.c getaddrinfo.h
 | 
				
			||||||
 | 
					endif # !HAVE_GETADDRINFO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if !HAVE_INET_ATON
 | 
				
			||||||
 | 
					SRCS += inet_aton.c inet_aton.h
 | 
				
			||||||
 | 
					endif # !HAVE_INET_ATON
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if !HAVE_LOCALTIME_R
 | 
				
			||||||
 | 
					SRCS += localtime_r.c localtime_r.h
 | 
				
			||||||
 | 
					endif # !HAVE_LOCALTIME_R
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if !HAVE_STRPTIME
 | 
				
			||||||
 | 
					SRCS += strptime.c strptime.h
 | 
				
			||||||
 | 
					endif # !HAVE_STRPTIME
 | 
				
			||||||
 | 
					
 | 
				
			||||||
noinst_LIBRARIES = libaria2c.a
 | 
					noinst_LIBRARIES = libaria2c.a
 | 
				
			||||||
libaria2c_a_SOURCES = $(SRCS)
 | 
					libaria2c_a_SOURCES = $(SRCS)
 | 
				
			||||||
aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
 | 
					aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
 | 
				
			||||||
	@LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@ @LIBARES_LIBS@\
 | 
						@LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@ @LIBARES_LIBS@\
 | 
				
			||||||
	@LIBCARES_LIBS@ # -lprofiler
 | 
						@LIBCARES_LIBS@ @WINSOCK_LIBS@ # -lprofiler
 | 
				
			||||||
#aria2c_LDFLAGS =  #-pg
 | 
					#aria2c_LDFLAGS =  #-pg
 | 
				
			||||||
AM_CPPFLAGS =  -Wall\
 | 
					AM_CPPFLAGS =  -Wall\
 | 
				
			||||||
	-I../lib -I../intl -I$(top_srcdir)/intl\
 | 
						-I../lib -I../intl -I$(top_srcdir)/intl\
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,6 +37,7 @@ PRE_UNINSTALL = :
 | 
				
			||||||
POST_UNINSTALL = :
 | 
					POST_UNINSTALL = :
 | 
				
			||||||
build_triplet = @build@
 | 
					build_triplet = @build@
 | 
				
			||||||
host_triplet = @host@
 | 
					host_triplet = @host@
 | 
				
			||||||
 | 
					target_triplet = @target@
 | 
				
			||||||
bin_PROGRAMS = aria2c$(EXEEXT)
 | 
					bin_PROGRAMS = aria2c$(EXEEXT)
 | 
				
			||||||
#	debug_new.cpp
 | 
					#	debug_new.cpp
 | 
				
			||||||
@ENABLE_MESSAGE_DIGEST_TRUE@am__append_1 = ChunkChecksumValidator.cc ChunkChecksumValidator.h\
 | 
					@ENABLE_MESSAGE_DIGEST_TRUE@am__append_1 = ChunkChecksumValidator.cc ChunkChecksumValidator.h\
 | 
				
			||||||
| 
						 | 
					@ -158,6 +159,11 @@ bin_PROGRAMS = aria2c$(EXEEXT)
 | 
				
			||||||
@ENABLE_METALINK_TRUE@	Xml2MetalinkProcessor.cc Xml2MetalinkProcessor.h\
 | 
					@ENABLE_METALINK_TRUE@	Xml2MetalinkProcessor.cc Xml2MetalinkProcessor.h\
 | 
				
			||||||
@ENABLE_METALINK_TRUE@	MetalinkRequestInfo.cc MetalinkRequestInfo.h
 | 
					@ENABLE_METALINK_TRUE@	MetalinkRequestInfo.cc MetalinkRequestInfo.h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@HAVE_BASENAME_FALSE@am__append_4 = libgen.c libgen.h
 | 
				
			||||||
 | 
					@HAVE_GETADDRINFO_FALSE@am__append_5 = getaddrinfo.c getaddrinfo.h
 | 
				
			||||||
 | 
					@HAVE_INET_ATON_FALSE@am__append_6 = inet_aton.c inet_aton.h
 | 
				
			||||||
 | 
					@HAVE_LOCALTIME_R_FALSE@am__append_7 = localtime_r.c localtime_r.h
 | 
				
			||||||
 | 
					@HAVE_STRPTIME_FALSE@am__append_8 = strptime.c strptime.h
 | 
				
			||||||
subdir = src
 | 
					subdir = src
 | 
				
			||||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in alloca.c
 | 
					DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in alloca.c
 | 
				
			||||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 | 
					ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 | 
				
			||||||
| 
						 | 
					@ -243,8 +249,8 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
 | 
				
			||||||
	RequestGroupEntry.cc RequestGroupEntry.h Cookie.cc Cookie.h \
 | 
						RequestGroupEntry.cc RequestGroupEntry.h Cookie.cc Cookie.h \
 | 
				
			||||||
	CookieParser.cc CookieParser.h CookieBoxFactory.cc \
 | 
						CookieParser.cc CookieParser.h CookieBoxFactory.cc \
 | 
				
			||||||
	CookieBoxFactory.h HttpHeaderProcessor.cc \
 | 
						CookieBoxFactory.h HttpHeaderProcessor.cc \
 | 
				
			||||||
	HttpHeaderProcessor.h FileEntry.cc FileEntry.h \
 | 
						HttpHeaderProcessor.h FileEntry.cc FileEntry.h Platform.cc \
 | 
				
			||||||
	ChunkChecksumValidator.cc ChunkChecksumValidator.h \
 | 
						Platform.h ChunkChecksumValidator.cc ChunkChecksumValidator.h \
 | 
				
			||||||
	IteratableChunkChecksumValidator.cc \
 | 
						IteratableChunkChecksumValidator.cc \
 | 
				
			||||||
	IteratableChunkChecksumValidator.h \
 | 
						IteratableChunkChecksumValidator.h \
 | 
				
			||||||
	IteratableChecksumValidator.cc IteratableChecksumValidator.h \
 | 
						IteratableChecksumValidator.cc IteratableChecksumValidator.h \
 | 
				
			||||||
| 
						 | 
					@ -319,7 +325,9 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
 | 
				
			||||||
	Metalinker.cc Metalinker.h MetalinkEntry.cc MetalinkEntry.h \
 | 
						Metalinker.cc Metalinker.h MetalinkEntry.cc MetalinkEntry.h \
 | 
				
			||||||
	MetalinkResource.cc MetalinkResource.h MetalinkProcessor.h \
 | 
						MetalinkResource.cc MetalinkResource.h MetalinkProcessor.h \
 | 
				
			||||||
	Xml2MetalinkProcessor.cc Xml2MetalinkProcessor.h \
 | 
						Xml2MetalinkProcessor.cc Xml2MetalinkProcessor.h \
 | 
				
			||||||
	MetalinkRequestInfo.cc MetalinkRequestInfo.h
 | 
						MetalinkRequestInfo.cc MetalinkRequestInfo.h libgen.c libgen.h \
 | 
				
			||||||
 | 
						getaddrinfo.c getaddrinfo.h inet_aton.c inet_aton.h \
 | 
				
			||||||
 | 
						localtime_r.c localtime_r.h strptime.c strptime.h
 | 
				
			||||||
@ENABLE_MESSAGE_DIGEST_TRUE@am__objects_1 =  \
 | 
					@ENABLE_MESSAGE_DIGEST_TRUE@am__objects_1 =  \
 | 
				
			||||||
@ENABLE_MESSAGE_DIGEST_TRUE@	ChunkChecksumValidator.$(OBJEXT) \
 | 
					@ENABLE_MESSAGE_DIGEST_TRUE@	ChunkChecksumValidator.$(OBJEXT) \
 | 
				
			||||||
@ENABLE_MESSAGE_DIGEST_TRUE@	IteratableChunkChecksumValidator.$(OBJEXT) \
 | 
					@ENABLE_MESSAGE_DIGEST_TRUE@	IteratableChunkChecksumValidator.$(OBJEXT) \
 | 
				
			||||||
| 
						 | 
					@ -396,7 +404,12 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
 | 
				
			||||||
@ENABLE_METALINK_TRUE@	MetalinkResource.$(OBJEXT) \
 | 
					@ENABLE_METALINK_TRUE@	MetalinkResource.$(OBJEXT) \
 | 
				
			||||||
@ENABLE_METALINK_TRUE@	Xml2MetalinkProcessor.$(OBJEXT) \
 | 
					@ENABLE_METALINK_TRUE@	Xml2MetalinkProcessor.$(OBJEXT) \
 | 
				
			||||||
@ENABLE_METALINK_TRUE@	MetalinkRequestInfo.$(OBJEXT)
 | 
					@ENABLE_METALINK_TRUE@	MetalinkRequestInfo.$(OBJEXT)
 | 
				
			||||||
am__objects_4 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \
 | 
					@HAVE_BASENAME_FALSE@am__objects_4 = libgen.$(OBJEXT)
 | 
				
			||||||
 | 
					@HAVE_GETADDRINFO_FALSE@am__objects_5 = getaddrinfo.$(OBJEXT)
 | 
				
			||||||
 | 
					@HAVE_INET_ATON_FALSE@am__objects_6 = inet_aton.$(OBJEXT)
 | 
				
			||||||
 | 
					@HAVE_LOCALTIME_R_FALSE@am__objects_7 = localtime_r.$(OBJEXT)
 | 
				
			||||||
 | 
					@HAVE_STRPTIME_FALSE@am__objects_8 = strptime.$(OBJEXT)
 | 
				
			||||||
 | 
					am__objects_9 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \
 | 
				
			||||||
	AbstractCommand.$(OBJEXT) \
 | 
						AbstractCommand.$(OBJEXT) \
 | 
				
			||||||
	InitiateConnectionCommandFactory.$(OBJEXT) \
 | 
						InitiateConnectionCommandFactory.$(OBJEXT) \
 | 
				
			||||||
	DownloadCommand.$(OBJEXT) \
 | 
						DownloadCommand.$(OBJEXT) \
 | 
				
			||||||
| 
						 | 
					@ -436,9 +449,11 @@ am__objects_4 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \
 | 
				
			||||||
	RealtimeCommand.$(OBJEXT) RequestGroupEntry.$(OBJEXT) \
 | 
						RealtimeCommand.$(OBJEXT) RequestGroupEntry.$(OBJEXT) \
 | 
				
			||||||
	Cookie.$(OBJEXT) CookieParser.$(OBJEXT) \
 | 
						Cookie.$(OBJEXT) CookieParser.$(OBJEXT) \
 | 
				
			||||||
	CookieBoxFactory.$(OBJEXT) HttpHeaderProcessor.$(OBJEXT) \
 | 
						CookieBoxFactory.$(OBJEXT) HttpHeaderProcessor.$(OBJEXT) \
 | 
				
			||||||
	FileEntry.$(OBJEXT) $(am__objects_1) $(am__objects_2) \
 | 
						FileEntry.$(OBJEXT) Platform.$(OBJEXT) $(am__objects_1) \
 | 
				
			||||||
	$(am__objects_3)
 | 
						$(am__objects_2) $(am__objects_3) $(am__objects_4) \
 | 
				
			||||||
am_libaria2c_a_OBJECTS = $(am__objects_4)
 | 
						$(am__objects_5) $(am__objects_6) $(am__objects_7) \
 | 
				
			||||||
 | 
						$(am__objects_8)
 | 
				
			||||||
 | 
					am_libaria2c_a_OBJECTS = $(am__objects_9)
 | 
				
			||||||
libaria2c_a_OBJECTS = $(am_libaria2c_a_OBJECTS)
 | 
					libaria2c_a_OBJECTS = $(am_libaria2c_a_OBJECTS)
 | 
				
			||||||
am__installdirs = "$(DESTDIR)$(bindir)"
 | 
					am__installdirs = "$(DESTDIR)$(bindir)"
 | 
				
			||||||
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 | 
					binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 | 
				
			||||||
| 
						 | 
					@ -449,15 +464,15 @@ aria2c_DEPENDENCIES = libaria2c.a @ALLOCA@
 | 
				
			||||||
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
 | 
					DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
 | 
				
			||||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
 | 
					depcomp = $(SHELL) $(top_srcdir)/depcomp
 | 
				
			||||||
am__depfiles_maybe = depfiles
 | 
					am__depfiles_maybe = depfiles
 | 
				
			||||||
 | 
					COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 | 
				
			||||||
 | 
						$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 | 
				
			||||||
 | 
					CCLD = $(CC)
 | 
				
			||||||
 | 
					LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 | 
				
			||||||
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
 | 
					CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
 | 
				
			||||||
	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
 | 
						$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
 | 
				
			||||||
CXXLD = $(CXX)
 | 
					CXXLD = $(CXX)
 | 
				
			||||||
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
 | 
					CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
 | 
				
			||||||
	-o $@
 | 
						-o $@
 | 
				
			||||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 | 
					 | 
				
			||||||
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 | 
					 | 
				
			||||||
CCLD = $(CC)
 | 
					 | 
				
			||||||
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 | 
					 | 
				
			||||||
SOURCES = $(libaria2c_a_SOURCES) $(aria2c_SOURCES)
 | 
					SOURCES = $(libaria2c_a_SOURCES) $(aria2c_SOURCES)
 | 
				
			||||||
DIST_SOURCES = $(am__libaria2c_a_SOURCES_DIST) $(aria2c_SOURCES)
 | 
					DIST_SOURCES = $(am__libaria2c_a_SOURCES_DIST) $(aria2c_SOURCES)
 | 
				
			||||||
ETAGS = etags
 | 
					ETAGS = etags
 | 
				
			||||||
| 
						 | 
					@ -506,6 +521,16 @@ GENCAT = @GENCAT@
 | 
				
			||||||
GLIBC21 = @GLIBC21@
 | 
					GLIBC21 = @GLIBC21@
 | 
				
			||||||
GMSGFMT = @GMSGFMT@
 | 
					GMSGFMT = @GMSGFMT@
 | 
				
			||||||
GREP = @GREP@
 | 
					GREP = @GREP@
 | 
				
			||||||
 | 
					HAVE_BASENAME_FALSE = @HAVE_BASENAME_FALSE@
 | 
				
			||||||
 | 
					HAVE_BASENAME_TRUE = @HAVE_BASENAME_TRUE@
 | 
				
			||||||
 | 
					HAVE_GETADDRINFO_FALSE = @HAVE_GETADDRINFO_FALSE@
 | 
				
			||||||
 | 
					HAVE_GETADDRINFO_TRUE = @HAVE_GETADDRINFO_TRUE@
 | 
				
			||||||
 | 
					HAVE_INET_ATON_FALSE = @HAVE_INET_ATON_FALSE@
 | 
				
			||||||
 | 
					HAVE_INET_ATON_TRUE = @HAVE_INET_ATON_TRUE@
 | 
				
			||||||
 | 
					HAVE_LOCALTIME_R_FALSE = @HAVE_LOCALTIME_R_FALSE@
 | 
				
			||||||
 | 
					HAVE_LOCALTIME_R_TRUE = @HAVE_LOCALTIME_R_TRUE@
 | 
				
			||||||
 | 
					HAVE_STRPTIME_FALSE = @HAVE_STRPTIME_FALSE@
 | 
				
			||||||
 | 
					HAVE_STRPTIME_TRUE = @HAVE_STRPTIME_TRUE@
 | 
				
			||||||
INSTALL_DATA = @INSTALL_DATA@
 | 
					INSTALL_DATA = @INSTALL_DATA@
 | 
				
			||||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
 | 
					INSTALL_PROGRAM = @INSTALL_PROGRAM@
 | 
				
			||||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
 | 
					INSTALL_SCRIPT = @INSTALL_SCRIPT@
 | 
				
			||||||
| 
						 | 
					@ -555,6 +580,7 @@ STRIP = @STRIP@
 | 
				
			||||||
USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
 | 
					USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
 | 
				
			||||||
USE_NLS = @USE_NLS@
 | 
					USE_NLS = @USE_NLS@
 | 
				
			||||||
VERSION = @VERSION@
 | 
					VERSION = @VERSION@
 | 
				
			||||||
 | 
					WINSOCK_LIBS = @WINSOCK_LIBS@
 | 
				
			||||||
XGETTEXT = @XGETTEXT@
 | 
					XGETTEXT = @XGETTEXT@
 | 
				
			||||||
XML2_CONFIG = @XML2_CONFIG@
 | 
					XML2_CONFIG = @XML2_CONFIG@
 | 
				
			||||||
XML_CPPFLAGS = @XML_CPPFLAGS@
 | 
					XML_CPPFLAGS = @XML_CPPFLAGS@
 | 
				
			||||||
| 
						 | 
					@ -606,7 +632,11 @@ psdir = @psdir@
 | 
				
			||||||
sbindir = @sbindir@
 | 
					sbindir = @sbindir@
 | 
				
			||||||
sharedstatedir = @sharedstatedir@
 | 
					sharedstatedir = @sharedstatedir@
 | 
				
			||||||
sysconfdir = @sysconfdir@
 | 
					sysconfdir = @sysconfdir@
 | 
				
			||||||
 | 
					target = @target@
 | 
				
			||||||
target_alias = @target_alias@
 | 
					target_alias = @target_alias@
 | 
				
			||||||
 | 
					target_cpu = @target_cpu@
 | 
				
			||||||
 | 
					target_os = @target_os@
 | 
				
			||||||
 | 
					target_vendor = @target_vendor@
 | 
				
			||||||
aria2c_SOURCES = main.cc
 | 
					aria2c_SOURCES = main.cc
 | 
				
			||||||
SRCS = Socket.h SocketCore.cc SocketCore.h Command.cc Command.h \
 | 
					SRCS = Socket.h SocketCore.cc SocketCore.h Command.cc Command.h \
 | 
				
			||||||
	AbstractCommand.cc AbstractCommand.h \
 | 
						AbstractCommand.cc AbstractCommand.h \
 | 
				
			||||||
| 
						 | 
					@ -668,13 +698,15 @@ SRCS = Socket.h SocketCore.cc SocketCore.h Command.cc Command.h \
 | 
				
			||||||
	RequestGroupEntry.cc RequestGroupEntry.h Cookie.cc Cookie.h \
 | 
						RequestGroupEntry.cc RequestGroupEntry.h Cookie.cc Cookie.h \
 | 
				
			||||||
	CookieParser.cc CookieParser.h CookieBoxFactory.cc \
 | 
						CookieParser.cc CookieParser.h CookieBoxFactory.cc \
 | 
				
			||||||
	CookieBoxFactory.h HttpHeaderProcessor.cc \
 | 
						CookieBoxFactory.h HttpHeaderProcessor.cc \
 | 
				
			||||||
	HttpHeaderProcessor.h FileEntry.cc FileEntry.h $(am__append_1) \
 | 
						HttpHeaderProcessor.h FileEntry.cc FileEntry.h Platform.cc \
 | 
				
			||||||
	$(am__append_2) $(am__append_3)
 | 
						Platform.h $(am__append_1) $(am__append_2) $(am__append_3) \
 | 
				
			||||||
 | 
						$(am__append_4) $(am__append_5) $(am__append_6) \
 | 
				
			||||||
 | 
						$(am__append_7) $(am__append_8)
 | 
				
			||||||
noinst_LIBRARIES = libaria2c.a
 | 
					noinst_LIBRARIES = libaria2c.a
 | 
				
			||||||
libaria2c_a_SOURCES = $(SRCS)
 | 
					libaria2c_a_SOURCES = $(SRCS)
 | 
				
			||||||
aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
 | 
					aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
 | 
				
			||||||
	@LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@ @LIBARES_LIBS@\
 | 
						@LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@ @LIBARES_LIBS@\
 | 
				
			||||||
	@LIBCARES_LIBS@ # -lprofiler
 | 
						@LIBCARES_LIBS@ @WINSOCK_LIBS@ # -lprofiler
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#aria2c_LDFLAGS =  #-pg
 | 
					#aria2c_LDFLAGS =  #-pg
 | 
				
			||||||
AM_CPPFLAGS = -Wall\
 | 
					AM_CPPFLAGS = -Wall\
 | 
				
			||||||
| 
						 | 
					@ -686,7 +718,7 @@ AM_CPPFLAGS = -Wall\
 | 
				
			||||||
all: all-am
 | 
					all: all-am
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.SUFFIXES:
 | 
					.SUFFIXES:
 | 
				
			||||||
.SUFFIXES: .cc .o .obj
 | 
					.SUFFIXES: .c .cc .o .obj
 | 
				
			||||||
$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 | 
					$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 | 
				
			||||||
	@for dep in $?; do \
 | 
						@for dep in $?; do \
 | 
				
			||||||
	  case '$(am__configure_deps)' in \
 | 
						  case '$(am__configure_deps)' in \
 | 
				
			||||||
| 
						 | 
					@ -880,6 +912,7 @@ distclean-compile:
 | 
				
			||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerListenCommand.Po@am__quote@
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerListenCommand.Po@am__quote@
 | 
				
			||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerMessageUtil.Po@am__quote@
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerMessageUtil.Po@am__quote@
 | 
				
			||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Piece.Po@am__quote@
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Piece.Po@am__quote@
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Platform.Po@am__quote@
 | 
				
			||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RealtimeCommand.Po@am__quote@
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RealtimeCommand.Po@am__quote@
 | 
				
			||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Request.Po@am__quote@
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Request.Po@am__quote@
 | 
				
			||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestFactory.Po@am__quote@
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestFactory.Po@am__quote@
 | 
				
			||||||
| 
						 | 
					@ -908,7 +941,26 @@ distclean-compile:
 | 
				
			||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UriListParser.Po@am__quote@
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UriListParser.Po@am__quote@
 | 
				
			||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Util.Po@am__quote@
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Util.Po@am__quote@
 | 
				
			||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Xml2MetalinkProcessor.Po@am__quote@
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Xml2MetalinkProcessor.Po@am__quote@
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getaddrinfo.Po@am__quote@
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inet_aton.Po@am__quote@
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgen.Po@am__quote@
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localtime_r.Po@am__quote@
 | 
				
			||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strptime.Po@am__quote@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.c.o:
 | 
				
			||||||
 | 
					@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
 | 
				
			||||||
 | 
					@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 | 
				
			||||||
 | 
					@am__fastdepCC_FALSE@	$(COMPILE) -c $<
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.c.obj:
 | 
				
			||||||
 | 
					@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
 | 
				
			||||||
 | 
					@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 | 
				
			||||||
 | 
					@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.cc.o:
 | 
					.cc.o:
 | 
				
			||||||
@am__fastdepCXX_TRUE@	if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
 | 
					@am__fastdepCXX_TRUE@	if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,18 +36,21 @@
 | 
				
			||||||
#include "File.h"
 | 
					#include "File.h"
 | 
				
			||||||
#include "DlAbortEx.h"
 | 
					#include "DlAbortEx.h"
 | 
				
			||||||
#include "message.h"
 | 
					#include "message.h"
 | 
				
			||||||
 | 
					#include "a2io.h"
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
MetaEntry* MetaFileUtil::parseMetaFile(const string& file) {
 | 
					MetaEntry* MetaFileUtil::parseMetaFile(const string& file) {
 | 
				
			||||||
  File f(file);
 | 
					  File f(file);
 | 
				
			||||||
  int32_t len = f.size();
 | 
					  int32_t len = f.size();
 | 
				
			||||||
  char* buf = new char[len];
 | 
					  char* buf = new char[len];
 | 
				
			||||||
  FILE* fp = fopen(file.c_str(), "r+");
 | 
					  FILE* fp = fopen(file.c_str(), "r+b");
 | 
				
			||||||
  try {
 | 
					  try {
 | 
				
			||||||
    if(fp == NULL) {
 | 
					    if(fp == NULL) {
 | 
				
			||||||
      throw new DlAbortEx("cannot open metainfo file");
 | 
					      throw new DlAbortEx("cannot open metainfo file");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					#ifdef HAVE_SETMODE
 | 
				
			||||||
 | 
					    setmode(fileno(fp), O_BINARY);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
    if(fread(buf, len, 1, fp) != 1) {
 | 
					    if(fread(buf, len, 1, fp) != 1) {
 | 
				
			||||||
      fclose(fp);
 | 
					      fclose(fp);
 | 
				
			||||||
      throw new DlAbortEx("cannot read metainfo");
 | 
					      throw new DlAbortEx("cannot read metainfo");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -121,7 +121,7 @@ void MultiDiskAdaptor::writeData(const unsigned char* data, int32_t len,
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if(!writing) {
 | 
					  if(!writing) {
 | 
				
			||||||
    throw new DlAbortEx(EX_FILE_OFFSET_OUT_OF_RANGE, offset);
 | 
					    throw new DlAbortEx(EX_FILE_OFFSET_OUT_OF_RANGE, Util::llitos(offset, true).c_str());
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -164,7 +164,7 @@ int32_t MultiDiskAdaptor::readData(unsigned char* data, int32_t len, int64_t off
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if(!reading) {
 | 
					  if(!reading) {
 | 
				
			||||||
    throw new DlAbortEx(EX_FILE_OFFSET_OUT_OF_RANGE, offset);
 | 
					    throw new DlAbortEx(EX_FILE_OFFSET_OUT_OF_RANGE, Util::llitos(offset, true).c_str());
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return totalReadLength;
 | 
					  return totalReadLength;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -212,7 +212,7 @@ string MultiDiskAdaptor::messageDigest(int64_t offset, int64_t length,
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if(!reading) {
 | 
					  if(!reading) {
 | 
				
			||||||
    throw new DlAbortEx(EX_FILE_OFFSET_OUT_OF_RANGE, offset);
 | 
					    throw new DlAbortEx(EX_FILE_OFFSET_OUT_OF_RANGE, Util::llitos(offset, true).c_str());
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  unsigned char hashValue[20];
 | 
					  unsigned char hashValue[20];
 | 
				
			||||||
  ctx.digestFinal(hashValue);
 | 
					  ctx.digestFinal(hashValue);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,10 +36,7 @@
 | 
				
			||||||
#define _D_NAME_RESOLVER_H_
 | 
					#define _D_NAME_RESOLVER_H_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "common.h"
 | 
					#include "common.h"
 | 
				
			||||||
#include <netdb.h>
 | 
					#include "a2netcompat.h"
 | 
				
			||||||
#include <sys/socket.h>
 | 
					 | 
				
			||||||
#include <netinet/in.h>
 | 
					 | 
				
			||||||
#include <arpa/inet.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef ENABLE_ASYNC_DNS
 | 
					#ifdef ENABLE_ASYNC_DNS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,7 +40,6 @@
 | 
				
			||||||
#include "Util.h"
 | 
					#include "Util.h"
 | 
				
			||||||
#include "FatalException.h"
 | 
					#include "FatalException.h"
 | 
				
			||||||
#include "prefs.h"
 | 
					#include "prefs.h"
 | 
				
			||||||
#include <netinet/in.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class NullOptionHandler : public OptionHandler {
 | 
					class NullOptionHandler : public OptionHandler {
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
| 
						 | 
					@ -91,14 +90,14 @@ public:
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      string msg = _optName+" ";
 | 
					      string msg = _optName+" ";
 | 
				
			||||||
      if(_min == -1 && _max != -1) {
 | 
					      if(_min == -1 && _max != -1) {
 | 
				
			||||||
	msg += _("must be smaller than or equal to %lld.");
 | 
						msg += _("must be smaller than or equal to %s.");
 | 
				
			||||||
	throw new FatalException(msg.c_str(), _max);
 | 
						throw new FatalException(msg.c_str(), Util::llitos(_max).c_str());
 | 
				
			||||||
      } else if(_min != -1 && _max != -1) {
 | 
					      } else if(_min != -1 && _max != -1) {
 | 
				
			||||||
	msg += _("must be between %lld and %lld.");
 | 
						msg += _("must be between %s and %s.");
 | 
				
			||||||
	throw new FatalException(msg.c_str(), _min, _max);
 | 
						throw new FatalException(msg.c_str(), Util::llitos(_min).c_str(), Util::llitos(_max).c_str());
 | 
				
			||||||
      } else if(_min != -1 && _max == -1) {
 | 
					      } else if(_min != -1 && _max == -1) {
 | 
				
			||||||
	msg += _("must be greater than or equal to %lld.");
 | 
						msg += _("must be greater than or equal to %s.");
 | 
				
			||||||
	throw new FatalException(msg.c_str(), _min);
 | 
						throw new FatalException(msg.c_str(), Util::llitos(_min).c_str());
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
	msg += _("must be a number.");
 | 
						msg += _("must be a number.");
 | 
				
			||||||
	throw new FatalException(msg.c_str());
 | 
						throw new FatalException(msg.c_str());
 | 
				
			||||||
| 
						 | 
					@ -218,9 +217,9 @@ public:
 | 
				
			||||||
  virtual void parseArg(Option* option, const string& optarg)
 | 
					  virtual void parseArg(Option* option, const string& optarg)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    pair<string, string> proxy = Util::split(optarg, ":");
 | 
					    pair<string, string> proxy = Util::split(optarg, ":");
 | 
				
			||||||
    in_port_t port = strtol(proxy.second.c_str(), 0, 10);
 | 
					    int32_t port = strtol(proxy.second.c_str(), 0, 10);
 | 
				
			||||||
    if(proxy.first.empty() || proxy.second.empty() ||
 | 
					    if(proxy.first.empty() || proxy.second.empty() ||
 | 
				
			||||||
       port <= 0) {
 | 
					       port <= 0 || 65535 < port) {
 | 
				
			||||||
      throw new FatalException(_("unrecognized proxy format"));
 | 
					      throw new FatalException(_("unrecognized proxy format"));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    option->put(PREF_HTTP_PROXY, optarg);
 | 
					    option->put(PREF_HTTP_PROXY, optarg);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,7 +39,7 @@
 | 
				
			||||||
#include "Util.h"
 | 
					#include "Util.h"
 | 
				
			||||||
#include "LogFactory.h"
 | 
					#include "LogFactory.h"
 | 
				
			||||||
#include "BtHandshakeMessage.h"
 | 
					#include "BtHandshakeMessage.h"
 | 
				
			||||||
#include <netinet/in.h>
 | 
					#include "a2netcompat.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PeerConnection::PeerConnection(int32_t cuid,
 | 
					PeerConnection::PeerConnection(int32_t cuid,
 | 
				
			||||||
			       const SocketHandle& socket,
 | 
								       const SocketHandle& socket,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,7 +35,7 @@
 | 
				
			||||||
#include "PeerMessageUtil.h"
 | 
					#include "PeerMessageUtil.h"
 | 
				
			||||||
#include "DlAbortEx.h"
 | 
					#include "DlAbortEx.h"
 | 
				
			||||||
#include "Util.h"
 | 
					#include "Util.h"
 | 
				
			||||||
#include <netinet/in.h>
 | 
					#include "a2netcompat.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int8_t PeerMessageUtil::getId(const unsigned char* msg) {
 | 
					int8_t PeerMessageUtil::getId(const unsigned char* msg) {
 | 
				
			||||||
  return msg[0];
 | 
					  return msg[0];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,63 @@
 | 
				
			||||||
 | 
					/* <!-- copyright */
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * aria2 - The high speed download utility
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Copyright (C) 2006 Tatsuhiro Tsujikawa
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is free software; you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation; either version 2 of the License, or
 | 
				
			||||||
 | 
					 * (at your option) any later version.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program; if not, write to the Free Software
 | 
				
			||||||
 | 
					 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * In addition, as a special exception, the copyright holders give
 | 
				
			||||||
 | 
					 * permission to link the code of portions of this program with the
 | 
				
			||||||
 | 
					 * OpenSSL library under certain conditions as described in each
 | 
				
			||||||
 | 
					 * individual source file, and distribute linked combinations
 | 
				
			||||||
 | 
					 * including the two.
 | 
				
			||||||
 | 
					 * You must obey the GNU General Public License in all respects
 | 
				
			||||||
 | 
					 * for all of the code used other than OpenSSL.  If you modify
 | 
				
			||||||
 | 
					 * file(s) with this exception, you may extend this exception to your
 | 
				
			||||||
 | 
					 * version of the file(s), but you are not obligated to do so.  If you
 | 
				
			||||||
 | 
					 * do not wish to do so, delete this exception statement from your
 | 
				
			||||||
 | 
					 * version.  If you delete this exception statement from all source
 | 
				
			||||||
 | 
					 * files in the program, then also delete it here.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					/* copyright --> */
 | 
				
			||||||
 | 
					#ifdef HAVE_CONFIG_H
 | 
				
			||||||
 | 
					# include "config.h"
 | 
				
			||||||
 | 
					#endif // HAVE_CONFIG_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef HAVE_WINSOCK2_H
 | 
				
			||||||
 | 
					# ifndef _WIN32_WINNT
 | 
				
			||||||
 | 
					#  define _WIN32_WINNT 0x501
 | 
				
			||||||
 | 
					# endif // _WIN32_WINNT
 | 
				
			||||||
 | 
					# include <winsock2.h>
 | 
				
			||||||
 | 
					#endif // HAVE_WINSOCK2_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "Platform.h"
 | 
				
			||||||
 | 
					#include "DlAbortEx.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Platform::Platform() {
 | 
				
			||||||
 | 
					#ifdef HAVE_WINSOCK2_H
 | 
				
			||||||
 | 
					  WSADATA wsaData;
 | 
				
			||||||
 | 
					  memset((char*)&wsaData, 0, sizeof(wsaData));
 | 
				
			||||||
 | 
					  if (WSAStartup(MAKEWORD(1, 1), &wsaData)) {
 | 
				
			||||||
 | 
					    throw new DlAbortEx(_("Windows socket library initialization failed"));
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					#endif // HAVE_WINSOCK2_H
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Platform::~Platform() {
 | 
				
			||||||
 | 
					#ifdef HAVE_WINSOCK2_H
 | 
				
			||||||
 | 
					  WSACleanup();
 | 
				
			||||||
 | 
					#endif // HAVE_WINSOCK2_H
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,45 @@
 | 
				
			||||||
 | 
					/* <!-- copyright */
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * aria2 - The high speed download utility
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Copyright (C) 2006 Tatsuhiro Tsujikawa
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is free software; you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation; either version 2 of the License, or
 | 
				
			||||||
 | 
					 * (at your option) any later version.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program; if not, write to the Free Software
 | 
				
			||||||
 | 
					 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * In addition, as a special exception, the copyright holders give
 | 
				
			||||||
 | 
					 * permission to link the code of portions of this program with the
 | 
				
			||||||
 | 
					 * OpenSSL library under certain conditions as described in each
 | 
				
			||||||
 | 
					 * individual source file, and distribute linked combinations
 | 
				
			||||||
 | 
					 * including the two.
 | 
				
			||||||
 | 
					 * You must obey the GNU General Public License in all respects
 | 
				
			||||||
 | 
					 * for all of the code used other than OpenSSL.  If you modify
 | 
				
			||||||
 | 
					 * file(s) with this exception, you may extend this exception to your
 | 
				
			||||||
 | 
					 * version of the file(s), but you are not obligated to do so.  If you
 | 
				
			||||||
 | 
					 * do not wish to do so, delete this exception statement from your
 | 
				
			||||||
 | 
					 * version.  If you delete this exception statement from all source
 | 
				
			||||||
 | 
					 * files in the program, then also delete it here.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					/* copyright --> */
 | 
				
			||||||
 | 
					#ifndef _D_PLATFORM_H_
 | 
				
			||||||
 | 
					#define _D_PLATFORM_H_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Platform {
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  Platform();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ~Platform();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _D_PLATFORM_H_
 | 
				
			||||||
| 
						 | 
					@ -44,6 +44,11 @@ public:
 | 
				
			||||||
  virtual long int getRandomNumber() = 0;
 | 
					  virtual long int getRandomNumber() = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  virtual long int getMaxRandomNumber() = 0;
 | 
					  virtual long int getMaxRandomNumber() = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Returns random number in [0, to).
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  virtual long int getRandomNumber(long int to) = 0;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef SharedHandle<Randomizer> RandomizerHandle;
 | 
					typedef SharedHandle<Randomizer> RandomizerHandle;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -269,8 +269,8 @@ void RequestGroup::validateTotalLength(int64_t expectedTotalLength,
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if(expectedTotalLength != actualTotalLength) {
 | 
					  if(expectedTotalLength != actualTotalLength) {
 | 
				
			||||||
    throw new DlAbortEx(EX_SIZE_MISMATCH,
 | 
					    throw new DlAbortEx(EX_SIZE_MISMATCH,
 | 
				
			||||||
			expectedTotalLength,
 | 
								Util::llitos(expectedTotalLength, true).c_str(),
 | 
				
			||||||
			actualTotalLength);
 | 
								Util::llitos(actualTotalLength, true).c_str());
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -43,9 +43,7 @@
 | 
				
			||||||
#ifdef ENABLE_MESSAGE_DIGEST
 | 
					#ifdef ENABLE_MESSAGE_DIGEST
 | 
				
			||||||
#include "ChunkChecksumValidator.h"
 | 
					#include "ChunkChecksumValidator.h"
 | 
				
			||||||
#endif // ENABLE_MESSAGE_DIGEST
 | 
					#endif // ENABLE_MESSAGE_DIGEST
 | 
				
			||||||
#include <sys/types.h>
 | 
					#include "a2io.h"
 | 
				
			||||||
#include <sys/stat.h>
 | 
					 | 
				
			||||||
#include <unistd.h>
 | 
					 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SegmentMan::SegmentMan():logger(LogFactory::getInstance()),
 | 
					SegmentMan::SegmentMan():logger(LogFactory::getInstance()),
 | 
				
			||||||
| 
						 | 
					@ -88,7 +86,7 @@ void SegmentMan::load() {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  string segFilename = getSegmentFilePath();
 | 
					  string segFilename = getSegmentFilePath();
 | 
				
			||||||
  logger->info(MSG_LOADING_SEGMENT_FILE, segFilename.c_str());
 | 
					  logger->info(MSG_LOADING_SEGMENT_FILE, segFilename.c_str());
 | 
				
			||||||
  FILE* segFile = openSegFile(segFilename, "r+");
 | 
					  FILE* segFile = openSegFile(segFilename, "r+b");
 | 
				
			||||||
  try {
 | 
					  try {
 | 
				
			||||||
    read(segFile);
 | 
					    read(segFile);
 | 
				
			||||||
    fclose(segFile);
 | 
					    fclose(segFile);
 | 
				
			||||||
| 
						 | 
					@ -106,7 +104,7 @@ void SegmentMan::save() const {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  string segFilename = getSegmentFilePath();
 | 
					  string segFilename = getSegmentFilePath();
 | 
				
			||||||
  logger->info(MSG_SAVING_SEGMENT_FILE, segFilename.c_str());
 | 
					  logger->info(MSG_SAVING_SEGMENT_FILE, segFilename.c_str());
 | 
				
			||||||
  FILE* segFile = openSegFile(segFilename, "w");
 | 
					  FILE* segFile = openSegFile(segFilename, "wb");
 | 
				
			||||||
  try {
 | 
					  try {
 | 
				
			||||||
    if(fwrite(&totalSize, sizeof(totalSize), 1, segFile) < 1) {
 | 
					    if(fwrite(&totalSize, sizeof(totalSize), 1, segFile) < 1) {
 | 
				
			||||||
      throw string("writeError");
 | 
					      throw string("writeError");
 | 
				
			||||||
| 
						 | 
					@ -155,6 +153,9 @@ FILE* SegmentMan::openSegFile(const string& segFilename, const string& mode) con
 | 
				
			||||||
    throw new DlAbortEx(EX_SEGMENT_FILE_OPEN,
 | 
					    throw new DlAbortEx(EX_SEGMENT_FILE_OPEN,
 | 
				
			||||||
			segFilename.c_str(), strerror(errno));
 | 
								segFilename.c_str(), strerror(errno));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					#ifdef HAVE_SETMODE
 | 
				
			||||||
 | 
					  setmode(fileno(segFile), O_BINARY);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
  return segFile;
 | 
					  return segFile;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -537,7 +538,7 @@ void SegmentMan::tryChunkChecksumValidation(const SegmentHandle& segment)
 | 
				
			||||||
	logger->info(MSG_GOOD_CHUNK_CHECKSUM);
 | 
						logger->info(MSG_GOOD_CHUNK_CHECKSUM);
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
	logger->info(EX_INVALID_CHUNK_CHECKSUM,
 | 
						logger->info(EX_INVALID_CHUNK_CHECKSUM,
 | 
				
			||||||
		     index, offset,
 | 
							     index, Util::llitos(offset, true).c_str(),
 | 
				
			||||||
		     expectedChecksum.c_str(), actualChecksum.c_str());
 | 
							     expectedChecksum.c_str(), actualChecksum.c_str());
 | 
				
			||||||
	logger->debug("Unset bit from %d to %d(inclusive)", startIndex, endIndex);
 | 
						logger->debug("Unset bit from %d to %d(inclusive)", startIndex, endIndex);
 | 
				
			||||||
	bitfield->unsetBitRange(startIndex, endIndex);
 | 
						bitfield->unsetBitRange(startIndex, endIndex);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,11 +36,15 @@
 | 
				
			||||||
#include "Util.h"
 | 
					#include "Util.h"
 | 
				
			||||||
#include "DlAbortEx.h"
 | 
					#include "DlAbortEx.h"
 | 
				
			||||||
#include "message.h"
 | 
					#include "message.h"
 | 
				
			||||||
 | 
					#include "a2io.h"
 | 
				
			||||||
#include <time.h>
 | 
					#include <time.h>
 | 
				
			||||||
#include <stdarg.h>
 | 
					#include <stdarg.h>
 | 
				
			||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef HAVE_LOCALTIME_R
 | 
				
			||||||
 | 
					# include "localtime_r.h"
 | 
				
			||||||
 | 
					#endif // HAVE_LOCALTIME_R
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define WRITE_LOG(LEVEL, MSG) \
 | 
					#define WRITE_LOG(LEVEL, MSG) \
 | 
				
			||||||
va_list ap;\
 | 
					va_list ap;\
 | 
				
			||||||
va_start(ap, MSG);\
 | 
					va_start(ap, MSG);\
 | 
				
			||||||
| 
						 | 
					@ -60,10 +64,13 @@ SimpleLogger::~SimpleLogger() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void SimpleLogger::openFile(const string& filename) {
 | 
					void SimpleLogger::openFile(const string& filename) {
 | 
				
			||||||
  file = fopen(filename.c_str(), "a");
 | 
					  file = fopen(filename.c_str(), "ab");
 | 
				
			||||||
  if(file == NULL) {
 | 
					  if(file == NULL) {
 | 
				
			||||||
    throw new DlAbortEx(EX_FILE_OPEN, filename.c_str(), strerror(errno));
 | 
					    throw new DlAbortEx(EX_FILE_OPEN, filename.c_str(), strerror(errno));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					#ifdef HAVE_SETMODE
 | 
				
			||||||
 | 
					  setmode(fileno(file), O_BINARY);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void SimpleLogger::closeFile() {
 | 
					void SimpleLogger::closeFile() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,18 +54,31 @@ public:
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  static void init() {
 | 
					  static void init() {
 | 
				
			||||||
 | 
					#ifdef HAVE_SRANDOM
 | 
				
			||||||
    srandom(time(0));
 | 
					    srandom(time(0));
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					    srand(time(0));
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  virtual ~SimpleRandomizer() {}
 | 
					  virtual ~SimpleRandomizer() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  virtual long int getRandomNumber() {
 | 
					  virtual long int getRandomNumber() {
 | 
				
			||||||
 | 
					#ifdef HAVE_RANDOM
 | 
				
			||||||
    return random();
 | 
					    return random();
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					    return rand();
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  virtual long int getMaxRandomNumber() {
 | 
					  virtual long int getMaxRandomNumber() {
 | 
				
			||||||
      return RAND_MAX;
 | 
					      return RAND_MAX;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  virtual long int getRandomNumber(long int to)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    return(int32_t)(((double)to)*getRandomNumber()/(getMaxRandomNumber()+1.0));
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // _D_SIMPLE_RANDOMIZER_H_
 | 
					#endif // _D_SIMPLE_RANDOMIZER_H_
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,17 +36,38 @@
 | 
				
			||||||
#include "DlRetryEx.h"
 | 
					#include "DlRetryEx.h"
 | 
				
			||||||
#include "DlAbortEx.h"
 | 
					#include "DlAbortEx.h"
 | 
				
			||||||
#include "message.h"
 | 
					#include "message.h"
 | 
				
			||||||
 | 
					#include "a2io.h"
 | 
				
			||||||
 | 
					#include "a2netcompat.h"
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
#include <fcntl.h>
 | 
					#include <fcntl.h>
 | 
				
			||||||
#include <netdb.h>
 | 
					 | 
				
			||||||
#include <sys/types.h>
 | 
					 | 
				
			||||||
#include <sys/socket.h>
 | 
					 | 
				
			||||||
#include <netinet/in.h>
 | 
					 | 
				
			||||||
#include <arpa/inet.h>
 | 
					 | 
				
			||||||
#include <sys/time.h>
 | 
					#include <sys/time.h>
 | 
				
			||||||
#include <netdb.h>
 | 
					 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __MINGW32__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static char *mingw_strerror(int err) {
 | 
				
			||||||
 | 
						err = WSAGetLastError();
 | 
				
			||||||
 | 
						static char buf[2048];
 | 
				
			||||||
 | 
						if (FormatMessage(
 | 
				
			||||||
 | 
							FORMAT_MESSAGE_FROM_SYSTEM |
 | 
				
			||||||
 | 
							FORMAT_MESSAGE_IGNORE_INSERTS,
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							err,
 | 
				
			||||||
 | 
							MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
 | 
				
			||||||
 | 
							(LPTSTR) &buf,
 | 
				
			||||||
 | 
							sizeof(buf),
 | 
				
			||||||
 | 
							NULL
 | 
				
			||||||
 | 
						) == 0) {
 | 
				
			||||||
 | 
							snprintf(buf, sizeof(buf), _("Unknown socket error %d"), err);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return buf;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define strerror mingw_strerror
 | 
				
			||||||
 | 
					#define gai_strerror mingw_strerror
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // __MINGW32__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SocketCore::SocketCore():sockfd(-1) {
 | 
					SocketCore::SocketCore():sockfd(-1) {
 | 
				
			||||||
  init();
 | 
					  init();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -86,7 +107,7 @@ void SocketCore::beginListen(int32_t port) {
 | 
				
			||||||
  if(sockfd == -1) {
 | 
					  if(sockfd == -1) {
 | 
				
			||||||
    throw new DlAbortEx(EX_SOCKET_OPEN, strerror(errno));
 | 
					    throw new DlAbortEx(EX_SOCKET_OPEN, strerror(errno));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  socklen_t sockopt = 1;
 | 
					  SOCKOPT_T sockopt = 1;
 | 
				
			||||||
  if(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof(socklen_t)) < 0) {
 | 
					  if(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof(socklen_t)) < 0) {
 | 
				
			||||||
    close(sockfd);
 | 
					    close(sockfd);
 | 
				
			||||||
    sockfd = -1;
 | 
					    sockfd = -1;
 | 
				
			||||||
| 
						 | 
					@ -151,7 +172,7 @@ void SocketCore::establishConnection(const string& host, int32_t port) {
 | 
				
			||||||
  if(sockfd == -1) {
 | 
					  if(sockfd == -1) {
 | 
				
			||||||
      throw new DlAbortEx(EX_SOCKET_OPEN, strerror(errno));
 | 
					      throw new DlAbortEx(EX_SOCKET_OPEN, strerror(errno));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  socklen_t sockopt = 1;
 | 
					  SOCKOPT_T sockopt = 1;
 | 
				
			||||||
  if(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof(socklen_t)) < 0) {
 | 
					  if(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof(socklen_t)) < 0) {
 | 
				
			||||||
    close(sockfd);
 | 
					    close(sockfd);
 | 
				
			||||||
    sockfd = -1;
 | 
					    sockfd = -1;
 | 
				
			||||||
| 
						 | 
					@ -188,15 +209,25 @@ void SocketCore::establishConnection(const string& host, int32_t port) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void SocketCore::setNonBlockingMode() const {
 | 
					void SocketCore::setNonBlockingMode() const {
 | 
				
			||||||
 | 
					#ifdef __MINGW32__
 | 
				
			||||||
 | 
					  u_long flag = 0;
 | 
				
			||||||
 | 
					  ::ioctlsocket(sockfd, FIONBIO, &flag);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
  int32_t flags = fcntl(sockfd, F_GETFL, 0);
 | 
					  int32_t flags = fcntl(sockfd, F_GETFL, 0);
 | 
				
			||||||
  // TODO add error handling
 | 
					  // TODO add error handling
 | 
				
			||||||
  fcntl(sockfd, F_SETFL, flags|O_NONBLOCK);
 | 
					  fcntl(sockfd, F_SETFL, flags|O_NONBLOCK);
 | 
				
			||||||
 | 
					#endif // __MINGW32__
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void SocketCore::setBlockingMode() const {
 | 
					void SocketCore::setBlockingMode() const {
 | 
				
			||||||
 | 
					#ifdef __MINGW32__
 | 
				
			||||||
 | 
					  u_long flag = 1;
 | 
				
			||||||
 | 
					  ::ioctlsocket(sockfd, FIONBIO, &flag);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
  int32_t flags = fcntl(sockfd, F_GETFL, 0);
 | 
					  int32_t flags = fcntl(sockfd, F_GETFL, 0);
 | 
				
			||||||
  // TODO add error handling
 | 
					  // TODO add error handling
 | 
				
			||||||
  fcntl(sockfd, F_SETFL, flags&(~O_NONBLOCK));
 | 
					  fcntl(sockfd, F_SETFL, flags&(~O_NONBLOCK));
 | 
				
			||||||
 | 
					#endif // __MINGW32__
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void SocketCore::closeConnection() {
 | 
					void SocketCore::closeConnection() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,6 +44,10 @@
 | 
				
			||||||
#include "DNSCache.h"
 | 
					#include "DNSCache.h"
 | 
				
			||||||
#include <signal.h>
 | 
					#include <signal.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef SA_RESETHAND
 | 
				
			||||||
 | 
					# define SA_RESETHAND 0x80000000
 | 
				
			||||||
 | 
					#endif // SA_RESETHAND
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern volatile sig_atomic_t btHaltRequested;
 | 
					extern volatile sig_atomic_t btHaltRequested;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void torrentHandler(int signal) {
 | 
					void torrentHandler(int signal) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										51
									
								
								src/Util.cc
								
								
								
								
							
							
						
						
									
										51
									
								
								src/Util.cc
								
								
								
								
							| 
						 | 
					@ -36,19 +36,19 @@
 | 
				
			||||||
#include "DlAbortEx.h"
 | 
					#include "DlAbortEx.h"
 | 
				
			||||||
#include "File.h"
 | 
					#include "File.h"
 | 
				
			||||||
#include "message.h"
 | 
					#include "message.h"
 | 
				
			||||||
 | 
					#include "SimpleRandomizer.h"
 | 
				
			||||||
 | 
					#include "a2io.h"
 | 
				
			||||||
 | 
					#include "a2netcompat.h"
 | 
				
			||||||
#include <ctype.h>
 | 
					#include <ctype.h>
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <sys/types.h>
 | 
					 | 
				
			||||||
#include <sys/stat.h>
 | 
					 | 
				
			||||||
#include <fcntl.h>
 | 
					#include <fcntl.h>
 | 
				
			||||||
#include <netinet/in.h>
 | 
					 | 
				
			||||||
#include <sys/socket.h>
 | 
					 | 
				
			||||||
#include <netinet/in.h>
 | 
					 | 
				
			||||||
#include <arpa/inet.h>
 | 
					 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
#include <signal.h>
 | 
					#include <signal.h>
 | 
				
			||||||
#include <iomanip>
 | 
					#include <iomanip>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef HAVE_STRPTIME
 | 
				
			||||||
 | 
					# include "strptime.h"
 | 
				
			||||||
 | 
					#endif // HAVE_STRPTIME
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template<typename T>
 | 
					template<typename T>
 | 
				
			||||||
string uint2str(T value, bool comma) {
 | 
					string uint2str(T value, bool comma) {
 | 
				
			||||||
| 
						 | 
					@ -311,6 +311,9 @@ string Util::toHex(const unsigned char* src, int32_t len) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FILE* Util::openFile(const string& filename, const string& mode) {
 | 
					FILE* Util::openFile(const string& filename, const string& mode) {
 | 
				
			||||||
  FILE* file = fopen(filename.c_str(), mode.c_str());
 | 
					  FILE* file = fopen(filename.c_str(), mode.c_str());
 | 
				
			||||||
 | 
					#ifdef HAVE_SETMODE
 | 
				
			||||||
 | 
					  setmode(fileno(file), O_BINARY);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
  return file;
 | 
					  return file;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -325,10 +328,10 @@ void Util::rangedFileCopy(const string& dest, const string& src, int64_t srcOffs
 | 
				
			||||||
  int32_t destFd = -1;
 | 
					  int32_t destFd = -1;
 | 
				
			||||||
  int32_t srcFd = -1;
 | 
					  int32_t srcFd = -1;
 | 
				
			||||||
  try {
 | 
					  try {
 | 
				
			||||||
    if((destFd = open(dest.c_str(), O_CREAT|O_WRONLY|O_TRUNC, OPEN_MODE)) == -1) {
 | 
					    if((destFd = open(dest.c_str(), O_CREAT|O_WRONLY|O_TRUNC|O_BINARY, OPEN_MODE)) == -1) {
 | 
				
			||||||
      throw new DlAbortEx(EX_FILE_OPEN, dest.c_str(), strerror(errno));
 | 
					      throw new DlAbortEx(EX_FILE_OPEN, dest.c_str(), strerror(errno));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if((srcFd = open(src.c_str(), O_RDONLY, OPEN_MODE)) == -1) {
 | 
					    if((srcFd = open(src.c_str(), O_RDONLY|O_BINARY, OPEN_MODE)) == -1) {
 | 
				
			||||||
      throw new DlAbortEx(EX_FILE_OPEN, src.c_str(), strerror(errno));
 | 
					      throw new DlAbortEx(EX_FILE_OPEN, src.c_str(), strerror(errno));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if(lseek(srcFd, srcOffset, SEEK_SET) != srcOffset) {
 | 
					    if(lseek(srcFd, srcOffset, SEEK_SET) != srcOffset) {
 | 
				
			||||||
| 
						 | 
					@ -508,7 +511,7 @@ void Util::fileChecksum(const string& filename, unsigned char* digest,
 | 
				
			||||||
  char buf[BUFLEN];
 | 
					  char buf[BUFLEN];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  int32_t fd;
 | 
					  int32_t fd;
 | 
				
			||||||
  if((fd = open(filename.c_str(), O_RDWR, OPEN_MODE)) < 0) {
 | 
					  if((fd = open(filename.c_str(), O_RDWR|O_BINARY, OPEN_MODE)) < 0) {
 | 
				
			||||||
    throw new DlAbortEx(EX_FILE_OPEN, filename.c_str(), strerror(errno));
 | 
					    throw new DlAbortEx(EX_FILE_OPEN, filename.c_str(), strerror(errno));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  while(1) {
 | 
					  while(1) {
 | 
				
			||||||
| 
						 | 
					@ -597,16 +600,11 @@ int32_t Util::countBit(uint32_t n) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
string Util::randomAlpha(int32_t length) {
 | 
					string Util::randomAlpha(int32_t length) {
 | 
				
			||||||
 | 
					  static char *random_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 | 
				
			||||||
  string str;
 | 
					  string str;
 | 
				
			||||||
  for(int32_t i = 0; i < length; i++) {
 | 
					  for(int32_t i = 0; i < length; i++) {
 | 
				
			||||||
    int32_t index = (int32_t)(((double)52)*random()/(RAND_MAX+1.0));
 | 
					    int32_t index = SimpleRandomizer::getInstance()->getRandomNumber(strlen(random_chars));
 | 
				
			||||||
    char ch;
 | 
					    str += random_chars[index];
 | 
				
			||||||
    if(index < 26) {
 | 
					 | 
				
			||||||
      ch = (char)('A'+index);
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
      ch = (char)('a'+index-26);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    str += ch;
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return str;
 | 
					  return str;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -647,11 +645,15 @@ bool Util::isNumbersAndDotsNotation(const string& name) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Util::setGlobalSignalHandler(int32_t signal, void (*handler)(int32_t), int32_t flags) {
 | 
					void Util::setGlobalSignalHandler(int32_t signal, void (*handler)(int32_t), int32_t flags) {
 | 
				
			||||||
 | 
					#ifdef HAVE_SIGACTION
 | 
				
			||||||
  struct sigaction sigact;
 | 
					  struct sigaction sigact;
 | 
				
			||||||
  sigact.sa_handler = handler;
 | 
					  sigact.sa_handler = handler;
 | 
				
			||||||
  sigact.sa_flags = flags;
 | 
					  sigact.sa_flags = flags;
 | 
				
			||||||
  sigemptyset(&sigact.sa_mask);
 | 
					  sigemptyset(&sigact.sa_mask);
 | 
				
			||||||
  sigaction(signal, &sigact, NULL);
 | 
					  sigaction(signal, &sigact, NULL);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					  signal(sig, handler);
 | 
				
			||||||
 | 
					#endif // HAVE_SIGACTION
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Util::indexRange(int32_t& startIndex, int32_t& endIndex,
 | 
					void Util::indexRange(int32_t& startIndex, int32_t& endIndex,
 | 
				
			||||||
| 
						 | 
					@ -715,8 +717,23 @@ time_t Util::httpGMT(const string& httpStdTime)
 | 
				
			||||||
  struct tm tm;
 | 
					  struct tm tm;
 | 
				
			||||||
  memset(&tm, 0, sizeof(tm));
 | 
					  memset(&tm, 0, sizeof(tm));
 | 
				
			||||||
  strptime(httpStdTime.c_str(), "%a, %Y-%m-%d %H:%M:%S GMT", &tm);
 | 
					  strptime(httpStdTime.c_str(), "%a, %Y-%m-%d %H:%M:%S GMT", &tm);
 | 
				
			||||||
 | 
					#ifdef HAVE_TIMEGM
 | 
				
			||||||
  time_t thetime = timegm(&tm);
 | 
					  time_t thetime = timegm(&tm);
 | 
				
			||||||
  return thetime;
 | 
					  return thetime;
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					  char *tz;
 | 
				
			||||||
 | 
					  tz = getenv("TZ");
 | 
				
			||||||
 | 
					  putenv("TZ=");
 | 
				
			||||||
 | 
					  tzset();
 | 
				
			||||||
 | 
					  time_t thetime = mktime(&tm);
 | 
				
			||||||
 | 
					  if (tz) {
 | 
				
			||||||
 | 
					    char s[256];
 | 
				
			||||||
 | 
					    sprintf("TZ=%s", tz);
 | 
				
			||||||
 | 
					    putenv(s);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  tzset();
 | 
				
			||||||
 | 
					  return thetime;
 | 
				
			||||||
 | 
					#endif // HAVE_TIMEGM
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Util::toStream(ostream& os, const FileEntries& fileEntries)
 | 
					void Util::toStream(ostream& os, const FileEntries& fileEntries)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,119 @@
 | 
				
			||||||
 | 
					/* <!-- copyright */
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * aria2 - The high speed download utility
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Copyright (C) 2006 Tatsuhiro Tsujikawa
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is free software; you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation; either version 2 of the License, or
 | 
				
			||||||
 | 
					 * (at your option) any later version.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program; if not, write to the Free Software
 | 
				
			||||||
 | 
					 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * In addition, as a special exception, the copyright holders give
 | 
				
			||||||
 | 
					 * permission to link the code of portions of this program with the
 | 
				
			||||||
 | 
					 * OpenSSL library under certain conditions as described in each
 | 
				
			||||||
 | 
					 * individual source file, and distribute linked combinations
 | 
				
			||||||
 | 
					 * including the two.
 | 
				
			||||||
 | 
					 * You must obey the GNU General Public License in all respects
 | 
				
			||||||
 | 
					 * for all of the code used other than OpenSSL.  If you modify
 | 
				
			||||||
 | 
					 * file(s) with this exception, you may extend this exception to your
 | 
				
			||||||
 | 
					 * version of the file(s), but you are not obligated to do so.  If you
 | 
				
			||||||
 | 
					 * do not wish to do so, delete this exception statement from your
 | 
				
			||||||
 | 
					 * version.  If you delete this exception statement from all source
 | 
				
			||||||
 | 
					 * files in the program, then also delete it here.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					/* copyright --> */
 | 
				
			||||||
 | 
					#ifndef _D_A2IO_H_
 | 
				
			||||||
 | 
					#define _D_A2IO_H_
 | 
				
			||||||
 | 
					#include "common.h"
 | 
				
			||||||
 | 
					#include <sys/types.h>
 | 
				
			||||||
 | 
					#include <sys/stat.h>
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					#include <fcntl.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef HAVE_IO_H
 | 
				
			||||||
 | 
					# include <io.h>
 | 
				
			||||||
 | 
					#endif // HAVE_IO_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// in some platforms following definitions are missing:
 | 
				
			||||||
 | 
					#ifndef EINPROGRESS
 | 
				
			||||||
 | 
					# define EINPROGRESS (WSAEINPROGRESS)
 | 
				
			||||||
 | 
					#endif // EINPROGRESS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_NONBLOCK
 | 
				
			||||||
 | 
					# define O_NONBLOCK (O_NDELAY)
 | 
				
			||||||
 | 
					#endif // O_NONBLOCK
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef O_BINARY
 | 
				
			||||||
 | 
					# define O_BINARY (0)
 | 
				
			||||||
 | 
					#endif // O_BINARY
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// st_mode flags
 | 
				
			||||||
 | 
					#ifndef S_IRUSR
 | 
				
			||||||
 | 
					# define		S_IRUSR	0000400	/* read permission, owner */
 | 
				
			||||||
 | 
					#endif /* S_IRUSR	*/
 | 
				
			||||||
 | 
					#ifndef S_IWUSR
 | 
				
			||||||
 | 
					# define		S_IWUSR	0000200	/* write permission, owner */
 | 
				
			||||||
 | 
					#endif /* S_IWUSR	*/
 | 
				
			||||||
 | 
					#ifndef S_IXUSR
 | 
				
			||||||
 | 
					# define		S_IXUSR 0000100/* execute/search permission, owner */
 | 
				
			||||||
 | 
					#endif /* S_IXUSR */
 | 
				
			||||||
 | 
					#ifndef S_IRWXU
 | 
				
			||||||
 | 
					# define	S_IRWXU 	(S_IRUSR | S_IWUSR | S_IXUSR)
 | 
				
			||||||
 | 
					#endif /* S_IRWXU 	*/
 | 
				
			||||||
 | 
					#ifndef S_IRGRP
 | 
				
			||||||
 | 
					# define		S_IRGRP	0000040	/* read permission, group */
 | 
				
			||||||
 | 
					#endif /* S_IRGRP	*/
 | 
				
			||||||
 | 
					#ifndef S_IWGRP
 | 
				
			||||||
 | 
					# define		S_IWGRP	0000020	/* write permission, grougroup */
 | 
				
			||||||
 | 
					#endif /* S_IWGRP	*/
 | 
				
			||||||
 | 
					#ifndef S_IXGRP
 | 
				
			||||||
 | 
					# define		S_IXGRP 0000010/* execute/search permission, group */
 | 
				
			||||||
 | 
					#endif /* S_IXGRP */
 | 
				
			||||||
 | 
					#ifndef S_IRWXG
 | 
				
			||||||
 | 
					# define	S_IRWXG		(S_IRGRP | S_IWGRP | S_IXGRP)
 | 
				
			||||||
 | 
					#endif /* S_IRWXG		*/
 | 
				
			||||||
 | 
					#ifndef S_IROTH
 | 
				
			||||||
 | 
					# define		S_IROTH	0000004	/* read permission, other */
 | 
				
			||||||
 | 
					#endif /* S_IROTH	*/
 | 
				
			||||||
 | 
					#ifndef S_IWOTH
 | 
				
			||||||
 | 
					# define		S_IWOTH	0000002	/* write permission, other */
 | 
				
			||||||
 | 
					#endif /* S_IWOTH	*/
 | 
				
			||||||
 | 
					#ifndef S_IXOTH
 | 
				
			||||||
 | 
					# define		S_IXOTH 0000001/* execute/search permission, other */
 | 
				
			||||||
 | 
					#endif /* S_IXOTH */
 | 
				
			||||||
 | 
					#ifndef S_IRWXO
 | 
				
			||||||
 | 
					# define	S_IRWXO		(S_IROTH | S_IWOTH | S_IXOTH)
 | 
				
			||||||
 | 
					#endif /* S_IRWXO		*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Use 'null' instead of /dev/null in win32.
 | 
				
			||||||
 | 
					#ifdef HAVE_WINSOCK2_H
 | 
				
			||||||
 | 
					# define DEV_NULL "nul"
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define DEV_NULL "/dev/null"
 | 
				
			||||||
 | 
					#endif // HAVE_WINSOCK2_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Use 'con' instead of '/dev/stdout' in win32.
 | 
				
			||||||
 | 
					#ifdef HAVE_WINSOCK2_H
 | 
				
			||||||
 | 
					# define DEV_STDOUT "con"
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define DEV_STDOUT "/dev/stdout"
 | 
				
			||||||
 | 
					#endif // HAVE_WINSOCK2_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __MINGW32__
 | 
				
			||||||
 | 
					# define a2mkdir(path, openMode) mkdir(path)
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define a2mkdir(path, openMode) mkdir(path, openMode)
 | 
				
			||||||
 | 
					#endif // __MINGW32__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _D_A2IO_H_
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,75 @@
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * aria2 - The high speed download utility
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Copyright (C) 2006 Tatsuhiro Tsujikawa
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is free software; you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation; either version 2 of the License, or
 | 
				
			||||||
 | 
					 * (at your option) any later version.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program; if not, write to the Free Software
 | 
				
			||||||
 | 
					 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * In addition, as a special exception, the copyright holders give
 | 
				
			||||||
 | 
					 * permission to link the code of portions of this program with the
 | 
				
			||||||
 | 
					 * OpenSSL library under certain conditions as described in each
 | 
				
			||||||
 | 
					 * individual source file, and distribute linked combinations
 | 
				
			||||||
 | 
					 * including the two.
 | 
				
			||||||
 | 
					 * You must obey the GNU General Public License in all respects
 | 
				
			||||||
 | 
					 * for all of the code used other than OpenSSL.  If you modify
 | 
				
			||||||
 | 
					 * file(s) with this exception, you may extend this exception to your
 | 
				
			||||||
 | 
					 * version of the file(s), but you are not obligated to do so.  If you
 | 
				
			||||||
 | 
					 * do not wish to do so, delete this exception statement from your
 | 
				
			||||||
 | 
					 * version.  If you delete this exception statement from all source
 | 
				
			||||||
 | 
					 * files in the program, then also delete it here.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					/* copyright --> */
 | 
				
			||||||
 | 
					#ifndef _D_A2NETCOMPAT_H_
 | 
				
			||||||
 | 
					#define _D_A2NETCOMPAT_H_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef HAVE_NETDB_H
 | 
				
			||||||
 | 
					# include <netdb.h>
 | 
				
			||||||
 | 
					#endif // HAVE_NETDB_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef HAVE_SYS_SOCKET_H
 | 
				
			||||||
 | 
					# include <sys/socket.h>
 | 
				
			||||||
 | 
					#endif // HAVE_SYS_SOCKET_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef HAVE_NETINET_IN_H
 | 
				
			||||||
 | 
					# include <netinet/in.h>
 | 
				
			||||||
 | 
					#endif // HAVE_NETINET_IN_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef HAVE_ARPA_INET_H
 | 
				
			||||||
 | 
					# include <arpa/inet.h>
 | 
				
			||||||
 | 
					#endif // HAVE_ARPA_INET_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef HAVE_NETINET_IN_H
 | 
				
			||||||
 | 
					# include <netinet/in.h>
 | 
				
			||||||
 | 
					#endif // HAVE_NETINET_IN_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef HAVE_INET_ATON
 | 
				
			||||||
 | 
					# include "inet_aton.h"
 | 
				
			||||||
 | 
					#endif // HAVE_INET_ATON
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __MINGW32__
 | 
				
			||||||
 | 
					# include <winsock2.h>
 | 
				
			||||||
 | 
					# undef ERROR
 | 
				
			||||||
 | 
					# include <ws2tcpip.h>
 | 
				
			||||||
 | 
					# define SOCKOPT_T const char
 | 
				
			||||||
 | 
					# define HAVE_GETADDRINFO
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define SOCKOPT_T socklen_t
 | 
				
			||||||
 | 
					#endif // __MINGW32__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef HAVE_GETADDRINFO
 | 
				
			||||||
 | 
					# include "getaddrinfo.h"
 | 
				
			||||||
 | 
					#endif // HAVE_GETADDRINFO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _D_A2NETCOMPAT_H_
 | 
				
			||||||
							
								
								
									
										19
									
								
								src/common.h
								
								
								
								
							
							
						
						
									
										19
									
								
								src/common.h
								
								
								
								
							| 
						 | 
					@ -45,6 +45,7 @@
 | 
				
			||||||
#include <assert.h>
 | 
					#include <assert.h>
 | 
				
			||||||
#include <limits.h>
 | 
					#include <limits.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <string>
 | 
					#include <string>
 | 
				
			||||||
#include <deque>
 | 
					#include <deque>
 | 
				
			||||||
#include <algorithm>
 | 
					#include <algorithm>
 | 
				
			||||||
| 
						 | 
					@ -81,4 +82,22 @@ typedef deque<int32_t> Integers;
 | 
				
			||||||
#define OPEN_MODE S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH
 | 
					#define OPEN_MODE S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH
 | 
				
			||||||
#define DIR_OPEN_MODE S_IRWXU|S_IRWXG|S_IRWXO
 | 
					#define DIR_OPEN_MODE S_IRWXU|S_IRWXG|S_IRWXO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __MINGW32__
 | 
				
			||||||
 | 
					# ifndef _WIN32_WINNT
 | 
				
			||||||
 | 
					#  define _WIN32_WINNT 0x501
 | 
				
			||||||
 | 
					# endif // _WIN32_WINNT
 | 
				
			||||||
 | 
					#endif // __MINGW32__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __MINGW32__
 | 
				
			||||||
 | 
					# define LONGLONG_PRINTF "%I64d"
 | 
				
			||||||
 | 
					# define ULONGLONG_PRINTF "%I64u"
 | 
				
			||||||
 | 
					# define LONGLONG_SCANF "%I64d"
 | 
				
			||||||
 | 
					# define ULONGLONG_SCANF "%I64u"
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define LONGLONG_PRINTF "%lld"
 | 
				
			||||||
 | 
					# define ULONGLONG_PRINTF "%llu"
 | 
				
			||||||
 | 
					# define LONGLONG_SCANF "%Ld"
 | 
				
			||||||
 | 
					# define ULONGLONG_SCANF "%Lu"
 | 
				
			||||||
 | 
					#endif // __MINGW32__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // _D_COMMON_H_
 | 
					#endif // _D_COMMON_H_
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,608 @@
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (c) 2001, 02  Motoyuki Kasahara
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Redistribution and use in source and binary forms, with or without
 | 
				
			||||||
 | 
					 * modification, are permitted provided that the following conditions
 | 
				
			||||||
 | 
					 * are met:
 | 
				
			||||||
 | 
					 * 1. Redistributions of source code must retain the above copyright
 | 
				
			||||||
 | 
					 *    notice, this list of conditions and the following disclaimer.
 | 
				
			||||||
 | 
					 * 2. Redistributions in binary form must reproduce the above copyright
 | 
				
			||||||
 | 
					 *    notice, this list of conditions and the following disclaimer in the
 | 
				
			||||||
 | 
					 *    documentation and/or other materials provided with the distribution.
 | 
				
			||||||
 | 
					 * 3. Neither the name of the project nor the names of its contributors
 | 
				
			||||||
 | 
					 *    may be used to endorse or promote products derived from this software
 | 
				
			||||||
 | 
					 *    without specific prior written permission.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
 | 
				
			||||||
 | 
					 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
				
			||||||
 | 
					 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 | 
				
			||||||
 | 
					 * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
 | 
				
			||||||
 | 
					 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
				
			||||||
 | 
					 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 | 
				
			||||||
 | 
					 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 | 
				
			||||||
 | 
					 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 | 
				
			||||||
 | 
					 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 | 
				
			||||||
 | 
					 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
				
			||||||
 | 
					 * SUCH DAMAGE.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * This program provides getaddrinfo() and getnameinfo() described in
 | 
				
			||||||
 | 
					 * RFC2133, 2553 and 3493.  These functions are mainly used for IPv6
 | 
				
			||||||
 | 
					 * application to resolve hostname or address.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is designed to be working on traditional IPv4 systems
 | 
				
			||||||
 | 
					 * which don't have those functions.  Therefore, this implementation
 | 
				
			||||||
 | 
					 * supports IPv4 only.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is useful for application which should support both IPv6
 | 
				
			||||||
 | 
					 * and traditional IPv4 systems.  Use genuine getaddrinfo() and getnameinfo()
 | 
				
			||||||
 | 
					 * provided by system if the system supports IPv6.  Otherwise, use this
 | 
				
			||||||
 | 
					 * implementation.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is intended to be used in combination with GNU Autoconf.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program also provides freeaddrinfo() and gai_strerror().
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * To use this program in your application, insert the following lines to
 | 
				
			||||||
 | 
					 * C source files after including `sys/types.h', `sys/socket.h' and
 | 
				
			||||||
 | 
					 * `netdb.h'.  `getaddrinfo.h' defines `struct addrinfo' and AI_, NI_,
 | 
				
			||||||
 | 
					 * EAI_ macros.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 *    #ifndef HAVE_GETADDRINFO
 | 
				
			||||||
 | 
					 *    #include "getaddrinfo.h"
 | 
				
			||||||
 | 
					 *    #endif
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Restriction:
 | 
				
			||||||
 | 
					 *   getaddrinfo() and getnameinfo() of this program are NOT thread
 | 
				
			||||||
 | 
					 *   safe, unless the cpp macro ENABLE_PTHREAD is defined.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Add the following code to your configure.ac (or configure.in).
 | 
				
			||||||
 | 
					 *   AC_C_CONST
 | 
				
			||||||
 | 
					 *   AC_HEADER_STDC
 | 
				
			||||||
 | 
					 *   AC_CHECK_HEADERS(string.h memory.h stdlib.h)
 | 
				
			||||||
 | 
					 *   AC_CHECK_FUNCS(memcpy)
 | 
				
			||||||
 | 
					 *   AC_REPLACE_FUNCS(memset)
 | 
				
			||||||
 | 
					 *   AC_TYPE_SOCKLEN_T
 | 
				
			||||||
 | 
					 *   AC_TYPE_IN_PORT_T
 | 
				
			||||||
 | 
					 *   AC_DECL_H_ERRNO
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 *   AC_CHECK_FUNCS(getaddrinfo getnameinfo)
 | 
				
			||||||
 | 
					 *   if test "$ac_cv_func_getaddrinfo$ac_cv_func_getnameinfo" != yesyes ; then
 | 
				
			||||||
 | 
					 *       LIBOBJS="$LIBOBJS getaddrinfo.$ac_objext"
 | 
				
			||||||
 | 
					 *   fi
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef HAVE_CONFIG_H
 | 
				
			||||||
 | 
					#include "config.h"
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __MINGW32__
 | 
				
			||||||
 | 
					# include <winsock2.h>
 | 
				
			||||||
 | 
					# undef ERROR
 | 
				
			||||||
 | 
					# include <ws2tcpip.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef HAVE_SYS_SOCKET_H
 | 
				
			||||||
 | 
					# include <sys/socket.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef HAVE_NETINET_IN_H
 | 
				
			||||||
 | 
					# include <netinet/in.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef HAVE_ARPA_INET_H
 | 
				
			||||||
 | 
					# include <arpa/inet.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef HAVE_NETDB_H
 | 
				
			||||||
 | 
					# include <netdb.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <sys/types.h>
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					#if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
 | 
				
			||||||
 | 
					#include <memory.h>
 | 
				
			||||||
 | 
					#endif /* not STDC_HEADERS and HAVE_MEMORY_H */
 | 
				
			||||||
 | 
					#else /* not STDC_HEADERS and not HAVE_STRING_H */
 | 
				
			||||||
 | 
					#include <strings.h>
 | 
				
			||||||
 | 
					#endif /* not STDC_HEADERS and not HAVE_STRING_H */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef HAVE_STDLIB_H
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef ENABLE_PTHREAD
 | 
				
			||||||
 | 
					#include <pthread.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef ENABLE_NLS
 | 
				
			||||||
 | 
					#include <libintl.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef HAVE_MEMCPY
 | 
				
			||||||
 | 
					#define memcpy(d, s, n) bcopy((s), (d), (n))
 | 
				
			||||||
 | 
					#ifdef __STDC__
 | 
				
			||||||
 | 
					void *memchr(const void *, int, size_t);
 | 
				
			||||||
 | 
					int memcmp(const void *, const void *, size_t);
 | 
				
			||||||
 | 
					void *memmove(void *, const void *, size_t);
 | 
				
			||||||
 | 
					void *memset(void *, int, size_t);
 | 
				
			||||||
 | 
					#else /* not __STDC__ */
 | 
				
			||||||
 | 
					char *memchr();
 | 
				
			||||||
 | 
					int memcmp();
 | 
				
			||||||
 | 
					char *memmove();
 | 
				
			||||||
 | 
					char *memset();
 | 
				
			||||||
 | 
					#endif /* not __STDC__ */
 | 
				
			||||||
 | 
					#endif /* not HAVE_MEMCPY */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef H_ERRNO_DECLARED
 | 
				
			||||||
 | 
					extern int h_errno;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "getaddrinfo.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef ENABLE_NLS
 | 
				
			||||||
 | 
					#define _(string) gettext(string)
 | 
				
			||||||
 | 
					#ifdef gettext_noop
 | 
				
			||||||
 | 
					#define N_(string) gettext_noop(string)
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					#define N_(string) (string)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					#define gettext(string) (string)
 | 
				
			||||||
 | 
					#define _(string) (string)
 | 
				
			||||||
 | 
					#define N_(string) (string)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Error messages for gai_strerror().
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					static char *eai_errlist[] = {
 | 
				
			||||||
 | 
					    N_("Success"),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* EAI_ADDRFAMILY */
 | 
				
			||||||
 | 
					    N_("Address family for hostname not supported"),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* EAI_AGAIN */
 | 
				
			||||||
 | 
					    N_("Temporary failure in name resolution"),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* EAI_BADFLAGS */
 | 
				
			||||||
 | 
					    N_("Invalid value for ai_flags"),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* EAI_FAIL */
 | 
				
			||||||
 | 
					    N_("Non-recoverable failure in name resolution"),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* EAI_FAMILY */
 | 
				
			||||||
 | 
					    N_("ai_family not supported"),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* EAI_MEMORY */
 | 
				
			||||||
 | 
					    N_("Memory allocation failure"),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* EAI_NONAME */
 | 
				
			||||||
 | 
					    N_("hostname nor servname provided, or not known"),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* EAI_OVERFLOW */
 | 
				
			||||||
 | 
					    N_("An argument buffer overflowed"),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* EAI_SERVICE */
 | 
				
			||||||
 | 
					    N_("servname not supported for ai_socktype"),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* EAI_SOCKTYPE */
 | 
				
			||||||
 | 
					    N_("ai_socktype not supported"),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* EAI_SYSTEM */
 | 
				
			||||||
 | 
					    N_("System error returned in errno")
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Default hints for getaddrinfo().
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					static struct addrinfo default_hints = {
 | 
				
			||||||
 | 
					    0, PF_UNSPEC, 0, 0, 0, NULL, NULL, NULL
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Mutex.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					#ifdef ENABLE_PTHREAD
 | 
				
			||||||
 | 
					static pthread_mutex_t gai_mutex = PTHREAD_MUTEX_INITIALIZER;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Declaration of static functions.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					#ifdef __STDC__
 | 
				
			||||||
 | 
					static int is_integer(const char *);
 | 
				
			||||||
 | 
					static int is_address(const char *);
 | 
				
			||||||
 | 
					static int itoa_length(int);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					static int is_integer();
 | 
				
			||||||
 | 
					static int is_address();
 | 
				
			||||||
 | 
					static int itoa_length();
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * gai_strerror().
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					const char *
 | 
				
			||||||
 | 
					gai_strerror(ecode)
 | 
				
			||||||
 | 
					    int ecode;
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (ecode < 0 || ecode > EAI_SYSTEM)
 | 
				
			||||||
 | 
						return _("Unknown error");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return gettext(eai_errlist[ecode]);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * freeaddrinfo().
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					freeaddrinfo(ai)
 | 
				
			||||||
 | 
					    struct addrinfo *ai;
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    struct addrinfo *next_ai;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    while (ai != NULL) {
 | 
				
			||||||
 | 
						if (ai->ai_canonname != NULL)
 | 
				
			||||||
 | 
						    free(ai->ai_canonname);
 | 
				
			||||||
 | 
						if (ai->ai_addr != NULL)
 | 
				
			||||||
 | 
						    free(ai->ai_addr);
 | 
				
			||||||
 | 
						next_ai = ai->ai_next;
 | 
				
			||||||
 | 
						free(ai);
 | 
				
			||||||
 | 
						ai = next_ai;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Return 1 if the string `s' represents an integer.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					is_integer(s)
 | 
				
			||||||
 | 
					    const char *s;
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (*s == '-' || *s == '+')
 | 
				
			||||||
 | 
						s++;
 | 
				
			||||||
 | 
					    if (*s < '0' || '9' < *s)
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    s++;
 | 
				
			||||||
 | 
					    while ('0' <= *s && *s <= '9')
 | 
				
			||||||
 | 
						s++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return (*s == '\0');
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Return 1 if the string `s' represents an IPv4 address.
 | 
				
			||||||
 | 
					 * Unlike inet_addr(), it doesn't permit malformed nortation such
 | 
				
			||||||
 | 
					 * as "192.168".
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					is_address(s)
 | 
				
			||||||
 | 
					    const char *s;
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    const static char delimiters[] = {'.', '.', '.', '\0'};
 | 
				
			||||||
 | 
					    int i, j;
 | 
				
			||||||
 | 
					    int octet;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (i = 0; i < 4; i++) {
 | 
				
			||||||
 | 
						if (*s == '0' && *(s + 1) != delimiters[i])
 | 
				
			||||||
 | 
						    return 0;
 | 
				
			||||||
 | 
						for (j = 0, octet = 0; '0' <= *s && *s <= '9' && j < 3; s++, j++)
 | 
				
			||||||
 | 
						    octet = octet * 10 + (*s - '0');
 | 
				
			||||||
 | 
						if (j == 0 || octet > 255 || *s != delimiters[i])
 | 
				
			||||||
 | 
						    return 0;
 | 
				
			||||||
 | 
						s++;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return 1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Calcurate length of the string `s', where `s' is set by
 | 
				
			||||||
 | 
					 * sprintf(s, "%d", n).
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					itoa_length(n)
 | 
				
			||||||
 | 
					    int n;
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    int result = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (n < 0) {
 | 
				
			||||||
 | 
						n = -n;
 | 
				
			||||||
 | 
						result++;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    while (n >= 10) {
 | 
				
			||||||
 | 
						result++;
 | 
				
			||||||
 | 
						n /= 10;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * getaddrinfo().
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					getaddrinfo(nodename, servname, hints, res)
 | 
				
			||||||
 | 
					    const char *nodename;
 | 
				
			||||||
 | 
					    const char *servname;
 | 
				
			||||||
 | 
					    const struct addrinfo *hints;
 | 
				
			||||||
 | 
					    struct addrinfo **res;
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    struct addrinfo *head_res = NULL;
 | 
				
			||||||
 | 
					    struct addrinfo *tail_res = NULL;
 | 
				
			||||||
 | 
					    struct addrinfo *new_res;
 | 
				
			||||||
 | 
					    struct sockaddr_in *sa_in;
 | 
				
			||||||
 | 
					    struct in_addr **addr_list;
 | 
				
			||||||
 | 
					    struct in_addr *addr_list_buf[2];
 | 
				
			||||||
 | 
					    struct in_addr addr_buf;
 | 
				
			||||||
 | 
					    struct in_addr **ap;
 | 
				
			||||||
 | 
					    struct servent *servent;
 | 
				
			||||||
 | 
					    struct hostent *hostent;
 | 
				
			||||||
 | 
					    const char *canonname = NULL;
 | 
				
			||||||
 | 
					    in_port_t port;
 | 
				
			||||||
 | 
					    int saved_h_errno;
 | 
				
			||||||
 | 
					    int result = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef ENABLE_PTHREAD
 | 
				
			||||||
 | 
					    pthread_mutex_lock(&gai_mutex);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    saved_h_errno = h_errno;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (nodename == NULL && servname == NULL) {
 | 
				
			||||||
 | 
						result = EAI_NONAME;
 | 
				
			||||||
 | 
						goto end;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (hints != NULL) {
 | 
				
			||||||
 | 
						if (hints->ai_family != PF_INET && hints->ai_family != PF_UNSPEC) {
 | 
				
			||||||
 | 
						    result = EAI_FAMILY;
 | 
				
			||||||
 | 
						    goto end;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (hints->ai_socktype != SOCK_DGRAM
 | 
				
			||||||
 | 
						    && hints->ai_socktype != SOCK_STREAM
 | 
				
			||||||
 | 
						    && hints->ai_socktype != 0) {
 | 
				
			||||||
 | 
						    result = EAI_SOCKTYPE;
 | 
				
			||||||
 | 
						    goto end;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
						hints = &default_hints;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (servname != NULL) {
 | 
				
			||||||
 | 
						if (is_integer(servname))
 | 
				
			||||||
 | 
						    port = htons(atoi(servname));
 | 
				
			||||||
 | 
						else  {
 | 
				
			||||||
 | 
						    if (hints->ai_flags & AI_NUMERICSERV) {
 | 
				
			||||||
 | 
							result = EAI_NONAME;
 | 
				
			||||||
 | 
							goto end;
 | 
				
			||||||
 | 
						    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						    if (hints->ai_socktype == SOCK_DGRAM)
 | 
				
			||||||
 | 
							servent = getservbyname(servname, "udp");
 | 
				
			||||||
 | 
						    else if (hints->ai_socktype == SOCK_STREAM)
 | 
				
			||||||
 | 
							servent = getservbyname(servname, "tcp");
 | 
				
			||||||
 | 
						    else if (hints->ai_socktype == 0)
 | 
				
			||||||
 | 
							servent = getservbyname(servname, "tcp");
 | 
				
			||||||
 | 
						    else {
 | 
				
			||||||
 | 
							result = EAI_SOCKTYPE;
 | 
				
			||||||
 | 
							goto end;
 | 
				
			||||||
 | 
						    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						    if (servent == NULL) {
 | 
				
			||||||
 | 
							result = EAI_SERVICE;
 | 
				
			||||||
 | 
							goto end;
 | 
				
			||||||
 | 
						    }
 | 
				
			||||||
 | 
						    port = servent->s_port;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
						port = htons(0);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (nodename != NULL) {
 | 
				
			||||||
 | 
						if (is_address(nodename)) {
 | 
				
			||||||
 | 
						    addr_buf.s_addr = inet_addr(nodename);
 | 
				
			||||||
 | 
						    addr_list_buf[0] = &addr_buf;
 | 
				
			||||||
 | 
						    addr_list_buf[1] = NULL;
 | 
				
			||||||
 | 
						    addr_list = addr_list_buf;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						    if (hints->ai_flags & AI_CANONNAME
 | 
				
			||||||
 | 
							&& !(hints->ai_flags & AI_NUMERICHOST)) {
 | 
				
			||||||
 | 
							hostent = gethostbyaddr((char *)&addr_buf,
 | 
				
			||||||
 | 
							    sizeof(struct in_addr), AF_INET);
 | 
				
			||||||
 | 
							if (hostent != NULL)
 | 
				
			||||||
 | 
							    canonname = hostent->h_name;
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
							    canonname = nodename;
 | 
				
			||||||
 | 
						    }
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
						    if (hints->ai_flags & AI_NUMERICHOST) {
 | 
				
			||||||
 | 
							result = EAI_NONAME;
 | 
				
			||||||
 | 
							goto end;
 | 
				
			||||||
 | 
						    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						    hostent = gethostbyname(nodename);
 | 
				
			||||||
 | 
						    if (hostent == NULL) {
 | 
				
			||||||
 | 
							switch (h_errno) {
 | 
				
			||||||
 | 
							case HOST_NOT_FOUND:
 | 
				
			||||||
 | 
							case NO_DATA:
 | 
				
			||||||
 | 
							    result = EAI_NONAME;
 | 
				
			||||||
 | 
							    goto end;
 | 
				
			||||||
 | 
							case TRY_AGAIN:
 | 
				
			||||||
 | 
							    result = EAI_AGAIN;
 | 
				
			||||||
 | 
							    goto end;
 | 
				
			||||||
 | 
							default:
 | 
				
			||||||
 | 
							    result = EAI_FAIL;
 | 
				
			||||||
 | 
							    goto end;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
						    }
 | 
				
			||||||
 | 
						    addr_list = (struct in_addr **)hostent->h_addr_list;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						    if (hints->ai_flags & AI_CANONNAME)
 | 
				
			||||||
 | 
							canonname = hostent->h_name;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
						if (hints->ai_flags & AI_PASSIVE)
 | 
				
			||||||
 | 
						    addr_buf.s_addr = htonl(INADDR_ANY);
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
						    addr_buf.s_addr = htonl(0x7F000001);
 | 
				
			||||||
 | 
						addr_list_buf[0] = &addr_buf;
 | 
				
			||||||
 | 
						addr_list_buf[1] = NULL;
 | 
				
			||||||
 | 
						addr_list = addr_list_buf;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (ap = addr_list; *ap != NULL; ap++) {
 | 
				
			||||||
 | 
						new_res = (struct addrinfo *)malloc(sizeof(struct addrinfo));
 | 
				
			||||||
 | 
						if (new_res == NULL) {
 | 
				
			||||||
 | 
						    if (head_res != NULL)
 | 
				
			||||||
 | 
							freeaddrinfo(head_res);
 | 
				
			||||||
 | 
						    result = EAI_MEMORY;
 | 
				
			||||||
 | 
						    goto end;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						new_res->ai_family = PF_INET;
 | 
				
			||||||
 | 
						new_res->ai_socktype = hints->ai_socktype;
 | 
				
			||||||
 | 
						new_res->ai_protocol = hints->ai_protocol;
 | 
				
			||||||
 | 
						new_res->ai_addr = NULL;
 | 
				
			||||||
 | 
						new_res->ai_addrlen = sizeof(struct sockaddr_in);
 | 
				
			||||||
 | 
						new_res->ai_canonname = NULL;
 | 
				
			||||||
 | 
						new_res->ai_next = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						new_res->ai_addr = (struct sockaddr *)
 | 
				
			||||||
 | 
						    malloc(sizeof(struct sockaddr_in));
 | 
				
			||||||
 | 
						if (new_res->ai_addr == NULL) {
 | 
				
			||||||
 | 
						    free(new_res);
 | 
				
			||||||
 | 
						    if (head_res != NULL)
 | 
				
			||||||
 | 
							freeaddrinfo(head_res);
 | 
				
			||||||
 | 
						    result = EAI_MEMORY;
 | 
				
			||||||
 | 
						    goto end;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						sa_in = (struct sockaddr_in *)new_res->ai_addr;
 | 
				
			||||||
 | 
						memset(sa_in, 0, sizeof(struct sockaddr_in));
 | 
				
			||||||
 | 
						sa_in->sin_family = PF_INET;
 | 
				
			||||||
 | 
						sa_in->sin_port = port;
 | 
				
			||||||
 | 
						memcpy(&sa_in->sin_addr, *ap, sizeof(struct in_addr));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (head_res == NULL)
 | 
				
			||||||
 | 
						    head_res = new_res;
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
						    tail_res->ai_next = new_res;
 | 
				
			||||||
 | 
						tail_res = new_res;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (canonname != NULL && head_res != NULL) {
 | 
				
			||||||
 | 
						head_res->ai_canonname = (char *)malloc(strlen(canonname) + 1);
 | 
				
			||||||
 | 
						if (head_res->ai_canonname != NULL)
 | 
				
			||||||
 | 
						    strcpy(head_res->ai_canonname, canonname);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    *res = head_res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  end:
 | 
				
			||||||
 | 
					    h_errno = saved_h_errno;
 | 
				
			||||||
 | 
					#ifdef ENABLE_PTHREAD
 | 
				
			||||||
 | 
					    pthread_mutex_unlock(&gai_mutex);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					    return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * getnameinfo().
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					getnameinfo(sa, salen, node, nodelen, serv, servlen, flags)
 | 
				
			||||||
 | 
					    const struct sockaddr *sa;
 | 
				
			||||||
 | 
					    socklen_t salen;
 | 
				
			||||||
 | 
					    char *node;
 | 
				
			||||||
 | 
					    socklen_t nodelen;
 | 
				
			||||||
 | 
					    char *serv;
 | 
				
			||||||
 | 
					    socklen_t servlen;
 | 
				
			||||||
 | 
					    int flags;
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    const struct sockaddr_in *sa_in = (const struct sockaddr_in *)sa;
 | 
				
			||||||
 | 
					    struct hostent *hostent;
 | 
				
			||||||
 | 
					    struct servent *servent;
 | 
				
			||||||
 | 
					    char *ntoa_address;
 | 
				
			||||||
 | 
					    int saved_h_errno;
 | 
				
			||||||
 | 
					    int result = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef ENABLE_PTHREAD
 | 
				
			||||||
 | 
					    pthread_mutex_lock(&gai_mutex);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    saved_h_errno = h_errno;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (sa_in->sin_family != PF_INET) {
 | 
				
			||||||
 | 
						result = EAI_FAMILY;
 | 
				
			||||||
 | 
						goto end;
 | 
				
			||||||
 | 
					    } else if (node == NULL && serv == NULL) {
 | 
				
			||||||
 | 
						result = EAI_NONAME;
 | 
				
			||||||
 | 
						goto end;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (serv != NULL && servlen > 0) {
 | 
				
			||||||
 | 
						if (flags & NI_NUMERICSERV)
 | 
				
			||||||
 | 
						    servent = NULL;
 | 
				
			||||||
 | 
						else if (flags & NI_DGRAM)
 | 
				
			||||||
 | 
						    servent = getservbyport(sa_in->sin_port, "udp");
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
						    servent = getservbyport(sa_in->sin_port, "tcp");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (servent != NULL) {
 | 
				
			||||||
 | 
						    if (servlen <= strlen(servent->s_name)) {
 | 
				
			||||||
 | 
							result = EAI_OVERFLOW;
 | 
				
			||||||
 | 
							goto end;
 | 
				
			||||||
 | 
						    }
 | 
				
			||||||
 | 
						    strcpy(serv, servent->s_name);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
						    if (servlen <= itoa_length(ntohs(sa_in->sin_port))) {
 | 
				
			||||||
 | 
							result = EAI_OVERFLOW;
 | 
				
			||||||
 | 
							goto end;
 | 
				
			||||||
 | 
						    }
 | 
				
			||||||
 | 
						    sprintf(serv, "%d", ntohs(sa_in->sin_port));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (node != NULL && nodelen > 0) {
 | 
				
			||||||
 | 
						if (flags & NI_NUMERICHOST)
 | 
				
			||||||
 | 
						    hostent = NULL;
 | 
				
			||||||
 | 
						else {
 | 
				
			||||||
 | 
						    hostent = gethostbyaddr((char *)&sa_in->sin_addr,
 | 
				
			||||||
 | 
							sizeof(struct in_addr), AF_INET);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (hostent != NULL) {
 | 
				
			||||||
 | 
						    if (nodelen <= strlen(hostent->h_name)) {
 | 
				
			||||||
 | 
							result = EAI_OVERFLOW;
 | 
				
			||||||
 | 
							goto end;
 | 
				
			||||||
 | 
						    }
 | 
				
			||||||
 | 
						    strcpy(node, hostent->h_name);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
						    if (flags & NI_NAMEREQD) {
 | 
				
			||||||
 | 
							result = EAI_NONAME;
 | 
				
			||||||
 | 
							goto end;
 | 
				
			||||||
 | 
						    }
 | 
				
			||||||
 | 
						    ntoa_address = inet_ntoa(sa_in->sin_addr);
 | 
				
			||||||
 | 
						    if (nodelen <= strlen(ntoa_address)) {
 | 
				
			||||||
 | 
							result = EAI_OVERFLOW;
 | 
				
			||||||
 | 
							goto end;
 | 
				
			||||||
 | 
						    }
 | 
				
			||||||
 | 
						    strcpy(node, ntoa_address);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  end:
 | 
				
			||||||
 | 
					    h_errno = saved_h_errno;
 | 
				
			||||||
 | 
					#ifdef ENABLE_PTHREAD
 | 
				
			||||||
 | 
					    pthread_mutex_unlock(&gai_mutex);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					    return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,249 @@
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (c) 2001, 02  Motoyuki Kasahara
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Redistribution and use in source and binary forms, with or without
 | 
				
			||||||
 | 
					 * modification, are permitted provided that the following conditions
 | 
				
			||||||
 | 
					 * are met:
 | 
				
			||||||
 | 
					 * 1. Redistributions of source code must retain the above copyright
 | 
				
			||||||
 | 
					 *    notice, this list of conditions and the following disclaimer.
 | 
				
			||||||
 | 
					 * 2. Redistributions in binary form must reproduce the above copyright
 | 
				
			||||||
 | 
					 *    notice, this list of conditions and the following disclaimer in the
 | 
				
			||||||
 | 
					 *    documentation and/or other materials provided with the distribution.
 | 
				
			||||||
 | 
					 * 3. Neither the name of the project nor the names of its contributors
 | 
				
			||||||
 | 
					 *    may be used to endorse or promote products derived from this software
 | 
				
			||||||
 | 
					 *    without specific prior written permission.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
 | 
				
			||||||
 | 
					 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
				
			||||||
 | 
					 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 | 
				
			||||||
 | 
					 * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
 | 
				
			||||||
 | 
					 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
				
			||||||
 | 
					 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 | 
				
			||||||
 | 
					 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 | 
				
			||||||
 | 
					 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 | 
				
			||||||
 | 
					 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 | 
				
			||||||
 | 
					 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
				
			||||||
 | 
					 * SUCH DAMAGE.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _D_GETADDRINFO_H
 | 
				
			||||||
 | 
					#define _D_GETADDRINFO_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					extern "C" {
 | 
				
			||||||
 | 
					#endif /* __cplusplus */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef HAVE_CONFIG_H
 | 
				
			||||||
 | 
					# include "config.h"
 | 
				
			||||||
 | 
					#endif // HAVE_CONFIG_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __MINGW32__
 | 
				
			||||||
 | 
					# ifndef _WIN32_WINNT
 | 
				
			||||||
 | 
					#  define _WIN32_WINNT 0x501
 | 
				
			||||||
 | 
					# endif // _WIN32_WINNT
 | 
				
			||||||
 | 
					# include <winsock2.h>
 | 
				
			||||||
 | 
					# undef ERROR
 | 
				
			||||||
 | 
					# include <ws2tcpip.h>
 | 
				
			||||||
 | 
					#endif // __MINGW32__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef HAVE_SYS_SOCKET_H
 | 
				
			||||||
 | 
					# include <sys/socket.h>
 | 
				
			||||||
 | 
					#endif // HAVE_SYS_SOCKET_H
 | 
				
			||||||
 | 
					#ifdef HAVE_NETDB_H
 | 
				
			||||||
 | 
					# include <netdb.h>
 | 
				
			||||||
 | 
					#endif // HAVE_NETDB_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <sys/types.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/********************************************************************/
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Undefine all the macros.
 | 
				
			||||||
 | 
					 * <netdb.h> might defines some of them.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					#ifdef EAI_ADDRFAMILY
 | 
				
			||||||
 | 
					#undef EAI_ADDRFAMILY
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef EAI_AGAIN
 | 
				
			||||||
 | 
					#undef EAI_AGAIN
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef EAI_BADFLAGS
 | 
				
			||||||
 | 
					#undef EAI_BADFLAGS
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef EAI_FAIL
 | 
				
			||||||
 | 
					#undef EAI_FAIL
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef EAI_FAMILY
 | 
				
			||||||
 | 
					#undef EAI_FAMILY
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef EAI_MEMORY
 | 
				
			||||||
 | 
					#undef EAI_MEMORY
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef EAI_NONAME
 | 
				
			||||||
 | 
					#undef EAI_NONAME
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef EAI_OVERFLOW
 | 
				
			||||||
 | 
					#undef EAI_OVERFLOW
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef EAI_SERVICE
 | 
				
			||||||
 | 
					#undef EAI_SERVICE
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef EAI_SOCKTYPE
 | 
				
			||||||
 | 
					#undef EAI_SOCKTYPE
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef EAI_SYSTEM
 | 
				
			||||||
 | 
					#undef EAI_SYSTEM
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef AI_PASSIVE
 | 
				
			||||||
 | 
					#undef AI_PASSIVE
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef AI_CANONNAME
 | 
				
			||||||
 | 
					#undef AI_CANONNAME
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef AI_NUMERICHOST
 | 
				
			||||||
 | 
					#undef AI_NUMERICHOST
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef AI_NUMERICSERV
 | 
				
			||||||
 | 
					#undef AI_NUMERICSERV
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef AI_V4MAPPED
 | 
				
			||||||
 | 
					#undef AI_V4MAPPED
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef AI_ALL
 | 
				
			||||||
 | 
					#undef AI_ALL
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef AI_ADDRCONFIG
 | 
				
			||||||
 | 
					#undef AI_ADDRCONFIG
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef AI_DEFAULT
 | 
				
			||||||
 | 
					#undef AI_DEFAULT
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef NI_NOFQDN
 | 
				
			||||||
 | 
					#undef NI_NOFQDN
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef NI_NUMERICHOST
 | 
				
			||||||
 | 
					#undef NI_NUMERICHOST
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef NI_NAMEREQD
 | 
				
			||||||
 | 
					#undef NI_NAMEREQD
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef NI_NUMERICSERV
 | 
				
			||||||
 | 
					#undef NI_NUMERICSERV
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef NI_NUMERICSCOPE
 | 
				
			||||||
 | 
					#undef NI_NUMERICSCOPE
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef NI_DGRAM
 | 
				
			||||||
 | 
					#undef NI_DGRAM
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef NI_MAXHOST
 | 
				
			||||||
 | 
					#undef NI_MAXHOST
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef NI_MAXSERV
 | 
				
			||||||
 | 
					#undef NI_MAXSERV
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Fake struct and function names.
 | 
				
			||||||
 | 
					 * <netdb.h> might declares all or some of them.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					#if defined(HAVE_GETADDRINFO) || defined(HAVE_GETNAMEINFO)
 | 
				
			||||||
 | 
					#define addrinfo my_addrinfo
 | 
				
			||||||
 | 
					#define gai_strerror my_gai_strerror
 | 
				
			||||||
 | 
					#define freeaddrinfo my_freeaddrinfo
 | 
				
			||||||
 | 
					#define getaddrinfo my_getaddrinfo
 | 
				
			||||||
 | 
					#define getnameinfo my_getnameinfo
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/********************************************************************/
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Error codes.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					#define EAI_ADDRFAMILY	1
 | 
				
			||||||
 | 
					#define EAI_AGAIN	2
 | 
				
			||||||
 | 
					#define EAI_BADFLAGS	3
 | 
				
			||||||
 | 
					#define EAI_FAIL	4
 | 
				
			||||||
 | 
					#define EAI_FAMILY	5
 | 
				
			||||||
 | 
					#define EAI_MEMORY	6
 | 
				
			||||||
 | 
					#define EAI_NONAME	7
 | 
				
			||||||
 | 
					#define EAI_OVERFLOW	8
 | 
				
			||||||
 | 
					#define EAI_SERVICE	9
 | 
				
			||||||
 | 
					#define EAI_SOCKTYPE	10
 | 
				
			||||||
 | 
					#define EAI_SYSTEM	11
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Flags for getaddrinfo().
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					#define AI_ADDRCONFIG	0x0001
 | 
				
			||||||
 | 
					#define AI_ALL		0x0002
 | 
				
			||||||
 | 
					#define AI_CANONNAME	0x0004
 | 
				
			||||||
 | 
					#define AI_NUMERICHOST	0x0008
 | 
				
			||||||
 | 
					#define AI_NUMERICSERV	0x0010
 | 
				
			||||||
 | 
					#define AI_PASSIVE	0x0020
 | 
				
			||||||
 | 
					#define AI_V4MAPPED	0x0040
 | 
				
			||||||
 | 
					#define AI_DEFAULT	(AI_V4MAPPED | AI_ADDRCONFIG)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Flags for getnameinfo().
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					#define NI_DGRAM	0x0001
 | 
				
			||||||
 | 
					#define NI_NAMEREQD	0x0002
 | 
				
			||||||
 | 
					#define NI_NOFQDN	0x0004
 | 
				
			||||||
 | 
					#define NI_NUMERICHOST	0x0008
 | 
				
			||||||
 | 
					#define NI_NUMERICSCOPE	0x0010
 | 
				
			||||||
 | 
					#define NI_NUMERICSERV	0x0020
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Maximum length of FQDN and servie name for getnameinfo().
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					#define NI_MAXHOST	1025
 | 
				
			||||||
 | 
					#define NI_MAXSERV	32
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Address families and Protocol families.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					#ifndef AF_UNSPEC
 | 
				
			||||||
 | 
					#define AF_UNSPEC AF_INET
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifndef PF_UNSPEC
 | 
				
			||||||
 | 
					#define PF_UNSPEC PF_INET
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * struct addrinfo.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					struct addrinfo {
 | 
				
			||||||
 | 
					    int ai_flags;
 | 
				
			||||||
 | 
					    int ai_family;
 | 
				
			||||||
 | 
					    int ai_socktype;
 | 
				
			||||||
 | 
					    int ai_protocol;
 | 
				
			||||||
 | 
					    socklen_t ai_addrlen;
 | 
				
			||||||
 | 
					    char *ai_canonname;
 | 
				
			||||||
 | 
					    struct sockaddr *ai_addr;
 | 
				
			||||||
 | 
					    struct addrinfo *ai_next;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Functions.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					#ifdef __STDC__
 | 
				
			||||||
 | 
					const char *gai_strerror(int);
 | 
				
			||||||
 | 
					void freeaddrinfo(struct addrinfo *);
 | 
				
			||||||
 | 
					int getaddrinfo(const char *, const char *, const struct addrinfo *,
 | 
				
			||||||
 | 
					    struct addrinfo **);
 | 
				
			||||||
 | 
					int getnameinfo(const struct sockaddr *, socklen_t, char *,
 | 
				
			||||||
 | 
					    socklen_t, char *, socklen_t, int);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					const char *gai_strerror();
 | 
				
			||||||
 | 
					void freeaddrinfo();
 | 
				
			||||||
 | 
					int getaddrinfo();
 | 
				
			||||||
 | 
					int getnameinfo();
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					#endif /* __cplusplus */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* not _D_GETADDRINFO_H */
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,69 @@
 | 
				
			||||||
 | 
					/* <!-- copyright */
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * aria2 - The high speed download utility
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Copyright (C) 2006 Tatsuhiro Tsujikawa
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is free software; you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation; either version 2 of the License, or
 | 
				
			||||||
 | 
					 * (at your option) any later version.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program; if not, write to the Free Software
 | 
				
			||||||
 | 
					 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * In addition, as a special exception, the copyright holders give
 | 
				
			||||||
 | 
					 * permission to link the code of portions of this program with the
 | 
				
			||||||
 | 
					 * OpenSSL library under certain conditions as described in each
 | 
				
			||||||
 | 
					 * individual source file, and distribute linked combinations
 | 
				
			||||||
 | 
					 * including the two.
 | 
				
			||||||
 | 
					 * You must obey the GNU General Public License in all respects
 | 
				
			||||||
 | 
					 * for all of the code used other than OpenSSL.  If you modify
 | 
				
			||||||
 | 
					 * file(s) with this exception, you may extend this exception to your
 | 
				
			||||||
 | 
					 * version of the file(s), but you are not obligated to do so.  If you
 | 
				
			||||||
 | 
					 * do not wish to do so, delete this exception statement from your
 | 
				
			||||||
 | 
					 * version.  If you delete this exception statement from all source
 | 
				
			||||||
 | 
					 * files in the program, then also delete it here.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					/* copyright --> */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef HAVE_CONFIG_H
 | 
				
			||||||
 | 
					# include "config.h"
 | 
				
			||||||
 | 
					#endif // HAVE_CONFIG_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __MINGW32__
 | 
				
			||||||
 | 
					# define _WIN32_WINNT 0x501
 | 
				
			||||||
 | 
					# include <winsock2.h>
 | 
				
			||||||
 | 
					# undef ERROR
 | 
				
			||||||
 | 
					# include <ws2tcpip.h>
 | 
				
			||||||
 | 
					#endif // __MINGW32__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef HAVE_NETDB_H
 | 
				
			||||||
 | 
					# include <netdb.h>
 | 
				
			||||||
 | 
					#endif // HAVE_NETDB_H
 | 
				
			||||||
 | 
					#ifdef HAVE_SYS_SOCKET_H
 | 
				
			||||||
 | 
					# include <sys/socket.h>
 | 
				
			||||||
 | 
					#endif // HAVE_SYS_SOCKET_H
 | 
				
			||||||
 | 
					#ifdef HAVE_NETINET_IN_H
 | 
				
			||||||
 | 
					# include <netinet/in.h>
 | 
				
			||||||
 | 
					#endif // HAVE_NETINET_IN_H
 | 
				
			||||||
 | 
					#ifdef HAVE_ARPA_INET_H
 | 
				
			||||||
 | 
					# include <arpa/inet.h>
 | 
				
			||||||
 | 
					#endif // HAVE_ARPA_INET_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int inet_aton(const char *cp, struct in_addr *inp) {
 | 
				
			||||||
 | 
						unsigned long res = inet_addr(cp);
 | 
				
			||||||
 | 
						if (res == INADDR_NONE && strcmp(cp, "255.255.255.255"))
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
						if (inp)
 | 
				
			||||||
 | 
							inp->s_addr = res;
 | 
				
			||||||
 | 
						return 1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,75 @@
 | 
				
			||||||
 | 
					/* <!-- copyright */
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * aria2 - The high speed download utility
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Copyright (C) 2006 Tatsuhiro Tsujikawa
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is free software; you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation; either version 2 of the License, or
 | 
				
			||||||
 | 
					 * (at your option) any later version.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program; if not, write to the Free Software
 | 
				
			||||||
 | 
					 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * In addition, as a special exception, the copyright holders give
 | 
				
			||||||
 | 
					 * permission to link the code of portions of this program with the
 | 
				
			||||||
 | 
					 * OpenSSL library under certain conditions as described in each
 | 
				
			||||||
 | 
					 * individual source file, and distribute linked combinations
 | 
				
			||||||
 | 
					 * including the two.
 | 
				
			||||||
 | 
					 * You must obey the GNU General Public License in all respects
 | 
				
			||||||
 | 
					 * for all of the code used other than OpenSSL.  If you modify
 | 
				
			||||||
 | 
					 * file(s) with this exception, you may extend this exception to your
 | 
				
			||||||
 | 
					 * version of the file(s), but you are not obligated to do so.  If you
 | 
				
			||||||
 | 
					 * do not wish to do so, delete this exception statement from your
 | 
				
			||||||
 | 
					 * version.  If you delete this exception statement from all source
 | 
				
			||||||
 | 
					 * files in the program, then also delete it here.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					/* copyright --> */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _D_INET_ATON_H
 | 
				
			||||||
 | 
					#define _D_INET_ATON_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					extern "C" {
 | 
				
			||||||
 | 
					#endif /* __cplusplus */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef HAVE_CONFIG_H
 | 
				
			||||||
 | 
					# include "config.h"
 | 
				
			||||||
 | 
					#endif // HAVE_CONFIG_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __MINGW32__
 | 
				
			||||||
 | 
					# ifndef _WIN32_WINNT
 | 
				
			||||||
 | 
					#  define _WIN32_WINNT 0x501
 | 
				
			||||||
 | 
					# endif // _WIN32_WINNT
 | 
				
			||||||
 | 
					# include <winsock2.h>
 | 
				
			||||||
 | 
					# undef ERROR
 | 
				
			||||||
 | 
					# include <ws2tcpip.h>
 | 
				
			||||||
 | 
					#endif // __MINGW32__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef HAVE_NETDB_H
 | 
				
			||||||
 | 
					# include <netdb.h>
 | 
				
			||||||
 | 
					#endif // HAVE_NETDB_H
 | 
				
			||||||
 | 
					#ifdef HAVE_SYS_SOCKET_H
 | 
				
			||||||
 | 
					# include <sys/socket.h>
 | 
				
			||||||
 | 
					#endif // HAVE_SYS_SOCKET_H
 | 
				
			||||||
 | 
					#ifdef HAVE_NETINET_IN_H
 | 
				
			||||||
 | 
					# include <netinet/in.h>
 | 
				
			||||||
 | 
					#endif // HAVE_NETINET_IN_H
 | 
				
			||||||
 | 
					#ifdef HAVE_ARPA_INET_H
 | 
				
			||||||
 | 
					# include <arpa/inet.h>
 | 
				
			||||||
 | 
					#endif // HAVE_ARPA_INET_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int inet_aton(const char *cp, struct in_addr *inp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					#endif /* __cplusplus */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* not _D_INET_ATON_H */
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,89 @@
 | 
				
			||||||
 | 
					/* <!-- copyright */
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * aria2 - The high speed download utility
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Copyright (C) 2006 Tatsuhiro Tsujikawa
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is free software; you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation; either version 2 of the License, or
 | 
				
			||||||
 | 
					 * (at your option) any later version.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program; if not, write to the Free Software
 | 
				
			||||||
 | 
					 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * In addition, as a special exception, the copyright holders give
 | 
				
			||||||
 | 
					 * permission to link the code of portions of this program with the
 | 
				
			||||||
 | 
					 * OpenSSL library under certain conditions as described in each
 | 
				
			||||||
 | 
					 * individual source file, and distribute linked combinations
 | 
				
			||||||
 | 
					 * including the two.
 | 
				
			||||||
 | 
					 * You must obey the GNU General Public License in all respects
 | 
				
			||||||
 | 
					 * for all of the code used other than OpenSSL.  If you modify
 | 
				
			||||||
 | 
					 * file(s) with this exception, you may extend this exception to your
 | 
				
			||||||
 | 
					 * version of the file(s), but you are not obligated to do so.  If you
 | 
				
			||||||
 | 
					 * do not wish to do so, delete this exception statement from your
 | 
				
			||||||
 | 
					 * version.  If you delete this exception statement from all source
 | 
				
			||||||
 | 
					 * files in the program, then also delete it here.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					/* copyright --> */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					#include <libgen.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined(__CYGWIN__) || defined(__DJGPP__) || defined(__MINGW32__)
 | 
				
			||||||
 | 
					# define IS_PATH_SEPARATOR(c) (((c) == '/') || ((c) == '\\'))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define IS_PATH_SEPARATOR(c) ((c) == '/')
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* per http://www.scit.wlv.ac.uk/cgi-bin/mansec?3C+basename */
 | 
				
			||||||
 | 
					char* basename(char* s) {
 | 
				
			||||||
 | 
						char* rv;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!s || !*s)
 | 
				
			||||||
 | 
							return ".";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						rv = s + strlen(s) - 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						do {
 | 
				
			||||||
 | 
							if (IS_PATH_SEPARATOR(*rv))
 | 
				
			||||||
 | 
								return rv + 1;
 | 
				
			||||||
 | 
							--rv;
 | 
				
			||||||
 | 
						} while (rv >= s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return s;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* per http://www.scit.wlv.ac.uk/cgi-bin/mansec?3C+dirname */
 | 
				
			||||||
 | 
					char* dirname(char* path) {
 | 
				
			||||||
 | 
						char *p;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (path == NULL || *path == '\0')
 | 
				
			||||||
 | 
							return ".";
 | 
				
			||||||
 | 
						p = path + strlen(path) - 1;
 | 
				
			||||||
 | 
						while (IS_PATH_SEPARATOR(*p)) {
 | 
				
			||||||
 | 
							if (p == path)
 | 
				
			||||||
 | 
								return path;
 | 
				
			||||||
 | 
							*p-- = '\0';
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						while (p >= path && !IS_PATH_SEPARATOR(*p))
 | 
				
			||||||
 | 
							p--;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (p < path)
 | 
				
			||||||
 | 
							return ".";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (p == path)
 | 
				
			||||||
 | 
							return "/";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						*p = '\0';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return path;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,60 @@
 | 
				
			||||||
 | 
					/* <!-- copyright */
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * aria2 - The high speed download utility
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Copyright (C) 2006 Tatsuhiro Tsujikawa
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is free software; you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation; either version 2 of the License, or
 | 
				
			||||||
 | 
					 * (at your option) any later version.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program; if not, write to the Free Software
 | 
				
			||||||
 | 
					 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * In addition, as a special exception, the copyright holders give
 | 
				
			||||||
 | 
					 * permission to link the code of portions of this program with the
 | 
				
			||||||
 | 
					 * OpenSSL library under certain conditions as described in each
 | 
				
			||||||
 | 
					 * individual source file, and distribute linked combinations
 | 
				
			||||||
 | 
					 * including the two.
 | 
				
			||||||
 | 
					 * You must obey the GNU General Public License in all respects
 | 
				
			||||||
 | 
					 * for all of the code used other than OpenSSL.  If you modify
 | 
				
			||||||
 | 
					 * file(s) with this exception, you may extend this exception to your
 | 
				
			||||||
 | 
					 * version of the file(s), but you are not obligated to do so.  If you
 | 
				
			||||||
 | 
					 * do not wish to do so, delete this exception statement from your
 | 
				
			||||||
 | 
					 * version.  If you delete this exception statement from all source
 | 
				
			||||||
 | 
					 * files in the program, then also delete it here.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					/* copyright --> */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _D_LIBGEN_H
 | 
				
			||||||
 | 
					#define _D_LIBGEN_H 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					extern "C" {
 | 
				
			||||||
 | 
					#endif /* __cplusplus */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __MINGW32__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					char *basename (char *path);
 | 
				
			||||||
 | 
					char *dirname (char *path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					char *basename (const char *path);
 | 
				
			||||||
 | 
					char *dirname (const char *path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // __MINGW32__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					#endif /* __cplusplus */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* not _D_LIBGEN_H */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,61 @@
 | 
				
			||||||
 | 
					/* <!-- copyright */
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * aria2 - The high speed download utility
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Copyright (C) 2007 Tatsuhiro Tsujikawa
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is free software; you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation; either version 2 of the License, or
 | 
				
			||||||
 | 
					 * (at your option) any later version.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program; if not, write to the Free Software
 | 
				
			||||||
 | 
					 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * In addition, as a special exception, the copyright holders give
 | 
				
			||||||
 | 
					 * permission to link the code of portions of this program with the
 | 
				
			||||||
 | 
					 * OpenSSL library under certain conditions as described in each
 | 
				
			||||||
 | 
					 * individual source file, and distribute linked combinations
 | 
				
			||||||
 | 
					 * including the two.
 | 
				
			||||||
 | 
					 * You must obey the GNU General Public License in all respects
 | 
				
			||||||
 | 
					 * for all of the code used other than OpenSSL.  If you modify
 | 
				
			||||||
 | 
					 * file(s) with this exception, you may extend this exception to your
 | 
				
			||||||
 | 
					 * version of the file(s), but you are not obligated to do so.  If you
 | 
				
			||||||
 | 
					 * do not wish to do so, delete this exception statement from your
 | 
				
			||||||
 | 
					 * version.  If you delete this exception statement from all source
 | 
				
			||||||
 | 
					 * files in the program, then also delete it here.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					/* copyright --> */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <time.h>
 | 
				
			||||||
 | 
					#ifdef __MINGW32__
 | 
				
			||||||
 | 
					#include <windows.h>
 | 
				
			||||||
 | 
					#endif // __MINGW32__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "localtime_r.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct tm * localtime_r(const time_t *clock, struct tm *result)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						static struct tm *local_tm;
 | 
				
			||||||
 | 
					#ifdef __MINGW32__
 | 
				
			||||||
 | 
						static CRITICAL_SECTION cs;
 | 
				
			||||||
 | 
						static int initialized = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!initialized) {
 | 
				
			||||||
 | 
							++initialized;
 | 
				
			||||||
 | 
							InitializeCriticalSection(&cs);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						EnterCriticalSection(&cs);
 | 
				
			||||||
 | 
						local_tm = localtime(clock);
 | 
				
			||||||
 | 
						memcpy(result, local_tm, sizeof(struct tm));
 | 
				
			||||||
 | 
						LeaveCriticalSection(&cs);
 | 
				
			||||||
 | 
					#endif // __MINGW32__
 | 
				
			||||||
 | 
						return result;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,51 @@
 | 
				
			||||||
 | 
					/* <!-- copyright */
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * aria2 - The high speed download utility
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Copyright (C) 2007 Tatsuhiro Tsujikawa
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is free software; you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation; either version 2 of the License, or
 | 
				
			||||||
 | 
					 * (at your option) any later version.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program; if not, write to the Free Software
 | 
				
			||||||
 | 
					 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * In addition, as a special exception, the copyright holders give
 | 
				
			||||||
 | 
					 * permission to link the code of portions of this program with the
 | 
				
			||||||
 | 
					 * OpenSSL library under certain conditions as described in each
 | 
				
			||||||
 | 
					 * individual source file, and distribute linked combinations
 | 
				
			||||||
 | 
					 * including the two.
 | 
				
			||||||
 | 
					 * You must obey the GNU General Public License in all respects
 | 
				
			||||||
 | 
					 * for all of the code used other than OpenSSL.  If you modify
 | 
				
			||||||
 | 
					 * file(s) with this exception, you may extend this exception to your
 | 
				
			||||||
 | 
					 * version of the file(s), but you are not obligated to do so.  If you
 | 
				
			||||||
 | 
					 * do not wish to do so, delete this exception statement from your
 | 
				
			||||||
 | 
					 * version.  If you delete this exception statement from all source
 | 
				
			||||||
 | 
					 * files in the program, then also delete it here.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					/* copyright --> */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _D_LOCALTIME_R_H
 | 
				
			||||||
 | 
					#define _D_LOCALTIME_R_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					extern "C" {
 | 
				
			||||||
 | 
					#endif /* __cplusplus */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <time.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct tm * localtime_r(const time_t *clock, struct tm *result);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					#endif /* __cplusplus */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* not _D_LOCALTIME_R_H */
 | 
				
			||||||
							
								
								
									
										21
									
								
								src/main.cc
								
								
								
								
							
							
						
						
									
										21
									
								
								src/main.cc
								
								
								
								
							| 
						 | 
					@ -54,6 +54,8 @@
 | 
				
			||||||
#include "CookieBoxFactory.h"
 | 
					#include "CookieBoxFactory.h"
 | 
				
			||||||
#include "a2algo.h"
 | 
					#include "a2algo.h"
 | 
				
			||||||
#include "message.h"
 | 
					#include "message.h"
 | 
				
			||||||
 | 
					#include "a2io.h"
 | 
				
			||||||
 | 
					#include "Platform.h"
 | 
				
			||||||
#include <deque>
 | 
					#include <deque>
 | 
				
			||||||
#include <algorithm>
 | 
					#include <algorithm>
 | 
				
			||||||
#include <time.h>
 | 
					#include <time.h>
 | 
				
			||||||
| 
						 | 
					@ -124,7 +126,9 @@ void showUsage() {
 | 
				
			||||||
  cout << _(" -o, --out=FILE               The file name for downloaded file.") << endl;
 | 
					  cout << _(" -o, --out=FILE               The file name for downloaded file.") << endl;
 | 
				
			||||||
  cout << _(" -l, --log=LOG                The file path to store log. If '-' is specified,\n"
 | 
					  cout << _(" -l, --log=LOG                The file path to store log. If '-' is specified,\n"
 | 
				
			||||||
	    "                              log is written to stdout.") << endl;
 | 
						    "                              log is written to stdout.") << endl;
 | 
				
			||||||
 | 
					#ifdef HAVE_DAEMON
 | 
				
			||||||
  cout << _(" -D, --daemon                 Run as daemon.") << endl;
 | 
					  cout << _(" -D, --daemon                 Run as daemon.") << endl;
 | 
				
			||||||
 | 
					#endif // HAVE_DAEMON
 | 
				
			||||||
  cout << _(" -s, --split=N                Download a file using N connections. N must be\n"
 | 
					  cout << _(" -s, --split=N                Download a file using N connections. N must be\n"
 | 
				
			||||||
	    "                              between 1 and 5. This option affects all URLs.\n"
 | 
						    "                              between 1 and 5. This option affects all URLs.\n"
 | 
				
			||||||
	    "                              Thus, aria2 connects to each URL with\n"
 | 
						    "                              Thus, aria2 connects to each URL with\n"
 | 
				
			||||||
| 
						 | 
					@ -323,6 +327,10 @@ void showUsage() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(int argc, char* argv[]) {
 | 
					int main(int argc, char* argv[]) {
 | 
				
			||||||
 | 
					#ifdef HAVE_WINSOCK2_H
 | 
				
			||||||
 | 
					  Platform platform;
 | 
				
			||||||
 | 
					#endif // HAVE_WINSOCK2_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef ENABLE_NLS
 | 
					#ifdef ENABLE_NLS
 | 
				
			||||||
  setlocale (LC_CTYPE, "");
 | 
					  setlocale (LC_CTYPE, "");
 | 
				
			||||||
  setlocale (LC_MESSAGES, "");
 | 
					  setlocale (LC_MESSAGES, "");
 | 
				
			||||||
| 
						 | 
					@ -388,7 +396,9 @@ int main(int argc, char* argv[]) {
 | 
				
			||||||
    int32_t optIndex = 0;
 | 
					    int32_t optIndex = 0;
 | 
				
			||||||
    int32_t lopt;
 | 
					    int32_t lopt;
 | 
				
			||||||
    static struct option longOpts[] = {
 | 
					    static struct option longOpts[] = {
 | 
				
			||||||
 | 
					#ifdef HAVE_DAEMON
 | 
				
			||||||
      { "daemon", no_argument, NULL, 'D' },
 | 
					      { "daemon", no_argument, NULL, 'D' },
 | 
				
			||||||
 | 
					#endif // HAVE_DAEMON
 | 
				
			||||||
      { "dir", required_argument, NULL, 'd' },
 | 
					      { "dir", required_argument, NULL, 'd' },
 | 
				
			||||||
      { "out", required_argument, NULL, 'o' },
 | 
					      { "out", required_argument, NULL, 'o' },
 | 
				
			||||||
      { "log", required_argument, NULL, 'l' },
 | 
					      { "log", required_argument, NULL, 'l' },
 | 
				
			||||||
| 
						 | 
					@ -565,9 +575,11 @@ int main(int argc, char* argv[]) {
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					#ifdef HAVE_DAEMON
 | 
				
			||||||
    case 'D':
 | 
					    case 'D':
 | 
				
			||||||
      cmdstream << PREF_DAEMON << "=" << V_TRUE << "\n";
 | 
					      cmdstream << PREF_DAEMON << "=" << V_TRUE << "\n";
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					#endif // HAVE_DAEMON
 | 
				
			||||||
    case 'd':
 | 
					    case 'd':
 | 
				
			||||||
      cmdstream << PREF_DIR << "=" << optarg << "\n";
 | 
					      cmdstream << PREF_DIR << "=" << optarg << "\n";
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
| 
						 | 
					@ -670,12 +682,14 @@ int main(int argc, char* argv[]) {
 | 
				
			||||||
      exit(EXIT_FAILURE);
 | 
					      exit(EXIT_FAILURE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					#ifdef HAVE_DAEMON
 | 
				
			||||||
  if(op->getAsBool(PREF_DAEMON)) {
 | 
					  if(op->getAsBool(PREF_DAEMON)) {
 | 
				
			||||||
    if(daemon(1, 1) < 0) {
 | 
					    if(daemon(1, 1) < 0) {
 | 
				
			||||||
      perror(MSG_DAEMON_FAILED);
 | 
					      perror(MSG_DAEMON_FAILED);
 | 
				
			||||||
      exit(EXIT_FAILURE);
 | 
					      exit(EXIT_FAILURE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					#endif // HAVE_DAEMON
 | 
				
			||||||
  Strings args(argv+optind, argv+argc);
 | 
					  Strings args(argv+optind, argv+argc);
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
#ifdef HAVE_LIBSSL
 | 
					#ifdef HAVE_LIBSSL
 | 
				
			||||||
| 
						 | 
					@ -693,11 +707,11 @@ int main(int argc, char* argv[]) {
 | 
				
			||||||
  BitfieldManFactory::setDefaultRandomizer(SimpleRandomizer::getInstance());
 | 
					  BitfieldManFactory::setDefaultRandomizer(SimpleRandomizer::getInstance());
 | 
				
			||||||
  FileAllocationMonitorFactory::setFactory(new ConsoleFileAllocationMonitorFactory());
 | 
					  FileAllocationMonitorFactory::setFactory(new ConsoleFileAllocationMonitorFactory());
 | 
				
			||||||
  if(op->getAsBool(PREF_STDOUT_LOG)) {
 | 
					  if(op->getAsBool(PREF_STDOUT_LOG)) {
 | 
				
			||||||
    LogFactory::setLogFile("/dev/stdout");
 | 
					    LogFactory::setLogFile(DEV_STDOUT);
 | 
				
			||||||
  } else if(op->get(PREF_LOG).size()) {
 | 
					  } else if(op->get(PREF_LOG).size()) {
 | 
				
			||||||
    LogFactory::setLogFile(op->get(PREF_LOG));
 | 
					    LogFactory::setLogFile(op->get(PREF_LOG));
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    LogFactory::setLogFile("/dev/null");
 | 
					    LogFactory::setLogFile(DEV_NULL);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  int32_t exitStatus = EXIT_SUCCESS;
 | 
					  int32_t exitStatus = EXIT_SUCCESS;
 | 
				
			||||||
  try {
 | 
					  try {
 | 
				
			||||||
| 
						 | 
					@ -736,8 +750,9 @@ int main(int argc, char* argv[]) {
 | 
				
			||||||
    RequestFactorySingletonHolder::instance(requestFactory);
 | 
					    RequestFactorySingletonHolder::instance(requestFactory);
 | 
				
			||||||
    CUIDCounterHandle cuidCounter = new CUIDCounter();
 | 
					    CUIDCounterHandle cuidCounter = new CUIDCounter();
 | 
				
			||||||
    CUIDCounterSingletonHolder::instance(cuidCounter);
 | 
					    CUIDCounterSingletonHolder::instance(cuidCounter);
 | 
				
			||||||
 | 
					#ifdef SIGPIPE
 | 
				
			||||||
    Util::setGlobalSignalHandler(SIGPIPE, SIG_IGN, 0);
 | 
					    Util::setGlobalSignalHandler(SIGPIPE, SIG_IGN, 0);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    RequestInfo* firstReqInfo;
 | 
					    RequestInfo* firstReqInfo;
 | 
				
			||||||
#ifdef ENABLE_BITTORRENT
 | 
					#ifdef ENABLE_BITTORRENT
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -111,7 +111,7 @@
 | 
				
			||||||
#define MSG_DOWNLOAD_COMPLETED _("The download was complete.")
 | 
					#define MSG_DOWNLOAD_COMPLETED _("The download was complete.")
 | 
				
			||||||
#define MSG_REMOVED_HAVE_ENTRY _("Removed %d have entries.")
 | 
					#define MSG_REMOVED_HAVE_ENTRY _("Removed %d have entries.")
 | 
				
			||||||
#define MSG_VALIDATING_FILE _("Validating file %s")
 | 
					#define MSG_VALIDATING_FILE _("Validating file %s")
 | 
				
			||||||
#define MSG_ALLOCATION_COMPLETED _("%d seconds to allocate %lld byte(s)")
 | 
					#define MSG_ALLOCATION_COMPLETED _("%d seconds to allocate %s byte(s)")
 | 
				
			||||||
#define MSG_FILE_ALLOCATION_DISPATCH _("Dispatching FileAllocationCommand for CUID#%d.")
 | 
					#define MSG_FILE_ALLOCATION_DISPATCH _("Dispatching FileAllocationCommand for CUID#%d.")
 | 
				
			||||||
#define MSG_METALINK_QUEUEING _("Metalink: Queueing %s for download.")
 | 
					#define MSG_METALINK_QUEUEING _("Metalink: Queueing %s for download.")
 | 
				
			||||||
#define MSG_FILE_DOWNLOAD_COMPLETED _("Download complete: %s")
 | 
					#define MSG_FILE_DOWNLOAD_COMPLETED _("Download complete: %s")
 | 
				
			||||||
| 
						 | 
					@ -136,10 +136,10 @@
 | 
				
			||||||
#define EX_CONNECTION_FAILED _("Connection failed.")
 | 
					#define EX_CONNECTION_FAILED _("Connection failed.")
 | 
				
			||||||
#define EX_FILENAME_MISMATCH _("The requested filename and the previously registered one are not same. Expected:%s Actual:%s")
 | 
					#define EX_FILENAME_MISMATCH _("The requested filename and the previously registered one are not same. Expected:%s Actual:%s")
 | 
				
			||||||
#define EX_BAD_STATUS _("The response status is not successful. status=%d")
 | 
					#define EX_BAD_STATUS _("The response status is not successful. status=%d")
 | 
				
			||||||
#define EX_TOO_LARGE_FILE _("Too large file size. size=%lld")
 | 
					#define EX_TOO_LARGE_FILE _("Too large file size. size=%s")
 | 
				
			||||||
#define EX_TRANSFER_ENCODING_NOT_SUPPORTED _("Transfer encoding %s is not supported.")
 | 
					#define EX_TRANSFER_ENCODING_NOT_SUPPORTED _("Transfer encoding %s is not supported.")
 | 
				
			||||||
#define EX_SSL_INIT_FAILURE _("SSL initialization failed.")
 | 
					#define EX_SSL_INIT_FAILURE _("SSL initialization failed.")
 | 
				
			||||||
#define EX_SIZE_MISMATCH _("Size mismatch Expected:%lld Actual:%lld")
 | 
					#define EX_SIZE_MISMATCH _("Size mismatch Expected:%s Actual:%s")
 | 
				
			||||||
#define EX_AUTH_FAILED _("Authorization failed.")
 | 
					#define EX_AUTH_FAILED _("Authorization failed.")
 | 
				
			||||||
#define EX_GOT_EOF _("Got EOF from the server.")
 | 
					#define EX_GOT_EOF _("Got EOF from the server.")
 | 
				
			||||||
#define EX_EOF_FROM_PEER _("Got EOF from peer.")
 | 
					#define EX_EOF_FROM_PEER _("Got EOF from peer.")
 | 
				
			||||||
| 
						 | 
					@ -151,7 +151,7 @@
 | 
				
			||||||
#define EX_DATA_READ _("Failed to read data from disk.")
 | 
					#define EX_DATA_READ _("Failed to read data from disk.")
 | 
				
			||||||
#define EX_FILE_SHA1SUM _("Failed to calculate SHA1 digest of or a part of the file %s, cause: %s")
 | 
					#define EX_FILE_SHA1SUM _("Failed to calculate SHA1 digest of or a part of the file %s, cause: %s")
 | 
				
			||||||
#define EX_FILE_SEEK _("Failed to seek the file %s, cause: %s")
 | 
					#define EX_FILE_SEEK _("Failed to seek the file %s, cause: %s")
 | 
				
			||||||
#define EX_FILE_OFFSET_OUT_OF_RANGE _("The offset is out of range, offset=%lld")
 | 
					#define EX_FILE_OFFSET_OUT_OF_RANGE _("The offset is out of range, offset=%s")
 | 
				
			||||||
#define EX_NOT_DIRECTORY _("%s is not a directory.")
 | 
					#define EX_NOT_DIRECTORY _("%s is not a directory.")
 | 
				
			||||||
#define EX_MAKE_DIR _("Failed to make the directory %s, cause: %s")
 | 
					#define EX_MAKE_DIR _("Failed to make the directory %s, cause: %s")
 | 
				
			||||||
#define EX_SEGMENT_FILE_OPEN _("Failed to open the segment file %s, cause: %s")
 | 
					#define EX_SEGMENT_FILE_OPEN _("Failed to open the segment file %s, cause: %s")
 | 
				
			||||||
| 
						 | 
					@ -175,7 +175,7 @@
 | 
				
			||||||
#define EX_FILE_ALREADY_EXISTS _("File %s exists, but %s does not exist.")
 | 
					#define EX_FILE_ALREADY_EXISTS _("File %s exists, but %s does not exist.")
 | 
				
			||||||
#define EX_INVALID_PAYLOAD_SIZE _("Invalid payload size for %s, size=%d. It should be %d.")
 | 
					#define EX_INVALID_PAYLOAD_SIZE _("Invalid payload size for %s, size=%d. It should be %d.")
 | 
				
			||||||
#define EX_INVALID_BT_MESSAGE_ID _("Invalid ID=%d for %s. It should be %d.")
 | 
					#define EX_INVALID_BT_MESSAGE_ID _("Invalid ID=%d for %s. It should be %d.")
 | 
				
			||||||
#define EX_INVALID_CHUNK_CHECKSUM _("Chunk checksum validation failed. checksumIndex=%d, offset=%lld, expectedHash=%s, actualHash=%s")
 | 
					#define EX_INVALID_CHUNK_CHECKSUM _("Chunk checksum validation failed. checksumIndex=%d, offset=%s, expectedHash=%s, actualHash=%s")
 | 
				
			||||||
#define EX_DOWNLOAD_ABORTED _("Download aborted.")
 | 
					#define EX_DOWNLOAD_ABORTED _("Download aborted.")
 | 
				
			||||||
#define EX_DUPLICATE_FILE_DOWNLOAD _("File %s is being downloaded by other command.")
 | 
					#define EX_DUPLICATE_FILE_DOWNLOAD _("File %s is being downloaded by other command.")
 | 
				
			||||||
#define EX_INSUFFICIENT_CHECKSUM _("Insufficient checksums.")
 | 
					#define EX_INSUFFICIENT_CHECKSUM _("Insufficient checksums.")
 | 
				
			||||||
| 
						 | 
					@ -187,7 +187,7 @@
 | 
				
			||||||
#define EX_TOO_SLOW_DOWNLOAD_SPEED _("Too slow Downloading speed: %d <= %d(B/s), host:%s")
 | 
					#define EX_TOO_SLOW_DOWNLOAD_SPEED _("Too slow Downloading speed: %d <= %d(B/s), host:%s")
 | 
				
			||||||
#define EX_NO_HTTP_REQUEST_ENTRY_FOUND _("No HttpRequestEntry found.")
 | 
					#define EX_NO_HTTP_REQUEST_ENTRY_FOUND _("No HttpRequestEntry found.")
 | 
				
			||||||
#define EX_LOCATION_HEADER_REQUIRED _("Got %d status, but no location header provided.")
 | 
					#define EX_LOCATION_HEADER_REQUIRED _("Got %d status, but no location header provided.")
 | 
				
			||||||
#define EX_INVALID_RANGE_HEADER _("Invalid range header. Request: %lld-%lld/%lld, Response: %lld-%lld/%lld")
 | 
					#define EX_INVALID_RANGE_HEADER _("Invalid range header. Request: %s-%s/%s, Response: %s-%s/%s")
 | 
				
			||||||
#define EX_NO_RESULT_WITH_YOUR_PREFS _("No file matched with your preference.")
 | 
					#define EX_NO_RESULT_WITH_YOUR_PREFS _("No file matched with your preference.")
 | 
				
			||||||
#define EX_EXCEPTION_CAUGHT _("Exception caught")
 | 
					#define EX_EXCEPTION_CAUGHT _("Exception caught")
 | 
				
			||||||
#define EX_TOO_LONG_PAYLOAD _("Max payload length exceeded or invalid. length = %d")
 | 
					#define EX_TOO_LONG_PAYLOAD _("Max payload length exceeded or invalid. length = %d")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,8 +40,11 @@
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Constants
 | 
					 * Constants
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					#undef V_TRUE
 | 
				
			||||||
#define V_TRUE "true"
 | 
					#define V_TRUE "true"
 | 
				
			||||||
 | 
					#undef V_FALSE
 | 
				
			||||||
#define V_FALSE "false"
 | 
					#define V_FALSE "false"
 | 
				
			||||||
 | 
					#undef V_NONE
 | 
				
			||||||
#define V_NONE "none"
 | 
					#define V_NONE "none"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,443 @@
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (c) 1999 Kungliga Tekniska Högskolan
 | 
				
			||||||
 | 
					 * (Royal Institute of Technology, Stockholm, Sweden).
 | 
				
			||||||
 | 
					 * All rights reserved.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Redistribution and use in source and binary forms, with or without
 | 
				
			||||||
 | 
					 * modification, are permitted provided that the following conditions
 | 
				
			||||||
 | 
					 * are met:
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * 1. Redistributions of source code must retain the above copyright
 | 
				
			||||||
 | 
					 *    notice, this list of conditions and the following disclaimer.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * 2. Redistributions in binary form must reproduce the above copyright
 | 
				
			||||||
 | 
					 *    notice, this list of conditions and the following disclaimer in the
 | 
				
			||||||
 | 
					 *    documentation and/or other materials provided with the distribution.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * 3. Neither the name of KTH nor the names of its contributors may be
 | 
				
			||||||
 | 
					 *    used to endorse or promote products derived from this software without
 | 
				
			||||||
 | 
					 *    specific prior written permission.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * THIS SOFTWARE IS PROVIDED BY KTH AND ITS CONTRIBUTORS ``AS IS'' AND ANY
 | 
				
			||||||
 | 
					 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
				
			||||||
 | 
					 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 | 
				
			||||||
 | 
					 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KTH OR ITS CONTRIBUTORS BE
 | 
				
			||||||
 | 
					 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 | 
				
			||||||
 | 
					 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 | 
				
			||||||
 | 
					 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 | 
				
			||||||
 | 
					 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 | 
				
			||||||
 | 
					 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 | 
				
			||||||
 | 
					 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 | 
				
			||||||
 | 
					 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stddef.h>
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					#include <time.h>
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					#include <ctype.h>
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "strptime.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const char *abb_weekdays[] = {
 | 
				
			||||||
 | 
					    "Sun",
 | 
				
			||||||
 | 
					    "Mon",
 | 
				
			||||||
 | 
					    "Tue",
 | 
				
			||||||
 | 
					    "Wed",
 | 
				
			||||||
 | 
					    "Thu",
 | 
				
			||||||
 | 
					    "Fri",
 | 
				
			||||||
 | 
					    "Sat",
 | 
				
			||||||
 | 
					    NULL
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const char *full_weekdays[] = {
 | 
				
			||||||
 | 
					    "Sunday",
 | 
				
			||||||
 | 
					    "Monday",
 | 
				
			||||||
 | 
					    "Tuesday",
 | 
				
			||||||
 | 
					    "Wednesday",
 | 
				
			||||||
 | 
					    "Thursday",
 | 
				
			||||||
 | 
					    "Friday",
 | 
				
			||||||
 | 
					    "Saturday",
 | 
				
			||||||
 | 
					    NULL
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const char *abb_month[] = {
 | 
				
			||||||
 | 
					    "Jan",
 | 
				
			||||||
 | 
					    "Feb",
 | 
				
			||||||
 | 
					    "Mar",
 | 
				
			||||||
 | 
					    "Apr",
 | 
				
			||||||
 | 
					    "May",
 | 
				
			||||||
 | 
					    "Jun",
 | 
				
			||||||
 | 
					    "Jul",
 | 
				
			||||||
 | 
					    "Aug",
 | 
				
			||||||
 | 
					    "Sep",
 | 
				
			||||||
 | 
					    "Oct",
 | 
				
			||||||
 | 
					    "Nov",
 | 
				
			||||||
 | 
					    "Dec",
 | 
				
			||||||
 | 
					    NULL
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const char *full_month[] = {
 | 
				
			||||||
 | 
					    "January",
 | 
				
			||||||
 | 
					    "February",
 | 
				
			||||||
 | 
					    "March",
 | 
				
			||||||
 | 
					    "April",
 | 
				
			||||||
 | 
					    "May",
 | 
				
			||||||
 | 
					    "June",
 | 
				
			||||||
 | 
					    "July",
 | 
				
			||||||
 | 
					    "August",
 | 
				
			||||||
 | 
					    "September",
 | 
				
			||||||
 | 
					    "October",
 | 
				
			||||||
 | 
					    "November",
 | 
				
			||||||
 | 
					    "December",
 | 
				
			||||||
 | 
					    NULL,
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const char *ampm[] = {
 | 
				
			||||||
 | 
					    "am",
 | 
				
			||||||
 | 
					    "pm",
 | 
				
			||||||
 | 
					    NULL
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * tm_year is relative this year
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					const int tm_year_base = 1900;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Return TRUE iff `year' was a leap year.
 | 
				
			||||||
 | 
					 * Needed for strptime.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					is_leap_year (int year)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return (year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Needed for strptime. */
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					match_string (const char **buf, const char **strs)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    int i = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (i = 0; strs[i] != NULL; ++i) {
 | 
				
			||||||
 | 
						int len = strlen (strs[i]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (strncasecmp (*buf, strs[i], len) == 0) {
 | 
				
			||||||
 | 
						    *buf += len;
 | 
				
			||||||
 | 
						    return i;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return -1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Needed for strptime. */
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					first_day (int year)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    int ret = 4;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (; year > 1970; --year)
 | 
				
			||||||
 | 
						ret = (ret + 365 + is_leap_year (year) ? 1 : 0) % 7;
 | 
				
			||||||
 | 
					    return ret;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Set `timeptr' given `wnum' (week number [0, 53])
 | 
				
			||||||
 | 
					 * Needed for strptime
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					set_week_number_sun (struct tm *timeptr, int wnum)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    int fday = first_day (timeptr->tm_year + tm_year_base);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    timeptr->tm_yday = wnum * 7 + timeptr->tm_wday - fday;
 | 
				
			||||||
 | 
					    if (timeptr->tm_yday < 0) {
 | 
				
			||||||
 | 
						timeptr->tm_wday = fday;
 | 
				
			||||||
 | 
						timeptr->tm_yday = 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Set `timeptr' given `wnum' (week number [0, 53])
 | 
				
			||||||
 | 
					 * Needed for strptime
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					set_week_number_mon (struct tm *timeptr, int wnum)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    int fday = (first_day (timeptr->tm_year + tm_year_base) + 6) % 7;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    timeptr->tm_yday = wnum * 7 + (timeptr->tm_wday + 6) % 7 - fday;
 | 
				
			||||||
 | 
					    if (timeptr->tm_yday < 0) {
 | 
				
			||||||
 | 
						timeptr->tm_wday = (fday + 1) % 7;
 | 
				
			||||||
 | 
						timeptr->tm_yday = 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Set `timeptr' given `wnum' (week number [0, 53])
 | 
				
			||||||
 | 
					 * Needed for strptime
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					set_week_number_mon4 (struct tm *timeptr, int wnum)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    int fday = (first_day (timeptr->tm_year + tm_year_base) + 6) % 7;
 | 
				
			||||||
 | 
					    int offset = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (fday < 4)
 | 
				
			||||||
 | 
						offset += 7;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    timeptr->tm_yday = offset + (wnum - 1) * 7 + timeptr->tm_wday - fday;
 | 
				
			||||||
 | 
					    if (timeptr->tm_yday < 0) {
 | 
				
			||||||
 | 
						timeptr->tm_wday = fday;
 | 
				
			||||||
 | 
						timeptr->tm_yday = 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* strptime: roken */
 | 
				
			||||||
 | 
					//extern "C"
 | 
				
			||||||
 | 
					char *
 | 
				
			||||||
 | 
					strptime (const char *buf, const char *format, struct tm *timeptr)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    char c;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (; (c = *format) != '\0'; ++format) {
 | 
				
			||||||
 | 
						char *s;
 | 
				
			||||||
 | 
						int ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (isspace (c)) {
 | 
				
			||||||
 | 
						    while (isspace (*buf))
 | 
				
			||||||
 | 
							++buf;
 | 
				
			||||||
 | 
						} else if (c == '%' && format[1] != '\0') {
 | 
				
			||||||
 | 
						    c = *++format;
 | 
				
			||||||
 | 
						    if (c == 'E' || c == 'O')
 | 
				
			||||||
 | 
							c = *++format;
 | 
				
			||||||
 | 
						    switch (c) {
 | 
				
			||||||
 | 
						    case 'A' :
 | 
				
			||||||
 | 
							ret = match_string (&buf, full_weekdays);
 | 
				
			||||||
 | 
							if (ret < 0)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							timeptr->tm_wday = ret;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'a' :
 | 
				
			||||||
 | 
							ret = match_string (&buf, abb_weekdays);
 | 
				
			||||||
 | 
							if (ret < 0)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							timeptr->tm_wday = ret;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'B' :
 | 
				
			||||||
 | 
							ret = match_string (&buf, full_month);
 | 
				
			||||||
 | 
							if (ret < 0)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							timeptr->tm_mon = ret;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'b' :
 | 
				
			||||||
 | 
						    case 'h' :
 | 
				
			||||||
 | 
							ret = match_string (&buf, abb_month);
 | 
				
			||||||
 | 
							if (ret < 0)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							timeptr->tm_mon = ret;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'C' :
 | 
				
			||||||
 | 
							ret = strtol (buf, &s, 10);
 | 
				
			||||||
 | 
							if (s == buf)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							timeptr->tm_year = (ret * 100) - tm_year_base;
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'c' :		/* %a %b %e %H:%M:%S %Y */
 | 
				
			||||||
 | 
							s = strptime (buf, "%a %b %e %H:%M:%S %Y", timeptr);
 | 
				
			||||||
 | 
							if (s == NULL)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'D' :		/* %m/%d/%y */
 | 
				
			||||||
 | 
							s = strptime (buf, "%m/%d/%y", timeptr);
 | 
				
			||||||
 | 
							if (s == NULL)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'd' :
 | 
				
			||||||
 | 
						    case 'e' :
 | 
				
			||||||
 | 
							ret = strtol (buf, &s, 10);
 | 
				
			||||||
 | 
							if (s == buf)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							timeptr->tm_mday = ret;
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'H' :
 | 
				
			||||||
 | 
						    case 'k' :
 | 
				
			||||||
 | 
							ret = strtol (buf, &s, 10);
 | 
				
			||||||
 | 
							if (s == buf)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							timeptr->tm_hour = ret;
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'I' :
 | 
				
			||||||
 | 
						    case 'l' :
 | 
				
			||||||
 | 
							ret = strtol (buf, &s, 10);
 | 
				
			||||||
 | 
							if (s == buf)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							if (ret == 12)
 | 
				
			||||||
 | 
							    timeptr->tm_hour = 0;
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
							    timeptr->tm_hour = ret;
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'j' :
 | 
				
			||||||
 | 
							ret = strtol (buf, &s, 10);
 | 
				
			||||||
 | 
							if (s == buf)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							timeptr->tm_yday = ret - 1;
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'm' :
 | 
				
			||||||
 | 
							ret = strtol (buf, &s, 10);
 | 
				
			||||||
 | 
							if (s == buf)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							timeptr->tm_mon = ret - 1;
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'M' :
 | 
				
			||||||
 | 
							ret = strtol (buf, &s, 10);
 | 
				
			||||||
 | 
							if (s == buf)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							timeptr->tm_min = ret;
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'n' :
 | 
				
			||||||
 | 
							if (*buf == '\n')
 | 
				
			||||||
 | 
							    ++buf;
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'p' :
 | 
				
			||||||
 | 
							ret = match_string (&buf, ampm);
 | 
				
			||||||
 | 
							if (ret < 0)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							if (timeptr->tm_hour == 0) {
 | 
				
			||||||
 | 
							    if (ret == 1)
 | 
				
			||||||
 | 
								timeptr->tm_hour = 12;
 | 
				
			||||||
 | 
							} else
 | 
				
			||||||
 | 
							    timeptr->tm_hour += 12;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'r' :		/* %I:%M:%S %p */
 | 
				
			||||||
 | 
							s = strptime (buf, "%I:%M:%S %p", timeptr);
 | 
				
			||||||
 | 
							if (s == NULL)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'R' :		/* %H:%M */
 | 
				
			||||||
 | 
							s = strptime (buf, "%H:%M", timeptr);
 | 
				
			||||||
 | 
							if (s == NULL)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'S' :
 | 
				
			||||||
 | 
							ret = strtol (buf, &s, 10);
 | 
				
			||||||
 | 
							if (s == buf)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							timeptr->tm_sec = ret;
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 't' :
 | 
				
			||||||
 | 
							if (*buf == '\t')
 | 
				
			||||||
 | 
							    ++buf;
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'T' :		/* %H:%M:%S */
 | 
				
			||||||
 | 
						    case 'X' :
 | 
				
			||||||
 | 
							s = strptime (buf, "%H:%M:%S", timeptr);
 | 
				
			||||||
 | 
							if (s == NULL)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'u' :
 | 
				
			||||||
 | 
							ret = strtol (buf, &s, 10);
 | 
				
			||||||
 | 
							if (s == buf)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							timeptr->tm_wday = ret - 1;
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'w' :
 | 
				
			||||||
 | 
							ret = strtol (buf, &s, 10);
 | 
				
			||||||
 | 
							if (s == buf)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							timeptr->tm_wday = ret;
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'U' :
 | 
				
			||||||
 | 
							ret = strtol (buf, &s, 10);
 | 
				
			||||||
 | 
							if (s == buf)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							set_week_number_sun (timeptr, ret);
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'V' :
 | 
				
			||||||
 | 
							ret = strtol (buf, &s, 10);
 | 
				
			||||||
 | 
							if (s == buf)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							set_week_number_mon4 (timeptr, ret);
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'W' :
 | 
				
			||||||
 | 
							ret = strtol (buf, &s, 10);
 | 
				
			||||||
 | 
							if (s == buf)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							set_week_number_mon (timeptr, ret);
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'x' :
 | 
				
			||||||
 | 
							s = strptime (buf, "%Y:%m:%d", timeptr);
 | 
				
			||||||
 | 
							if (s == NULL)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'y' :
 | 
				
			||||||
 | 
							ret = strtol (buf, &s, 10);
 | 
				
			||||||
 | 
							if (s == buf)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							if (ret < 70)
 | 
				
			||||||
 | 
							    timeptr->tm_year = 100 + ret;
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
							    timeptr->tm_year = ret;
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'Y' :
 | 
				
			||||||
 | 
							ret = strtol (buf, &s, 10);
 | 
				
			||||||
 | 
							if (s == buf)
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							timeptr->tm_year = ret - tm_year_base;
 | 
				
			||||||
 | 
							buf = s;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case 'Z' :
 | 
				
			||||||
 | 
							/* Unsupported. Just ignore.  */
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    case '\0' :
 | 
				
			||||||
 | 
							--format;
 | 
				
			||||||
 | 
							/* FALLTHROUGH */
 | 
				
			||||||
 | 
						    case '%' :
 | 
				
			||||||
 | 
							if (*buf == '%')
 | 
				
			||||||
 | 
							    ++buf;
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    default :
 | 
				
			||||||
 | 
							if (*buf == '%' || *++buf == c)
 | 
				
			||||||
 | 
							    ++buf;
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
							    return NULL;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						    }
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
						    if (*buf == c)
 | 
				
			||||||
 | 
							++buf;
 | 
				
			||||||
 | 
						    else
 | 
				
			||||||
 | 
							return NULL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return (char *)buf;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,51 @@
 | 
				
			||||||
 | 
					/* <!-- copyright */
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * aria2 - The high speed download utility
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Copyright (C) 2007 Tatsuhiro Tsujikawa
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is free software; you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation; either version 2 of the License, or
 | 
				
			||||||
 | 
					 * (at your option) any later version.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program; if not, write to the Free Software
 | 
				
			||||||
 | 
					 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * In addition, as a special exception, the copyright holders give
 | 
				
			||||||
 | 
					 * permission to link the code of portions of this program with the
 | 
				
			||||||
 | 
					 * OpenSSL library under certain conditions as described in each
 | 
				
			||||||
 | 
					 * individual source file, and distribute linked combinations
 | 
				
			||||||
 | 
					 * including the two.
 | 
				
			||||||
 | 
					 * You must obey the GNU General Public License in all respects
 | 
				
			||||||
 | 
					 * for all of the code used other than OpenSSL.  If you modify
 | 
				
			||||||
 | 
					 * file(s) with this exception, you may extend this exception to your
 | 
				
			||||||
 | 
					 * version of the file(s), but you are not obligated to do so.  If you
 | 
				
			||||||
 | 
					 * do not wish to do so, delete this exception statement from your
 | 
				
			||||||
 | 
					 * version.  If you delete this exception statement from all source
 | 
				
			||||||
 | 
					 * files in the program, then also delete it here.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					/* copyright --> */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _D_STRPTIME_H
 | 
				
			||||||
 | 
					#define _D_STRPTIME_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					extern "C" {
 | 
				
			||||||
 | 
					#endif /* __cplusplus */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <time.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					char * strptime (const char *buf, const char *format, struct tm *timeptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					#endif /* __cplusplus */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* not _D_STRPTIME_H */
 | 
				
			||||||
| 
						 | 
					@ -19,6 +19,11 @@ public:
 | 
				
			||||||
    return RAND_MAX;
 | 
					    return RAND_MAX;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  virtual long int getRandomNumber(long int to)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    return getRandomNumber();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void setFixedNumber(int32_t num) {
 | 
					  void setFixedNumber(int32_t num) {
 | 
				
			||||||
    this->fixedNumber = num;
 | 
					    this->fixedNumber = num;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,6 +35,7 @@ PRE_UNINSTALL = :
 | 
				
			||||||
POST_UNINSTALL = :
 | 
					POST_UNINSTALL = :
 | 
				
			||||||
build_triplet = @build@
 | 
					build_triplet = @build@
 | 
				
			||||||
host_triplet = @host@
 | 
					host_triplet = @host@
 | 
				
			||||||
 | 
					target_triplet = @target@
 | 
				
			||||||
check_PROGRAMS = $(am__EXEEXT_1)
 | 
					check_PROGRAMS = $(am__EXEEXT_1)
 | 
				
			||||||
subdir = test
 | 
					subdir = test
 | 
				
			||||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 | 
					DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 | 
				
			||||||
| 
						 | 
					@ -168,6 +169,16 @@ GENCAT = @GENCAT@
 | 
				
			||||||
GLIBC21 = @GLIBC21@
 | 
					GLIBC21 = @GLIBC21@
 | 
				
			||||||
GMSGFMT = @GMSGFMT@
 | 
					GMSGFMT = @GMSGFMT@
 | 
				
			||||||
GREP = @GREP@
 | 
					GREP = @GREP@
 | 
				
			||||||
 | 
					HAVE_BASENAME_FALSE = @HAVE_BASENAME_FALSE@
 | 
				
			||||||
 | 
					HAVE_BASENAME_TRUE = @HAVE_BASENAME_TRUE@
 | 
				
			||||||
 | 
					HAVE_GETADDRINFO_FALSE = @HAVE_GETADDRINFO_FALSE@
 | 
				
			||||||
 | 
					HAVE_GETADDRINFO_TRUE = @HAVE_GETADDRINFO_TRUE@
 | 
				
			||||||
 | 
					HAVE_INET_ATON_FALSE = @HAVE_INET_ATON_FALSE@
 | 
				
			||||||
 | 
					HAVE_INET_ATON_TRUE = @HAVE_INET_ATON_TRUE@
 | 
				
			||||||
 | 
					HAVE_LOCALTIME_R_FALSE = @HAVE_LOCALTIME_R_FALSE@
 | 
				
			||||||
 | 
					HAVE_LOCALTIME_R_TRUE = @HAVE_LOCALTIME_R_TRUE@
 | 
				
			||||||
 | 
					HAVE_STRPTIME_FALSE = @HAVE_STRPTIME_FALSE@
 | 
				
			||||||
 | 
					HAVE_STRPTIME_TRUE = @HAVE_STRPTIME_TRUE@
 | 
				
			||||||
INSTALL_DATA = @INSTALL_DATA@
 | 
					INSTALL_DATA = @INSTALL_DATA@
 | 
				
			||||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
 | 
					INSTALL_PROGRAM = @INSTALL_PROGRAM@
 | 
				
			||||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
 | 
					INSTALL_SCRIPT = @INSTALL_SCRIPT@
 | 
				
			||||||
| 
						 | 
					@ -217,6 +228,7 @@ STRIP = @STRIP@
 | 
				
			||||||
USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
 | 
					USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
 | 
				
			||||||
USE_NLS = @USE_NLS@
 | 
					USE_NLS = @USE_NLS@
 | 
				
			||||||
VERSION = @VERSION@
 | 
					VERSION = @VERSION@
 | 
				
			||||||
 | 
					WINSOCK_LIBS = @WINSOCK_LIBS@
 | 
				
			||||||
XGETTEXT = @XGETTEXT@
 | 
					XGETTEXT = @XGETTEXT@
 | 
				
			||||||
XML2_CONFIG = @XML2_CONFIG@
 | 
					XML2_CONFIG = @XML2_CONFIG@
 | 
				
			||||||
XML_CPPFLAGS = @XML_CPPFLAGS@
 | 
					XML_CPPFLAGS = @XML_CPPFLAGS@
 | 
				
			||||||
| 
						 | 
					@ -268,7 +280,11 @@ psdir = @psdir@
 | 
				
			||||||
sbindir = @sbindir@
 | 
					sbindir = @sbindir@
 | 
				
			||||||
sharedstatedir = @sharedstatedir@
 | 
					sharedstatedir = @sharedstatedir@
 | 
				
			||||||
sysconfdir = @sysconfdir@
 | 
					sysconfdir = @sysconfdir@
 | 
				
			||||||
 | 
					target = @target@
 | 
				
			||||||
target_alias = @target_alias@
 | 
					target_alias = @target_alias@
 | 
				
			||||||
 | 
					target_cpu = @target_cpu@
 | 
				
			||||||
 | 
					target_os = @target_os@
 | 
				
			||||||
 | 
					target_vendor = @target_vendor@
 | 
				
			||||||
TESTS = aria2c
 | 
					TESTS = aria2c
 | 
				
			||||||
aria2c_SOURCES = AllTest.cc\
 | 
					aria2c_SOURCES = AllTest.cc\
 | 
				
			||||||
	FileUriListParserTest.cc\
 | 
						FileUriListParserTest.cc\
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue