aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2013-07-22 10:41:58 +0200
committerAndreas Schneider <asn@cryptomilk.org>2013-07-23 10:44:51 +0200
commitdf81a05505514b384d10c9b192137584040e4984 (patch)
tree79c078d9f70668ccb42836489dee3febb2abd7d0
parent7d07e1f1bd06b509b8ee4bae4b22338c5e16735a (diff)
downloadlibssh-df81a05505514b384d10c9b192137584040e4984.tar.gz
libssh-df81a05505514b384d10c9b192137584040e4984.tar.xz
libssh-df81a05505514b384d10c9b192137584040e4984.zip
cmake: Check for unistd.h.
-rw-r--r--ConfigureChecks.cmake1
-rw-r--r--config.h.cmake3
-rw-r--r--examples/sample.c13
-rw-r--r--examples/samplesftp.c4
-rw-r--r--examples/sshnetcat.c6
-rw-r--r--src/agent.c4
-rw-r--r--src/channels1.c2
-rw-r--r--src/getpass.c6
-rw-r--r--src/gssapi.c27
-rw-r--r--src/poll.c5
-rw-r--r--tests/torture.c5
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 <termios.h> header file. */
#cmakedefine HAVE_TERMIOS_H 1
+/* Define to 1 if you have the <unistd.h> header file. */
+#cmakedefine HAVE_UNISTD_H 1
+
/* Define to 1 if you have the <openssl/aes.h> 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 <stdio.h>
-#include <unistd.h>
#include <stdlib.h>
#include <string.h>
-#include <termios.h>
#include <sys/select.h>
#include <sys/time.h>
+
+#ifdef HAVE_TERMIOS_H
+#include <termios.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#ifdef HAVE_PTY_H
#include <pty.h>
#endif
+
#include <sys/ioctl.h>
#include <signal.h>
#include <errno.h>
+#include <fcntl.h>
+
#include <libssh/callbacks.h>
#include <libssh/libssh.h>
#include <libssh/sftp.h>
-#include <fcntl.h>
#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 <sys/statvfs.h>
#include <stdio.h>
-#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#include <libssh/libssh.h>
#include <libssh/sftp.h>
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 <stdio.h>
-#include <unistd.h>
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_TERMIOS_H
#include <termios.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#include <sys/select.h>
#include <sys/time.h>
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 <string.h>
#include <stdio.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
-#ifndef _WIN32
#include <netinet/in.h>
#include <arpa/inet.h>
-#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 <stdio.h>
#ifndef _WIN32
#include <arpa/inet.h>
+#endif
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
#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 <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -163,8 +165,12 @@ int ssh_getpass(const char *prompt,
#else
#include <fcntl.h>
+#ifdef HAVE_TERMIOS_H
#include <termios.h>
+#endif
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#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 <gssapi.h>
-
-/* to remove */
#include <stdio.h>
-#include <unistd.h>
#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <gssapi.h>
+
+#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>
/** 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 <sys/select.h>
#include <sys/socket.h>
-#include <unistd.h>
#include <sys/time.h>
#endif /* _WIN32 */
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#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 <sys/stat.h>
# include <dirent.h>
# include <errno.h>
-# include <unistd.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
#endif
#include "torture.h"