mirror of
https://github.com/libssh2/libssh2.git
synced 2025-08-05 20:55:47 +03:00
add portable LIBSSH2_SOCKET_CLOSE()
macro
Add `LIBSSH2_SOCKET_CLOSE()` to the public `libssh2.h` header, for user code. It translates to `closesocket()` on Windows and `close()` on other platforms. Use it in example code. It makes them more readable by reducing the number of `_WIN32` guards. Closes #1278
This commit is contained in:
@@ -143,9 +143,11 @@ typedef long long libssh2_int64_t;
|
||||
#ifdef _WIN32
|
||||
typedef SOCKET libssh2_socket_t;
|
||||
#define LIBSSH2_INVALID_SOCKET INVALID_SOCKET
|
||||
#define LIBSSH2_SOCKET_CLOSE(s) closesocket(s)
|
||||
#else /* !_WIN32 */
|
||||
typedef int libssh2_socket_t;
|
||||
#define LIBSSH2_INVALID_SOCKET -1
|
||||
#define LIBSSH2_SOCKET_CLOSE(s) close(s)
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user