r721 - in trunk/varnish-cache: . include lib/libcompat

des at projects.linpro.no des at projects.linpro.no
Mon Aug 7 17:24:24 CEST 2006


Author: des
Date: 2006-08-07 17:24:24 +0200 (Mon, 07 Aug 2006)
New Revision: 721

Added:
   trunk/varnish-cache/lib/libcompat/asprintf.c
   trunk/varnish-cache/lib/libcompat/vasprintf.c
Modified:
   trunk/varnish-cache/configure.ac
   trunk/varnish-cache/include/compat.h
   trunk/varnish-cache/lib/libcompat/Makefile.am
   trunk/varnish-cache/lib/libcompat/strlcat.c
   trunk/varnish-cache/lib/libcompat/strlcpy.c
Log:
Add implementations of asprintf(3) and vasprintf(3).

Modified: trunk/varnish-cache/configure.ac
===================================================================
--- trunk/varnish-cache/configure.ac	2006-08-07 15:09:53 UTC (rev 720)
+++ trunk/varnish-cache/configure.ac	2006-08-07 15:24:24 UTC (rev 721)
@@ -61,6 +61,8 @@
 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])
 

Modified: trunk/varnish-cache/include/compat.h
===================================================================
--- trunk/varnish-cache/include/compat.h	2006-08-07 15:09:53 UTC (rev 720)
+++ trunk/varnish-cache/include/compat.h	2006-08-07 15:24:24 UTC (rev 721)
@@ -5,6 +5,14 @@
 #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

Modified: trunk/varnish-cache/lib/libcompat/Makefile.am
===================================================================
--- trunk/varnish-cache/lib/libcompat/Makefile.am	2006-08-07 15:09:53 UTC (rev 720)
+++ trunk/varnish-cache/lib/libcompat/Makefile.am	2006-08-07 15:24:24 UTC (rev 721)
@@ -5,6 +5,8 @@
 lib_LIBRARIES = libcompat.a
 
 libcompat_a_SOURCES = \
+	asprintf.c \
+	vasprintf.c \
 	strlcat.c \
 	strlcpy.c
 

Added: trunk/varnish-cache/lib/libcompat/asprintf.c
===================================================================
--- trunk/varnish-cache/lib/libcompat/asprintf.c	2006-08-07 15:09:53 UTC (rev 720)
+++ trunk/varnish-cache/lib/libcompat/asprintf.c	2006-08-07 15:24:24 UTC (rev 721)
@@ -0,0 +1,23 @@
+/*
+ * $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


Property changes on: trunk/varnish-cache/lib/libcompat/asprintf.c
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: trunk/varnish-cache/lib/libcompat/strlcat.c
===================================================================
--- trunk/varnish-cache/lib/libcompat/strlcat.c	2006-08-07 15:09:53 UTC (rev 720)
+++ trunk/varnish-cache/lib/libcompat/strlcat.c	2006-08-07 15:24:24 UTC (rev 721)
@@ -20,7 +20,6 @@
 #include <sys/types.h>
 #include <string.h>
 
-#include "config.h"
 #include "compat.h"
 
 #ifndef HAVE_STRLCAT

Modified: trunk/varnish-cache/lib/libcompat/strlcpy.c
===================================================================
--- trunk/varnish-cache/lib/libcompat/strlcpy.c	2006-08-07 15:09:53 UTC (rev 720)
+++ trunk/varnish-cache/lib/libcompat/strlcpy.c	2006-08-07 15:24:24 UTC (rev 721)
@@ -20,7 +20,6 @@
 #include <sys/types.h>
 #include <string.h>
 
-#include "config.h"
 #include "compat.h"
 
 #ifndef HAVE_STRLCPY

Added: trunk/varnish-cache/lib/libcompat/vasprintf.c
===================================================================
--- trunk/varnish-cache/lib/libcompat/vasprintf.c	2006-08-07 15:09:53 UTC (rev 720)
+++ trunk/varnish-cache/lib/libcompat/vasprintf.c	2006-08-07 15:24:24 UTC (rev 721)
@@ -0,0 +1,26 @@
+/*
+ * $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


Property changes on: trunk/varnish-cache/lib/libcompat/vasprintf.c
___________________________________________________________________
Name: svn:keywords
   + Id




More information about the varnish-commit mailing list