mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-06 20:49:29 +03:00
Before this patch, the `snprintf()` fallback logic for envs not supporting this function (i.e. Visual Studio 2013 and older) varied depending on build tool, and used different techniques in examples, tests and libssh2 itself. This patch aims to apply a common logic to libssh2 and examples/tests. - libssh2: use local `snprintf()` fallback with all build tools. We already had a local implementation, but only with CMake. Move that to the library as `_libssh2_snprintf()`, and map `snprintf()` to it when `HAVE_SNPRINTF` is not set. Also change the length type from `int` to `size_t`, and fix formatting. - set or detect `HAVE_SNPRINTF` in non-CMake builds. Detect in autotools. Keep existing logic in `win32/libssh2_config.h`. Always set for OS/400, NetWare and VMS, keeping existing behaviour. (OS/400 builds use a different local implementation) - examples/tests: drop the CMake-specific fallback logic and map `snprintf()` to `_snprintf()` for old MSVC versions, like we did before with other build tools. This is unsafe, but should be fine for these uses. - `win32/libssh2_config.h`: make it easier to read. Closes #812
42 lines
817 B
C
42 lines
817 B
C
#ifndef LIBSSH2_CONFIG_H
|
|
#define LIBSSH2_CONFIG_H
|
|
|
|
#ifndef WIN32
|
|
#define WIN32
|
|
#endif
|
|
|
|
#ifndef _CRT_SECURE_NO_DEPRECATE
|
|
#define _CRT_SECURE_NO_DEPRECATE 1
|
|
#endif
|
|
|
|
#define HAVE_LIBCRYPT32
|
|
#define HAVE_WINSOCK2_H
|
|
#define HAVE_IOCTLSOCKET
|
|
#define HAVE_SELECT
|
|
#define HAVE_SNPRINTF
|
|
|
|
#ifdef __MINGW32__
|
|
# define HAVE_UNISTD_H
|
|
# define HAVE_INTTYPES_H
|
|
# define HAVE_SYS_TIME_H
|
|
# define HAVE_GETTIMEOFDAY
|
|
#elif defined(_MSC_VER)
|
|
# if _MSC_VER < 1900
|
|
# undef HAVE_SNPRINTF
|
|
# if _MSC_VER < 1500
|
|
# define vsnprintf _vsnprintf
|
|
# endif
|
|
# define strdup _strdup
|
|
# define strncasecmp _strnicmp
|
|
# define strcasecmp _stricmp
|
|
# endif
|
|
#else
|
|
# define strncasecmp strnicmp
|
|
# define strcasecmp stricmp
|
|
#endif
|
|
|
|
/* Enable newer diffie-hellman-group-exchange-sha1 syntax */
|
|
#define LIBSSH2_DH_GEX_NEW 1
|
|
|
|
#endif /* LIBSSH2_CONFIG_H */
|