AC_CHECK_FUNCS([strerror])
AC_FUNC_STRERROR_R
AC_CHECK_FUNCS([socket])
+AC_CHECK_FUNCS([vasprintf])
+AC_CHECK_FUNCS([asprintf])
AC_CHECK_FUNCS([strlcat])
AC_CHECK_FUNCS([strlcpy])
#ifndef COMPAT_H_INCLUDED
#define COMPAT_H_INCLUDED
+#ifndef HAVE_VASPRINTF
+int asprintf(char **strp, const char *fmt, va_list ap)
+#endif
+
+#ifndef HAVE_ASPRINTF
+int asprintf(char **strp, const char *fmt, ...)
+#endif
+
#ifndef HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t size);
#endif
lib_LIBRARIES = libcompat.a
libcompat_a_SOURCES = \
+ asprintf.c \
+ vasprintf.c \
strlcat.c \
strlcpy.c
--- /dev/null
+/*
+ * $Id$
+ *
+ */
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#include "compat.h"
+
+#ifndef HAVE_ASPRINTF
+int
+asprintf(char **strp, const char *fmt, ...)
+{
+ va_list ap;
+ int ret;
+
+ va_start(ap, fmt);
+ ret = vasprintf(strp, fmt, ap);
+ va_end(ap);
+ return (ret);
+}
+#endif
#include <sys/types.h>
#include <string.h>
-#include "config.h"
#include "compat.h"
#ifndef HAVE_STRLCAT
#include <sys/types.h>
#include <string.h>
-#include "config.h"
#include "compat.h"
#ifndef HAVE_STRLCPY
--- /dev/null
+/*
+ * $Id$
+ *
+ */
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#include "compat.h"
+
+#ifndef HAVE_VASPRINTF
+int
+asprintf(char **strp, const char *fmt, va_list ap)
+{
+ va_list ap, aq;
+ int ret;
+
+ va_copy(aq, ap);
+ ret = vsnprintf(NULL, 0, fmt, aq);
+ va_end(aq);
+ if ((*strp = malloc(ret + 1)) == NULL)
+ return (-1);
+ ret = vsnprintf(*strp, ret + 1, fmt, ap);
+ return (ret);
+}
+#endif