extern int sigvec (int, struct sigvec *, struct sigvec *);
#endif
-#if HW_WANT_RPL_VSNPRINTF
-#define vsnprintf rpl_vsnprintf
-int rpl_vsnprintf(char *, size_t, const char *, va_list);
-#endif
-
-#if HW_WANT_RPL_SNPRINTF
-#define snprintf rpl_snprintf
-int rpl_snprintf(char *, size_t, const char *, ...);
-#endif
-
#ifdef DECL_STDIO_0
#if defined(FILE) || defined(BUFSIZ)
extern int _flsbuf (int, FILE *);
static const char *fmt = "%u.%u.%u.%u";
char tmp[sizeof("255.255.255.255")];
- /* NTP local change to use SNPRINTF() macro for SunOS4 compat */
- if (SNPRINTF((tmp, sizeof(tmp), fmt, src[0], src[1], src[2],
- src[3])) >= size)
+ if (snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2],
+ src[3]) >= size)
{
errno = ENOSPC;
return (NULL);
#endif
#include <stdio.h>
+#include "ntp_string.h"
#include "ntp.h"
#include "ntp_debug.h"
-#include "ntp_string.h"
#include "ntp_syslog.h"
#ifdef SYS_WINNT
void addto_syslog (int, const char *);
void format_errmsg (char *, size_t, const char *, int);
+/*
+ * Work around misdetection by AC_FUNC_STRERROR_R on Debian Linux.
+ */
+#if defined(STRERROR_R_CHAR_P) && strerror_r == __xpg_strerror_r
+# undef STRERROR_R_CHAR_P
+#endif
+
/*
* errno_to_str() - a thread-safe strerror() replacement.
# if defined(STRERROR_R_CHAR_P) || !HAVE_DECL_STRERROR_R
char * pstatic;
+ buf[0] = '\0';
# ifdef STRERROR_R_CHAR_P
/*
* For older GNU strerror_r, the return value either points to
# else
pstatic = strerror(err);
# endif
- if (pstatic != buf)
+ if (NULL == pstatic && '\0' == buf[0])
+ snprintf(buf, bufsiz, "%s(%d): errno %d",
+# ifdef STRERROR_R_CHAR_P
+ "strerror_r",
+# else
+ "strerror",
+# endif
+ err, errno);
+ /* protect against believing an int return is a pointer */
+ else if (pstatic != buf && pstatic > (char *)bufsiz)
strlcpy(buf, pstatic, bufsiz);
# else
int rc;
#define HAVE_BSD_NICE /* emulate BSD setpriority() */
#define HW_WANT_RPL_VSNPRINTF 1
+#define vsnprintf rpl_vsnprintf
+#include <stdarg.h>
+int rpl_vsnprintf(char *, size_t, const char *, va_list);
#define HW_WANT_RPL_SNPRINTF 1
+#define snprintf rpl_snprintf
+int rpl_snprintf(char *, size_t, const char *, ...);
#define HAVE_VSNPRINTF 1
#define HAVE_SNPRINTF 1
#include <isc/strerror.h>
#include <lib_strbuf.h>
+#include "ntp_stdlib.h"
+
#include "messages.h"
static HANDLE hAppLog = NULL;
AC_FUNC_FORK
AC_FUNC_ALLOCA
+AC_FUNC_STRERROR_R
ac_busted_vpath_in_make=no
case "$build" in
esac
AC_TYPE_UID_T
-AC_FUNC_STRERROR_R
m4_divert_text([HELP_ENABLE],
[AS_HELP_STRING([defaults:],
AM_CONDITIONAL([PTHREADS], [test "$have_pthreads" != "no"])
AC_DEFUN([NTP_BEFORE_HW_FUNC_VSNPRINTF], [
-AC_BEFORE([$0], [HW_FUNC_VSNPRINTF])
-AC_BEFORE([$0], [HW_FUNC_SNPRINTF])
-AC_ARG_ENABLE(
- [c99-snprintf],
- [AS_HELP_STRING([--enable-c99-snprintf], [s force replacement])],
- [force_c99_snprintf=$enableval],
- [force_c99_snprintf=no]
- )
-case "$force_c99_snprintf" in
- yes)
- hw_force_rpl_snprintf=yes
- hw_force_rpl_vsnprintf=yes
-esac
-hw_nodef_snprintf=yes
-hw_nodef_vsnprintf=yes
+ AC_BEFORE([$0], [HW_FUNC_VSNPRINTF])dnl
+ AC_BEFORE([$0], [HW_FUNC_SNPRINTF])dnl
+ AC_ARG_ENABLE(
+ [c99-snprintf],
+ [AS_HELP_STRING([--enable-c99-snprintf], [s force replacement])],
+ [force_c99_snprintf=$enableval],
+ [force_c99_snprintf=no]
+ )
+ case "$force_c99_snprintf" in
+ yes)
+ hw_force_rpl_snprintf=yes
+ hw_force_rpl_vsnprintf=yes
+ esac
+ AH_TOP([
+ #if !defined(_KERNEL) && !defined(PARSESTREAM)
+ # include <stdio.h> /* before #define vsnprintf rpl_... */
+ #endif
+ ])
+ AH_BOTTOM([
+ #if !defined(_KERNEL) && !defined(PARSESTREAM)
+ # if defined(HW_WANT_RPL_VSNPRINTF)
+ # if defined(__cplusplus)
+ extern "C" {
+ # endif
+ # include <stdarg.h>
+ int rpl_vsnprintf(char *, size_t, const char *, va_list);
+ # if defined(__cplusplus)
+ }
+ # endif
+ # endif
+ # if defined(HW_WANT_RPL_SNPRINTF)
+ # if defined(__cplusplus)
+ extern "C" {
+ # endif
+ int rpl_snprintf(char *, size_t, const char *, ...);
+ # if defined(__cplusplus)
+ }
+ # endif
+ # endif
+ #endif /* !defined(_KERNEL) && !defined(PARSESTREAM) */
+ ])
]) dnl end of AC_DEFUN of NTP_BEFORE_HW_FUNC_VSNPRINTF
AC_DEFUN([NTP_C99_SNPRINTF], [
-AC_REQUIRE([NTP_BEFORE_HW_FUNC_VSNPRINTF])
-AC_REQUIRE([HW_FUNC_VSNPRINTF])
-AC_REQUIRE([HW_FUNC_SNPRINTF])
+ AC_REQUIRE([NTP_BEFORE_HW_FUNC_VSNPRINTF])dnl
+ AC_REQUIRE([HW_FUNC_VSNPRINTF])dnl
+ AC_REQUIRE([HW_FUNC_SNPRINTF])dnl
]) dnl end of DEFUN of NTP_C99_SNPRINTF
NTP_C99_SNPRINTF
# libopts to avoid their own replacement of snprintf.
#
# Changed to honor hw_nodef_snprintf, etc. which prevent config.h from
-# aliasing snprintf to rpl_snprintf, etc. NTP uses this to defer that
-# definition until after system include files to avoid problems seen
-# on Linux building sntp/tests:
-# /usr/include/c++/4.4/cstdio:165: error: '::snprintf' has not been declared
-# This cstdio #undef's snprintf and then re-declares ::snprintf, however
-# the earlier stdio.h had its declarations aliased to rpl_snprintf, etc.
+# aliasing snprintf to rpl_snprintf, etc.
#
# Changed to honor hw_force_rpl_snprintf=yes, etc. This is used by NTP
# to test rpl_snprintf() and rpl_vsnprintf() on platforms which provide
extern "C" {
#include <stdio.h>
+#include <string.h>
#include <errno.h>
// format_errmsg() is normally private to msyslog.c
void format_errmsg (char *, size_t, const char *, int);