aboutsummaryrefslogtreecommitdiff
path: root/include/libssh/priv.h
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cynapses.org>2010-07-13 15:10:19 +0200
committerAndreas Schneider <asn@cynapses.org>2010-08-03 18:13:59 +0200
commit296f6a9217cb7afa080edb0efc16d309db77c06b (patch)
tree85395c82c66a1292d99a751a2a94f65b940ba8fb /include/libssh/priv.h
parentd688ed2553cd756d9e0bdacd62145d1e9e1f1367 (diff)
downloadlibssh-296f6a9217cb7afa080edb0efc16d309db77c06b.tar.gz
libssh-296f6a9217cb7afa080edb0efc16d309db77c06b.tar.xz
libssh-296f6a9217cb7afa080edb0efc16d309db77c06b.zip
build: Fixed the Windows preprocessor macros and defines.
Diffstat (limited to 'include/libssh/priv.h')
-rw-r--r--include/libssh/priv.h96
1 files changed, 61 insertions, 35 deletions
diff --git a/include/libssh/priv.h b/include/libssh/priv.h
index a5d6e418..b7e231b9 100644
--- a/include/libssh/priv.h
+++ b/include/libssh/priv.h
@@ -32,46 +32,72 @@
#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
-
-#undef snprintf
-#define snprintf(d, n, ...) _snprintf_s((d), (n), _TRUNCATE, __VA_ARGS__)
+#ifdef _WIN32
-#ifndef HAVE_VSNPRINTF
-#ifdef HAVE__VSNPRINTF_S
-#define vsnprintf(s, n, f, v) _vsnprintf_s((s), (n), _TRUNCATE, (f), (v))
-#elif HAVE__VSNPRINTF
-#define vsnprintf _vsnprintf
-#else /* HAVE_VSNPRINTF */
-#error "No vsnprintf compatibel function found"
-#endif
-#endif /* HAVE_VSNPRINTF */
-
-#ifndef HAVE_STRNCPY
-#define strncpy(d, s, n) strncpy_s((d), (n), (s), _TRUNCATE)
-#endif
-#else /* _MSC_VER */
+/* Imitate define of inttypes.h */
+# ifndef PRIdS
+# define PRIdS "Id"
+# endif
+
+# ifdef _MSC_VER
+# include <stdio.h>
+
+/* On Microsoft compilers define inline to __inline on all others use inline */
+# undef inline
+# define inline __inline
+
+# undef strdup
+# define strdup _strdup
+
+# 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 defined(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 */
+
+#else /* _WIN32 */
#include <unistd.h>
#define PRIdS "zd"
-#endif /* _MSC_VER */
+#endif /* _WIN32 */
#include "libssh/libssh.h"
#include "libssh/callbacks.h"