summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 836df60)
raw | patch | inline | side by side (parent: 836df60)
author | Pierre-Yves Ritschard <pyr@spootnik.org> | |
Fri, 1 Aug 2014 09:13:27 +0000 (11:13 +0200) | ||
committer | Pierre-Yves Ritschard <pyr@spootnik.org> | |
Fri, 1 Aug 2014 09:13:27 +0000 (11:13 +0200) |
configure.ac | patch | blob | history | |
src/dbi.c | patch | blob | history |
diff --git a/configure.ac b/configure.ac
index c3347fa71514ee511908bbdbe5f2b891c1eb8232..1757e2fa21c3228cc1b7c99c0c5e7144be1a8cb3 100644 (file)
--- a/configure.ac
+++ b/configure.ac
LDFLAGS="$LDFLAGS $with_libdbi_ldflags"
AC_CHECK_LIB(dbi, dbi_initialize, [with_libdbi="yes"], [with_libdbi="no (Symbol 'dbi_initialize' not found)"])
+ AC_CHECK_LIB(dbi, dbi_driver_open_r, [with_libdbi_r="yes"], [with_libdbi_r="no"])
CPPFLAGS="$SAVE_CPPFLAGS"
LDFLAGS="$SAVE_LDFLAGS"
AC_SUBST(BUILD_WITH_LIBDBI_CPPFLAGS)
AC_SUBST(BUILD_WITH_LIBDBI_LDFLAGS)
AC_SUBST(BUILD_WITH_LIBDBI_LIBS)
+
+ if test "x$with_libdbi_r" = "xyes"
+ then
+ AC_DEFINE(HAVE_LIBDBI_R, 1, [Define if reentrant dbi facility is present and usable.])
+ fi
fi
AM_CONDITIONAL(BUILD_WITH_LIBDBI, test "x$with_libdbi" = "xyes")
# }}}
diff --git a/src/dbi.c b/src/dbi.c
index 7fec73c549c5249feef63ae4dd194a3071aa3ab6..223e159f3f9ab88293a8a7edd4d68df1bc661459 100644 (file)
--- a/src/dbi.c
+++ b/src/dbi.c
#include <dbi/dbi.h>
+#ifdef HAVE_LIBDBI_R
+ dbi_inst inst = NULL;
+#endif
/*
* Data types
*/
else if (src_type == DBI_TYPE_STRING)
{
const char *value;
-
+
value = dbi_result_get_string_idx (res, index);
if (value == NULL)
sstrncpy (buffer, "", buffer_size);
* </Result>
* ...
* </Query>
- *
+ *
* <Database "plugin_instance1">
* Driver "mysql"
* DriverOption "hostname" "localhost"
return (-1);
}
+#ifdef HAVE_LIBDBI_R
+ status = dbi_initialize_r (NULL, &inst);
+#else
status = dbi_initialize (NULL);
+#endif
if (status < 0)
{
ERROR ("dbi plugin: cdbi_init: dbi_initialize failed with status %i.",
db->connection = NULL;
}
+#ifdef HAVE_LIBDBI_R
+ driver = dbi_driver_open_r (db->driver, inst);
+#else
driver = dbi_driver_open (db->driver);
+#endif
if (driver == NULL)
{
ERROR ("dbi plugin: cdbi_connect_database: dbi_driver_open (%s) failed.",
db->driver);
INFO ("dbi plugin: Maybe the driver isn't installed? "
"Known drivers are:");
+#ifdef HAVE_LIBDBI_R
+ for (driver = dbi_driver_list_r (NULL, inst);
+ driver != NULL;
+ driver = dbi_driver_list_r (driver, inst))
+#else
for (driver = dbi_driver_list (NULL);
driver != NULL;
driver = dbi_driver_list (driver))
+#endif
{
INFO ("dbi plugin: * %s", dbi_driver_get_name (driver));
}