dnl these tests have been comfirmed to be needed in 2011
AC_CHECK_FUNCS(backtrace_symbols dirfd getusershell pread pwrite pselect)
-AC_CHECK_FUNCS(setlinebuf strlcat strlcpy strnlen mempcpy)
+AC_CHECK_FUNCS(setlinebuf strlcat strlcpy strnlen mempcpy vasprintf)
AC_CHECK_FUNCS(mmap utime getpagesize) dnl needed by tbd
dnl search for necessary libraries
extern size_t strlcat (char *, const char *, size_t);
#endif
+#ifndef HAVE_VASPRINTF
+#include <stdio.h>
+#include <stdarg.h>
+extern int vasprintf(char **ret, const char *fmt, va_list ap);
+#endif
+
#endif
#include "config.h"
#endif /* HAVE_CONFIG_H */
+#include <stdio.h>
+#include <stdarg.h>
+
#include <atalk/compat.h>
#if !defined HAVE_DIRFD && defined SOLARIS
return len;
}
#endif
+
+#ifndef HAVE_VASPRINTF
+int vasprintf(char **ret, const char *fmt, va_list ap)
+{
+ int n, size = 64;
+ char *p, *np;
+
+ if ((p = malloc(size)) == NULL)
+ return NULL;
+
+ while (1) {
+ /* Try to print in the allocated space. */
+ n = vsnprintf(p, size, fmt, ap);
+ /* If that worked, return the string. */
+ if (n > -1 && n < size) {
+ *ret = p;
+ return n;
+ }
+ /* Else try again with more space. */
+ if (n > -1) /* glibc 2.1 */
+ size = n+1; /* precisely what is needed */
+ else /* glibc 2.0 */
+ size *= 2; /* twice the old size */
+ if ((np = realloc (p, size)) == NULL) {
+ free(p);
+ *ret = NULL;
+ return -1;
+ } else {
+ p = np;
+ }
+ }
+}
+#endif