mirror of
https://github.com/curl/curl.git
synced 2026-08-25 15:13:41 +03:00
windows: use built-in _WIN32 macro to detect Windows
Windows compilers define `_WIN32` automatically. Windows SDK headers or build env defines `WIN32`, or we have to take care of it. The agreement seems to be that `_WIN32` is the preferred practice here. Make the source code rely on that to detect we're building for Windows. Public `curl.h` was using `WIN32`, `__WIN32__` and `CURL_WIN32` for Windows detection, next to the official `_WIN32`. After this patch it only uses `_WIN32` for this. Also, make it stop defining `CURL_WIN32`. There is a slight chance these break compatibility with Windows compilers that fail to define `_WIN32`. I'm not aware of any obsolete or modern compiler affected, but in case there is one, one possible solution is to define this macro manually. grepping for `WIN32` remains useful to discover Windows-specific code. Also: - extend `checksrc` to ensure we're not using `WIN32` anymore. - apply minor formatting here and there. - delete unnecessary checks for `!MSDOS` when `_WIN32` is present. Co-authored-by: Jay Satiro Reviewed-by: Daniel Stenberg Closes #12376
This commit is contained in:
parent
1c37d472a0
commit
e9a7d4a1c8
99 changed files with 223 additions and 227 deletions
|
|
@ -60,13 +60,13 @@
|
|||
#include "progress.h"
|
||||
#include "timediff.h"
|
||||
|
||||
# if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
|
||||
defined(WIN32)
|
||||
# define CARES_STATICLIB
|
||||
# endif
|
||||
# include <ares.h>
|
||||
# include <ares_version.h> /* really old c-ares didn't include this by
|
||||
itself */
|
||||
#if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
|
||||
defined(_WIN32)
|
||||
# define CARES_STATICLIB
|
||||
#endif
|
||||
#include <ares.h>
|
||||
#include <ares_version.h> /* really old c-ares didn't include this by
|
||||
itself */
|
||||
|
||||
#if ARES_VERSION >= 0x010500
|
||||
/* c-ares 1.5.0 or later, the callback proto is modified */
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@
|
|||
#include "memdebug.h"
|
||||
|
||||
|
||||
#if defined(ENABLE_IPV6) && defined(IPV6_V6ONLY) && defined(WIN32)
|
||||
#if defined(ENABLE_IPV6) && defined(IPV6_V6ONLY) && defined(_WIN32)
|
||||
/* It makes support for IPv4-mapped IPv6 addresses.
|
||||
* Linux kernel, NetBSD, FreeBSD and Darwin: default is off;
|
||||
* Windows Vista and later: default is on;
|
||||
|
|
@ -659,7 +659,7 @@ static bool verifyconnect(curl_socket_t sockfd, int *error)
|
|||
int err = 0;
|
||||
curl_socklen_t errSize = sizeof(err);
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
* In October 2003 we effectively nullified this function on Windows due to
|
||||
* problems with it using all CPU in multi-threaded cases.
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@
|
|||
#undef send
|
||||
#undef recv
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
# ifdef UNICODE
|
||||
# undef wcsdup
|
||||
# undef _wcsdup
|
||||
|
|
@ -134,7 +134,7 @@ extern curl_free_callback Curl_cfree;
|
|||
extern curl_realloc_callback Curl_crealloc;
|
||||
extern curl_strdup_callback Curl_cstrdup;
|
||||
extern curl_calloc_callback Curl_ccalloc;
|
||||
#if defined(WIN32) && defined(UNICODE)
|
||||
#if defined(_WIN32) && defined(UNICODE)
|
||||
extern curl_wcsdup_callback Curl_cwcsdup;
|
||||
#endif
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ extern curl_wcsdup_callback Curl_cwcsdup;
|
|||
#undef free
|
||||
#define free(ptr) Curl_cfree(ptr)
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
# ifdef UNICODE
|
||||
# undef wcsdup
|
||||
# define wcsdup(ptr) Curl_cwcsdup(ptr)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
#include "curl_setup.h"
|
||||
|
||||
#if defined(WIN32)
|
||||
#if defined(_WIN32)
|
||||
|
||||
#include "curl_multibyte.h"
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w)
|
|||
return str_utf8;
|
||||
}
|
||||
|
||||
#endif /* WIN32 */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#if defined(USE_WIN32_LARGE_FILES) || defined(USE_WIN32_SMALL_FILES)
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
***************************************************************************/
|
||||
#include "curl_setup.h"
|
||||
|
||||
#if defined(WIN32)
|
||||
#if defined(_WIN32)
|
||||
|
||||
/*
|
||||
* MultiByte conversions using Windows kernel32 library.
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
wchar_t *curlx_convert_UTF8_to_wchar(const char *str_utf8);
|
||||
char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w);
|
||||
#endif /* WIN32 */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/*
|
||||
* Macros curlx_convert_UTF8_to_tchar(), curlx_convert_tchar_to_UTF8()
|
||||
|
|
@ -54,7 +54,7 @@ char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w);
|
|||
* ensure that the curl memdebug override macros do not replace them.
|
||||
*/
|
||||
|
||||
#if defined(UNICODE) && defined(WIN32)
|
||||
#if defined(UNICODE) && defined(_WIN32)
|
||||
|
||||
#define curlx_convert_UTF8_to_tchar(ptr) curlx_convert_UTF8_to_wchar((ptr))
|
||||
#define curlx_convert_tchar_to_UTF8(ptr) curlx_convert_wchar_to_UTF8((ptr))
|
||||
|
|
@ -78,7 +78,7 @@ typedef union {
|
|||
const unsigned char *const_tbyte_ptr;
|
||||
} xcharp_u;
|
||||
|
||||
#endif /* UNICODE && WIN32 */
|
||||
#endif /* UNICODE && _WIN32 */
|
||||
|
||||
#define curlx_unicodefree(ptr) \
|
||||
do { \
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
#include <curl/curl.h>
|
||||
#include "urldata.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
# undef PATH_MAX
|
||||
# define PATH_MAX MAX_PATH
|
||||
# ifndef R_OK
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
/* The last #include file should be: */
|
||||
#include "memdebug.h"
|
||||
|
||||
#if defined(WIN32) && !defined(USE_LWIPSOCK)
|
||||
#if defined(_WIN32) && !defined(USE_LWIPSOCK)
|
||||
#define setsockopt(a,b,c,d,e) (setsockopt)(a,b,c,(const char *)d,(int)e)
|
||||
#define SET_RCVTIMEO(tv,s) int tv = s*1000
|
||||
#elif defined(LWIP_SO_SNDRCVTIMEO_NONSTANDARD)
|
||||
|
|
|
|||
|
|
@ -41,15 +41,7 @@
|
|||
#pragma warning(disable:4127)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define WIN32 when build target is Win32 API
|
||||
*/
|
||||
|
||||
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
|
||||
#define WIN32
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
* Don't include unneeded stuff in Windows headers to avoid compiler
|
||||
* warnings and macro clashes.
|
||||
|
|
@ -87,7 +79,7 @@
|
|||
#ifdef _WIN32_WCE
|
||||
# include "config-win32ce.h"
|
||||
#else
|
||||
# ifdef WIN32
|
||||
# ifdef _WIN32
|
||||
# include "config-win32.h"
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -505,11 +497,11 @@
|
|||
5. set dir/file naming defines
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
|
||||
# define DIR_CHAR "\\"
|
||||
|
||||
#else /* WIN32 */
|
||||
#else /* _WIN32 */
|
||||
|
||||
# ifdef MSDOS /* Watt-32 */
|
||||
|
||||
|
|
@ -534,7 +526,7 @@
|
|||
|
||||
# define DIR_CHAR "/"
|
||||
|
||||
#endif /* WIN32 */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* resolver specialty compile-time defines */
|
||||
|
|
@ -557,7 +549,7 @@
|
|||
|
||||
#if defined(ENABLE_IPV6) && defined(HAVE_GETADDRINFO)
|
||||
# define CURLRES_IPV6
|
||||
#elif defined(ENABLE_IPV6) && (defined(WIN32) || defined(__CYGWIN__))
|
||||
#elif defined(ENABLE_IPV6) && (defined(_WIN32) || defined(__CYGWIN__))
|
||||
/* assume on Windows that IPv6 without getaddrinfo is a broken build */
|
||||
# error "Unexpected build: IPv6 is enabled but getaddrinfo was not found."
|
||||
#else
|
||||
|
|
@ -714,7 +706,7 @@
|
|||
/* In Windows the default file mode is text but an application can override it.
|
||||
Therefore we specify it explicitly. https://github.com/curl/curl/pull/258
|
||||
*/
|
||||
#if defined(WIN32) || defined(MSDOS)
|
||||
#if defined(_WIN32) || defined(MSDOS)
|
||||
#define FOPEN_READTEXT "rt"
|
||||
#define FOPEN_WRITETEXT "wt"
|
||||
#define FOPEN_APPENDTEXT "at"
|
||||
|
|
@ -783,11 +775,11 @@ int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf,
|
|||
/* Certain Windows implementations are not aligned with what curl expects,
|
||||
so always use the local one on this platform. E.g. the mingw-w64
|
||||
implementation can return wrong results for non-ASCII inputs. */
|
||||
#if defined(HAVE_BASENAME) && defined(WIN32)
|
||||
#if defined(HAVE_BASENAME) && defined(_WIN32)
|
||||
#undef HAVE_BASENAME
|
||||
#endif
|
||||
|
||||
#if defined(USE_UNIX_SOCKETS) && defined(WIN32)
|
||||
#if defined(USE_UNIX_SOCKETS) && defined(_WIN32)
|
||||
# if !defined(UNIX_PATH_MAX)
|
||||
/* Replicating logic present in afunix.h
|
||||
(distributed with newer Windows 10 SDK versions only) */
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@
|
|||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ curl_free_callback Curl_cfree = (curl_free_callback)free;
|
|||
curl_realloc_callback Curl_crealloc = (curl_realloc_callback)realloc;
|
||||
curl_strdup_callback Curl_cstrdup = (curl_strdup_callback)system_strdup;
|
||||
curl_calloc_callback Curl_ccalloc = (curl_calloc_callback)calloc;
|
||||
#if defined(WIN32) && defined(UNICODE)
|
||||
#if defined(_WIN32) && defined(UNICODE)
|
||||
curl_wcsdup_callback Curl_cwcsdup = Curl_wcsdup;
|
||||
#endif
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ static CURLcode global_init(long flags, bool memoryfuncs)
|
|||
Curl_crealloc = (curl_realloc_callback)realloc;
|
||||
Curl_cstrdup = (curl_strdup_callback)system_strdup;
|
||||
Curl_ccalloc = (curl_calloc_callback)calloc;
|
||||
#if defined(WIN32) && defined(UNICODE)
|
||||
#if defined(_WIN32) && defined(UNICODE)
|
||||
Curl_cwcsdup = (curl_wcsdup_callback)_wcsdup;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -287,7 +287,7 @@ void curl_global_cleanup(void)
|
|||
Curl_ssl_cleanup();
|
||||
Curl_resolver_global_cleanup();
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
Curl_win32_cleanup(easy_init_flags);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@
|
|||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#if defined(WIN32) || defined(MSDOS) || defined(__EMX__)
|
||||
#if defined(_WIN32) || defined(MSDOS) || defined(__EMX__)
|
||||
#define DOS_FILESYSTEM 1
|
||||
#elif defined(__amigaos4__)
|
||||
#define AMIGA_FILESYSTEM 1
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
2. For systems with config-*.h files, define them there.
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
/* int recv(SOCKET, char *, int, int) */
|
||||
#define RECV_TYPE_ARG1 SOCKET
|
||||
#define RECV_TYPE_ARG2 char *
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ static char *GetEnv(const char *variable)
|
|||
defined(__ORBIS__) || defined(__PROSPERO__) /* PlayStation 4 and 5 */
|
||||
(void)variable;
|
||||
return NULL;
|
||||
#elif defined(WIN32)
|
||||
#elif defined(_WIN32)
|
||||
/* This uses Windows API instead of C runtime getenv() to get the environment
|
||||
variable since some changes aren't always visible to the latter. #4774 */
|
||||
char *buf = NULL;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
#ifdef USE_LIBIDN2
|
||||
#include <idn2.h>
|
||||
|
||||
#if defined(WIN32) && defined(UNICODE)
|
||||
#if defined(_WIN32) && defined(UNICODE)
|
||||
#define IDN2_LOOKUP(name, host, flags) \
|
||||
idn2_lookup_u8((const uint8_t *)name, (uint8_t **)host, flags)
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ ALLOC_FUNC char *curl_dbg_strdup(const char *str,
|
|||
return mem;
|
||||
}
|
||||
|
||||
#if defined(WIN32) && defined(UNICODE)
|
||||
#if defined(_WIN32) && defined(UNICODE)
|
||||
ALLOC_FUNC wchar_t *curl_dbg_wcsdup(const wchar_t *str,
|
||||
int line, const char *source)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ CURL_EXTERN ALLOC_SIZE(2) void *curl_dbg_realloc(void *ptr,
|
|||
CURL_EXTERN void curl_dbg_free(void *ptr, int line, const char *source);
|
||||
CURL_EXTERN ALLOC_FUNC char *curl_dbg_strdup(const char *str, int line,
|
||||
const char *src);
|
||||
#if defined(WIN32) && defined(UNICODE)
|
||||
#if defined(_WIN32) && defined(UNICODE)
|
||||
CURL_EXTERN ALLOC_FUNC wchar_t *curl_dbg_wcsdup(const wchar_t *str,
|
||||
int line,
|
||||
const char *source);
|
||||
|
|
@ -121,7 +121,7 @@ CURL_EXTERN int curl_dbg_fclose(FILE *file, int line, const char *source);
|
|||
#define send(a,b,c,d) curl_dbg_send(a,b,c,d, __LINE__, __FILE__)
|
||||
#define recv(a,b,c,d) curl_dbg_recv(a,b,c,d, __LINE__, __FILE__)
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
# ifdef UNICODE
|
||||
# undef wcsdup
|
||||
# define wcsdup(ptr) curl_dbg_wcsdup(ptr, __LINE__, __FILE__)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
# ifndef R_OK
|
||||
# define R_OK 4
|
||||
# endif
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ int Curl_parsenetrc(const char *host, char **loginp, char **passwordp,
|
|||
}
|
||||
retcode = parsenetrc(host, loginp, passwordp, filealloc);
|
||||
free(filealloc);
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
if(retcode == NETRC_FILE_MISSING) {
|
||||
/* fallback to the old-style "_netrc" file */
|
||||
filealloc = curl_maprintf("%s%s_netrc", home, DIR_CHAR);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
|
||||
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600
|
||||
# define HAVE_WIN_BCRYPTGENRANDOM
|
||||
|
|
@ -133,7 +133,7 @@ static CURLcode randit(struct Curl_easy *data, unsigned int *rnd)
|
|||
|
||||
/* ---- non-cryptographic version following ---- */
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
if(!seeded) {
|
||||
result = Curl_win32_random((unsigned char *)rnd, sizeof(*rnd));
|
||||
if(result != CURLE_NOT_BUILT_IN)
|
||||
|
|
@ -148,7 +148,7 @@ static CURLcode randit(struct Curl_easy *data, unsigned int *rnd)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(RANDOM_FILE) && !defined(WIN32)
|
||||
#if defined(RANDOM_FILE) && !defined(_WIN32)
|
||||
if(!seeded) {
|
||||
/* if there's a random file to read a seed from, use it */
|
||||
int fd = open(RANDOM_FILE, O_RDONLY);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd,
|
|||
CURLcode Curl_rand_alnum(struct Curl_easy *data, unsigned char *rnd,
|
||||
size_t num);
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
/* Random generator shared between the Schannel vtls and Curl_rand*()
|
||||
functions */
|
||||
CURLcode Curl_win32_random(unsigned char *entropy, size_t length);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
/* return 0 on success, 1 on error */
|
||||
int Curl_rename(const char *oldpath, const char *newpath)
|
||||
{
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
/* rename() on Windows doesn't overwrite, so we can't use it here.
|
||||
MoveFileEx() will overwrite and is usually atomic, however it fails
|
||||
when there are open handles to the file. */
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ int Curl_wait_ms(timediff_t timeout_ms)
|
|||
}
|
||||
#if defined(MSDOS)
|
||||
delay(timeout_ms);
|
||||
#elif defined(WIN32)
|
||||
#elif defined(_WIN32)
|
||||
/* prevent overflow, timeout_ms is typecast to ULONG/DWORD. */
|
||||
#if TIMEDIFF_T_MAX >= ULONG_MAX
|
||||
if(timeout_ms >= ULONG_MAX)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#if !defined(CURL_DISABLE_SMB) && defined(USE_CURL_NTLM_CORE)
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#define getpid GetCurrentProcessId
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
#include "rand.h"
|
||||
|
||||
#if !defined(HAVE_SOCKETPAIR) && !defined(CURL_DISABLE_SOCKETPAIR)
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
* This is a socketpair() implementation for Windows.
|
||||
*/
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
#ifndef INADDR_LOOPBACK
|
||||
#define INADDR_LOOPBACK 0x7f000001
|
||||
#endif /* !INADDR_LOOPBACK */
|
||||
#endif /* !WIN32 */
|
||||
#endif /* !_WIN32 */
|
||||
|
||||
#include "nonblock.h" /* for curlx_nonblock */
|
||||
#include "timeval.h" /* needed before select.h */
|
||||
|
|
@ -87,7 +87,7 @@ int Curl_socketpair(int domain, int type, int protocol,
|
|||
|
||||
socks[0] = socks[1] = CURL_SOCKET_BAD;
|
||||
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
/* don't set SO_REUSEADDR on Windows */
|
||||
(void)reuse;
|
||||
#ifdef SO_EXCLUSIVEADDRUSE
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ char *Curl_strdup(const char *str)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
/***************************************************************************
|
||||
*
|
||||
* Curl_wcsdup(source)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
#ifndef HAVE_STRDUP
|
||||
char *Curl_strdup(const char *str);
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
wchar_t* Curl_wcsdup(const wchar_t* src);
|
||||
#endif
|
||||
void *Curl_memdup(const void *src, size_t buffer_length);
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32_WCE)
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE)
|
||||
#define PRESERVE_WINDOWS_ERROR_CODE
|
||||
#endif
|
||||
|
||||
|
|
@ -762,7 +762,7 @@ get_winsock_error (int err, char *buf, size_t len)
|
|||
}
|
||||
#endif /* USE_WINSOCK */
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32_WCE)
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE)
|
||||
/* This is a helper function for Curl_strerror that converts Windows API error
|
||||
* codes (GetLastError) to error messages.
|
||||
* Returns NULL if no error message was found for error code.
|
||||
|
|
@ -804,7 +804,7 @@ get_winapi_error(int err, char *buf, size_t buflen)
|
|||
|
||||
return (*buf ? buf : NULL);
|
||||
}
|
||||
#endif /* WIN32 || _WIN32_WCE */
|
||||
#endif /* _WIN32 || _WIN32_WCE */
|
||||
|
||||
/*
|
||||
* Our thread-safe and smart strerror() replacement.
|
||||
|
|
@ -837,15 +837,15 @@ const char *Curl_strerror(int err, char *buf, size_t buflen)
|
|||
if(!buflen)
|
||||
return NULL;
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32
|
||||
DEBUGASSERT(err >= 0);
|
||||
#endif
|
||||
|
||||
max = buflen - 1;
|
||||
*buf = '\0';
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32_WCE)
|
||||
#if defined(WIN32)
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE)
|
||||
#if defined(_WIN32)
|
||||
/* 'sys_nerr' is the maximum errno number, it is not widely portable */
|
||||
if(err >= 0 && err < sys_nerr)
|
||||
strncpy(buf, sys_errlist[err], max);
|
||||
|
|
@ -923,7 +923,7 @@ const char *Curl_strerror(int err, char *buf, size_t buflen)
|
|||
* Curl_winapi_strerror:
|
||||
* Variant of Curl_strerror if the error code is definitely Windows API.
|
||||
*/
|
||||
#if defined(WIN32) || defined(_WIN32_WCE)
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE)
|
||||
const char *Curl_winapi_strerror(DWORD err, char *buf, size_t buflen)
|
||||
{
|
||||
#ifdef PRESERVE_WINDOWS_ERROR_CODE
|
||||
|
|
@ -958,7 +958,7 @@ const char *Curl_winapi_strerror(DWORD err, char *buf, size_t buflen)
|
|||
|
||||
return buf;
|
||||
}
|
||||
#endif /* WIN32 || _WIN32_WCE */
|
||||
#endif /* _WIN32 || _WIN32_WCE */
|
||||
|
||||
#ifdef USE_WINDOWS_SSPI
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
#define STRERROR_LEN 256 /* a suitable length */
|
||||
|
||||
const char *Curl_strerror(int err, char *buf, size_t buflen);
|
||||
#if defined(WIN32) || defined(_WIN32_WCE)
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE)
|
||||
const char *Curl_winapi_strerror(DWORD err, char *buf, size_t buflen);
|
||||
#endif
|
||||
#ifdef USE_WINDOWS_SSPI
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "curl_setup.h"
|
||||
|
||||
#if defined(WIN32)
|
||||
#if defined(_WIN32)
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include "system_win32.h"
|
||||
|
|
@ -238,4 +238,4 @@ HMODULE Curl_load_library(LPCTSTR filename)
|
|||
#endif
|
||||
}
|
||||
|
||||
#endif /* WIN32 */
|
||||
#endif /* _WIN32 */
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include "curl_setup.h"
|
||||
|
||||
#if defined(WIN32)
|
||||
#if defined(_WIN32)
|
||||
|
||||
extern LARGE_INTEGER Curl_freq;
|
||||
extern bool Curl_isVistaOrGreater;
|
||||
|
|
@ -42,8 +42,8 @@ extern IF_NAMETOINDEX_FN Curl_if_nametoindex;
|
|||
|
||||
/* This is used to dynamically load DLLs */
|
||||
HMODULE Curl_load_library(LPCTSTR filename);
|
||||
#else /* WIN32 */
|
||||
#else /* _WIN32 */
|
||||
#define Curl_win32_init(x) CURLE_OK
|
||||
#endif /* !WIN32 */
|
||||
#endif /* !_WIN32 */
|
||||
|
||||
#endif /* HEADER_CURL_SYSTEM_WIN32_H */
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ struct timeval *curlx_mstotv(struct timeval *tv, timediff_t ms)
|
|||
#endif
|
||||
tv->tv_sec = (time_t)tv_sec;
|
||||
tv->tv_usec = (suseconds_t)tv_usec;
|
||||
#elif defined(WIN32) /* maybe also others in the future */
|
||||
#elif defined(_WIN32) /* maybe also others in the future */
|
||||
#if TIMEDIFF_T_MAX > LONG_MAX
|
||||
/* tv_sec overflow check on Windows there we know it is long */
|
||||
if(tv_sec > LONG_MAX)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "timeval.h"
|
||||
|
||||
#if defined(WIN32)
|
||||
#if defined(_WIN32)
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include "system_win32.h"
|
||||
|
|
|
|||
|
|
@ -820,7 +820,7 @@ CURLcode Curl_done_sending(struct Curl_easy *data,
|
|||
return CURLE_OK;
|
||||
}
|
||||
|
||||
#if defined(WIN32) && defined(USE_WINSOCK)
|
||||
#if defined(_WIN32) && defined(USE_WINSOCK)
|
||||
#ifndef SIO_IDEAL_SEND_BACKLOG_QUERY
|
||||
#define SIO_IDEAL_SEND_BACKLOG_QUERY 0x4004747B
|
||||
#endif
|
||||
|
|
@ -1014,7 +1014,7 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
|
|||
if(result)
|
||||
return result;
|
||||
|
||||
#if defined(WIN32) && defined(USE_WINSOCK)
|
||||
#if defined(_WIN32) && defined(USE_WINSOCK)
|
||||
{
|
||||
struct curltime n = Curl_now();
|
||||
if(Curl_timediff(n, k->last_sndbuf_update) > 1000) {
|
||||
|
|
|
|||
|
|
@ -1724,14 +1724,14 @@ static void zonefrom_url(CURLU *uh, struct Curl_easy *data,
|
|||
conn->scope_id = (unsigned int)scope;
|
||||
#if defined(HAVE_IF_NAMETOINDEX)
|
||||
else {
|
||||
#elif defined(WIN32)
|
||||
#elif defined(_WIN32)
|
||||
else if(Curl_if_nametoindex) {
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_IF_NAMETOINDEX) || defined(WIN32)
|
||||
#if defined(HAVE_IF_NAMETOINDEX) || defined(_WIN32)
|
||||
/* Zone identifier is not numeric */
|
||||
unsigned int scopeidx = 0;
|
||||
#if defined(WIN32)
|
||||
#if defined(_WIN32)
|
||||
scopeidx = Curl_if_nametoindex(zoneid);
|
||||
#else
|
||||
scopeidx = if_nametoindex(zoneid);
|
||||
|
|
@ -1746,7 +1746,7 @@ static void zonefrom_url(CURLU *uh, struct Curl_easy *data,
|
|||
else
|
||||
conn->scope_id = scopeidx;
|
||||
}
|
||||
#endif /* HAVE_IF_NAMETOINDEX || WIN32 */
|
||||
#endif /* HAVE_IF_NAMETOINDEX || _WIN32 */
|
||||
|
||||
free(zoneid);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ size_t Curl_is_absolute_url(const char *url, char *buf, size_t buflen,
|
|||
(void)buflen; /* only used in debug-builds */
|
||||
if(buf)
|
||||
buf[0] = 0; /* always leave a defined value in buf */
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
if(guess_scheme && STARTS_WITH_DRIVE_PREFIX(url))
|
||||
return 0;
|
||||
#endif
|
||||
|
|
@ -1056,7 +1056,7 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags)
|
|||
ptr += 9; /* now points to the slash after the host */
|
||||
}
|
||||
else {
|
||||
#if defined(WIN32)
|
||||
#if defined(_WIN32)
|
||||
size_t len;
|
||||
|
||||
/* the host name, NetBIOS computer name, can not contain disallowed
|
||||
|
|
@ -1095,7 +1095,7 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags)
|
|||
/* no host for file: URLs by default */
|
||||
Curl_dyn_reset(&host);
|
||||
|
||||
#if !defined(MSDOS) && !defined(WIN32) && !defined(__CYGWIN__)
|
||||
#if !defined(_WIN32) && !defined(MSDOS) && !defined(__CYGWIN__)
|
||||
/* Don't allow Windows drive letters when not in Windows.
|
||||
* This catches both "file:/c:" and "file:c:" */
|
||||
if(('/' == path[0] && STARTS_WITH_URL_DRIVE_PREFIX(&path[1])) ||
|
||||
|
|
|
|||
|
|
@ -721,7 +721,7 @@ struct SingleRequest {
|
|||
#ifndef CURL_DISABLE_DOH
|
||||
struct dohdata *doh; /* DoH specific data for this request */
|
||||
#endif
|
||||
#if defined(WIN32) && defined(USE_WINSOCK)
|
||||
#if defined(_WIN32) && defined(USE_WINSOCK)
|
||||
struct curltime last_sndbuf_update; /* last time readwrite_upload called
|
||||
win_update_buffer_size */
|
||||
#endif
|
||||
|
|
@ -1394,7 +1394,7 @@ struct UrlState {
|
|||
|
||||
/* a place to store the most recently set (S)FTP entrypath */
|
||||
char *most_recent_ftp_entrypath;
|
||||
#if !defined(WIN32) && !defined(MSDOS) && !defined(__EMX__)
|
||||
#if !defined(_WIN32) && !defined(MSDOS) && !defined(__EMX__)
|
||||
/* do FTP line-end conversions on most platforms */
|
||||
#define CURL_DO_LINEEND_CONV
|
||||
/* for FTP downloads: track CRLF sequences that span blocks */
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
#ifdef USE_ARES
|
||||
# if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
|
||||
defined(WIN32)
|
||||
defined(_WIN32)
|
||||
# define CARES_STATICLIB
|
||||
# endif
|
||||
# include <ares.h>
|
||||
|
|
@ -512,7 +512,7 @@ static const struct feat features_table[] = {
|
|||
#ifdef CURLDEBUG
|
||||
FEATURE("TrackMemory", NULL, CURL_VERSION_CURLDEBUG),
|
||||
#endif
|
||||
#if defined(WIN32) && defined(UNICODE) && defined(_UNICODE)
|
||||
#if defined(_WIN32) && defined(UNICODE) && defined(_UNICODE)
|
||||
FEATURE("Unicode", NULL, CURL_VERSION_UNICODE),
|
||||
#endif
|
||||
#ifdef USE_UNIX_SOCKETS
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "curl_setup.h"
|
||||
|
||||
#if defined(WIN32)
|
||||
#if defined(_WIN32)
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include "version_win32.h"
|
||||
|
|
@ -316,4 +316,4 @@ bool curlx_verify_windows_version(const unsigned int majorVersion,
|
|||
return matched;
|
||||
}
|
||||
|
||||
#endif /* WIN32 */
|
||||
#endif /* _WIN32 */
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include "curl_setup.h"
|
||||
|
||||
#if defined(WIN32)
|
||||
#if defined(_WIN32)
|
||||
|
||||
/* Version condition */
|
||||
typedef enum {
|
||||
|
|
@ -51,6 +51,6 @@ bool curlx_verify_windows_version(const unsigned int majorVersion,
|
|||
const PlatformIdentifier platform,
|
||||
const VersionCondition condition);
|
||||
|
||||
#endif /* WIN32 */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#endif /* HEADER_CURL_VERSION_WIN32_H */
|
||||
|
|
|
|||
|
|
@ -1406,7 +1406,7 @@ static CURLcode cf_connect_start(struct Curl_cfilter *cf,
|
|||
}
|
||||
|
||||
/* Known to not work on Windows */
|
||||
#if !defined(WIN32) && defined(HAVE_QUICHE_CONN_SET_QLOG_FD)
|
||||
#if !defined(_WIN32) && defined(HAVE_QUICHE_CONN_SET_QLOG_FD)
|
||||
{
|
||||
int qfd;
|
||||
(void)Curl_qlogdir(data, ctx->scid, sizeof(ctx->scid), &qfd);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ Curl_tls_keylog_open(void)
|
|||
if(keylog_file_name) {
|
||||
keylog_file_fp = fopen(keylog_file_name, FOPEN_APPENDTEXT);
|
||||
if(keylog_file_fp) {
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
if(setvbuf(keylog_file_fp, NULL, _IONBF, 0))
|
||||
#else
|
||||
if(setvbuf(keylog_file_fp, NULL, _IOLBF, 4096))
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include "warnless.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#undef read
|
||||
#undef write
|
||||
#endif
|
||||
|
|
@ -367,7 +367,7 @@ curl_socket_t curlx_sitosk(int i)
|
|||
|
||||
#endif /* USE_WINSOCK */
|
||||
|
||||
#if defined(WIN32)
|
||||
#if defined(_WIN32)
|
||||
|
||||
ssize_t curlx_read(int fd, void *buf, size_t count)
|
||||
{
|
||||
|
|
@ -379,7 +379,7 @@ ssize_t curlx_write(int fd, const void *buf, size_t count)
|
|||
return (ssize_t)write(fd, buf, curlx_uztoui(count));
|
||||
}
|
||||
|
||||
#endif /* WIN32 */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/* Ensure that warnless.h redefinitions continue to have an effect
|
||||
in "unity" builds. */
|
||||
|
|
|
|||
|
|
@ -69,13 +69,13 @@ curl_socket_t curlx_sitosk(int i);
|
|||
|
||||
#endif /* USE_WINSOCK */
|
||||
|
||||
#if defined(WIN32)
|
||||
#if defined(_WIN32)
|
||||
|
||||
ssize_t curlx_read(int fd, void *buf, size_t count);
|
||||
|
||||
ssize_t curlx_write(int fd, const void *buf, size_t count);
|
||||
|
||||
#endif /* WIN32 */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#if defined(__INTEL_COMPILER) && defined(__unix__)
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ unsigned short curlx_ntohs(unsigned short usnum);
|
|||
#ifndef HEADER_CURL_WARNLESS_H_REDEFS
|
||||
#define HEADER_CURL_WARNLESS_H_REDEFS
|
||||
|
||||
#if defined(WIN32)
|
||||
#if defined(_WIN32)
|
||||
#undef read
|
||||
#define read(fd, buf, count) curlx_read(fd, buf, count)
|
||||
#undef write
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue