aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cynapses.org>2010-07-13 15:10:19 +0200
committerAndreas Schneider <asn@cynapses.org>2010-07-13 15:10:19 +0200
commit7029d2f4b8af5a9cf067a17d17f3805c5a2f537a (patch)
treeb839b8bd9825942c1f469c4fddff6f93f4229ee8
parent3c9c358385fbb0d49609c99439ea481aa7f5e4cc (diff)
downloadlibssh-7029d2f4b8af5a9cf067a17d17f3805c5a2f537a.tar.gz
libssh-7029d2f4b8af5a9cf067a17d17f3805c5a2f537a.tar.xz
libssh-7029d2f4b8af5a9cf067a17d17f3805c5a2f537a.zip
build: Fixed the Windows preprocessor macros and defines.
-rw-r--r--ConfigureChecks.cmake9
-rw-r--r--config.h.cmake47
-rw-r--r--include/libssh/priv.h51
3 files changed, 52 insertions, 55 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index c214660f..7191a3df 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -40,15 +40,14 @@ if (WIN32)
endif (HAVE_WSPIAPI_H OR HAVE_WS2TCPIP_H)
check_function_exists(vsnprintf HAVE_VSNPRINTF)
- if(NOT HAVE_VSNPRINTF)
+ check_function_exists(snprintf HAVE_SNPRINTF)
+
+ if (WIN32)
check_function_exists(_vsnprintf_s HAVE__VSNPRINTF_S)
check_function_exists(_vsnprintf HAVE__VSNPRINTF)
- endif(NOT HAVE_VSNPRINTF)
- check_function_exists(snprintf HAVE_SNPRINTF)
- if(NOT HAVE_SNPRINTF)
check_function_exists(_snprintf HAVE__SNPRINTF)
check_function_exists(_snprintf_s HAVE__SNPRINTF_S)
- endif(NOT HAVE_SNPRINTF)
+ endif (WIN32)
check_function_exists(strncpy HAVE_STRNCPY)
set(HAVE_SELECT TRUE)
diff --git a/config.h.cmake b/config.h.cmake
index db5f32fe..f1a27581 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -127,6 +127,51 @@
# undef strdup
# define strdup _strdup
-# endif // _MSC_VER
+
+/* Imitate define of inttypes.h */
+# define PRIdS "Id"
+
+# define strcasecmp _stricmp
+# define strncasecmp _strnicmp
+# define strtoull _strtoui64
+# define isblank(ch) ((ch) == ' ' || (ch) == '\t' || (ch) == '\n' || (ch) == '\r')
+
+# define usleep(X) Sleep(((X)+1000)/1000)
+
+# undef strtok_r
+# define strtok_r strtok_s
+
+# if defined(HAVE__SNPRINTF_S)
+# undef snprintf
+# define snprintf(d, n, ...) _snprintf_s((d), (n), _TRUNCATE, __VA_ARGS__)
+# else /* HAVE__SNPRINTF_S */
+# if defined(HAVE__SNPRINTF)
+# undef snprintf
+# define snprintf _snprintf
+# else /* HAVE__SNPRINTF */
+# if !defined(HAVE_SNPRINTF)
+# error "no snprintf compatible function found"
+# endif /* HAVE_SNPRINTF */
+# endif /* HAVE__SNPRINTF */
+# endif /* HAVE__SNPRINTF_S */
+
+# if defined(HAVE__VSNPRINTF_S)
+# undef vsnprintf
+# define vsnprintf(s, n, f, v) _vsnprintf_s((s), (n), _TRUNCATE, (f), (v))
+# else /* HAVE__VSNPRINTF_S */
+# if deffined(HAVE__VSNPRINTF)
+# undef vsnprintf
+# define vsnprintf _vsnprintf
+# else
+# if !defined(HAVE_VSNPRINTF)
+# error "No vsnprintf compatible function found"
+# endif /* HAVE_VSNPRINTF */
+# endif /* HAVE__VSNPRINTF */
+# endif /* HAVE__VSNPRINTF_S */
+
+# ifndef HAVE_STRNCPY
+# define strncpy(d, s, n) strncpy_s((d), (n), (s), _TRUNCATE)
+# endif
+# endif /* _MSC_VER */
#endif /* _WIN32 */
diff --git a/include/libssh/priv.h b/include/libssh/priv.h
index f3c2babd..1672fb48 100644
--- a/include/libssh/priv.h
+++ b/include/libssh/priv.h
@@ -32,57 +32,10 @@
#include "config.h"
-#ifdef _MSC_VER
-
-/** Imitate define of inttypes.h */
-#define PRIdS "Id"
-
-#define strcasecmp _stricmp
-#define strncasecmp _strnicmp
-#define strtoull _strtoui64
-#define isblank(ch) ((ch) == ' ' || (ch) == '\t' || (ch) == '\n' || (ch) == '\r')
-
-#if _MSC_VER >= 1400
-#define strdup _strdup
-#endif
-#define usleep(X) Sleep(((X)+1000)/1000)
-
-#undef strtok_r
-#define strtok_r strtok_s
-
-#ifndef HAVE_SNPRINTF
-#ifdef HAVE__SNPRINTF_S
-#define snprintf(d, n, ...) _snprintf_s((d), (n), _TRUNCATE, __VA_ARGS__)
-#else
-#ifdef HAVE__SNPRINTF
-#define snprintf _snprintf
-#else
-#error "no snprintf compatible function found"
-#endif /* HAVE__SNPRINTF */
-#endif /* HAVE__SNPRINTF_S */
-#endif /* HAVE_SNPRINTF */
-
-#ifndef HAVE_VSNPRINTF
-#ifdef HAVE__VSNPRINTF_S
-#define vsnprintf(s, n, f, v) _vsnprintf_s((s), (n), _TRUNCATE, (f), (v))
-#else
-#ifdef HAVE__VSNPRINTF
-#define vsnprintf _vsnprintf
-#else /* HAVE_VSNPRINTF */
-#error "No vsnprintf compatible function found"
-#endif /* HAVE__VSNPRINTF */
-#endif /* HAVE__VSNPRINTF_S */
-#endif /* HAVE_VSNPRINTF */
-
-#ifndef HAVE_STRNCPY
-#define strncpy(d, s, n) strncpy_s((d), (n), (s), _TRUNCATE)
-#endif
-#else /* _MSC_VER */
-
+#ifndef _WIN32
#include <unistd.h>
#define PRIdS "zd"
-
-#endif /* _MSC_VER */
+#endif /* _WIN32 */
#include "libssh/libssh.h"
#include "libssh/callbacks.h"