mirror of https://github.com/aria2/aria2
more windows headers
pullin the CRT equivalents for some things ensure gai_strerror and getaddrinfo play nicepull/2045/head
parent
c7e5767a11
commit
b66d981ffc
30
src/a2io.h
30
src/a2io.h
|
@ -146,6 +146,9 @@
|
|||
# define a2open(path, flags, mode) _wsopen(path, flags, _SH_DENYNO, mode)
|
||||
# define a2fopen(path, mode) _wfsopen(path, mode, _SH_DENYNO)
|
||||
// # define a2ftruncate(fd, length): We don't use ftruncate in Mingw build
|
||||
# ifndef off_t
|
||||
# define off_t _off_t
|
||||
# endif
|
||||
# define a2_off_t off_t
|
||||
#elif defined(__ANDROID__) || defined(ANDROID)
|
||||
# define a2lseek(fd, offset, origin) lseek64(fd, offset, origin)
|
||||
|
@ -201,4 +204,31 @@ extern int ftruncate64(int fd, off64_t length);
|
|||
# define A2_BAD_FD -1
|
||||
#endif // !__MINGW32__
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
// Present with their _ prefixes on MSVC
|
||||
# define O_RDONLY _O_RDONLY
|
||||
# define O_WRONLY _O_WRONLY
|
||||
# define O_RDWR _O_RDWR
|
||||
# define O_APPEND _O_APPEND
|
||||
# define O_CREAT _O_CREAT
|
||||
# define O_EXCL _O_EXCL
|
||||
# define O_TRUNC _O_TRUNC
|
||||
|
||||
# define STDIN_FILENO _fileno(stdin)
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# define a2_isatty _isatty
|
||||
# define a2_fileno _fileno
|
||||
# define a2_read _read
|
||||
# define a2_close _close
|
||||
# define a2_dup _dup
|
||||
#else
|
||||
# define a2_isatty isatty
|
||||
# define a2_fileno fileno
|
||||
# define a2_read read
|
||||
# define a2_close close
|
||||
# define a2_dub dup
|
||||
#endif // !_MSC_VER
|
||||
|
||||
#endif // D_A2IO_H
|
||||
|
|
|
@ -84,7 +84,9 @@
|
|||
|
||||
#ifndef HAVE_GETADDRINFO
|
||||
# include "getaddrinfo.h"
|
||||
# define HAVE_GAI_STRERROR
|
||||
# ifndef HAVE_GAI_STRERROR
|
||||
# define HAVE_GAI_STRERROR
|
||||
# endif
|
||||
#endif // HAVE_GETADDRINFO
|
||||
|
||||
#ifndef HAVE_GAI_STRERROR
|
||||
|
|
|
@ -56,7 +56,7 @@ extern "C" {
|
|||
/*
|
||||
* Functions.
|
||||
*/
|
||||
#ifdef __STDC__
|
||||
#if defined(__STDC__) || defined(_MSC_VER)
|
||||
const char* gai_strerror(int);
|
||||
#else
|
||||
const char* gai_strerror();
|
||||
|
|
|
@ -124,7 +124,7 @@
|
|||
|
||||
#ifndef HAVE_MEMCPY
|
||||
# define memcpy(d, s, n) bcopy((s), (d), (n))
|
||||
# ifdef __STDC__
|
||||
# if defined(__STDC__) || defined(_MSC_VER)
|
||||
void* memchr(const void*, int, size_t);
|
||||
int memcmp(const void*, const void*, size_t);
|
||||
void* memmove(void*, const void*, size_t);
|
||||
|
@ -137,6 +137,10 @@ char* memset();
|
|||
# endif /* not __STDC__ */
|
||||
#endif /* not HAVE_MEMCPY */
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# define H_ERRNO_DECLARED 1
|
||||
#endif
|
||||
|
||||
#ifndef H_ERRNO_DECLARED
|
||||
extern int h_errno;
|
||||
#endif
|
||||
|
@ -156,6 +160,11 @@ extern int h_errno;
|
|||
# define N_(string) (string)
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# include <stdint.h>
|
||||
# define in_port_t uint16_t
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Error messages for gai_strerror().
|
||||
*/
|
||||
|
@ -211,7 +220,7 @@ static pthread_mutex_t gai_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|||
/*
|
||||
* Declaration of static functions.
|
||||
*/
|
||||
#ifdef __STDC__
|
||||
#if defined(__STDC__) || defined(_MSC_VER)
|
||||
static int is_integer(const char*);
|
||||
static int is_address(const char*);
|
||||
static int itoa_length(int);
|
||||
|
@ -494,7 +503,9 @@ struct addrinfo** res;
|
|||
*res = head_res;
|
||||
|
||||
end:
|
||||
#if !defined(_MSC_VER) // h_errno >> WSAGetLastError() ; not editable
|
||||
h_errno = saved_h_errno;
|
||||
#endif
|
||||
#ifdef ENABLE_PTHREAD
|
||||
pthread_mutex_unlock(&gai_mutex);
|
||||
#endif
|
||||
|
@ -588,7 +599,9 @@ int flags;
|
|||
}
|
||||
|
||||
end:
|
||||
#if !defined(_MSC_VER) // h_errno >> WSAGetLastError() ; not editable
|
||||
h_errno = saved_h_errno;
|
||||
#endif
|
||||
#ifdef ENABLE_PTHREAD
|
||||
pthread_mutex_unlock(&gai_mutex);
|
||||
#endif
|
||||
|
|
|
@ -41,7 +41,7 @@ extern "C" {
|
|||
# include "config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#if defined(__MINGW32__) || defined(__MSVC__)
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# ifndef _WIN32_WINNT
|
||||
# define _WIN32_WINNT 0x501
|
||||
# endif // _WIN32_WINNT
|
||||
|
@ -240,7 +240,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/* Nexenta OS(GNU/Solaris OS) defines `struct addrinfo' in netdb.h */
|
||||
#if !defined(__MINGW32__) && !defined(__sun) && !defined(_MSC_VER)
|
||||
#if !defined(__MINGW32__) && !defined(__sun) // && !defined(_MSC_VER)
|
||||
|
||||
/*
|
||||
* struct addrinfo.
|
||||
|
@ -261,7 +261,7 @@ struct addrinfo {
|
|||
/*
|
||||
* Functions.
|
||||
*/
|
||||
#ifdef __STDC__
|
||||
#if defined(__STDC__) || defined(_MSC_VER)
|
||||
const char* gai_strerror(int);
|
||||
void freeaddrinfo(struct addrinfo*);
|
||||
int getaddrinfo(const char*, const char*, const struct addrinfo*,
|
||||
|
|
|
@ -23,7 +23,15 @@
|
|||
* Danny Smith <dannysmith@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
#include <sys/time.h>
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
# include <winsock2.h>
|
||||
#endif /* HAVE_WINSOCK2_H */
|
||||
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
|
||||
|
|
|
@ -54,11 +54,21 @@
|
|||
#endif // HAVE_ALLOCA_H
|
||||
|
||||
#ifdef HAVE_MALLOC_H
|
||||
# if defined(_MSC_VER)
|
||||
// pull in alloca _alloca def
|
||||
# define _CRT_INTERNAL_NONSTDC_NAMES 1
|
||||
# endif
|
||||
# include <malloc.h>
|
||||
#endif // HAVE_MALLOC_H
|
||||
|
||||
#include "strptime.h"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# define tzname _tzname
|
||||
# define strncasecmp _strnicmp
|
||||
# define strcasecmp _stricmp
|
||||
#endif
|
||||
|
||||
static const char* abb_weekdays[] = {"Sun", "Mon", "Tue", "Wed",
|
||||
"Thu", "Fri", "Sat", NULL};
|
||||
|
||||
|
|
|
@ -117,6 +117,11 @@ typedef SSIZE_T ssize_t;
|
|||
#endif
|
||||
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# define strdup _strdup
|
||||
# define wdscup _wcsdup
|
||||
#endif
|
||||
|
||||
namespace util {
|
||||
|
||||
extern const char DEFAULT_STRIP_CHARSET[];
|
||||
|
|
Loading…
Reference in New Issue