1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-07-29 13:01:14 +03:00

tidy-up: C header use

- drop unused or duplicate C headers.
- add missing ones (that worked by chance).
  (`string.h`, `stdlib.h`)
- mention the functions that need certain headers.
- move some headers from crypto header to crypto C source.
- reorder headers in some places.
- simplify the #if tree for `sys/select.h` in `libssh2_priv.h`.
- move scp-specific macros next to their header to `scp.c`
  Follow-up to 5db836b2a8

Closes #999
This commit is contained in:
Viktor Szakats
2023-04-24 21:45:28 +00:00
parent d67aaaffc4
commit a683133dfe
47 changed files with 63 additions and 212 deletions

View File

@ -141,7 +141,7 @@ check_include_files(inttypes.h HAVE_INTTYPES_H)
if(NOT MSVC) if(NOT MSVC)
check_include_files(unistd.h HAVE_UNISTD_H) check_include_files(unistd.h HAVE_UNISTD_H)
check_include_files(sys/time.h HAVE_SYS_TIME_H) check_include_files(sys/time.h HAVE_SYS_TIME_H)
check_include_files(sys/param.h HAVE_SYS_PARAM_H) check_include_files(sys/param.h HAVE_SYS_PARAM_H) # tests
endif() endif()
if(NOT WIN32) if(NOT WIN32)
check_include_files(sys/select.h HAVE_SYS_SELECT_H) check_include_files(sys/select.h HAVE_SYS_SELECT_H)

View File

@ -10,9 +10,6 @@
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -23,11 +20,9 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#ifndef INADDR_NONE #ifndef INADDR_NONE
#define INADDR_NONE (in_addr_t)~0 #define INADDR_NONE (in_addr_t)~0

View File

@ -22,11 +22,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h>
static const char *pubkey = "/home/username/.ssh/id_rsa.pub"; static const char *pubkey = "/home/username/.ssh/id_rsa.pub";
static const char *privkey = "/home/username/.ssh/id_rsa"; static const char *privkey = "/home/username/.ssh/id_rsa";

View File

@ -17,9 +17,6 @@
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -33,11 +30,7 @@
#include <sys/time.h> #include <sys/time.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h>
static const char *pubkey = "/home/username/.ssh/id_rsa.pub"; static const char *pubkey = "/home/username/.ssh/id_rsa.pub";
static const char *privkey = "/home/username/.ssh/id_rsa"; static const char *privkey = "/home/username/.ssh/id_rsa";

View File

@ -18,11 +18,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h>
static const char *pubkey = "/home/username/.ssh/id_rsa.pub"; static const char *pubkey = "/home/username/.ssh/id_rsa.pub";
static const char *privkey = "/home/username/.ssh/id_rsa"; static const char *privkey = "/home/username/.ssh/id_rsa";

View File

@ -8,9 +8,6 @@
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -21,12 +18,8 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <time.h> /* for time() */
#include <time.h>
static const char *pubkey = "/home/username/.ssh/id_rsa.pub"; static const char *pubkey = "/home/username/.ssh/id_rsa.pub";
static const char *privkey = "/home/username/.ssh/id_rsa"; static const char *privkey = "/home/username/.ssh/id_rsa";

View File

@ -28,11 +28,8 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <string.h>
static const char *pubkey = "/home/username/.ssh/id_rsa.pub"; static const char *pubkey = "/home/username/.ssh/id_rsa.pub";
static const char *privkey = "/home/username/.ssh/id_rsa"; static const char *privkey = "/home/username/.ssh/id_rsa";

View File

@ -18,9 +18,6 @@
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -28,11 +25,7 @@
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h>
static const char *pubkey = "/home/username/.ssh/id_rsa.pub"; static const char *pubkey = "/home/username/.ssh/id_rsa.pub";
static const char *privkey = "/home/username/.ssh/id_rsa"; static const char *privkey = "/home/username/.ssh/id_rsa";

View File

@ -24,11 +24,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h>
static const char *pubkey = "/home/username/.ssh/id_rsa.pub"; static const char *pubkey = "/home/username/.ssh/id_rsa.pub";
static const char *privkey = "/home/username/.ssh/id_rsa"; static const char *privkey = "/home/username/.ssh/id_rsa";

View File

@ -24,11 +24,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h>
static const char *pubkey = "/home/username/.ssh/id_rsa.pub"; static const char *pubkey = "/home/username/.ssh/id_rsa.pub";
static const char *privkey = "/home/username/.ssh/id_rsa"; static const char *privkey = "/home/username/.ssh/id_rsa";

View File

@ -24,11 +24,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h>
static const char *pubkey = "/home/username/.ssh/id_rsa.pub"; static const char *pubkey = "/home/username/.ssh/id_rsa.pub";
static const char *privkey = "/home/username/.ssh/id_rsa"; static const char *privkey = "/home/username/.ssh/id_rsa";

View File

@ -18,9 +18,6 @@
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -34,11 +31,7 @@
#include <sys/time.h> #include <sys/time.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h>
static const char *pubkey = "/home/username/.ssh/id_rsa.pub"; static const char *pubkey = "/home/username/.ssh/id_rsa.pub";
static const char *privkey = "/home/username/.ssh/id_rsa"; static const char *privkey = "/home/username/.ssh/id_rsa";

View File

@ -24,11 +24,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h>
static const char *pubkey = "/home/username/.ssh/id_rsa.pub"; static const char *pubkey = "/home/username/.ssh/id_rsa.pub";
static const char *privkey = "/home/username/.ssh/id_rsa"; static const char *privkey = "/home/username/.ssh/id_rsa";

View File

@ -14,9 +14,6 @@
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -27,12 +24,8 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <time.h> /* for time() */
#include <time.h>
static const char *pubkey = "/home/username/.ssh/id_rsa.pub"; static const char *pubkey = "/home/username/.ssh/id_rsa.pub";
static const char *privkey = "/home/username/.ssh/id_rsa"; static const char *privkey = "/home/username/.ssh/id_rsa";

View File

@ -14,9 +14,6 @@
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -27,12 +24,9 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <time.h> /* for time() */
#include <time.h> #include <string.h>
static const char *pubkey = "/home/username/.ssh/id_rsa.pub"; static const char *pubkey = "/home/username/.ssh/id_rsa.pub";
static const char *privkey = "/home/username/.ssh/id_rsa"; static const char *privkey = "/home/username/.ssh/id_rsa";

View File

@ -24,11 +24,8 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <string.h>
#if defined(_MSC_VER) #if defined(_MSC_VER)
#define __FILESIZE "I64u" #define __FILESIZE "I64u"

View File

@ -24,11 +24,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h>
#if defined(_MSC_VER) #if defined(_MSC_VER)
#define __FILESIZE "I64u" #define __FILESIZE "I64u"

View File

@ -28,12 +28,9 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <string.h>
#if defined(_MSC_VER) && _MSC_VER < 1900 #if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf _snprintf #define snprintf _snprintf

View File

@ -22,12 +22,8 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <string.h>
#include <ctype.h>
static const char *username = "username"; static const char *username = "username";

View File

@ -17,9 +17,6 @@
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -30,12 +27,8 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h>
static const char *hostname = "127.0.0.1"; static const char *hostname = "127.0.0.1";
static const char *commandline = "uptime"; static const char *commandline = "uptime";

View File

@ -12,9 +12,6 @@
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -25,12 +22,9 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <string.h>
static const char *hostname = "127.0.0.1"; static const char *hostname = "127.0.0.1";
static const char *commandline = "cat"; static const char *commandline = "cat";

View File

@ -14,9 +14,6 @@
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -27,12 +24,9 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <string.h>
static const char *hostname = "127.0.0.1"; static const char *hostname = "127.0.0.1";
static const char *commandline = "uptime"; static const char *commandline = "uptime";

View File

@ -14,11 +14,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#ifndef INADDR_NONE #ifndef INADDR_NONE

View File

@ -10,9 +10,6 @@
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -23,11 +20,9 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#ifndef INADDR_NONE #ifndef INADDR_NONE
#define INADDR_NONE (in_addr_t)~0 #define INADDR_NONE (in_addr_t)~0

View File

@ -20,9 +20,6 @@
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -33,11 +30,7 @@
#include <sys/un.h> #include <sys/un.h>
#endif #endif
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h>
#include <string.h> #include <string.h>
#include <termios.h> #include <termios.h>

View File

@ -185,8 +185,6 @@ typedef int libssh2_socket_t;
#ifdef LIBSSH2_USE_WIN32_LARGE_FILES #ifdef LIBSSH2_USE_WIN32_LARGE_FILES
# include <io.h> # include <io.h>
# include <sys/types.h>
# include <sys/stat.h>
# define LIBSSH2_STRUCT_STAT_SIZE_FORMAT "%I64d" # define LIBSSH2_STRUCT_STAT_SIZE_FORMAT "%I64d"
typedef struct _stati64 libssh2_struct_stat; typedef struct _stati64 libssh2_struct_stat;
typedef __int64 libssh2_struct_stat_size; typedef __int64 libssh2_struct_stat_size;
@ -197,8 +195,6 @@ typedef __int64 libssh2_struct_stat_size;
*/ */
#ifdef LIBSSH2_USE_WIN32_SMALL_FILES #ifdef LIBSSH2_USE_WIN32_SMALL_FILES
# include <sys/types.h>
# include <sys/stat.h>
# ifndef _WIN32_WCE # ifndef _WIN32_WCE
# define LIBSSH2_STRUCT_STAT_SIZE_FORMAT "%d" # define LIBSSH2_STRUCT_STAT_SIZE_FORMAT "%d"
typedef struct _stat libssh2_struct_stat; typedef struct _stat libssh2_struct_stat;

View File

@ -39,7 +39,10 @@
#include "libssh2_priv.h" #include "libssh2_priv.h"
#include "agent.h" #include "agent.h"
#include <errno.h> #include <errno.h>
#include <stdlib.h> /* for getenv() */
#ifdef HAVE_SYS_UN_H #ifdef HAVE_SYS_UN_H
#include <sys/un.h> #include <sys/un.h>
#else #else
@ -48,6 +51,7 @@
support them. */ support them. */
#undef PF_UNIX #undef PF_UNIX
#endif #endif
#include "userauth.h" #include "userauth.h"
#include "session.h" #include "session.h"

View File

@ -39,7 +39,6 @@
#include "libssh2_priv.h" #include "libssh2_priv.h"
#include "agent.h" #include "agent.h"
#include <errno.h>
#if defined(WIN32) && !defined(LIBSSH2_WINDOWS_UWP) #if defined(WIN32) && !defined(LIBSSH2_WINDOWS_UWP)

View File

@ -20,10 +20,6 @@
#ifndef HAVE_BCRYPT_PBKDF #ifndef HAVE_BCRYPT_PBKDF
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#define LIBSSH2_BCRYPT_PBKDF_C #define LIBSSH2_BCRYPT_PBKDF_C
#include "blowfish.c" #include "blowfish.c"

View File

@ -39,13 +39,14 @@
*/ */
#include "libssh2_priv.h" #include "libssh2_priv.h"
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <fcntl.h>
#ifdef HAVE_INTTYPES_H #ifdef HAVE_INTTYPES_H
#include <inttypes.h> #include <inttypes.h>
#endif #endif
#include <assert.h> #include <assert.h>
#include "channel.h" #include "channel.h"

View File

@ -37,6 +37,7 @@
*/ */
#include "libssh2_priv.h" #include "libssh2_priv.h"
#ifdef LIBSSH2_HAVE_ZLIB #ifdef LIBSSH2_HAVE_ZLIB
#include <zlib.h> #include <zlib.h>
#undef compress /* dodge name clash with ZLIB macro */ #undef compress /* dodge name clash with ZLIB macro */

View File

@ -38,8 +38,6 @@
#ifdef LIBSSH2_CRYPTO_C /* Compile this via crypto.c */ #ifdef LIBSSH2_CRYPTO_C /* Compile this via crypto.c */
#include <string.h>
#if LIBSSH2_RSA #if LIBSSH2_RSA
int int
_libssh2_rsa_new(libssh2_rsa_ctx ** rsa, _libssh2_rsa_new(libssh2_rsa_ctx ** rsa,

View File

@ -47,6 +47,7 @@
#include "libssh2_setup.h" #include "libssh2_setup.h"
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <time.h> #include <time.h>
#include <limits.h> #include <limits.h>
@ -59,14 +60,8 @@
*/ */
#ifdef HAVE_POLL #ifdef HAVE_POLL
# include <poll.h> # include <poll.h>
#else #elif defined(HAVE_SELECT) && defined(HAVE_SYS_SELECT_H)
# if defined(HAVE_SELECT) && !defined(WIN32) # include <sys/select.h>
# ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
# else
# include <sys/types.h>
# endif
# endif
#endif #endif
/* Needed for struct iovec on some platforms */ /* Needed for struct iovec on some platforms */
@ -914,14 +909,6 @@ struct _LIBSSH2_SESSION
long packet_read_timeout; long packet_read_timeout;
}; };
#if defined(HAVE_STRTOLL)
#define scpsize_strtol strtoll
#elif defined(HAVE_STRTOI64)
#define scpsize_strtol _strtoi64
#else
#define scpsize_strtol strtol
#endif
/* session.state bits */ /* session.state bits */
#define LIBSSH2_STATE_EXCHANGING_KEYS 0x00000001 #define LIBSSH2_STATE_EXCHANGING_KEYS 0x00000001
#define LIBSSH2_STATE_NEWKEYS 0x00000002 #define LIBSSH2_STATE_NEWKEYS 0x00000002

View File

@ -37,6 +37,8 @@
#ifdef LIBSSH2_CRYPTO_C /* Compile this via crypto.c */ #ifdef LIBSSH2_CRYPTO_C /* Compile this via crypto.c */
#include <stdlib.h>
#if MBEDTLS_VERSION_NUMBER < 0x03000000 #if MBEDTLS_VERSION_NUMBER < 0x03000000
#define mbedtls_cipher_info_get_key_bitlen(c) (c->key_bitlen) #define mbedtls_cipher_info_get_key_bitlen(c) (c->key_bitlen)
#define mbedtls_cipher_info_get_iv_size(c) (c->iv_size) #define mbedtls_cipher_info_get_iv_size(c) (c->iv_size)

View File

@ -39,9 +39,6 @@
#define LIBSSH2_CRYPTO_ENGINE libssh2_mbedtls #define LIBSSH2_CRYPTO_ENGINE libssh2_mbedtls
#include <stdlib.h>
#include <string.h>
#include <mbedtls/platform.h> #include <mbedtls/platform.h>
#include <mbedtls/md.h> #include <mbedtls/md.h>
#include <mbedtls/rsa.h> #include <mbedtls/rsa.h>
@ -162,6 +159,7 @@
#define libssh2_sha1(data, datalen, hash) \ #define libssh2_sha1(data, datalen, hash) \
_libssh2_mbedtls_hash(data, datalen, MBEDTLS_MD_SHA1, hash) _libssh2_mbedtls_hash(data, datalen, MBEDTLS_MD_SHA1, hash)
/*******************************************************************/ /*******************************************************************/
/* /*
* mbedTLS backend: SHA256 functions * mbedTLS backend: SHA256 functions

View File

@ -40,21 +40,18 @@
#include "libssh2_priv.h" #include "libssh2_priv.h"
#include "misc.h" #include "misc.h"
#include <stdlib.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <errno.h>
#ifdef WIN32 #ifdef WIN32
/* Force parameter type. */ /* Force parameter type. */
#define recv(s, b, l, f) recv((s), (b), (int)(l), (f)) #define recv(s, b, l, f) recv((s), (b), (int)(l), (f))
#define send(s, b, l, f) send((s), (b), (int)(l), (f)) #define send(s, b, l, f) send((s), (b), (int)(l), (f))
#endif #endif
#include <stdio.h>
#include <errno.h>
/* snprintf not in Visual Studio CRT and _snprintf dangerously incompatible. /* snprintf not in Visual Studio CRT and _snprintf dangerously incompatible.
We provide a safe wrapper if snprintf not found */ We provide a safe wrapper if snprintf not found */
#ifdef LIBSSH2_SNPRINTF #ifdef LIBSSH2_SNPRINTF

View File

@ -40,8 +40,8 @@
#ifdef LIBSSH2_CRYPTO_C /* Compile this via crypto.c */ #ifdef LIBSSH2_CRYPTO_C /* Compile this via crypto.c */
#include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <string.h>
#ifndef EVP_MAX_BLOCK_LENGTH #ifndef EVP_MAX_BLOCK_LENGTH
#define EVP_MAX_BLOCK_LENGTH 32 #define EVP_MAX_BLOCK_LENGTH 32

View File

@ -41,7 +41,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <alloca.h> #include <alloca.h>
#include <sys/uio.h> #include <sys/uio.h>

View File

@ -39,24 +39,18 @@
*/ */
#include "libssh2_priv.h" #include "libssh2_priv.h"
#include <errno.h>
#include <fcntl.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef HAVE_INTTYPES_H #ifdef HAVE_INTTYPES_H
#include <inttypes.h> #include <inttypes.h>
#endif #endif
/* Needed for struct iovec on some platforms */ /* Needed for struct iovec on some platforms */
#ifdef HAVE_SYS_UIO_H #ifdef HAVE_SYS_UIO_H
#include <sys/uio.h> #include <sys/uio.h>
#endif #endif
#include <sys/types.h>
#include "transport.h" #include "transport.h"
#include "channel.h" #include "channel.h"
#include "packet.h" #include "packet.h"

