diff -uwrN aria2c-0.13.2+1.orig/src/ConsoleStatCalc.cc aria2c-0.13.2+1/src/ConsoleStatCalc.cc --- aria2c-0.13.2+1.orig/src/ConsoleStatCalc.cc 2008-05-15 07:37:02.000000000 -0700 +++ aria2c-0.13.2+1/src/ConsoleStatCalc.cc 2008-06-07 12:46:54.499625000 -0700 @@ -43,8 +43,12 @@ #ifdef ENABLE_BITTORRENT # include "BtContext.h" #endif // ENABLE_BITTORRENT +#ifdef HAVE_TERMIOS_H #include +#endif // HAVE_TERMIOS_H +#ifdef HAVE_SYS_IOCTL_H #include +#endif // HAVE_SYS_IOCTL_H #include #include #include @@ -135,9 +139,14 @@ { time_t now; struct tm* staticNowtmPtr; +#ifdef HAVE_ASCTIME_R char buf[26]; - if(time(&now) != (time_t)-1 && (staticNowtmPtr = localtime(&now)) != 0 && - asctime_r(staticNowtmPtr, buf) != 0) { + asctime_r(staticNowtmPtr, buf); +#else + char *buf; + buf = asctime(staticNowtmPtr); +#endif // HAVE_ASCTIME_R + if(time(&now) != (time_t)-1 && (staticNowtmPtr = localtime(&now)) != 0 && buf != 0) { char* lfptr = strchr(buf, '\n'); if(lfptr) { *lfptr = '\0'; @@ -168,6 +177,7 @@ bool isTTY = isatty(STDOUT_FILENO) == 1; unsigned short int cols = 80; +#ifdef HAVE_TERMIOS_H if(isTTY) { struct winsize size; if(ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) == 0) { @@ -175,6 +185,7 @@ } std::cout << '\r' << std::setfill(' ') << std::setw(cols) << ' ' << '\r'; } +#endif // HAVE_TERMIOS_H std::ostringstream o; if(requestGroupMan->countRequestGroup() > 0) { if(_summaryInterval > 0 && _summaryIntervalCount%_summaryInterval == 0) { diff -uwrN aria2c-0.13.2+1.orig/src/SimpleLogger.cc aria2c-0.13.2+1/src/SimpleLogger.cc --- aria2c-0.13.2+1.orig/src/SimpleLogger.cc 2008-05-15 08:48:41.000000000 -0700 +++ aria2c-0.13.2+1/src/SimpleLogger.cc 2008-06-07 12:37:44.374625000 -0700 @@ -154,7 +154,12 @@ } { char* res; +#ifdef HAVE_VASPRINTF if(vasprintf(&res, std::string(Util::replace(msg, A2STR::CR_C, A2STR::NIL)+A2STR::LF_C).c_str(), apCopy) == -1) { +#else + res = (char*) malloc(65536); + if(!res || vsnprintf(res, 65536, std::string(Util::replace(msg, A2STR::CR_C, A2STR::NIL)+A2STR::LF_C).c_str(), apCopy) < 0) { +#endif o << "SimpleLogger error, cannot allocate memory.\n"; } else { o << res; diff -uwrN aria2c-0.13.2+1.orig/src/StringFormat.cc aria2c-0.13.2+1/src/StringFormat.cc --- aria2c-0.13.2+1.orig/src/StringFormat.cc 2008-04-26 19:22:14.000000000 -0700 +++ aria2c-0.13.2+1/src/StringFormat.cc 2008-06-07 12:48:17.905875000 -0700 @@ -46,7 +46,12 @@ va_list ap; va_start(ap, fmt); char* strp; +#ifdef HAVE_VASPRINTF if(vasprintf(&strp, fmt, ap) != -1) { +#else + strp = (char*) malloc(65536); + if(strp && vsnprintf(strp, 65536, fmt, ap) >= 0) { +#endif _msg.assign(&strp[0], &strp[strlen(strp)]); free(strp); } diff -uwrN aria2c-0.13.2+1.orig/src/asctime_r.c aria2c-0.13.2+1/src/asctime_r.c --- aria2c-0.13.2+1.orig/src/asctime_r.c 1969-12-31 16:00:00.000000000 -0800 +++ aria2c-0.13.2+1/src/asctime_r.c 2008-06-07 13:11:59.780875000 -0700 @@ -0,0 +1,73 @@ +/* */ + +#include +#include + +#ifdef __MINGW32__ +#define WIN32_LEAN_AND_MEAN +#include +#endif // __MINGW32__ + +#include "asctime_r.h" + +#ifdef __MINGW32__ + +static CRITICAL_SECTION asctime_r_cs; + +static void asctime_r_atexit() +{ + DeleteCriticalSection(&asctime_r_cs); +} + +char * asctime_r (const struct tm*, char *buf); +{ + static char *p; + static int initialized = 0; + + if (!initialized) { + ++initialized; + InitializeCriticalSection(&asctime_r_cs); + atexit(asctime_r_atexit); + } + + EnterCriticalSection(&asctime_r_cs); + p = asctime(tm); + memcpy(buf, p, 26); + LeaveCriticalSection(&asctime_r_cs); + return buf; +}; + +#endif // __MINGW32__ diff -uwrN aria2c-0.13.2+1.orig/src/asctime_r.h aria2c-0.13.2+1/src/asctime_r.h --- aria2c-0.13.2+1.orig/src/asctime_r.h 1969-12-31 16:00:00.000000000 -0800 +++ aria2c-0.13.2+1/src/asctime_r.h 2008-06-07 13:07:50.187125000 -0700 @@ -0,0 +1,51 @@ +/* */ + +#ifndef _D_LOCALTIME_R_H +#define _D_LOCALTIME_R_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include + +char * asctime_r (const struct tm*); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* not _D_LOCALTIME_R_H */ diff -uwrN aria2c-0.13.2+1.orig/src/getaddrinfo.h aria2c-0.13.2+1/src/getaddrinfo.h --- aria2c-0.13.2+1.orig/src/getaddrinfo.h 2008-03-03 07:41:58.000000000 -0800 +++ aria2c-0.13.2+1/src/getaddrinfo.h 2008-06-07 12:59:51.921500000 -0700 @@ -161,50 +161,68 @@ #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) +# +/* Possible values for `ai_flags' field in `addrinfo' structure. */ +# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */ +# define AI_CANONNAME 0x0002 /* Request for canonical name. */ +# define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */ +# define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */ +# define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */ +# define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose + returned address type.. */ +# ifdef __USE_GNU +# define AI_IDN 0x0040 /* IDN encode input (assuming it is encoded + in the current locale's character set) + before looking it up. */ +# define AI_CANONIDN 0x0080 /* Translate canonical name from IDN format. */ +# define AI_IDN_ALLOW_UNASSIGNED 0x0100 /* Don't reject unassigned Unicode + code points. */ +# define AI_IDN_USE_STD3_ASCII_RULES 0x0200 /* Validate strings according to + STD3 rules. */ +# endif +# define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */ -/* - * 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 +/* Error values for `getaddrinfo' function. */ +# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */ +# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */ +# define EAI_AGAIN -3 /* Temporary failure in name resolution. */ +# define EAI_FAIL -4 /* Non-recoverable failure in name res. */ +# define EAI_NODATA -5 /* No address associated with NAME. */ +# define EAI_FAMILY -6 /* `ai_family' not supported. */ +# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */ +# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */ +# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */ +# define EAI_MEMORY -10 /* Memory allocation failure. */ +# define EAI_SYSTEM -11 /* System error returned in `errno'. */ +# define EAI_OVERFLOW -12 /* Argument buffer overflow. */ +# ifdef __USE_GNU +# define EAI_INPROGRESS -100 /* Processing request in progress. */ +# define EAI_CANCELED -101 /* Request canceled. */ +# define EAI_NOTCANCELED -102 /* Request not canceled. */ +# define EAI_ALLDONE -103 /* All requests done. */ +# define EAI_INTR -104 /* Interrupted by a signal. */ +# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */ +# endif -/* - * Maximum length of FQDN and servie name for getnameinfo(). - */ #define NI_MAXHOST 1025 #define NI_MAXSERV 32 +# define NI_NUMERICHOST 1 /* Don't try to look up hostname. */ +# define NI_NUMERICSERV 2 /* Don't convert port number to name. */ +# define NI_NOFQDN 4 /* Only return nodename portion. */ +# define NI_NAMEREQD 8 /* Don't return numeric addresses. */ +# define NI_DGRAM 16 /* Look up UDP service rather than TCP. */ +# ifdef __USE_GNU +# define NI_IDN 32 /* Convert name from IDN format. */ +# define NI_IDN_ALLOW_UNASSIGNED 64 /* Don't reject unassigned Unicode + code points. */ +# define NI_IDN_USE_STD3_ASCII_RULES 128 /* Validate strings according to + STD3 rules. */ +# endif +# + +#define AI_DEFAULT (AI_V4MAPPED | AI_ADDRCONFIG) + /* * Address families and Protocol families. */