Commit 0baad165 authored by Dag Erling Smørgrav's avatar Dag Erling Smørgrav

Split compat.h into one header per function to avoid issues with e.g. the

vasprintf() prototype needing <stdarg.h> even when it isn't used.

git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@761 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent f455287c
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "compat.h" #include "compat/vasprintf.h"
#include "cli_priv.h" #include "cli_priv.h"
#include "cli.h" #include "cli.h"
#include "vsb.h" #include "vsb.h"
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "compat.h" #include "compat/asprintf.h"
#include "vsb.h" #include "vsb.h"
#include "queue.h" #include "queue.h"
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "compat.h" #include "compat/asprintf.h"
#include "shmlog.h" #include "shmlog.h"
#include "cache.h" #include "cache.h"
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "compat/strlcpy.h"
#include "heritage.h" #include "heritage.h"
#include "mgt.h" #include "mgt.h"
......
...@@ -5,7 +5,10 @@ noinst_HEADERS = \ ...@@ -5,7 +5,10 @@ noinst_HEADERS = \
cli.h \ cli.h \
cli_common.h \ cli_common.h \
cli_priv.h \ cli_priv.h \
compat.h \ compat/asprintf.h \
compat/strlcat.h \
compat/strlcpy.h \
compat/vasprintf.h \
hash.h \ hash.h \
http_headers.h \ http_headers.h \
libvarnish.h \ libvarnish.h \
......
/*
* $Id$
*/
#ifndef COMPAT_H_INCLUDED
#define COMPAT_H_INCLUDED
#ifndef HAVE_VASPRINTF
#ifdef va_start /* make sure <stdarg.h> is in scope */
int vasprintf(char **strp, const char *fmt, va_list ap);
#endif
#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
#ifndef HAVE_STRLCAT
size_t strlcat(char *dst, const char *src, size_t size);
#endif
#endif
/*
* $Id$
*/
#ifndef COMPAT_ASPRINTF_H_INCLUDED
#define COMPAT_ASPRINTF_H_INCLUDED
#ifndef HAVE_ASPRINTF
int asprintf(char **strp, const char *fmt, ...);
#endif
#endif
/*
* $Id$
*/
#ifndef COMPAT_STRLCAT_H_INCLUDED
#define COMPAT_STRLCAT_H_INCLUDED
#ifndef HAVE_STRLCAT
size_t strlcat(char *dst, const char *src, size_t size);
#endif
#endif
/*
* $Id$
*/
#ifndef COMPAT_STRLCPY_H_INCLUDED
#define COMPAT_STRLCPY_H_INCLUDED
#ifndef HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t size);
#endif
#endif
/*
* $Id$
*/
#ifndef COMPAT_VASPRINTF_H_INCLUDED
#define COMPAT_VASPRINTF_H_INCLUDED
#ifndef HAVE_VASPRINTF
int vasprintf(char **strp, const char *fmt, va_list ap);
#endif
#endif
...@@ -3,12 +3,14 @@ ...@@ -3,12 +3,14 @@
* *
*/ */
#ifndef HAVE_ASPRINTF
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include "compat.h" #include "compat/asprintf.h"
#include "compat/vasprintf.h"
#ifndef HAVE_ASPRINTF
int int
asprintf(char **strp, const char *fmt, ...) asprintf(char **strp, const char *fmt, ...)
{ {
......
...@@ -17,12 +17,13 @@ ...@@ -17,12 +17,13 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
#ifndef HAVE_STRLCAT
#include <sys/types.h> #include <sys/types.h>
#include <string.h> #include <string.h>
#include "compat.h" #include "compat/strlcat.h"
#ifndef HAVE_STRLCAT
/* /*
* Appends src to string dst of size siz (unlike strncat, siz is the * Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters * full size of dst, not space left). At most siz-1 characters
......
...@@ -17,12 +17,13 @@ ...@@ -17,12 +17,13 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
#ifndef HAVE_STRLCPY
#include <sys/types.h> #include <sys/types.h>
#include <string.h> #include <string.h>
#include "compat.h" #include "compat/strlcpy.h"
#ifndef HAVE_STRLCPY
/* /*
* Copy src to string dst of size siz. At most siz-1 characters * Copy src to string dst of size siz. At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0). * will be copied. Always NUL terminates (unless siz == 0).
......
...@@ -3,13 +3,14 @@ ...@@ -3,13 +3,14 @@
* *
*/ */
#ifndef HAVE_VASPRINTF
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "compat.h" #include "compat/vasprintf.h"
#ifndef HAVE_VASPRINTF
int int
vasprintf(char **strp, const char *fmt, va_list ap) vasprintf(char **strp, const char *fmt, va_list ap)
{ {
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
#include <queue.h> #include <queue.h>
#include <unistd.h> #include <unistd.h>
#include "compat.h" #include "compat/asprintf.h"
#include "vsb.h" #include "vsb.h"
#include "vcc_priv.h" #include "vcc_priv.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment