Remove HAVE_ macros from mdbtools.h and mdbsql.h

Generate mdbtools.h at configure-time. This ensures that the public
interface matches the compiled structures.

See #316
This commit is contained in:
Evan Miller 2021-08-04 15:29:23 -04:00
parent a44a8ed8ae
commit e88e3cc7e7
4 changed files with 37 additions and 24 deletions

View File

@ -221,8 +221,33 @@ if test "$enable_glib" = "yes"; then
fi
AM_CONDITIONAL(FAKE_GLIB, test "x$enable_glib" != "xyes")
dnl Set up substitution variables
if test "$am_cv_func_iconv" = "yes"; then
ICONV_INCLUDE_HEADER=iconv.h
ICONV_TYPE=iconv_t
else
ICONV_INCLUDE_HEADER=locale.h
ICONV_TYPE=[void *]
fi
AC_SUBST(ICONV_INCLUDE_HEADER)
AC_SUBST(ICONV_TYPE)
if test "$ac_cv_header_xlocale_h" = "yes"; then
LOCALE_INCLUDE_HEADER=xlocale.h
else
LOCALE_INCLUDE_HEADER=locale.h
fi
AC_SUBST(LOCALE_INCLUDE_HEADER)
if test "$enable_glib" = "yes"; then
GLIB_INCLUDE_HEADER=glib.h
else
GLIB_INCLUDE_HEADER=mdbfakeglib.h
fi
AC_SUBST(GLIB_INCLUDE_HEADER)
AC_SUBST([OPTDIRS])
AC_CONFIG_FILES([src/Makefile])
AC_CONFIG_FILES([src/Makefile include/mdbtools.h])
##################################################
# Check for txt2man

View File

@ -1,4 +1,8 @@
include_HEADERS = mdbtools.h mdbsql.h
EXTRA_DIST = mdbtools.h.in
include_HEADERS = mdbtools.h
if SQL
include_HEADERS += mdbsql.h
endif
if FAKE_GLIB
include_HEADERS += mdbfakeglib.h
endif

View File

@ -25,11 +25,6 @@
#include <stdio.h>
#include <string.h>
#ifdef HAVE_GLIB
#include <glib.h>
#else
#include <mdbfakeglib.h>
#endif
#include <mdbtools.h>
typedef struct MdbSQL

View File

@ -30,19 +30,9 @@
#include <unistd.h>
#include <ctype.h>
#include <string.h>
#include <locale.h>
#ifdef HAVE_GLIB
#include <glib.h>
#else
#include <mdbfakeglib.h>
#endif
#if defined(HAVE_ICONV)
#include <iconv.h>
#elif defined(HAVE_XLOCALE_H)
#include <xlocale.h>
#endif
#include <@ICONV_INCLUDE_HEADER@>
#include <@LOCALE_INCLUDE_HEADER@>
#include <@GLIB_INCLUDE_HEADER@>
#ifdef _WIN32
#include <io.h>
@ -308,10 +298,9 @@ typedef struct {
char *relationships_values[5];
MdbStatistics *stats;
GHashTable *backends;
#ifdef HAVE_ICONV
iconv_t iconv_in;
iconv_t iconv_out;
#elif defined(_WIN32) || defined(WIN32) || defined(_WIN64) || defined(WIN64) || defined(WINDOWS)
@ICONV_TYPE@ iconv_in;
@ICONV_TYPE@ iconv_out;
#if defined(_WIN32) || defined(WIN32) || defined(_WIN64) || defined(WIN64) || defined(WINDOWS)
_locale_t locale;
#else
locale_t locale;