- All files have prominent copyright and SPDX identifier
- If not embedded in the file, in the .reuse/dep5 file
- All used licenses are in LICENSES/ (not shipped in tarballs)
- A new REUSE CI job verify that all files are OK
Assisted-by: Viktor Szakats
Closes#1084
Drop checks from Windows builds and enable it based on `WIN32`.
This saves detection time and also makes 3rd party builds simpler.
Also:
- delete `HAVE_DISABLED_NONBLOCKING`, that we used in build tools to
explicitly disable an explicit `#error` in `session.c`.
- replace existing `WSAEWOULDBLOCK` check for Windows support with
`WIN32`. Cleaner with the same result.
Follow-up to f1e80d8d8ce9570d81836da96ba02f4d4552a7b3
Follow-up to 5644eea2161b17f7c16e18f3a10465ebb217ca1f
Closes#980
Skip testing unixy methods on Windows and vice versa.
I continue to assume that CMake doesn't define `WIN32` with Cygwin
(as Cygwin doesn't define `_WIN32`/`WIN32` for C), though I haven't
tested this.
Closes#970
- introduce the concept of a project level setup header
`src/libssh2_setup.h`, that is used by `src`, `example` and `tests`
alike. Move there all common platform/compiler configuration from
`src/libssh2_priv.h`, individual sources and `CMakeFiles.txt` files.
Also move there our hand-crafted (= not auto-generated by CMake or
autotools) configuration `win32/libssh2-config.h`.
- `win32` directory is empty now, delete it.
- `Makefile.mk`: adapt to the above. Build-directory is the target
triplet, or any custom name set via `BLD_DIR`.
- sync header path order between build systems:
build/src -> source/src -> source/include
- delete redundant references to `windows.h`, `winsock2.h`,
`ws2tcpip.h`.
- delete unnecessary #includes, update order (`libssh2_setup.h` first,
`winsock2.h` first), simplify where possible.
This makes the code warning-free without `WIN32_LEAN_AND_MEAN`.
At the same time this patch applies this macro globally, to avoid
header bloat.
- example: add missing *nix header guards.
- example: fix misindented `HAVE_UNISTD_H` `#ifdef`s.
- set `WIN32` with all build-tools.
- set `HAVE_SYS_PARAM_H` in the hand-crafted config for MinGW.
To match auto-detection.
- move a source-specific macro to `misc.c` from `libssh2_priv.h`.
See the PR's individual commits for step-by-step updates.
Closes#932
- cmake: fix compiler warnings in `CheckNonblockingSocketSupport`.
detection functions.
Without this, these detections fail when `ENABLE_WERROR=ON`.
- cmake: disable ENABLE_WERROR for MSVC during symbol checks in `src`.
CMake's built-in symbol check function `check_symbol_exists()`
generate warnings with MSVC. With warnings considered errors, these
detections fail permanently. Our workaround is to disable
warnings-as-errors while running these checks.
```
CheckSymbolExists.c(8): warning C4054: 'type cast': from function pointer '__int64 (__cdecl *)(const char *,char **,int)' to data pointer 'int *'
in `return ((int*)(&strtoll))[argc];`
```
Ref: https://ci.appveyor.com/project/libssh2org/libssh2/builds/46537222/job/4vg4yg333mu2lg9b
- example: replace `strcasecmp()` with C89 `strcmp()`.
To avoid using CMake symbol checks in `example`.
Another option is to duplicate the `check_symbol_exists()` workaround
from `src`, but I figure it's not worth the complexity. We use
`strcasecmp()` solely to check optional command-line options for
example programs, and those are fine as lower-case.
Without this, these detections fail when `ENABLE_WERROR=ON`.
- also delete `__function__` detection/use in `example`.
To avoid the complexity for the sake of using it at a single place in
of the example's error branch. Replace that use with a literal name of
the function.
- cmake: also use `CMakePushCheckState` functions instead of manual
save/restore.
Closes#857
- cmake: always link `ws2_32` on Windows. Also add it to `libssh2.pc`.
Fixes#745
- agent: fix gcc compiler warning:
`src/agent.c:296:35: warning: 'snprintf' output truncated before the last format character [-Wformat-truncation=]`
- autotools: fix `EVP_aes_128_ctr` detection with binutils `ld`
The prerequisite for a successful detection is setting
`LIBS=-lbcrypt` if the chosen openssl-compatible library requires
it, e.g. libressl, or quictls/openssl built with
`-DUSE_BCRYPTGENRANDOM`.
With llvm `lld`, detection works out of the box. With binutils `ld`,
it does not. The reason is `ld`s world-famous pickiness with lib
order.
To fix it, we pass all custom libs before and after the TLS libs.
This ugly hack makes `ld` happy and detection succeed.
- agent: fix Windows-specific warning:
`src/agent.c:318:10: warning: implicit conversion loses integer precision: 'LRESULT' (aka 'long long') to 'int' [-Wshorten-64-to-32]`
- src: fix llvm/clang compiler warning:
`src/libssh2_priv.h:987:28: warning: variadic macros are a C99 feature [-Wvariadic-macros]`
- src: support `inline` with `__GNUC__` (llvm/clang and gcc), fixing:
```
src/libssh2_priv.h:990:8: warning: extension used [-Wlanguage-extension-token]
static inline void
^
```
- blowfish: support `inline` keyword with MSVC.
Also switch to `__inline__` (from `__inline`) for `__GNUC__`:
https://gcc.gnu.org/onlinedocs/gcc/Inline.htmlhttps://clang.llvm.org/docs/UsersManual.html#differences-between-various-standard-modes
- example/test: fix MSVC compiler warnings:
- `example\direct_tcpip.c(209): warning C4244: 'function': conversion from 'unsigned int' to 'u_short', possible loss of data`
- `tests\session_fixture.c(96): warning C4013: 'getcwd' undefined; assuming extern returning int`
- `tests\session_fixture.c(100): warning C4013: 'chdir' undefined; assuming extern returning int`
- delete unused macros:
- `HAVE_SOCKET`
- `HAVE_INET_ADDR`
- `NEED_LIB_NSL`
- `NEED_LIB_SOCKET`
- `HAVE_NTSTATUS_H`
- `HAVE_NTDEF_H`
- build: delete stale zlib/openssl version numbers from path defaults.
- cmake: convert tabs to spaces, add newline at EOFs.
Closes#811