aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2010-05-14 12:46:17 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2010-05-14 12:46:17 +0200
commitabc61fa1ccfa5472ab4dbc0088663f8b26582196 (patch)
treee1f9fe451ec0c6e50b0f2e1e1f334beb31fb94d3
parente94bff02ba513628088fd112c5c7cbd9f9a4a57f (diff)
downloadlibssh-abc61fa1ccfa5472ab4dbc0088663f8b26582196.tar.gz
libssh-abc61fa1ccfa5472ab4dbc0088663f8b26582196.tar.xz
libssh-abc61fa1ccfa5472ab4dbc0088663f8b26582196.zip
Fix build on VC7
-rw-r--r--ConfigureChecks.cmake6
-rw-r--r--config.h.cmake10
-rw-r--r--include/libssh/priv.h13
3 files changed, 26 insertions, 3 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index f4ef836f..fd31e4ec 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -44,7 +44,11 @@ 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_HAVE_SNPRINTF)
check_function_exists(strncpy HAVE_STRNCPY)
set(HAVE_SELECT TRUE)
diff --git a/config.h.cmake b/config.h.cmake
index 4b96e28c..db5f32fe 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -46,6 +46,16 @@
/* Define to 1 if you have the `_vsnprintf_s' function. */
#cmakedefine HAVE__VSNPRINTF_S
+/* Define to 1 if you have the `snprintf' function. */
+#cmakedefine HAVE_SNPRINTF
+
+/* Define to 1 if you have the `_snprintf' function. */
+#cmakedefine HAVE__SNPRINTF
+
+/* Define to 1 if you have the `_snprintf_s' function. */
+#cmakedefine HAVE__SNPRINTF_S
+
+
/* Define to 1 if you have the `strncpy' function. */
#cmakedefine HAVE_STRNCPY
diff --git a/include/libssh/priv.h b/include/libssh/priv.h
index 826e9692..77423bfb 100644
--- a/include/libssh/priv.h
+++ b/include/libssh/priv.h
@@ -50,8 +50,17 @@
#undef strtok_r
#define strtok_r strtok_s
-#undef snprintf
+#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
@@ -59,7 +68,7 @@
#elif HAVE__VSNPRINTF
#define vsnprintf _vsnprintf
#else /* HAVE_VSNPRINTF */
-#error "No vsnprintf compatibel function found"
+#error "No vsnprintf compatible function found"
#endif
#endif /* HAVE_VSNPRINTF */