mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-06-28 15:39:02 +08:00
Rearrange some ODBC code
Move unixODBC specific code to its own source file, and support old iODBC installations that have only iodbinst.h.
This commit is contained in:
parent
c04a3fb9a7
commit
77ee311eec
@ -153,7 +153,6 @@ if test "$with_iodbc"; then
|
|||||||
ODBC_CFLAGS=$(iodbc-config --prefix="$with_iodbc" --cflags)
|
ODBC_CFLAGS=$(iodbc-config --prefix="$with_iodbc" --cflags)
|
||||||
ODBC_LIBS=$(iodbc-config --prefix="$with_iodbc" --libs)
|
ODBC_LIBS=$(iodbc-config --prefix="$with_iodbc" --libs)
|
||||||
ODBC_LDFLAGS=""
|
ODBC_LDFLAGS=""
|
||||||
CFLAGS="$CFLAGS -DIODBC"
|
|
||||||
|
|
||||||
OLDLDFLAGS=$LDFLAGS
|
OLDLDFLAGS=$LDFLAGS
|
||||||
LDFLAGS="$LDFLAGS $ODBC_LIBS"
|
LDFLAGS="$LDFLAGS $ODBC_LIBS"
|
||||||
@ -169,7 +168,6 @@ if test "$with_unixodbc"; then
|
|||||||
HAVE_ODBC=true
|
HAVE_ODBC=true
|
||||||
ODBC_CFLAGS="-I$with_unixodbc/include"
|
ODBC_CFLAGS="-I$with_unixodbc/include"
|
||||||
ODBC_LIBS="-L$with_unixodbc/$libdir"
|
ODBC_LIBS="-L$with_unixodbc/$libdir"
|
||||||
CFLAGS="$CFLAGS -DUNIXODBC"
|
|
||||||
|
|
||||||
dnl SIZEOF_LONG_INT and HAVE_LONG_LONG are required by some versions of unixODBC
|
dnl SIZEOF_LONG_INT and HAVE_LONG_LONG are required by some versions of unixODBC
|
||||||
dnl https://github.com/lurcher/unixODBC/issues/40
|
dnl https://github.com/lurcher/unixODBC/issues/40
|
||||||
@ -192,12 +190,18 @@ if test "$with_unixodbc"; then
|
|||||||
ODBC_LDFLAGS=""])
|
ODBC_LDFLAGS=""])
|
||||||
LDFLAGS=$OLDLDFLAGS
|
LDFLAGS=$OLDLDFLAGS
|
||||||
fi
|
fi
|
||||||
|
AM_CONDITIONAL([UNIXODBC], test "$with_unixodbc")
|
||||||
|
|
||||||
if test "x$HAVE_ODBC" = "xtrue"; then
|
if test "x$HAVE_ODBC" = "xtrue"; then
|
||||||
if test "x$sql" != "xtrue" ; then
|
if test "x$sql" != "xtrue" ; then
|
||||||
AC_MSG_ERROR([ODBC requires flex and bison for the SQL engine])
|
AC_MSG_ERROR([ODBC requires flex and bison for the SQL engine])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
OLDCFLAGS=$CFLAGS
|
||||||
|
CFLAGS="$CFLAGS $ODBC_CFLAGS"
|
||||||
|
AC_CHECK_HEADERS(odbcinst.h iodbcinst.h)
|
||||||
|
CFLAGS=$OLDCFLAGS
|
||||||
|
|
||||||
AC_SUBST(ODBC_CFLAGS)
|
AC_SUBST(ODBC_CFLAGS)
|
||||||
AC_SUBST(ODBC_LIBS)
|
AC_SUBST(ODBC_LIBS)
|
||||||
AC_SUBST(ODBC_LDFLAGS)
|
AC_SUBST(ODBC_LDFLAGS)
|
||||||
|
@ -5,6 +5,9 @@ lib_LTLIBRARIES = libmdbodbc.la
|
|||||||
libdir=@libdir@/odbc
|
libdir=@libdir@/odbc
|
||||||
AM_CFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) $(ODBC_CFLAGS)
|
AM_CFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) $(ODBC_CFLAGS)
|
||||||
libmdbodbc_la_SOURCES = odbc.c connectparams.c
|
libmdbodbc_la_SOURCES = odbc.c connectparams.c
|
||||||
|
if UNIXODBC
|
||||||
|
libmdbodbc_la_SOURCES += getproperties.c
|
||||||
|
endif
|
||||||
libmdbodbc_la_LIBADD = ../libmdb/libmdb.la ../sql/libmdbsql.la $(ODBC_LIBS)
|
libmdbodbc_la_LIBADD = ../libmdb/libmdb.la ../sql/libmdbsql.la $(ODBC_LIBS)
|
||||||
libmdbodbc_la_LDFLAGS = -avoid-version -export-symbols-regex '^(SQL|ODBCINST)' $(ODBC_LDFLAGS)
|
libmdbodbc_la_LDFLAGS = -avoid-version -export-symbols-regex '^(SQL|ODBCINST)' $(ODBC_LDFLAGS)
|
||||||
lib_LTLIBRARIES += libmdbodbcW.la
|
lib_LTLIBRARIES += libmdbodbcW.la
|
||||||
|
@ -23,11 +23,11 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#ifdef UNIXODBC
|
#if defined(HAVE_ODBCINST_H)
|
||||||
#include <odbcinstext.h>
|
|
||||||
#else
|
|
||||||
#include <odbcinst.h>
|
#include <odbcinst.h>
|
||||||
#endif
|
#elif defined(HAVE_IODBCINST_H)
|
||||||
|
#include <iodbcinst.h>
|
||||||
|
#endif /* HAVE_ODBCINST_H */
|
||||||
#include "connectparams.h"
|
#include "connectparams.h"
|
||||||
|
|
||||||
|
|
||||||
@ -297,24 +297,4 @@ static void cleanup (gpointer key, gpointer value, gpointer user_data)
|
|||||||
g_free (value);
|
g_free (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef UNIXODBC
|
|
||||||
|
|
||||||
int
|
|
||||||
ODBCINSTGetProperties(HODBCINSTPROPERTY hLastProperty)
|
|
||||||
{
|
|
||||||
hLastProperty->pNext = malloc(sizeof(ODBCINSTPROPERTY));
|
|
||||||
hLastProperty = hLastProperty->pNext;
|
|
||||||
memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
|
|
||||||
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_FILENAME;
|
|
||||||
strncpy(hLastProperty->szName, "Database", INI_MAX_PROPERTY_NAME);
|
|
||||||
strncpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE);
|
|
||||||
hLastProperty->pszHelp = (char *) g_strdup("Filename and Path of MDB file to connect to.\n"
|
|
||||||
"Use the full path to the database file.");
|
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/** @}*/
|
/** @}*/
|
||||||
|
38
src/odbc/getproperties.c
Normal file
38
src/odbc/getproperties.c
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/* MDB Tools - A library for reading MS Access database file
|
||||||
|
* Copyright (C) 2000-2004 Brian Bruns
|
||||||
|
*
|
||||||
|
* portions based on FreeTDS, Copyright (C) 1998-1999 Brian Bruns
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <odbcinstext.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
ODBCINSTGetProperties(HODBCINSTPROPERTY hLastProperty)
|
||||||
|
{
|
||||||
|
hLastProperty->pNext = malloc(sizeof(ODBCINSTPROPERTY));
|
||||||
|
hLastProperty = hLastProperty->pNext;
|
||||||
|
memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
|
||||||
|
hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_FILENAME;
|
||||||
|
strncpy(hLastProperty->szName, "Database", INI_MAX_PROPERTY_NAME);
|
||||||
|
strncpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE);
|
||||||
|
hLastProperty->pszHelp = strdup("Filename and Path of MDB file to connect to.\n"
|
||||||
|
"Use the full path to the database file.");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
@ -21,9 +21,9 @@
|
|||||||
|
|
||||||
#include <sql.h>
|
#include <sql.h>
|
||||||
#include <sqlext.h>
|
#include <sqlext.h>
|
||||||
#if defined(UNIXODBC)
|
#if defined(HAVE_ODBCINST_H)
|
||||||
# include <odbcinst.h>
|
# include <odbcinst.h>
|
||||||
#elif defined(IODBC)
|
#elif defined(HAVE_IODBCINST_H)
|
||||||
# include <iodbcinst.h>
|
# include <iodbcinst.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user