1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Fixes for winelib building (used by our Coverity build).

Avoided referring to some functions and header files that aren't there
in the winelib world (_vsnprintf, _stricmp, SecureZeroMemory,
multimon.h), and worked around a really amazingly annoying issue in
which Winelib objects to you using the type 'fd_set' unless you
included winsock2.h before stdlib.h.
This commit is contained in:
Simon Tatham 2017-02-14 23:19:13 +00:00
parent bec33b2311
commit 991d30412d
5 changed files with 42 additions and 4 deletions

2
misc.c
View File

@ -406,7 +406,7 @@ static char *dupvprintf_inner(char *buf, int oldlen, int oldsize,
}
while (1) {
#if defined _WINDOWS && _MSC_VER < 1900 /* 1900 == VS2015 has real snprintf */
#if defined _WINDOWS && !defined __WINE__ && _MSC_VER < 1900 /* 1900 == VS2015 has real snprintf */
#define vsnprintf _vsnprintf
#endif
#ifdef va_copy

View File

@ -10,6 +10,10 @@
#include <limits.h>
#include <assert.h>
#ifdef __WINE__
#define NO_MULTIMON /* winelib doesn't have this */
#endif
#ifndef NO_MULTIMON
#define COMPILE_MULTIMON_STUBS
#endif

View File

@ -5,11 +5,15 @@
* unfix.org.
*/
#include <winsock2.h> /* need to put this first, for winelib builds */
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#define DEFINE_PLUG_METHOD_MACROS
#define NEED_DECLARATION_OF_SELECT /* in order to initialise it */
#include "putty.h"
#include "network.h"
#include "tree234.h"
@ -236,6 +240,13 @@ int sk_startup(int hi, int lo)
return TRUE;
}
/* Actually define this function pointer, which won't have been
* defined alongside all the others by PUTTY_DO_GLOBALS because of the
* annoying winelib header-ordering issue. (See comment in winstuff.h.) */
DECL_WINDOWS_FUNCTION(/* empty */, int, select,
(int, fd_set FAR *, fd_set FAR *,
fd_set FAR *, const struct timeval FAR *));
void sk_init(void)
{
#ifndef NO_IPV6

View File

@ -2,8 +2,11 @@
* winsftp.c: the Windows-specific parts of PSFTP and PSCP.
*/
#include <winsock2.h> /* need to put this first, for winelib builds */
#include <assert.h>
#define NEED_DECLARATION_OF_SELECT
#include "putty.h"
#include "psftp.h"
#include "ssh.h"

View File

@ -89,14 +89,25 @@ struct FontSpec *fontspec_new(const char *name,
#define BOXRESULT (DLGWINDOWEXTRA + sizeof(LONG_PTR))
#define DF_END 0x0001
#ifdef __WINE__
#define NO_SECUREZEROMEMORY /* winelib doesn't have this */
#endif
#ifndef NO_SECUREZEROMEMORY
#define PLATFORM_HAS_SMEMCLR /* inhibit cross-platform one in misc.c */
#endif
#ifndef __WINE__
/* Up-to-date Windows headers warn that the unprefixed versions of
* these names are deprecated. */
#define stricmp _stricmp
#define strnicmp _strnicmp
#else
/* Compiling with winegcc, _neither_ version of these functions
* exists. Use the POSIX names. */
#define stricmp strcasecmp
#define strnicmp strncasecmp
#endif
#define BROKEN_PIPE_ERROR_CODE ERROR_BROKEN_PIPE /* used in sshshare.c */
@ -276,12 +287,21 @@ DECL_WINDOWS_FUNCTION(GLOBAL, int, WSAAsyncSelect,
(SOCKET, HWND, u_int, long));
DECL_WINDOWS_FUNCTION(GLOBAL, int, WSAEventSelect,
(SOCKET, WSAEVENT, long));
DECL_WINDOWS_FUNCTION(GLOBAL, int, select,
(int, fd_set FAR *, fd_set FAR *,
fd_set FAR *, const struct timeval FAR *));
DECL_WINDOWS_FUNCTION(GLOBAL, int, WSAGetLastError, (void));
DECL_WINDOWS_FUNCTION(GLOBAL, int, WSAEnumNetworkEvents,
(SOCKET, WSAEVENT, LPWSANETWORKEVENTS));
#ifdef NEED_DECLARATION_OF_SELECT
/* This declaration is protected by an ifdef for the sake of building
* against winelib, in which you have to include winsock2.h before
* stdlib.h so that the right fd_set type gets defined. It would be a
* pain to do that throughout this codebase, so instead I arrange that
* only a modules actually needing to use (or define, or initialise)
* this function pointer will see its declaration, and _those_ modules
* - which will be Windows-specific anyway - can take more care. */
DECL_WINDOWS_FUNCTION(GLOBAL, int, select,
(int, fd_set FAR *, fd_set FAR *,
fd_set FAR *, const struct timeval FAR *));
#endif
extern int socket_writable(SOCKET skt);