Index: configure.in =================================================================== --- configure.in (revision 887) +++ configure.in (working copy) @@ -808,6 +808,13 @@ [ AC_MSG_RESULT([no]) ]) ]) +dnl Check for SQLGetPrivateProfileStringW +need_odbcinstw=yes +if test "x$enable_odbcinstlink" != "xno" ; then + AC_CHECK_FUNC(SQLGetPrivateProfileStringW, [ need_odbcinstw=no ]) +fi +AM_CONDITIONAL(ODBCINSTW, test "x$need_odbcinstw" != "xno") + ################################################################### # # # Generate Makefiles # Index: ChangeLog =================================================================== --- ChangeLog (revision 888) +++ ChangeLog (working copy) @@ -23,6 +23,9 @@ 5.1.1 Functionality added or changed: + * Add wrappers for missing ODBC driver manager installer functions. + (This makes it possible to use the driver with unixODBC 2.2.11, which + is the most recent version shipped with Debian and Ubuntu.) * Disallow 'SET NAMES' in initial statement and in executed statements. * Replaced the internal library which handles creation and loading of DSN information. The new library, which was originally a part of Index: util/Makefile.am =================================================================== --- util/Makefile.am (revision 887) +++ util/Makefile.am (working copy) @@ -36,6 +36,12 @@ MYODBCUtilWriteDriver.c endif +if ODBCINSTW +libmyodbc3u_la_SOURCES += \ + odbcinstw.c +endif + + # libmysql lib deps libmyodbc3u_la_LIBADD = $(LTLIBS_DEPS) @LTDL_LIB@ @MYSQL_LIB@ libmyodbc3u_la_DEPENDENCIES = $(LTLIBS_DEPS) Index: util/odbcinstw.c =================================================================== --- util/odbcinstw.c (revision 0) +++ util/odbcinstw.c (revision 0) @@ -0,0 +1,167 @@ +/* + Copyright (C) 2007 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + There are special exceptions to the terms and conditions of the GPL + as it is applied to this software. View the full text of the exception + in file LICENSE.exceptions in the top-level directory of this software + distribution. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/** + @file odbcinstw.c + @brief Installer API Unicode wrapper functions. + + unixODBC 2.2.11 does not include the Unicode versions of the ODBC + installer API. As of November 2007, this was still the current version + shipped with Debian and Ubuntu Linux. + + SQLGetPrivateProfileString() also has a few bugs in unixODBC 2.2.11 that + our version of SQLGetPrivateProfileStringW() will work around. +*/ + +#include "../MYODBC_CONF.h" + +#include "stringutil.h" + +#include +#include + + +typedef const LPWSTR LPCWSTR; + +#define INSTAPI + +#ifndef FALSE +# define FALSE 0 +#endif + + +int INSTAPI +SQLGetPrivateProfileStringW(LPCWSTR lpszSection, LPCWSTR lpszEntry, + LPCWSTR lpszDefault, LPWSTR lpszRetBuffer, + int cbRetBuffer, LPCWSTR lpszFilename) +{ + SQLINTEGER len; + int rc; + char *section, *entry, *def, *ret, *filename; + + len= SQL_NTS; + section= sqlwchar_as_utf8(lpszSection, &len); + len= SQL_NTS; + entry= sqlwchar_as_utf8(lpszEntry, &len); + len= SQL_NTS; + def= sqlwchar_as_utf8(lpszDefault, &len); + len= SQL_NTS; + filename= sqlwchar_as_utf8(lpszFilename, &len); + + if (lpszRetBuffer && cbRetBuffer) + ret= malloc(cbRetBuffer + 1); + else + ret= NULL; + + /* unixODBC 2.2.11 can't handle NULL for default, so pass "" instead. */ + rc= SQLGetPrivateProfileString(section, entry, def ? def : "", ret, + cbRetBuffer, filename); + + if (rc > 0 && lpszRetBuffer) + { + /* + unixODBC 2.2.11 returns the wrong value from SQLGetPrivateProfileString + when getting the list of entries in a section, so we have to + re-calculate the correct length by walking the list of values. + */ + if (!entry) + { + char *pos= ret; + while (*pos && pos < ret + cbRetBuffer) + pos+= strlen(pos) + 1; + rc= pos - ret; + } + + /** @todo error handling */ + utf8_as_sqlwchar(lpszRetBuffer, cbRetBuffer, ret, rc); + } + + if (section) + free(section); + if (entry) + free(entry); + if (def) + free(def); + if (ret) + free(ret); + if (filename) + free(filename); + + return rc; +} + + +/** + @todo The rest of the replacement functions are not actually implemented. +*/ + + +BOOL INSTAPI +SQLInstallDriverExW(LPCWSTR lpszDriver, LPCWSTR lpszPathIn, LPWSTR lpszPathOut, + WORD cbPathOutMax, WORD *pcbPathOut, WORD fRequest, + LPDWORD lpdwUsageCount) +{ + return FALSE; +} + + +RETCODE INSTAPI +SQLPostInstallerErrorW(DWORD fErrorCode, LPWSTR szErrorMsg) +{ + return SQL_ERROR; +} + + +BOOL INSTAPI +SQLRemoveDSNFromIniW(LPCWSTR lpszDSN) +{ + return FALSE; +} + + +BOOL INSTAPI +SQLRemoveDriverW(LPCWSTR lpszDriver, BOOL fRemoveDSN, LPDWORD lpdwUsageCount) +{ + return FALSE; +} + + +BOOL INSTAPI +SQLValidDSNW(LPCWSTR lpszDSN) +{ + return FALSE; +} + + +BOOL INSTAPI +SQLWriteDSNToIniW(LPCWSTR lpszDSN, LPCWSTR lpszDriver) +{ + return FALSE; +} + + +BOOL INSTAPI +SQLWritePrivateProfileStringW(LPCWSTR lpszSection, LPCWSTR lpszEntry, + LPCWSTR lpszString, LPCWSTR lpszFilename) +{ + return FALSE; +}