View File

@ -37,12 +37,19 @@
*/ */
#include "libssh2_priv.h" #include "libssh2_priv.h"
#include <errno.h>
#include <stdlib.h>
#include "channel.h" #include "channel.h"
#include "session.h" #include "session.h"
#include <stdlib.h> /* strtoll(), _strtoi64(), strtol() */
#if defined(HAVE_STRTOLL)
#define scpsize_strtol strtoll
#elif defined(HAVE_STRTOI64)
#define scpsize_strtol _strtoi64
#else
#define scpsize_strtol strtol
#endif
/* Max. length of a quoted string after libssh2_shell_quotearg() processing */ /* Max. length of a quoted string after libssh2_shell_quotearg() processing */
#define _libssh2_shell_quotedsize(s) (3 * strlen(s) + 2) #define _libssh2_shell_quotedsize(s) (3 * strlen(s) + 2)

View File

@ -42,18 +42,17 @@
#ifdef WIN32 #ifdef WIN32
#include <ws2tcpip.h> /* for socklen_t */ #include <ws2tcpip.h> /* for socklen_t */
#endif #endif
#include <errno.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <stdlib.h>
#include <fcntl.h>
#ifdef HAVE_ALLOCA_H #ifdef HAVE_ALLOCA_H
#include <alloca.h> #include <alloca.h>
#endif #endif
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include "transport.h" #include "transport.h"
#include "session.h" #include "session.h"
#include "channel.h" #include "channel.h"

View File

@ -37,14 +37,15 @@
* OF SUCH DAMAGE. * OF SUCH DAMAGE.
*/ */
#include <assert.h>
#include "libssh2_priv.h" #include "libssh2_priv.h"
#include "libssh2_sftp.h" #include "libssh2_sftp.h"
#include "channel.h" #include "channel.h"
#include "session.h" #include "session.h"
#include "sftp.h" #include "sftp.h"
#include <assert.h>
/* This release of libssh2 implements Version 5 with automatic downgrade /* This release of libssh2 implements Version 5 with automatic downgrade
* based on server's declaration * based on server's declaration
* https://www.ietf.org/archive/id/draft-ietf-secsh-filexfer-05.txt * https://www.ietf.org/archive/id/draft-ietf-secsh-filexfer-05.txt

View File

@ -39,13 +39,9 @@
*/ */
#include "libssh2_priv.h" #include "libssh2_priv.h"
#include <errno.h>
#include <fcntl.h>
#include <ctype.h>
#ifdef LIBSSH2DEBUG
#include <stdio.h>
#endif
#include <errno.h>
#include <ctype.h>
#include <assert.h> #include <assert.h>
#include "transport.h" #include "transport.h"

View File

@ -40,9 +40,6 @@
#include "libssh2_priv.h" #include "libssh2_priv.h"
#include <ctype.h> #include <ctype.h>
#include <stdio.h>
#include <assert.h>
/* Needed for struct iovec on some platforms */ /* Needed for struct iovec on some platforms */
#ifdef HAVE_SYS_UIO_H #ifdef HAVE_SYS_UIO_H

View File

@ -41,19 +41,20 @@
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <ctype.h>
#if defined(WIN32) && defined(_WIN64) #if defined(WIN32) && defined(_WIN64)
#define LIBSSH2_SOCKET_MASK "%lld" #define LIBSSH2_SOCKET_MASK "%lld"

View File

@ -38,25 +38,25 @@
#include "session_fixture.h" #include "session_fixture.h"
#include "openssh_fixture.h" #include "openssh_fixture.h"
#include <stdio.h> #ifdef HAVE_SYS_SOCKET_H
#include <stdlib.h> #include <sys/socket.h>
#endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#ifdef _MSC_VER #ifdef _MSC_VER
#include <direct.h> #include <direct.h>
#define chdir _chdir #define chdir _chdir
#endif #endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#include <assert.h>
static LIBSSH2_SESSION *connected_session = NULL; static LIBSSH2_SESSION *connected_session = NULL;
static libssh2_socket_t connected_socket = LIBSSH2_INVALID_SOCKET; static libssh2_socket_t connected_socket = LIBSSH2_INVALID_SOCKET;

View File

@ -17,7 +17,7 @@
#endif #endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h> /* for getenv() */
static const char *hostname = "127.0.0.1"; static const char *hostname = "127.0.0.1";
static const unsigned short port_number = 4711; static const unsigned short port_number = 4711;