From f8277a8370e8d5bdbd1bd39dcc720b99fddc81b7 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Wed, 7 May 2008 14:41:13 +0000 Subject: [PATCH] added configure check and support for sqlite3 libraries without sqlite3_prepare_v2 --- configure.in | 11 +++++++++-- src/libstrongswan/plugins/sqlite/sqlite_database.c | 6 +++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index fd24f6d465..d9473fd1cd 100644 --- a/configure.in +++ b/configure.in @@ -568,7 +568,7 @@ AC_TRY_COMPILE( ) if test x$gmp = xtrue; then - AC_HAVE_LIBRARY([gmp],[LIBS="$LIBS"],[AC_MSG_ERROR([GNU Multi Precision library gmp not found])]) + AC_HAVE_LIBRARY([gmp],[LIBS="$LIBS"],[AC_MSG_ERROR([GNU Multi Precision library gmp not found])]) AC_MSG_CHECKING([gmp.h version >= 4.1.4]) AC_TRY_COMPILE( [#include "gmp.h"], @@ -620,9 +620,16 @@ if test x$mysql = xtrue; then AC_CHECK_HEADER([mysql/mysql.h],,[AC_MSG_ERROR([MySQL header mysql/mysql.h not found!])]) fi -if test x$mysql = xtrue; then +if test x$sqlite = xtrue; then AC_HAVE_LIBRARY([sqlite3],[LIBS="$LIBS"],[AC_MSG_ERROR([SQLite library sqlite3 not found])]) AC_CHECK_HEADER([sqlite3.h],,[AC_MSG_ERROR([SQLite header sqlite3.h not found!])]) + AC_MSG_CHECKING([sqlite3_prepare_v2]) + AC_TRY_COMPILE( + [#include ], + [ + void *test = sqlite3_prepare_v2; + ], + [AC_MSG_RESULT([yes])]; AC_DEFINE_UNQUOTED(HAVE_SQLITE3_PREPARE_V2, 1), [AC_MSG_RESULT([no])]) fi if test x$openssl = xtrue; then diff --git a/src/libstrongswan/plugins/sqlite/sqlite_database.c b/src/libstrongswan/plugins/sqlite/sqlite_database.c index d71b296f32..99f86a84a5 100644 --- a/src/libstrongswan/plugins/sqlite/sqlite_database.c +++ b/src/libstrongswan/plugins/sqlite/sqlite_database.c @@ -53,8 +53,12 @@ static sqlite3_stmt* run(private_sqlite_database_t *this, char *sql, { sqlite3_stmt *stmt = NULL; int params, i, res = SQLITE_OK; - + +#ifdef HAVE_SQLITE3_PREPARE_V2 if (sqlite3_prepare_v2(this->db, sql, -1, &stmt, NULL) == SQLITE_OK) +#else + if (sqlite3_prepare(this->db, sql, -1, &stmt, NULL) == SQLITE_OK) +#endif { params = sqlite3_bind_parameter_count(stmt); for (i = 1; i <= params; i++)