Commit 94affa18 authored by David Woodhouse's avatar David Woodhouse

Export asprintf() and vasprintf() compatibility functions

We'll want this for legacy charset handling.
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 5f101851
......@@ -42,9 +42,8 @@ time_t openconnect__time(time_t *t)
}
#endif
#ifndef HAVE_ASPRINTF
static int oc_vasprintf(char **strp, const char *fmt, va_list ap)
#ifndef HAVE_VASPRINTF
int openconnect__vasprintf(char **strp, const char *fmt, va_list ap)
{
va_list ap2;
char *res = NULL;
......@@ -102,14 +101,16 @@ static int oc_vasprintf(char **strp, const char *fmt, va_list ap)
*strp = res;
return ret;
}
#endif
#ifndef HAVE_ASPRINTF
int openconnect__asprintf(char **strp, const char *fmt, ...)
{
va_list ap;
int ret;
va_start(ap, fmt);
ret = oc_vasprintf(strp, fmt, ap);
ret = vasprintf(strp, fmt, ap);
va_end(ap);
return ret;
}
......
......@@ -23,6 +23,8 @@ m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR],
use_openbsd_libtool=
symver_time=
symver_getline=
symver_asprintf=
symver_vasprintf=
case $host_os in
*linux* | *gnu*)
......@@ -106,8 +108,12 @@ AC_CHECK_FUNC(getline, [AC_DEFINE(HAVE_GETLINE, 1, [Have getline() function])],
[symver_getline="openconnect__getline;"])
AC_CHECK_FUNC(strcasestr, [AC_DEFINE(HAVE_STRCASESTR, 1, [Have strcasestr() function])], [])
AC_CHECK_FUNC(strndup, [AC_DEFINE(HAVE_STRNDUP, 1, [Have strndup() function])], [])
AC_CHECK_FUNC(asprintf, [AC_DEFINE(HAVE_ASPRINTF, 1, [Have asprintf() function])], [])
if test -n "$symver_asprintf"; then
AC_CHECK_FUNC(asprintf, [AC_DEFINE(HAVE_ASPRINTF, 1, [Have asprintf() function])],
[symver_asprintf="openconnect__asprintf;"])
AC_CHECK_FUNC(vasprintf, [AC_DEFINE(HAVE_VASPRINTF, 1, [Have vasprintf() function])],
[symver_vasprintf="openconnect__vasprintf;"])
if test -n "$symver_vasprintf"; then
AC_MSG_CHECKING([for va_copy])
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <stdarg.h>
......@@ -126,11 +132,13 @@ if test -n "$symver_asprintf"; then
[AC_DEFINE(HAVE___VA_COPY, 1, [Have __va_copy()])
AC_MSG_RESULT(__va_copy)],
[AC_MSG_RESULT(no)
AC_MSG_ERROR([Your system lacks asprintf() and va_copy()])])
AC_MSG_ERROR([Your system lacks vasprintf() and va_copy()])])
])
fi
AC_SUBST(SYMVER_TIME, $symver_time)
AC_SUBST(SYMVER_GETLINE, $symver_getline)
AC_SUBST(SYMVER_ASPRINTF, $symver_asprintf)
AC_SUBST(SYMVER_VASPRINTF, $symver_vasprintf)
AS_COMPILER_FLAGS(WFLAGS,
"-Wall
......
......@@ -62,7 +62,7 @@ OPENCONNECT_3.3 {
} OPENCONNECT_3.1;
OPENCONNECT_PRIVATE {
global: @SYMVER_TIME@ @SYMVER_GETLINE@ @SYMVER_JAVA@
global: @SYMVER_TIME@ @SYMVER_GETLINE@ @SYMVER_JAVA@ @SYMVER_ASPRINTF@ @SYMVER_VASPRINTF@
openconnect_version_str;
openconnect_sha1;
local:
......
......@@ -445,6 +445,10 @@ struct openconnect_info {
#define time(x) openconnect__time(x)
time_t openconnect__time(time_t *t);
#endif
#ifndef HAVE_VASPRINTF
#define vasprintf openconnect__vasprintf
int openconnect__vasprintf(char **strp, const char *fmt, va_list ap);
#endif
#ifndef HAVE_ASPRINTF
#define asprintf openconnect__asprintf
int openconnect__asprintf(char **strp, const char *fmt, ...);
......
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