#include "config.h"
-#if STDC_HEADERS
+#ifdef STDC_HEADERS
# include <stdlib.h>
# include <string.h>
#endif /* STDC_HEADERS */
-#if defined HAVE_STRINGS_H && !defined _STRING_H && !defined __USE_BSD
+#if defined(HAVE_STRINGS_H) && !defined(_STRING_H) && !defined(__USE_BSD)
# include <strings.h>
#endif /* HAVE_STRINGS_H */
#include "json_object_private.h"
#include "json_util.h"
-#if !HAVE_STRNDUP
+#if !defined(HAVE_STRDUP) && defined(_MSC_VER)
+ /* MSC has the version as _strdup */
+# define strdup _strdup
+#elif !defined(HAVE_STRDUP)
+# error You do not have strdup on your system.
+#endif /* HAVE_STRDUP */
+
+#if !defined(HAVE_STRNDUP)
char* strndup(const char* str, size_t n);
#endif /* !HAVE_STRNDUP */
#include "json_tokener.h"
#include "json_util.h"
+#if !HAVE_STRDUP && defined(_MSC_VER)
+ /* MSC has the version as _strdup */
+# define strdup _strdup
+#elif !HAVE_STRDUP
+# error You do not have strdup on your system.
+#endif /* HAVE_STRDUP */
+
#if !HAVE_STRNCASECMP && defined(_MSC_VER)
/* MSC has the version as _strnicmp */
# define strncasecmp _strnicmp
# error You do not have strncasecmp on your system.
#endif /* HAVE_STRNCASECMP */
-
static const char* json_null_str = "null";
static const char* json_true_str = "true";
static const char* json_false_str = "false";
#include <errno.h>
#include <ctype.h>
-#if HAVE_SYS_TYPES_H
+#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */
-#if HAVE_SYS_STAT_H
+#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif /* HAVE_SYS_STAT_H */
-#if HAVE_FCNTL_H
+#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif /* HAVE_FCNTL_H */
-#if HAVE_UNISTD_H
+#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
# include <io.h>
#endif /* defined(WIN32) */
-#if !HAVE_OPEN && defined(WIN32)
+#if !defined(HAVE_OPEN) && defined(WIN32)
# define open _open
#endif
+#if !defined(HAVE_SNPRINTF) && defined(_MSC_VER)
+ /* MSC has the version as _snprintf */
+# define snprintf _snprintf
+#elif !defined(HAVE_SNPRINTF)
+# error You do not have snprintf on your system.
+#endif /* HAVE_SNPRINTF */
#include "bits.h"
#include "debug.h"
return 0;
}
-#if HAVE_REALLOC == 0
+#ifndef HAVE_REALLOC
void* rpl_realloc(void* p, size_t n)
{
if (n == 0)
#include <stdlib.h>
#include <string.h>
-#if HAVE_STDARG_H
+#ifdef HAVE_STDARG_H
# include <stdarg.h>
#else /* !HAVE_STDARG_H */
# error Not enough var arg support!
return 0;
}
-#if !HAVE_VSNPRINTF && defined(_MSC_VER)
+#if !defined(HAVE_VSNPRINTF) && defined(_MSC_VER)
# define vsnprintf _vsnprintf
-#elif !HAVE_VSNPRINTF /* !HAVE_VSNPRINTF */
+#elif !defined(HAVE_VSNPRINTF) /* !HAVE_VSNPRINTF */
# error Need vsnprintf!
#endif /* !HAVE_VSNPRINTF && defined(WIN32) */
-#if !HAVE_VASPRINTF
+#if !defined(HAVE_VASPRINTF)
/* CAW: compliant version of vasprintf */
static int vasprintf(char **buf, const char *fmt, va_list ap)
{