From df81a05505514b384d10c9b192137584040e4984 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 22 Jul 2013 10:41:58 +0200 Subject: [PATCH] cmake: Check for unistd.h. --- ConfigureChecks.cmake | 1 + config.h.cmake | 3 +++ examples/sample.c | 13 ++++++++++--- examples/samplesftp.c | 4 +++- examples/sshnetcat.c | 6 +++++- src/agent.c | 4 ++-- src/channels1.c | 2 ++ src/getpass.c | 6 ++++++ src/gssapi.c | 27 +++++++++++++++------------ src/poll.c | 5 ++++- tests/torture.c | 5 ++++- 11 files changed, 55 insertions(+), 21 deletions(-) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index d56f15b3..5364739a 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -49,6 +49,7 @@ endif(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW AND NOT OS2) check_include_file(argp.h HAVE_ARGP_H) check_include_file(pty.h HAVE_PTY_H) check_include_file(termios.h HAVE_TERMIOS_H) +check_include_file(unistd.h HAVE_UNISTD_H) if (WIN32) check_include_files("winsock2.h;ws2tcpip.h;wspiapi.h" HAVE_WSPIAPI_H) diff --git a/config.h.cmake b/config.h.cmake index 18d82e4b..f7f8957f 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -23,6 +23,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_TERMIOS_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_OPENSSL_AES_H 1 diff --git a/examples/sample.c b/examples/sample.c index 1fd96364..616372cb 100644 --- a/examples/sample.c +++ b/examples/sample.c @@ -14,24 +14,31 @@ clients must be made or how a client should react. #include "config.h" #include -#include #include #include -#include #include #include + +#ifdef HAVE_TERMIOS_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif #ifdef HAVE_PTY_H #include #endif + #include #include #include +#include + #include #include #include -#include #include "examples_common.h" #define MAXCMD 10 diff --git a/examples/samplesftp.c b/examples/samplesftp.c index 968624e8..457e60a4 100644 --- a/examples/samplesftp.c +++ b/examples/samplesftp.c @@ -15,11 +15,13 @@ clients must be made or how a client should react. #include #include -#include #include #include #include #include +#ifdef HAVE_UNISTD_H +#include +#endif #include #include diff --git a/examples/sshnetcat.c b/examples/sshnetcat.c index 19f6500a..052cabf4 100644 --- a/examples/sshnetcat.c +++ b/examples/sshnetcat.c @@ -13,10 +13,14 @@ clients must be made or how a client should react. #include "config.h" #include -#include #include #include +#ifdef HAVE_TERMIOS_H #include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif #include #include diff --git a/src/agent.c b/src/agent.c index 1f7454e6..1b094ed4 100644 --- a/src/agent.c +++ b/src/agent.c @@ -42,12 +42,12 @@ #include #include +#ifdef HAVE_UNISTD_H #include +#endif -#ifndef _WIN32 #include #include -#endif #include "libssh/agent.h" #include "libssh/priv.h" diff --git a/src/channels1.c b/src/channels1.c index 30030db0..bc66488d 100644 --- a/src/channels1.c +++ b/src/channels1.c @@ -27,6 +27,8 @@ #include #ifndef _WIN32 #include +#endif +#ifdef HAVE_UNISTD_H #include #endif diff --git a/src/getpass.c b/src/getpass.c index cc6d33ca..0ffb955d 100644 --- a/src/getpass.c +++ b/src/getpass.c @@ -21,6 +21,8 @@ * MA 02111-1307, USA. */ +#include "config.h" + #include #include #include @@ -163,8 +165,12 @@ int ssh_getpass(const char *prompt, #else #include +#ifdef HAVE_TERMIOS_H #include +#endif +#ifdef HAVE_UNISTD_H #include +#endif /** * @ingroup libssh_misc diff --git a/src/gssapi.c b/src/gssapi.c index 5856d114..228eaef7 100644 --- a/src/gssapi.c +++ b/src/gssapi.c @@ -19,21 +19,24 @@ * MA 02111-1307, USA. */ -#include "libssh/gssapi.h" -#include "libssh/libssh.h" -#include "libssh/ssh2.h" -#include "libssh/buffer.h" -#include "libssh/crypto.h" -#include "libssh/callbacks.h" -#include "libssh/string.h" -#include "libssh/server.h" +#include "config.h" + +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif #include -/* to remove */ -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include /** current state of an GSSAPI authentication */ enum ssh_gssapi_state_e { diff --git a/src/poll.c b/src/poll.c index 85ee655d..bde0198d 100644 --- a/src/poll.c +++ b/src/poll.c @@ -115,10 +115,13 @@ static poll_fn ssh_poll_emu; #else /* _WIN32 */ #include #include -#include #include #endif /* _WIN32 */ +#ifdef HAVE_UNISTD_H +#include +#endif + /* * This is a poll(2)-emulation using select for systems not providing a native diff --git a/tests/torture.c b/tests/torture.c index 2a49f0d7..c7031fcb 100644 --- a/tests/torture.c +++ b/tests/torture.c @@ -30,7 +30,10 @@ # include # include # include -# include +#endif + +#ifdef HAVE_UNISTD_H +#include #endif #include "torture.h"