Skip to content

Instantly share code, notes, and snippets.

@Habbie
Created April 26, 2013 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Habbie/5466690 to your computer and use it in GitHub Desktop.
Save Habbie/5466690 to your computer and use it in GitHub Desktop.
Index: configure.ac
===================================================================
--- configure.ac (revision 1697)
+++ configure.ac (working copy)
@@ -239,6 +239,9 @@
[AC_DEFINE([HAVE_LDAP_SASL_BIND], 1, [Define to 1 if you have ldap_sasl_bind])]
)
;;
+ godbc )
+ needunixodbc=yes
+ ;;
opendbx)
AC_CHECK_HEADERS([odbx.h], , [AC_MSG_ERROR([opendbx header (odbx.h) not found])])
AC_SUBST([LIBOPENDBX])
@@ -496,7 +499,65 @@
# LIBS="$LIBS -lsqlite3"
fi
+if test "$needunixodbc"
+then
+ AC_ARG_WITH(unixodbc,
+ [ --with-unixodbc=<path> root directory path of unixodbc installation],
+ [UNIXODBC_lib_check="$withval/lib/unixodbc $with_unixodbc/lib $withval/lib"
+ UNIXODBC_inc_check="$withval/include/unixodbc"],
+ [UNIXODBC_lib_check="/usr/local/unixodbc/lib/unixodbc /usr/local/lib/unixodbc /usr/lib/unixodbc /usr/local/unixodbc/lib /usr/local/lib /opt/unixodbc/lib /usr/lib"
+ UNIXODBC_inc_check="/usr/local/unixodbc/include/unixodbc /usr/local/include/unixodbc/ /usr/local/include /opt/unixodbc/include/unixodbc /opt/unixodbc/include /usr/include/ /usr/include/unixodbc"])
+ AC_ARG_WITH(unixodbc-lib,
+ [ --with-unixodbc-lib=<path> directory path of unixodbc library installation],
+ [UNIXODBC_lib_check="$withval/lib/unixodbc $withval/unixodbc $withval"])
+ AC_ARG_WITH(unixodbc-includes,
+ [ --with-unixodbc-includes=<path> directory path of unixodbc header installation],
+ [UNIXODBC_inc_check="$withval/include $withval/include/unixodbc $withval/unixodbc $withval"])
+ AC_MSG_CHECKING([for SQLite3 library directory])
+ UNIXODBC_libdir=
+ for m in $UNIXODBC_lib_check; do
+ if test -d "$m" && \
+ (test -f "$m/libodbc.so" || test -f "$m/libodbc.a")
+ then
+ UNIXODBC_libdir=$m
+ break
+ fi
+ done
+ if test -z "$UNIXODBC_libdir"; then
+ AC_MSG_ERROR([Didn't find the unixodbc library dir in '$UNIXODBC_lib_check'])
+ fi
+ case "$UNIXODBC_libdir" in
+ /usr/lib ) UNIXODBC_lib="" ;;
+ /* ) UNIXODBC_lib="-L$UNIXODBC_libdir -Wl,-rpath,$UNIXODBC_libdir"
+ LDFLAGS="$UNIXODBC_lib $LDFLAGS"
+ ;;
+ * ) AC_MSG_ERROR([The unixodbc library directory ($UNIXODBC_libdir) must be an absolute path.]) ;;
+ esac
+ AC_SUBST(UNIXODBC_lib)
+ AC_MSG_RESULT([$UNIXODBC_libdir])
+ AC_MSG_CHECKING([for unixodbc include directory])
+ UNIXODBC_incdir=
+ for m in $UNIXODBC_inc_check; do
+ if test -d "$m" && test -f "$m/sql.h"
+ then
+ UNIXODBC_incdir=$m
+ break
+ fi
+ done
+ if test -z "$UNIXODBC_incdir"; then
+ AC_MSG_ERROR([Didn't find the unixodbc include dir in '$UNIXODBC_inc_check'])
+ fi
+ case "$UNIXODBC_incdir" in
+ /* ) ;;
+ * ) AC_MSG_ERROR([The unixodbc include directory ($UNIXODBC_incdir) must be an absolute path.]) ;;
+ esac
+ AC_SUBST(UNIXODBC_incdir)
+ AC_MSG_RESULT([$UNIXODBC_incdir])
+
+# LIBS="$LIBS -lunixodbc"
+fi
+
for a in $modules
do
moduledirs="$moduledirs ${a}backend"
@@ -533,7 +594,7 @@
modules/gmysqlbackend/Makefile modules/db2backend/Makefile \
modules/geobackend/Makefile modules/opendbxbackend/Makefile \
modules/pipebackend/Makefile modules/oraclebackend/Makefile \
-modules/xdbbackend/Makefile modules/odbcbackend/Makefile \
+modules/xdbbackend/Makefile modules/godbcbackend/Makefile \
modules/gpgsqlbackend/Makefile modules/ldapbackend/Makefile
modules/gsqlitebackend/Makefile modules/gsqlite3backend/Makefile
modules/goraclebackend/Makefile modules/mydnsbackend/Makefile)
Index: modules/godbcbackend/godbcbackend.hh
===================================================================
--- modules/godbcbackend/godbcbackend.hh (revision 1697)
+++ modules/godbcbackend/godbcbackend.hh (working copy)
@@ -2,7 +2,7 @@
// By Michel Stol <michel@powerdns.com>
#include <string>
-#include "backends/gsql/gsqlbackend.hh"
+#include "pdns/backends/gsql/gsqlbackend.hh"
class gODBCBackend : public GSQLBackend
{
Index: modules/godbcbackend/sodbc.hh
===================================================================
--- modules/godbcbackend/sodbc.hh (revision 1697)
+++ modules/godbcbackend/sodbc.hh (working copy)
@@ -8,12 +8,12 @@
#include <vector>
// The following line makes Bert puke everytime he sees it.
-#define WINDOWS_LEAN_AND_MEAN
-#include <windows.h>
+//#define WINDOWS_LEAN_AND_MEAN
+//#include <windows.h>
#include <sql.h>
#include <sqlext.h>
-#include "backends/gsql/ssql.hh"
+#include "pdns/backends/gsql/ssql.hh"
//! ODBC SSql implementation for use with the Generic ODBC Backend.
@@ -24,7 +24,7 @@
struct column_t
{
SQLSMALLINT m_type; //!< Type of the column.
- SQLUINTEGER m_size; //!< Column size.
+ SQLULEN m_size; //!< Column size.
SQLPOINTER m_pData; //!< Pointer to the memory where to store the data.
bool m_canBeNull; //!< Can this column be null?
};
Index: modules/godbcbackend/Makefile.am
===================================================================
--- modules/godbcbackend/Makefile.am (revision 0)
+++ modules/godbcbackend/Makefile.am (revision 0)
@@ -0,0 +1,12 @@
+AM_CPPFLAGS=@THREADFLAGS@
+lib_LTLIBRARIES = libgodbcbackend.la
+
+EXTRA_DIST=OBJECTFILES OBJECTLIBS
+
+INCLUDES=-I@UNIXODBC_incdir@
+
+libgodbcbackend_la_SOURCES=godbcbackend.cc godbcbackend.hh \
+ sodbc.hh sodbc.cc
+
+
+libgodbcbackend_la_LDFLAGS=-module -avoid-version -lodbc
Index: modules/godbcbackend/godbcbackend.cc
===================================================================
--- modules/godbcbackend/godbcbackend.cc (revision 1697)
+++ modules/godbcbackend/godbcbackend.cc (working copy)
@@ -1,18 +1,18 @@
// The Generic ODBC Backend
// By Michel Stol <michel@powerdns.com>
-#include "utility.hh"
+#include "pdns/utility.hh"
#include <map>
#include <sstream>
#include <string>
-#include "dns.hh"
-#include "dnsbackend.hh"
-#include "dnspacket.hh"
-#include "ueberbackend.hh"
-#include "ahuexception.hh"
-#include "logger.hh"
-#include "arguments.hh"
+#include "pdns/dns.hh"
+#include "pdns/dnsbackend.hh"
+#include "pdns/dnspacket.hh"
+#include "pdns/ueberbackend.hh"
+#include "pdns/ahuexception.hh"
+#include "pdns/logger.hh"
+#include "pdns/arguments.hh"
#include "sodbc.hh"
#include "godbcbackend.hh"
Index: modules/godbcbackend/sodbc.cc
===================================================================
--- modules/godbcbackend/sodbc.cc (revision 1697)
+++ modules/godbcbackend/sodbc.cc (working copy)
@@ -1,11 +1,12 @@
// The Generic ODBC Backend
// By Michel Stol <michel@powerdns.com>
-#include "utility.hh"
+#include "pdns/utility.hh"
#include <sstream>
#include "sodbc.hh"
+#include <malloc.h>
+#include <string.h>
-
// Constructor.
SODBC::SODBC(
const std::string & dsn,
@@ -28,9 +29,9 @@
testResult( result, "Could not allocate a connection handle." );
// Connect to the database.
- char *l_dsn = _strdup( dsn.c_str());
- char *l_username = _strdup( username.c_str());
- char *l_password = _strdup( password.c_str());
+ char *l_dsn = strdup( dsn.c_str());
+ char *l_username = strdup( username.c_str());
+ char *l_password = strdup( password.c_str());
result = SQLConnect( m_connection,
reinterpret_cast< SQLTCHAR * >( l_dsn ), dsn.length(),
@@ -81,7 +82,7 @@
if ( m_busy )
throw SSqlException( "Tried to execute another query while being busy." );
- tmp = _strdup( query.c_str());
+ tmp = strdup( query.c_str());
// Execute query.
result = SQLExecDirect( m_statement, reinterpret_cast< SQLTCHAR * >( tmp ), query.length());
@@ -176,7 +177,7 @@
if ( m_busy )
throw SSqlException( "Tried to execute another query while being busy." );
- tmp = _strdup( command.c_str());
+ tmp = strdup( command.c_str());
// Execute query.
result = SQLExecDirect( m_statement, reinterpret_cast< SQLTCHAR * >( tmp ), command.length());
@@ -216,7 +217,7 @@
if ( result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO )
{
// We've got a data row, now lets get the results.
- SQLINTEGER len;
+ SQLLEN len;
for ( int i = 0; i < m_columnInfo.size(); i++ )
{
if ( m_columnInfo[ i ].m_pData == NULL )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment