Removed:
branches/guffert/Build.bat
branches/guffert/Build.sh
branches/guffert/PostBuildTest.bat
branches/guffert/RemoveMakefiles.sh
branches/guffert/dsn-editor/
branches/guffert/monitor/
Modified:
branches/guffert/CMakeLists.txt
branches/guffert/ChangeLog
branches/guffert/CreateSourceZip.bat
branches/guffert/Install.bat
branches/guffert/Makefile.am
branches/guffert/README
branches/guffert/Uninstall.bat
branches/guffert/Upgrade.bat
branches/guffert/configure.in
branches/guffert/installer/CMakeLists.txt
branches/guffert/installer/Makefile.am
branches/guffert/installer/myodbc3i.c
branches/guffert/scripts/macosx/postflight
branches/guffert/scripts/myodbc3.spec.sh
branches/guffert/util/CMakeLists.txt
branches/guffert/util/installer.c
branches/guffert/util/stringutil.c
Log:
added new myodbc3i (and renamed to myodbc-installer), ported from c/odbc 5.0, and required
build changes
removed myodbc3c, myodbc3m, and some old scripts
removed support for "debug" builds (whatever support existed)
Deleted: branches/guffert/Build.bat
===================================================================
--- branches/guffert/Build.bat 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/Build.bat 2007-11-19 21:10:00 UTC (rev 877)
@@ -1,27 +0,0 @@
-@ECHO OFF
-REM ########################################################
-REM
-REM \brief Build myodbc.
-REM
-REM This exists for those working with the Windows source
-REM distribution.
-REM
-REM \sa README.win
-REM
-REM #########################################################
-
-# This is a future place holder for doing nmake builds on
-# Windows
-
-ECHO "+-----------------------------------------------------+"
-ECHO "| BUILD DONE |"
-ECHO "+-----------------------------------------------------+"
-ECHO "| |"
-ECHO "| Hopefully things went well and you have results in |"
-ECHO "| lib and bin sub-dirs. Consider running Install.bat |"
-ECHO "| next. |"
-ECHO "| |"
-ECHO "+-----------------------------------------------------+"
-EXIT /B 0
-
-
Deleted: branches/guffert/Build.sh
===================================================================
--- branches/guffert/Build.sh 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/Build.sh 2007-11-19 21:10:00 UTC (rev 877)
@@ -1,21 +0,0 @@
-# #########################################################
-#
-# \brief Make the sources.
-#
-#
-# #########################################################
-
-echo "+-----------------------"
-echo "| Force relink..."
-echo "+-----------------------"
-rm -rf lib
-rm -rf bin
-
-./CreateMakefiles.sh
-
-echo "+-----------------------"
-echo "| Making the libraries and executables..."
-echo "+-----------------------"
-make
-
-
Modified: branches/guffert/CMakeLists.txt
===================================================================
--- branches/guffert/CMakeLists.txt 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/CMakeLists.txt 2007-11-19 21:10:00 UTC (rev 877)
@@ -159,7 +159,6 @@
IF(NOT DISABLE_GUI)
IF(USE_LEGACY_ODBC_GUI)
ADD_SUBDIRECTORY(setup)
- ADD_SUBDIRECTORY(dsn-editor)
ELSE(USE_LEGACY_ODBC_GUI)
ADD_SUBDIRECTORY(setupgui)
ENDIF(USE_LEGACY_ODBC_GUI)
@@ -167,7 +166,6 @@
ADD_SUBDIRECTORY(dltest)
ADD_SUBDIRECTORY(installer)
-ADD_SUBDIRECTORY(monitor)
ADD_SUBDIRECTORY(test)
Modified: branches/guffert/ChangeLog
===================================================================
--- branches/guffert/ChangeLog 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/ChangeLog 2007-11-19 21:10:00 UTC (rev 877)
@@ -29,6 +29,9 @@
of DSN information. The new library, which was originally a part of
Connector/ODBC 5.0, supports Unicode option values.
* Implement native Windows setup library
+ * Removed monitor (myodbc3m) and dsn-editor (myodbc3c).
+ * Replaced myodbc3i (now myodbc-installer) with Connector/ODBC 5.0
+ version.
Bugs fixed:
* SQL statements limited to 64k. (Bug #30983)
Modified: branches/guffert/CreateSourceZip.bat
===================================================================
--- branches/guffert/CreateSourceZip.bat 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/CreateSourceZip.bat 2007-11-19 21:10:00 UTC (rev 877)
@@ -80,17 +80,6 @@
copy installer\*.pro mysql-connector-odbc-%1-win-src\installer
copy installer\*.c mysql-connector-odbc-%1-win-src\installer
-REM monitor
-mkdir mysql-connector-odbc-%1-win-src\monitor
-copy monitor\*.pro mysql-connector-odbc-%1-win-src\monitor
-copy monitor\*.c mysql-connector-odbc-%1-win-src\monitor
-copy monitor\*.h mysql-connector-odbc-%1-win-src\monitor
-
-REM dsn-editor
-mkdir mysql-connector-odbc-%1-win-src\dsn-editor
-copy dsn-editor\*.pro mysql-connector-odbc-%1-win-src\dsn-editor
-copy dsn-editor\*.cpp mysql-connector-odbc-%1-win-src\dsn-editor
-
REM driver
mkdir mysql-connector-odbc-%1-win-src\driver
copy driver\*.pro mysql-connector-odbc-%1-win-src\driver
Modified: branches/guffert/Install.bat
===================================================================
--- branches/guffert/Install.bat 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/Install.bat 2007-11-19 21:10:00 UTC (rev 877)
@@ -6,6 +6,9 @@
REM This exists for those working with the Windows source
REM distribution.
REM
+REM Use this to copy the driver and supporting files
+REM to the system directory and register the driver.
+REM
REM \sa README.win
REM
REM #########################################################
@@ -15,13 +18,8 @@
IF EXIST %windir%\system32\nul SET installdir=%windir%\system32
IF %installdir%==none GOTO :doError5
-IF "%1"=="1" GOTO :doDebug
-IF "%1"=="0" GOTO :doNormal
-GOTO doSyntax
+IF EXIST %installdir%\myodbc-installer.exe GOTO :doError4
-:doNormal
-IF EXIST %installdir%\myodbc3i.exe GOTO :doError4
-
REM ****
REM * Find out the bin/lib directory, or use default
REM ****
@@ -29,63 +27,33 @@
SET bindir=bin
IF EXIST lib\release\myodbc5.lib SET libdir=lib\release
IF EXIST lib\relwithdebinfo\myodbc5.lib SET libdir=lib\relwithdebinfo
-IF EXIST bin\release\myodbc3i.exe SET bindir=bin\release
-IF EXIST bin\relwithdebinfo\myodbc3i.exe SET bindir=bin\relwithdebinfo
+IF EXIST bin\release\myodbc-installer.exe SET bindir=bin\release
+IF EXIST bin\relwithdebinfo\myodbc-installer.exe SET bindir=bin\relwithdebinfo
REM ****
REM * Copying myodbc libraries and executables to install dir...
REM ****
+ECHO Copying installation files
IF NOT EXIST %libdir%\myodbc5.lib GOTO :doError2
IF NOT EXIST %libdir%\myodbc5S.lib GOTO :doError2
-IF NOT EXIST %bindir%\myodbc3i.exe GOTO :doError2
-IF NOT EXIST %bindir%\myodbc3m.exe GOTO :doError2
+IF NOT EXIST %bindir%\myodbc-installer.exe GOTO :doError2
copy %libdir%\myodbc5S.dll %installdir%
copy %libdir%\myodbc5S.lib %installdir%
copy %libdir%\myodbc5.dll %installdir%
copy %libdir%\myodbc5.lib %installdir%
-copy %bindir%\myodbc3i.exe %installdir%
-copy %bindir%\myodbc3m.exe %installdir%
+copy %bindir%\myodbc-installer.exe %installdir%
copy doc\*.hlp %installdir%
REM ****
REM * Registering driver...
REM *
-REM * We can do this with myodbc3i.exe or the MS Windows ODBCConf.exe. It
+REM * We can do this with myodbc-installer.exe or the MS Windows ODBCConf.exe. It
REM * may be safer to use the ODBCConf.exe when we think about such things
REM * as 64bit windows.
REM ****
-myodbc3i -a -d -t"MySQL ODBC 5.1 Driver;DRIVER=myodbc5.dll;SETUP=myodbc5S.dll"
+ECHO Registering driver
+myodbc-installer -d -a -n "MySQL ODBC 5.1 Driver" -t
"DRIVER=myodbc5.dll;SETUP=myodbc5S.dll"
-GOTO doSuccess
-
-
-:doDebug
-REM ****
-REM * Find out the bin/lib directory, or use default
-REM ****
-SET libdir=lib
-IF EXIST lib\debug\myodbc5d.lib SET libdir=lib\debug
-
-IF NOT EXIST %libdir%\myodbc5d.lib goto doError3
-IF NOT EXIST %libdir%\myodbc5E.lib goto doError3
-IF NOT EXIST %installdir%\myodbc3i.exe goto doError1
-REM ****
-REM * Copying myodbc debug libraries to install dir...
-REM ****
-copy %libdir%\myodbc5E.dll %installdir%
-copy %libdir%\myodbc5E.lib %installdir%
-copy %libdir%\myodbc5d.dll %installdir%
-copy %libdir%\myodbc5d.lib %installdir%
-
-REM ****
-REM * Registering driver...
-REM ****
-myodbc3i -a -d -t"MySQL ODBC 5.1 Driver (debug);DRIVER=myodbc5d.dll;SETUP=myodbc5E.dll"
-
-goto doSuccess
-
-
-:doSuccess
ECHO "+-----------------------------------------------------+"
ECHO "| DONE |"
ECHO "+-----------------------------------------------------+"
@@ -105,42 +73,17 @@
ECHO "+-----------------------------------------------------+"
EXIT /B 0
-:doError1
-ECHO "+-----------------------------------------------------+"
-ECHO "| ERROR |"
-ECHO "+-----------------------------------------------------+"
-ECHO "| |"
-ECHO "| The non-debug version of Connector/ODBC needs to be |"
-ECHO "| installed. |"
-ECHO "| |"
-ECHO "+-----------------------------------------------------+"
-PAUSE
-EXIT /B 1
-
:doError2
ECHO "+-----------------------------------------------------+"
ECHO "| ERROR |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
-ECHO "| Connector/ODBC not built. Consider executing |"
-ECHO "| Build.bat. |"
+ECHO "| Connector/ODBC not built. |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
PAUSE
EXIT /B 1
-:doError3
-ECHO "+-----------------------------------------------------+"
-ECHO "| ERROR |"
-ECHO "+-----------------------------------------------------+"
-ECHO "| |"
-ECHO "| Connector/ODBC (debug) not built. Consider executing|"
-ECHO "| Build.bat. |"
-ECHO "| |"
-ECHO "+-----------------------------------------------------+"
-PAUSE
-EXIT /B 1
-
:doError4
ECHO "+-----------------------------------------------------+"
ECHO "| ERROR |"
@@ -163,26 +106,3 @@
PAUSE
EXIT /B 1
-:doSyntax
-ECHO "+-----------------------------------------------------+"
-ECHO "| Install.bat |"
-ECHO "+-----------------------------------------------------+"
-ECHO "| |"
-ECHO "| DESCRIPTION |"
-ECHO "| |"
-ECHO "| Use this to copy the driver and supporting files |"
-ECHO "| to the system directory and register the driver. |"
-ECHO "| |"
-ECHO "| You can not properly install the debug version |"
-ECHO "| without first installing the regular version. |"
-ECHO "| |"
-ECHO "| SYNTAX |"
-ECHO "| |"
-ECHO "| Install <debug> |"
-ECHO "| |"
-ECHO "| <debug> must be; |"
-ECHO "| 0 - to install a regular build |"
-ECHO "| 1 - to install a debug version |"
-ECHO "| |"
-ECHO "+-----------------------------------------------------+"
-
Modified: branches/guffert/Makefile.am
===================================================================
--- branches/guffert/Makefile.am 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/Makefile.am 2007-11-19 21:10:00 UTC (rev 877)
@@ -39,9 +39,7 @@
util \
driver \
setup \
- dsn-editor \
installer \
- monitor \
@myodbc_test_dir@ \
scripts \
dltest
@@ -50,9 +48,7 @@
util \
driver \
setup \
- dsn-editor \
installer \
- monitor \
test \
scripts \
dltest
@@ -103,14 +99,10 @@
MYODBC_MYSQL.h \
MYODBC_ODBC.h \
mysql.bmp \
- Build.sh \
- Build.bat \
CreateBinaryMsi.bat \
CreateBinaryZip.bat \
CreateSourceZip.bat \
- RemoveMakefiles.sh \
Install.bat \
- PostBuildTest.bat \
Uninstall.bat \
Upgrade.bat \
CMakeLists.txt \
Deleted: branches/guffert/PostBuildTest.bat
===================================================================
--- branches/guffert/PostBuildTest.bat 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/PostBuildTest.bat 2007-11-19 21:10:00 UTC (rev 877)
@@ -1,77 +0,0 @@
-@ECHO OFF
-REM #########################################################
-REM
-REM \brief Execute post build tests.
-REM
-REM This executes a series of post-build tests. This is
-REM useful for a small sanity check before proceeding with
-REM more extensive tests.
-REM
-REM This is not automatically executed after each build.
-REM Typical usage would be to;
-REM
-REM > Uninstall.bat
-REM > Build.bat
-REM > Install.bat
-REM > PostBuildTest.bat
-REM
-REM \sa Build.bat
-REM
-REM #########################################################
-
-IF "%1"=="" GOTO doSyntax
-
-ECHO BEGIN: Post build test...
-GOTO d
-test\bin\connect.exe %1 %2 %3
-test\bin\basics.exe %1 %2 %3
-test\bin\param.exe %1 %2 %3
-test\bin\result.exe %1 %2 %3
-test\bin\cursor.exe %1 %2 %3
-test\bin\tran.exe %1 %2 %3
-test\bin\position.exe %1 %2 %3
-test\bin\relative.exe %1 %2 %3
-test\bin\scroll.exe %1 %2 %3
-test\bin\col_length.exe %1 %2 %3
-test\bin\blob.exe %1 %2 %3
-test\bin\bulk.exe %1 %2 %3
-test\bin\unixodbc.exe %1 %2 %3
-test\bin\dyn_cursor.exe %1 %2 %3
-test\bin\timestamp.exe %1 %2 %3
-test\bin\keys.exe %1 %2 %3
-test\bin\curext.exe %1 %2 %3
-test\bin\error.exe %1 %2 %3
-test\bin\tran_ext.exe %1 %2 %3
-REM test\bin\use_result.exe 10000 %1 %2 %3
-test\bin\use_result.exe 100 %1 %2 %3
-test\bin\catalog.exe %1 %2 %3
-:d
-test\bin\test32.exe %1 %2 %3
-EXIT /B 0
-
-ECHO END: Post build test.
-
-EXIT /B 0
-
-:doSyntax
-ECHO "+-----------------------------------------------------+"
-ECHO "| PostBuildTest.bat |"
-ECHO "+-----------------------------------------------------+"
-ECHO "| |"
-ECHO "| DESCRIPTION |"
-ECHO "| |"
-ECHO "| Use this to execute a series of post-build tests. |"
-ECHO "| This is often done after a Build.bat. |"
-ECHO "| |"
-ECHO "| SYNTAX |"
-ECHO "| |"
-ECHO "| PostBuildTest <DSN> [UID] [PWD] |"
-ECHO "| |"
-ECHO "| EXAMPLE |"
-ECHO "| |"
-ECHO "| PostBuildTest test |"
-ECHO "| |"
-ECHO "+-----------------------------------------------------+"
-
-
-
Modified: branches/guffert/README
===================================================================
--- branches/guffert/README 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/README 2007-11-19 21:10:00 UTC (rev 877)
@@ -86,29 +86,11 @@
Invoke myodbc3i, in a command shell and without options, to
get help on its use.
-Monitor (myodbc3m.exe)
-
- This command-line utility can be used to; send statements to the
- MySQL server and to view the results. It can provide output in
- several different formats - making it useful as a batch processing
- tool but it was developed to test a connection and for problem
- solving.
-
- Invoke myodbc3m, in a command shell and without options, to
- get help on its use.
-
Library Loading Tester (dltest.exe)
This command-line utility is useful fo debugging problems related
to loading a library and resolving symbols in it.
-Data Source Name Editor (myodbc3c.exe, no Windows version in ODBC 5.1)
-
- This is a GUI application designed to be invoked from the
- command-line. It allows a GUI to be invoked to add/edit a DSN. It
- is not useful on all platforms but on most platforms it can be a
- great aid during an install process.
-
Connector/ODBC SDK
---------------------------------------------------------------
Deleted: branches/guffert/RemoveMakefiles.sh
===================================================================
--- branches/guffert/RemoveMakefiles.sh 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/RemoveMakefiles.sh 2007-11-19 21:10:00 UTC (rev 877)
@@ -1,54 +0,0 @@
-# #########################################################
-#
-# \brief Remove makefiles so gnu auto-tools will create new ones.
-#
-#
-# #########################################################
-
-echo "+-----------------------"
-echo "| Removing Makefiles..."
-echo "+-----------------------"
-
-echo "dltest..."
-cd dltest
-rm -f Makefile.in
-rm -f Makefile
-cd ..
-
-echo "util..."
-cd util
-rm -f Makefile.in
-rm -f Makefile
-cd ..
-
-echo "setup..."
-cd setup
-rm -f Makefile.in
-rm -f Makefile
-cd ..
-
-echo "installer..."
-cd installer
-rm -f Makefile.in
-rm -f Makefile
-cd ..
-
-echo "monitor..."
-cd monitor
-rm -f Makefile.in
-rm -f Makefile
-cd ..
-
-echo "dsn-editor..."
-cd dsn-editor
-rm -f Makefile.in
-rm -f Makefile
-cd ..
-
-echo "driver..."
-cd driver
-rm -f Makefile.in
-rm -f Makefile
-cd ..
-
-
Modified: branches/guffert/Uninstall.bat
===================================================================
--- branches/guffert/Uninstall.bat 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/Uninstall.bat 2007-11-19 21:10:00 UTC (rev 877)
@@ -6,6 +6,9 @@
REM This exists for those working with the Windows source
REM distribution.
REM
+REM Use this to remove the driver and supporting files
+REM from the system directory and deregister the driver.
+REM
REM \sa README.win
REM
REM #########################################################
@@ -15,16 +18,11 @@
IF EXIST %windir%\system32\nul SET installdir=%windir%\system32
IF %installdir%==none GOTO :doError4
-IF "%1"=="0" GOTO doNormal
-IF "%1"=="1" GOTO doDebug
-GOTO doSyntax
-
-:doNormal
-IF NOT EXIST %installdir%\myodbc3i.exe GOTO doError2
+IF NOT EXIST %installdir%\myodbc-installer.exe GOTO doError2
REM ****
REM * Deregistering driver...
REM ****
-myodbc3i -r -d -n"MySQL ODBC 5.1 Driver"
+myodbc-installer -d -r -n "MySQL ODBC 5.1 Driver"
REM ****
REM * Removing files...
@@ -33,29 +31,9 @@
del /Q /F %installdir%\myodbc5S.lib
del /Q /F %installdir%\myodbc5.dll
del /Q /F %installdir%\myodbc5.lib
-del /Q /F %installdir%\myodbc3i.exe
-del /Q /F %installdir%\myodbc3m.exe
+del /Q /F %installdir%\myodbc-installer.exe
del /Q /F %installdir%\myodbc3*.hlp
-GOTO doSuccess
-:doDebug
-IF NOT EXIST %installdir%\myodbc5d.dll GOTO doError3
-IF NOT EXIST %installdir%\myodbc3i.exe GOTO doError1
-REM ****
-REM * Deregistering driver...
-REM ****
-myodbc3i -r -d -n"MySQL ODBC 5.1 Driver (debug)"
-
-REM ****
-REM * Removing files...
-REM ****
-del /Q /F %installdir%\myodbc5E.dll
-del /Q /F %installdir%\myodbc5E.lib
-del /Q /F %installdir%\myodbc5d.dll
-del /Q /F %installdir%\myodbc5d.lib
-GOTO doSuccess
-
-:doSuccess
ECHO "+-----------------------------------------------------+"
ECHO "| DONE |"
ECHO "+-----------------------------------------------------+"
@@ -67,18 +45,6 @@
ECHO "+-----------------------------------------------------+"
EXIT /B 0
-:doError1
-ECHO "+-----------------------------------------------------+"
-ECHO "| ERROR |"
-ECHO "+-----------------------------------------------------+"
-ECHO "| |"
-ECHO "| The non-debug version of Connector/ODBC needs to be |"
-ECHO "| installed. |"
-ECHO "| |"
-ECHO "+-----------------------------------------------------+"
-PAUSE
-EXIT /B 1
-
:doError2
ECHO "+-----------------------------------------------------+"
ECHO "| ERROR |"
@@ -90,18 +56,6 @@
PAUSE
EXIT /B 1
-:doError3
-ECHO "+-----------------------------------------------------+"
-ECHO "| ERROR |"
-ECHO "+-----------------------------------------------------+"
-ECHO "| |"
-ECHO "| Connector/ODBC (debug) does not appear to be |"
-ECHO "| installed. |"
-ECHO "| |"
-ECHO "+-----------------------------------------------------+"
-PAUSE
-EXIT /B 1
-
:doError4
ECHO "+-----------------------------------------------------+"
ECHO "| ERROR |"
@@ -113,26 +67,3 @@
PAUSE
EXIT /B 1
-:doSyntax
-ECHO "+-----------------------------------------------------+"
-ECHO "| Uninstall.bat |"
-ECHO "+-----------------------------------------------------+"
-ECHO "| |"
-ECHO "| DESCRIPTION |"
-ECHO "| |"
-ECHO "| Use this to remove the driver and supporting files |"
-ECHO "| from the system directory and deregister the driver.|"
-ECHO "| |"
-ECHO "| The regular version must be installed for the |"
-ECHO "| debug version to be properly uninstalled. |"
-ECHO "| |"
-ECHO "| SYNTAX |"
-ECHO "| |"
-ECHO "| Uninstall <debug> |"
-ECHO "| |"
-ECHO "| <debug> must be; |"
-ECHO "| 0 - to uninstall a regular build |"
-ECHO "| 1 - to uninstall a debug version |"
-ECHO "| |"
-ECHO "+-----------------------------------------------------+"
-
Modified: branches/guffert/Upgrade.bat
===================================================================
--- branches/guffert/Upgrade.bat 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/Upgrade.bat 2007-11-19 21:10:00 UTC (rev 877)
@@ -6,38 +6,14 @@
REM Often when testing you want to Uninstall and Install. This
REM script does this.
REM
+REM Use this upgrade an existing install. This just
+REM calls Uninstall/Install so it has nothing to do
+REM with MS installed software thingy in Control Panel.
+REM
REM \sa README.win
REM
REM #########################################################
-
-IF "%1"=="1" GOTO :doIt
-IF "%1"=="0" GOTO :doIt
-
-:doSyntax
-ECHO "+-----------------------------------------------------+"
-ECHO "| Upgrade.bat |"
-ECHO "+-----------------------------------------------------+"
-ECHO "| |"
-ECHO "| DESCRIPTION |"
-ECHO "| |"
-ECHO "| Use this upgrade an existing install. This just |"
-ECHO "| calls Uninstall/Install so it has nothing to do |"
-ECHO "| with MS installed software thingy in Control Panel. |"
-ECHO "| |"
-ECHO "| SYNTAX |"
-ECHO "| |"
-ECHO "| Upgrade <debug> |"
-ECHO "| |"
-ECHO "| <debug> must be; |"
-ECHO "| 0 - to install a regular build |"
-ECHO "| 1 - to install a debug version |"
-ECHO "| |"
-ECHO "+-----------------------------------------------------+"
-EXIT /B 1
-
-:doIt
CALL Uninstall.bat %1
CALL Install.bat %1
-
Modified: branches/guffert/configure.in
===================================================================
--- branches/guffert/configure.in 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/configure.in 2007-11-19 21:10:00 UTC (rev 877)
@@ -130,40 +130,22 @@
###################################################################
#
-# --enable-myodbc3i
+# --enable-myodbc-installer
#
###################################################################
-AC_ARG_ENABLE( myodbc3i,
-[AC_HELP_STRING([--enable-myodbc3i],[Build myodbc installer command-line interface
[default=yes]])],
+AC_ARG_ENABLE( myodbc-installer,
+[AC_HELP_STRING([--enable-myodbc-installer],[Build myodbc installer command-line
interface [default=yes]])],
[ case "${enableval}" in
- yes) myodbc3i=true ;;
- no) myodbc3i=false ;;
- *) AC_MSG_ERROR(bad value ${enableval} for --enable-myodbc3i) ;;
- esac],[myodbc3i=true])
+ yes) myodbc_installer=true ;;
+ no) myodbc_installer=false ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-myodbc-installer) ;;
+ esac],[myodbc_installer=true])
#
# TO DO: Ensure we have libltdl.
#
-AM_CONDITIONAL(MYODBCINST, test "x$myodbc3i" = "xtrue" )
+AM_CONDITIONAL(MYODBCINST, test "x$myodbc_installer" = "xtrue" )
-###################################################################
-#
-# --enable-myodbc3m
-#
-###################################################################
-AC_ARG_ENABLE( myodbc3m,
-[AC_HELP_STRING([--enable-myodbc3m],[Build myodbc command-line shell [default=yes]])],
-[ case "${enableval}" in
- yes) myodbc3m=true ;;
- no) myodbc3m=false ;;
- *) AC_MSG_ERROR(bad value ${enableval} for --enable-myodbc3m) ;;
- esac],[myodbc3m=true])
-#
-# TO DO: Ensure we have libltdl.
-#
-
-AM_CONDITIONAL(IMYODBC, test "x$myodbc3m" = "xtrue" )
-
dnl Enable system-specific compiler flags
case "$target_os" in
*aix*)
@@ -835,9 +817,7 @@
util/Makefile
driver/Makefile
setup/Makefile
- dsn-editor/Makefile
installer/Makefile
- monitor/Makefile
test/Makefile
scripts/Makefile
dltest/Makefile
Modified: branches/guffert/installer/CMakeLists.txt
===================================================================
--- branches/guffert/installer/CMakeLists.txt 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/installer/CMakeLists.txt 2007-11-19 21:10:00 UTC (rev 877)
@@ -20,8 +20,12 @@
##########################################################################
-ADD_EXECUTABLE(myodbc3i myodbc3i.c)
-TARGET_LINK_LIBRARIES(myodbc3i myodbc3u ${ODBCLIB} ${ODBCINSTLIB})
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/util)
-INSTALL(TARGETS myodbc3i DESTINATION bin)
+ADD_EXECUTABLE(myodbc-installer myodbc3i.c)
+TARGET_LINK_LIBRARIES(myodbc-installer myodbc3u ${ODBCLIB} ${ODBCINSTLIB}
+ ${MYSQL_CLIENT_LIBS})
+INSTALL(TARGETS myodbc-installer DESTINATION bin)
+
Modified: branches/guffert/installer/Makefile.am
===================================================================
--- branches/guffert/installer/Makefile.am 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/installer/Makefile.am 2007-11-19 21:10:00 UTC (rev 877)
@@ -20,11 +20,13 @@
INCLUDES = -I$(top_srcdir)
-bin_PROGRAMS = myodbc3i
+bin_PROGRAMS = myodbc-installer
myodbc3i_SOURCES = myodbc3i.c
myodbc3i_LDADD = ../util/libmyodbc3u.la @LTDL_LIB@
myodbc3i_DEPENDENCIES = ../util/libmyodbc3u.la
+INCLUDES=-I.. -I../util
+
# LDFLAGS=@EXTRA_LDFLAGS@
endif
Modified: branches/guffert/installer/myodbc3i.c
===================================================================
--- branches/guffert/installer/myodbc3i.c 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/installer/myodbc3i.c 2007-11-19 21:10:00 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2005 MySQL AB
+/* Copyright (C) 2000-2007 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,933 +19,719 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*!
- \file myodbc3i.c
- \author Peter Harvey <peterh@stripped>
- \brief This program will aid installers when installing/uninstalling
+ @brief This program will aid installers when installing/uninstalling
MyODBC.
- This program can; register/deregister a myodbc driver and create
+ This program can register/deregister a myodbc driver and create
a sample dsn. The key thing here is that it does this with
cross-platform code - thanks to the ODBC installer API. This is
most useful to those creating installers (apps using myodbc or
myodbc itself).
- For example; this program is used in the postinstall script
+ For example, this program is used in the postinstall script
of the MyODBC for Mac OS X installer package.
*/
-/*!
- \note This program uses MYODBCUtil in similar fashion to the *driver*
- but does not use it the way the setup library does.
-*/
+/*
+ * Installer utility application. Handles installing/removing/listing, etc
+ * driver and data source entries in the system. See usage text for details.
+ */
-#include <stdio.h>
-
-#ifndef TRUE
- #define TRUE 1
- #define FALSE 0
+#ifdef _WIN32
+# include <windows.h>
#endif
-#ifdef WIN32
- #include <windows.h>
-#else
- #include <ltdl.h>
-#endif
+#include <stdio.h>
+#include <stdlib.h>
-#include "../util/MYODBCUtil.h"
-
-#ifdef USE_IODBC
-#include <iodbcinst.h>
-#else
+#include <sql.h>
+#include <sqlext.h>
#include <odbcinst.h>
-#endif
-typedef BOOL (INSTAPI *ConfigDSNFunctor)(HWND, WORD, LPCSTR, LPCSTR);
+#include "installer.h"
+#include "stringutil.h"
+#include "VersionInfo.h"
+#include "MYODBC_MYSQL.h"
-/*! Our syntax. This is likely to expand over time. */
-char *szSyntax =
-"\n" \
-"+----------------------------------------------------------+\n" \
-"| myodbc3i |\n" \
-"+----------------------------------------------------------+\n" \
-"\n" \
-" Use this program to manage ODBC system information from the\n" \
-" command-line. This is particularly useful for installation \n" \
-" processes. It is also useful for testing the abstraction/\n" \
-" portability of ODBC system information provided by the \n" \
-" MYODBCUtil library.\n" \
-"\n" \
-"+----------------------------------------------------------+\n" \
-"| U S A G E |\n" \
-"+----------------------------------------------------------+\n" \
-"\n" \
-" $ myodbc3i <action> <object> <option>\n" \
-"\n" \
-"+----------------------------------------------------------+\n" \
-"| A C T I O N |\n" \
-"+----------------------------------------------------------+\n" \
-"\n" \
-" q Query\n" \
-" a Add\n" \
-" e Edit\n" \
-" r Remove\n" \
-"\n" \
-"+----------------------------------------------------------+\n" \
-"| O B J E C T |\n" \
-"+----------------------------------------------------------+\n" \
-"\n" \
-" d Driver.\n" \
-" n Driver or data source name. String follows this.\n" \
-" s User & system data source(s).\n" \
-" su User data source(s).\n" \
-" ss System data source(s).\n" \
-"\n" \
-"+----------------------------------------------------------+\n" \
-"| O P T I O N |\n" \
-"+----------------------------------------------------------+\n" \
-"\n" \
-" t Attribute string. String of semi delim key=value pairs follows this.\n" \
-" w Window handle. Numeric follows this. 0 to disable GUI prompts, 1 to fake a window
handle (default).\n" \
-"\n" \
-"+----------------------------------------------------------+\n" \
-"| S Y N T A X |\n" \
-"+----------------------------------------------------------+\n" \
-"\n" \
-" q d|s|su|ss [n] [w]\n" \
-" a d|s|su|ss t [w]\n" \
-" e s|su|ss t [w]\n" \
-" r d|s|su|ss n [w]\n" \
-"\n" \
-"+----------------------------------------------------------+\n" \
-"| E X A M P L E S |\n" \
-"+----------------------------------------------------------+\n" \
-"\n" \
-" List all data source names;\n" \
-" $ myodbc3i -q -s\n" \
-" List data source attributes for MyODBC;\n" \
-" $ myodbc3i -q -s -n\"MySQL ODBC 3.51 Driver\"\n" \
-" Register a driver;\n" \
-" $ myodbc3i -a -d -t\"MySQL ODBC 3.51
Driver;Driver=/usr/lib/libmyodbc5.so;Setup=/usr/lib/libmyodbc5S.so\"\n" \
-" Create a user data source name;\n" \
-" $ myodbc3i -a -su -t\"DSN=MyDSN;Driver=MySQL ODBC 3.51
Driver;Server=localhost;UID=pharvey\"\n";
+const char *usage =
+"+--- \n"
+"| myodbc3i v" MYODBC_VERSION " \n"
+"+--- \n"
+"| \n"
+"| Description \n"
+"| \n"
+"| This program can be used to create, edit or remove a DSN. It \n"
+"| can also be used to register or deregister a driver. In other \n"
+"| words - it can be used to manage ODBC system information. \n"
+"| \n"
+"| This operates consistently across platforms. This has been created\n"
+"| specifically for MySQL Connector/ODBC. \n"
+"| \n"
+"| Syntax \n"
+"| \n"
+"| myodbc3i <Object> <Action> [Options] \n"
+"| \n"
+"| Object \n"
+"| \n"
+"| -d driver \n"
+"| -s datasource \n"
+"| \n"
+"| Action \n"
+"| \n"
+"| -l list \n"
+"| -a add (add/update for data source) \n"
+"| -r remove \n"
+"| \n"
+"| Options \n"
+"| \n"
+"| -n <name> \n"
+"| -t <attribute string> \n"
+/* Note: These scope values line up with the SQLSetConfigMode constants */
+"| -c0 both \n"
+"| -c1 user data source \n"
+"| -c2 system data source (default) \n"
+"| \n"
+"| Examples \n"
+"| \n"
+"| List drivers \n"
+"| -d -l \n"
+"| \n"
+"| Register a driver (Windows specific) \n"
+"| -d -a -n \"MySQL ODBC 5.1 Driver\" \\ \n"
+"| -t \"DRIVER=myodbc5.dll;SETUP=myodbc5S.dll\" \n"
+"| \n"
+"| Add a new data source name \n"
+"| -s -a -c2 -n \"test\" \\ \n"
+"| -t \"DRIVER=MySQL ODBC 5.1
Driver;SERVER=localhost;DATABASE=test;UID=myid;PWD=mypwd\"\n"
+"| \n"
+"| List data source name attributes for 'test' \n"
+"| -s -l -c2 -n \"test\" \n"
+"+--- \n";
-/*
- Register Driver for Various Platforms
-
- XP
-
- $ myodbc3i -a -d -t"MySQL ODBC 3.51 Driver;Driver=myodbc5.dll;Setup=myodbc5S.dll"
-
- OR for old GUI...
-
- $ myodbc3i -a -d -t"MySQL ODBC 3.51 Driver;Driver=myodbc5.dll;Setup=myodbc5.dll"
-
- Mac OS X
+/* command line args */
+#define OBJ_DRIVER 'd'
+#define OBJ_DATASOURCE 's'
- At least some of the functions dealing with the
- odbc system information are case sensitive
- (contrary to the ODBC spec.). They appear to like
- leading caps.
-
- $ myodbc3i -a -d -t"MySQL ODBC 3.51
Driver;Driver=/usr/lib/libmyodbc5.so;Setup=/usr/lib/libmyodbc5S.dylib"
-
- UNIX/Linux
-
- $ myodbc3i -a -d -t"MySQL ODBC 3.51
Driver;DRIVER=/usr/lib/libmyodbc5.so;SETUP=/usr/lib/libmyodbc5S.so"
+#define ACTION_LIST 'l'
+#define ACTION_ADD 'a'
+#define ACTION_REMOVE 'r'
-*/
+#define OPT_NAME 'n'
+#define OPT_ATTR 't'
+#define OPT_SCOPE 'c'
-char cAction = '\0';
-char cObject = '\0';
-char cObjectSub = '\0';
-long nWnd = 1;
-char * pszName = NULL;
-char * pszAttributes = NULL;
+static char obj= 0;
+static char action= 0;
+static UWORD scope= ODBC_SYSTEM_DSN; /* default = system */
-char szBuffer[32000];
-int nBuffer = 32000;
+/* these two are 'paired' and the char data is converted to the wchar buf.
+ * we check the char * to see if the arg was given then use the wchar in the
+ * installer api. */
+static char *name= NULL;
+static SQLWCHAR *wname;
-#if defined(WIN32)
-/*!
- \brief Get the last *Windows* error and display string ver of it.
-*/
-void doPrintLastErrorString()
-{
- LPVOID pszMsg;
+static char *attrstr= NULL;
+static SQLWCHAR *wattrs;
- FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR)&pszMsg,
- 0,
- NULL );
- fprintf( stderr, pszMsg );
- LocalFree( pszMsg );
-}
-#endif
-/*!
- \brief Prints any installer errors sitting in the installers
- error queue.
-
- General purpose error dump function for installer
- errors. Hopefully; it provides useful information about
- any failed installer call.
-
- \note Does not try to process all 8 possible records from the queue.
-*/
-void doPrintInstallerError( char *pszFile, int nLine )
+void object_usage()
{
- WORD nRecord = 1;
- DWORD nError;
- char szError[SQL_MAX_MESSAGE_LENGTH];
- RETCODE nReturn;
-
- nReturn = SQLInstallerError( nRecord, &nError, szError, SQL_MAX_MESSAGE_LENGTH -
1, 0 );
- if ( SQL_SUCCEEDED( nReturn ) )
- fprintf( stderr, "[%s][%d][ERROR] ODBC Installer error %d: %s\n", pszFile, nLine,
(int)nError, szError );
- else
- fprintf( stderr, "[%s][%d][ERROR] ODBC Installer error (unknown)\n", pszFile,
nLine );
+ fprintf(stderr,
+ "[ERROR] Object must be either driver (d) or data source (s)\n");
}
-int doQuery();
-int doQueryDriver();
-int doQueryDriverName();
-int doQueryDataSource();
-int doQueryDataSourceName( UWORD nScope );
-int doAdd();
-int doAddDriver();
-int doAddDataSource();
-int doEdit();
-int doEditDriver();
-int doEditDataSource();
-int doRemove();
-int doRemoveDriver();
-int doRemoveDataSource();
-int doRemoveDataSourceName();
-int doConfigDataSource( WORD nRequest );
-
-/*!
- \brief This is the entry point to this program.
-
- \note More features/args will probably be added in the future.
-*/
-int main( int argc, char *argv[] )
+void action_usage()
{
- int nArg;
- int nReturn;
+ fprintf(stderr, "[ERROR] One action must be specified\n");
+}
- /*
- help; possible newbie
- */
- if ( argc <= 1 )
- {
- printf( szSyntax );
- exit( 1 );
- }
- /*
- parse args
- */
- for ( nArg = 1; nArg < argc; nArg++ )
- {
- if ( argv[nArg][0] == '-' )
- {
- switch ( argv[nArg][1] )
- {
- /* actions */
- case 'e':
- case 'q':
- case 'a':
- case 'r':
- cAction = argv[nArg][1];
- break;
- /* objects */
- case 'd':
- case 's':
- cObject = argv[nArg][1];
- cObjectSub = argv[nArg][2]; /* '\0' if not provided */
- break;
- /* options */
- case 'n':
- pszName = &(argv[nArg][2]);
- break;
- case 't':
- pszAttributes = &(argv[nArg][2]);
- break;
- case 'w':
- nWnd = atoi( &(argv[nArg][2]) );
- break;
- default:
- {
- printf( szSyntax );
- exit( 1 );
- }
- }
- }
- else
- {
- printf( szSyntax );
- exit( 1 );
- }
- }
-
- /*
- process args
- */
- switch ( cAction )
- {
- case 'q':
- nReturn = doQuery();
- break;
- case 'a':
- nReturn = doAdd();
- break;
- case 'e':
- nReturn = doEdit();
- break;
- case 'r':
- nReturn = doRemove();
- break;
- default:
- printf( "[%s][%d][ERROR] Invalid, or missing, action.\n", __FILE__, __LINE__
);
- exit( 1 );
- }
-
- return ( !nReturn );
+void main_usage()
+{
+ fprintf(stderr, usage);
}
-/*!
- \brief Show a list of drivers or data source names.
-
- \note XP
-
- SQLGetPrivateProfileString() with a NULL 1st arg does not
- return anything - ever. To return a list of drivers we can
- use SQLGetInstalledDrivers() but no alternative in ODBC
- installer for getting a list of data source names.
-*/
-int doQuery()
+/*
+ * Print an error retrieved from SQLInstallerError.
+ */
+void print_installer_error()
{
- switch ( cObject )
- {
- case 'd':
- return doQueryDriver();
- case 's':
- return doQueryDataSource();
- default:
- fprintf( stderr, "[%s][%d][ERROR] Missing or invalid object type
specified.\n", __FILE__, __LINE__ );
- return 0;
- }
+ int msgno;
+ DWORD errcode;
+ SQLCHAR errmsg[256];
+ for(msgno= 1; msgno < 9; ++msgno)
+ {
+ if (SQLInstallerError(msgno, &errcode, errmsg, 256, NULL) != SQL_SUCCESS)
+ return;
+ fprintf(stderr, "[ERROR] SQLInstaller error %d: %s\n", errcode, errmsg);
+ }
}
-int doQueryDriver()
+
+/*
+ * Print a general ODBC error (non-odbcinst).
+ */
+void print_odbc_error(SQLHANDLE hnd, SQLSMALLINT type)
{
- char *psz;
+ char sqlstate[20];
+ char errmsg[1000];
+ SQLINTEGER nativeerr;
- if ( pszName )
- return doQueryDriverName();
+ fprintf(stderr, "[ERROR] ODBC error");
- if ( !MYODBCUtilGetDriverNames( szBuffer, nBuffer ) )
- {
- doPrintInstallerError( __FILE__, __LINE__ );
- fprintf( stderr, "[%s][%d][WARNING] Failed to get driver names. Perhaps none
installed?\n", __FILE__, __LINE__ );
- return 0;
- }
-
- psz = szBuffer;
- while ( *psz )
- {
- printf( "%s\n", psz );
- psz += strlen( psz ) + 1;
- }
-
- return 1;
+ if(SQL_SUCCEEDED(SQLGetDiagRec(type, hnd, 1, sqlstate, &nativeerr,
+ errmsg, 1000, NULL)))
+ printf(": [%s] %d -> %s\n", sqlstate, nativeerr, errmsg);
+ printf("\n");
}
-int doQueryDriverName()
+
+/*
+ * Handler for "list driver" command (-d -l -n drivername)
+ */
+int list_driver_details(Driver *driver)
{
- int bReturn = 0;
- MYODBCUTIL_DRIVER *pDriver = MYODBCUtilAllocDriver();
+ SQLWCHAR buf[50000];
+ SQLWCHAR *entries= buf;
+ int rc;
- if ( !MYODBCUtilReadDriver( pDriver, pszName, NULL ) )
- {
- fprintf( stderr, "[%s][%d][WARNING] Could not load (%s)\n", __FILE__, __LINE__,
pszName );
- goto doQueryDriverNameExit1;
- }
+ /* lookup the driver */
+ if ((rc= driver_lookup(driver)) < 0)
+ {
+ fprintf(stderr, "[ERROR] Driver not found '%s'\n",
+ ds_get_utf8attr(driver->name, &driver->name8));
+ return 1;
+ }
+ else if (rc > 0)
+ {
+ print_installer_error();
+ return 1;
+ }
- printf( "Name............: %s\n", pDriver->pszName );
- printf( "DRIVER..........: %s\n", pDriver->pszDRIVER );
- printf( "SETUP...........: %s\n", pDriver->pszSETUP );
+ /* print driver details */
+ printf("FriendlyName: %s\n", ds_get_utf8attr(driver->name, &driver->name8));
+ printf("DRIVER : %s\n", ds_get_utf8attr(driver->lib, &driver->lib8));
+ printf("SETUP : %s\n", ds_get_utf8attr(driver->setup_lib,
+ &driver->setup_lib8));
- bReturn = 1;
-
- doQueryDriverNameExit1:
- MYODBCUtilFreeDriver( pDriver );
-
- return bReturn;
+ return 0;
}
-int doQueryDataSource()
+
+/*
+ * Handler for "list drivers" command (-d -l)
+ */
+int list_drivers()
{
- int bReturn;
- char * psz;
+ SQLCHAR buf[50000];
+ SQLCHAR *drivers= buf;
- switch ( cObjectSub )
- {
- case '\0':
- if ( pszName )
- return doQueryDataSourceName( ODBC_BOTH_DSN );
- else
- bReturn = MYODBCUtilGetDataSourceNames( szBuffer, nBuffer, ODBC_BOTH_DSN
);
- break;
- case 'u':
- if ( pszName )
- return doQueryDataSourceName( ODBC_USER_DSN );
- else
- bReturn = MYODBCUtilGetDataSourceNames( szBuffer, nBuffer, ODBC_USER_DSN
);
- break;
- case 's':
- if ( pszName )
- return doQueryDataSourceName( ODBC_SYSTEM_DSN );
- else
- bReturn = MYODBCUtilGetDataSourceNames( szBuffer, nBuffer,
ODBC_SYSTEM_DSN );
- break;
- default:
- fprintf( stderr, "[%s][%d][ERROR] Invalid object type qualifier
specified.\n", __FILE__, __LINE__ );
- return 0;
- }
+ if (!SQLGetInstalledDrivers(buf, 50000, NULL))
+ {
+ print_installer_error();
+ return 1;
+ }
- if ( !bReturn )
- {
- doPrintInstallerError( __FILE__, __LINE__ );
- return 0;
- }
+ while (*drivers)
+ {
+ printf("%s\n", drivers);
+ drivers += strlen(drivers) + 1;
+ }
- psz = szBuffer;
- while ( *psz )
- {
- printf( "%s\n", psz );
- psz += strlen( psz ) + 1;
- }
-
- return 1;
+ return 0;
}
-int doQueryDataSourceName( UWORD nScope )
+
+/*
+ * Handler for "add driver" command (-d -a -n drivername -t attrs)
+ */
+int add_driver(Driver *driver, const SQLWCHAR *attrs)
{
- int bReturn = 0;
- MYODBCUTIL_DATASOURCE *pDataSource = MYODBCUtilAllocDataSource(
MYODBCUTIL_DATASOURCE_MODE_DSN_VIEW );
+ DWORD usage_count;
+ SQLWCHAR attrs_null[4096]; /* null-delimited pairs */
+ SQLWCHAR prevpath[256];
- /* set scope */
- if ( !SQLSetConfigMode( nScope ) )
- return FALSE;
+ /* read driver attributes into object */
+ if (driver_from_kvpair_semicolon(driver, attrs))
+ {
+ fprintf(stderr,
+ "[ERROR] Could not parse key-value pair attribute string\n");
+ return 1;
+ }
- if ( !MYODBCUtilReadDataSource( pDataSource, pszName ) )
- {
- fprintf( stderr, "[%s][%d][WARNING] Could not load (%s)\n", __FILE__, __LINE__,
pszName );
- goto doQueryDataSourceNameExit1;
- }
+ /* convert to null-delimited for installer API */
+ if (driver_to_kvpair_null(driver, attrs_null, 4096))
+ {
+ fprintf(stderr,
+ "[ERROR] Could not create new key-value pair attribute string\n");
+ return 1;
+ }
- printf( "DSN.............: %s\n", pDataSource->pszDSN );
- printf( "DRIVER..........: %s\n", pDataSource->pszDRIVER );
- printf( "Driver file name: %s\n", pDataSource->pszDriverFileName );
- printf( "DESCRIPTION.....: %s\n", pDataSource->pszDESCRIPTION );
- printf( "SERVER..........: %s\n", pDataSource->pszSERVER );
- printf( "UID.............: %s\n", pDataSource->pszUSER );
- printf( "PWD.............: %s\n", pDataSource->pszPASSWORD );
- printf( "DATABASE........: %s\n", pDataSource->pszDATABASE );
- printf( "PORT............: %s\n", pDataSource->pszPORT );
- printf( "SOCKET..........: %s\n", pDataSource->pszSOCKET );
- printf( "STMT............: %s\n", pDataSource->pszSTMT );
- printf( "OPTION..........: %s\n", pDataSource->pszOPTION );
+ if (SQLInstallDriverExW(attrs_null, NULL, prevpath, 256, NULL,
+ ODBC_INSTALL_COMPLETE, &usage_count) != TRUE)
+ {
+ print_installer_error();
+ return 1;
+ }
- bReturn = 1;
+ printf("Success: Usage count is %d\n", usage_count);
-doQueryDataSourceNameExit1:
- /* unset scope */
- switch ( nScope )
- {
- case ODBC_BOTH_DSN:
- SQLSetConfigMode( ODBC_BOTH_DSN );
- break;
- case ODBC_USER_DSN:
- case ODBC_SYSTEM_DSN:
- SQLSetConfigMode( ODBC_BOTH_DSN );
- break;
- }
-
- MYODBCUtilFreeDataSource( pDataSource );
-
- return bReturn;
+ return 0;
}
-int doAdd()
+
+/*
+ * Handler for "remove driver" command (-d -a -n drivername)
+ */
+int remove_driver(Driver *driver)
{
- switch ( cObject )
- {
- case 'd':
- return doAddDriver();
- case 's':
- return doAddDataSource();
- default:
- fprintf( stderr, "[%s][%d][ERROR] Missing or invalid object type
specified.\n", __FILE__, __LINE__ );
- return 0;
- }
-}
+ DWORD usage_count;
-/*!
- \brief Register the driver (or just increase usage count).
+ if (SQLRemoveDriverW(driver->name, FALSE, &usage_count) != TRUE)
+ {
+ print_installer_error();
+ return 1;
+ }
- \note XP
-
- On MS Windows (XP for example) the driver is registered in two places;
- 1) \windows\system32\odbcinst.ini
- 2) registry
- Fortunately the installer calls will ensure they are both updated.
+ printf("Success: Usage count is %d\n", usage_count);
- All ODBC drivers *should* be installed in the standard location
(\windows\system32) and this call
- reflects this as no path is given for the driver file.
+ return 0;
+}
- \note Mac OS X
-
- On Mac OS X there are many odbcinst.ini files - each account has one in
~/Library/ODBC and there
- is a system wide one in /Library/ODBC.
- There are at least two notable complicating factors;
- - the files are read-ony for average user so one should use sudo when doing
this
- - the files do not exist until someone manually creates entries using the
ODBC Administrator AND
- they are not created by iodbc installer lib when we execute this code (we
get error)
-
- ODBC spec says that "Driver" should NOT include path
- but path seems needed for iodbc. The implication is that
- the driver *must* be installed in /usr/lib for this to work.
-
- Usage Count is not returned on Mac OS X and returned location does not seem
to reflect reality.
-
- \note Linux/UNIX
-
- ODBC spec says that "Driver" should NOT include path
- but path seems needed for unixODBC. The implication is that
- the driver *must* be installed in /usr/lib for this to work.
-
- Location returned does not seem to reflect reality.
-*/
-int doAddDriver()
+/*
+ * Handle driver actions. We setup a driver object to be used
+ * for all actions.
+ */
+int handle_driver_action()
{
- char *pszDriverInfo = NULL;
- char szLoc[FILENAME_MAX];
- WORD nLocLen;
- DWORD nUsageCount;
- int nChar;
+ int rc= 0;
+ Driver *driver= driver_new();
- if ( !pszAttributes )
+ /* check name is given if needed */
+ switch (action)
+ {
+ case ACTION_ADD:
+ case ACTION_REMOVE:
+ if (!name)
{
- fprintf( stderr, "[%s][%d][ERROR] Please provide driver attributes.\n", __FILE__,
__LINE__ );
- return 0;
+ fprintf(stderr, "[ERROR] Name missing to add/remove driver\n");
+ rc= 1;
+ goto end;
}
+ }
- switch (cObjectSub) {
- case 'u':
- if (!SQLSetConfigMode(ODBC_USER_DSN))
- return FALSE;
- case 's':
- if (!SQLSetConfigMode(ODBC_SYSTEM_DSN))
- return FALSE;
- }
+ /* set the driver name */
+ if (name)
+ sqlwcharncpy(driver->name, wname, ODBCDRIVER_STRLEN);
- /*
- Create a oopy of pszAttributes where the ';' are replaced
- with '\0' and ensure that at least 2 '\0' are at the end.
- SQLInstallDriverEx() needs it formatted this way.
- */
- pszDriverInfo = (char *)malloc( strlen(pszAttributes) + 2 );
-
- for ( nChar = 0; pszAttributes[nChar]; nChar++ )
+ /* perform given action */
+ switch (action)
+ {
+ case ACTION_LIST:
+ if (name)
+ rc= list_driver_details(driver);
+ else
+ rc= list_drivers();
+ break;
+ case ACTION_ADD:
+ if (attrstr)
+ rc= add_driver(driver, wattrs);
+ else
{
- if ( pszAttributes[nChar] == ';' )
- pszDriverInfo[nChar] = '\0';
- else
- pszDriverInfo[nChar] = pszAttributes[nChar];
+ fprintf(stderr, "[ERROR] Attribute string missing to add driver\n");
+ rc= 1;
}
+ break;
+ case ACTION_REMOVE:
+ rc= remove_driver(driver);
+ break;
+ }
- pszDriverInfo[nChar++] = '\0';
- pszDriverInfo[nChar] = '\0';
+end:
+ driver_delete(driver);
+ return rc;
+}
- /*
- Call ODBC installer to do the work.
- */
- if ( !SQLInstallDriverEx( pszDriverInfo, 0, szLoc, FILENAME_MAX, &nLocLen,
ODBC_INSTALL_COMPLETE, &nUsageCount ) )
- {
- doPrintInstallerError( __FILE__, __LINE__ );
- fprintf( stderr, "[%s][%d][ERROR] Failed to register driver\n", __FILE__,
__LINE__ );
- free( pszDriverInfo );
- return 0;
- }
- printf( "[%s][%d][INFO] Driver registered. Usage count is %d. Location \"%s\" \n",
__FILE__, __LINE__, (int)nUsageCount, szLoc );
- free( pszDriverInfo );
+/*
+ * Handler for "list data source" command (-s -l -n drivername)
+ */
+int list_datasource_details(DataSource *ds)
+{
+ int rc;
+ if ((rc= ds_lookup(ds)) < 0)
+ {
+ fprintf(stderr, "[ERROR] Data source not found '%s'\n",
+ ds_get_utf8attr(ds->name, &ds->name8));
return 1;
+ }
+ else if (rc > 0)
+ {
+ print_installer_error();
+ return 1;
+ }
+
+ /* print the data source fields */
+ printf("Name: %s\n", ds_get_utf8attr(ds->name,
&ds->name8));
+ if (ds->driver ) printf("Driver: %s\n",
ds_get_utf8attr(ds->driver, &ds->driver8));
+ if (ds->description) printf("Description: %s\n",
ds_get_utf8attr(ds->description, &ds->description8));
+ if (ds->server ) printf("Server: %s\n",
ds_get_utf8attr(ds->server, &ds->server8));
+ if (ds->uid ) printf("Uid: %s\n", ds_get_utf8attr(ds->uid,
&ds->uid8));
+ if (ds->pwd ) printf("Pwd: %s\n", ds_get_utf8attr(ds->pwd,
&ds->pwd8));
+ if (ds->database ) printf("Database: %s\n",
ds_get_utf8attr(ds->database, &ds->database8));
+ if (ds->socket ) printf("Socket: %s\n",
ds_get_utf8attr(ds->socket, &ds->socket8));
+ if (ds->initstmt ) printf("Initial statement: %s\n",
ds_get_utf8attr(ds->initstmt, &ds->initstmt8));
+ if (ds->initstmt ) printf("Option: %s\n",
ds_get_utf8attr(ds->option, &ds->option8));
+ if (ds->initstmt ) printf("Character set: %s\n",
ds_get_utf8attr(ds->charset, &ds->charset8));
+ if (ds->initstmt ) printf("SSL key: %s\n",
ds_get_utf8attr(ds->sslkey, &ds->sslkey8));
+ if (ds->initstmt ) printf("SSL cert: %s\n",
ds_get_utf8attr(ds->sslcert, &ds->sslcert8));
+ if (ds->initstmt ) printf("SSL CA: %s\n",
ds_get_utf8attr(ds->sslca, &ds->sslca8));
+ if (ds->initstmt ) printf("SSL CA path: %s\n",
ds_get_utf8attr(ds->sslcapath, &ds->sslcapath8));
+ if (ds->initstmt ) printf("SSL cipher: %s\n",
ds_get_utf8attr(ds->sslcipher, &ds->sslcipher8));
+ if (ds->port ) printf("Port: %d\n", ds->port);
+
+ return 0;
}
-int doAddDataSource()
+/*
+ * Handler for "list data sources" command (-s -l)
+ */
+int list_datasources()
{
- int bReturn = 1;
+ SQLHANDLE env;
+ SQLRETURN rc;
+ SQLUSMALLINT dir= 0; /* SQLDataSources fetch direction */
+ SQLCHAR name[256];
+ SQLCHAR description[256];
- switch ( cObjectSub )
- {
- case '\0':
- return doConfigDataSource( ODBC_ADD_DSN );
- case 'u':
- if ( !SQLSetConfigMode( (UWORD)ODBC_USER_DSN ) )
- {
- doPrintInstallerError( __FILE__, __LINE__ );
- fprintf( stderr, "[%s][%d][ERROR] Failed to set config mode.\n",
__FILE__, __LINE__ );
- return 0;
- }
- bReturn = doConfigDataSource( ODBC_ADD_DSN );
- SQLSetConfigMode( (UWORD)ODBC_BOTH_DSN );
- break;
- case 's':
- if ( !SQLSetConfigMode( (UWORD)ODBC_SYSTEM_DSN ) )
- {
- doPrintInstallerError( __FILE__, __LINE__ );
- fprintf( stderr, "[%s][%d][ERROR] Failed to set config mode.\n",
__FILE__, __LINE__ );
- return 0;
- }
- bReturn = doConfigDataSource( ODBC_ADD_DSN );
- SQLSetConfigMode( (UWORD)ODBC_BOTH_DSN );
- break;
- default:
- fprintf( stderr, "[%s][%d][ERROR] Missing or invalid object sub-type
specified.\n", __FILE__, __LINE__ );
- return 0;
- }
+ /* determine 'direction' to pass to SQLDataSources */
+ switch (scope)
+ {
+ case ODBC_BOTH_DSN:
+ dir= SQL_FETCH_FIRST;
+ break;
+ case ODBC_USER_DSN:
+ dir= SQL_FETCH_FIRST_USER;
+ break;
+ case ODBC_SYSTEM_DSN:
+ dir= SQL_FETCH_FIRST_SYSTEM;
+ break;
+ }
- return bReturn;
-}
+ /* allocate handle and set ODBC API v3 */
+ if ((rc= SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE,
+ &env)) != SQL_SUCCESS)
+ {
+ fprintf(stderr, "[ERROR] Failed to allocate env handle\n");
+ return 1;
+ }
-int doEdit()
-{
- switch ( cObject )
- {
- case 'd':
- return doEditDriver();
- case 's':
- return doEditDataSource();
- default:
- fprintf( stderr, "[%s][%d][ERROR] Missing or invalid object type
specified.\n", __FILE__, __LINE__ );
- return 0;
- }
-}
-
-int doEditDriver()
-{
+ if ((rc= SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3,
+ SQL_IS_INTEGER)) != SQL_SUCCESS)
+ {
+ print_odbc_error(env, SQL_HANDLE_ENV);
+ SQLFreeHandle(SQL_HANDLE_ENV, env);
return 1;
-}
+ }
-int doEditDataSource()
-{
- int bReturn = 1;
+ /* retrieve and print data source */
+ while ((rc= SQLDataSources(env, dir, name, 256, NULL, description,
+ 256, NULL)) == SQL_SUCCESS)
+ {
+ printf("%-20s - %s\n", name, description);
+ dir= SQL_FETCH_NEXT;
+ }
- switch ( cObjectSub )
- {
- case '\0':
- return doConfigDataSource( ODBC_CONFIG_DSN );
- case 'u':
- if ( !SQLSetConfigMode( ODBC_USER_DSN ) )
- {
- doPrintInstallerError( __FILE__, __LINE__ );
- fprintf( stderr, "[%s][%d][ERROR] Failed to set config mode.\n",
__FILE__, __LINE__ );
- return 0;
- }
- bReturn = doConfigDataSource( ODBC_CONFIG_DSN );
- SQLSetConfigMode( ODBC_BOTH_DSN );
- break;
- case 's':
- if ( !SQLSetConfigMode( ODBC_SYSTEM_DSN ) )
- {
- doPrintInstallerError( __FILE__, __LINE__ );
- fprintf( stderr, "[%s][%d][ERROR] Failed to set config mode.\n",
__FILE__, __LINE__ );
- return 0;
- }
- bReturn = doConfigDataSource( ODBC_CONFIG_DSN );
- SQLSetConfigMode( ODBC_BOTH_DSN );
- break;
- default:
- fprintf( stderr, "[%s][%d][ERROR] Invalid object sub-type specified.\n",
__FILE__, __LINE__ );
- return 0;
- }
+ if (rc != SQL_NO_DATA)
+ {
+ print_odbc_error(env, SQL_HANDLE_ENV);
+ SQLFreeHandle(SQL_HANDLE_ENV, env);
+ return 1;
+ }
- return bReturn;
-}
+ SQLFreeHandle(SQL_HANDLE_ENV, env);
-int doRemove()
-{
- switch ( cObject )
- {
- case 'd':
- return doRemoveDriver();
- case 's':
- return doRemoveDataSource();
- default:
- fprintf( stderr, "[%s][%d][ERROR] Missing or invalid object type
specified.\n", __FILE__, __LINE__ );
- return 0;
- }
+ return 0;
}
-/*!
- \brief Deregister the driver.
- Simply removes driver from the list of known ODBC
- drivers - does not remove any files.
-*/
-int doRemoveDriver()
+/*
+ * Handler for "add data source" command (-s -a -n drivername -t attrs)
+ */
+int add_datasource(DataSource *ds, const SQLWCHAR *attrs)
{
- DWORD nUsageCount;
- BOOL bRemoveDSNs = FALSE;
+ Driver *driver= NULL;
+ int rc= 1;
- if ( !pszName )
- {
- fprintf( stderr, "[%s][%d][ERROR] Please provide driver name.\n", __FILE__,
__LINE__ );
- return 0;
- }
+ /* read datasource object from attributes */
+ if (ds_from_kvpair(ds, attrs, ';'))
+ {
+ fprintf(stderr,
+ "[ERROR] Could not parse key-value pair attribute string\n");
+ goto end;
+ }
- if ( !SQLRemoveDriver( pszName, bRemoveDSNs, &nUsageCount ) )
- {
- doPrintInstallerError( __FILE__, __LINE__ );
- fprintf( stderr, "[%s][%d][ERROR] Failed to deregister driver.\n", __FILE__,
__LINE__ );
- return 0;
- }
+ /* validate */
+ if (!ds->driver)
+ {
+ fprintf(stderr, "[ERROR] Driver must be specified for a data source\n");
+ goto end;
+ }
- printf( "[%s][%d][INFO] Driver deregistered. Usage count is %d.\n", __FILE__,
__LINE__, (int)nUsageCount );
- return 1;
-}
+ /* Lookup driver filename and add to DataSource */
+ driver= driver_new();
+ memcpy(driver->name, ds->driver,
+ (sqlwcharlen(ds->driver) + 1) * sizeof(SQLWCHAR));
+ if (driver_lookup(driver))
+ {
+ fprintf(stderr, "[ERROR] Cannot locate driver\n");
+ goto end;
+ }
+ ds_set_strattr(&ds->driver, driver->lib);
-int doRemoveDataSource()
-{
- int bReturn = 1;
+ /* Add it */
+ if (ds_add(ds))
+ {
+ print_installer_error();
+ fprintf(stderr,
+ "[ERROR] Data source entry failed, remove or try again\n");
+ goto end;
+ }
- switch ( cObjectSub )
- {
- case '\0':
- bReturn = doRemoveDataSourceName();
- break;
- case 'u':
- if ( !SQLSetConfigMode( ODBC_USER_DSN ) )
- {
- doPrintInstallerError( __FILE__, __LINE__ );
- fprintf( stderr, "[%s][%d][ERROR] Failed to set config mode.\n",
__FILE__, __LINE__ );
- return 0;
- }
- bReturn = doRemoveDataSourceName();
- SQLSetConfigMode( ODBC_BOTH_DSN );
- case 's':
- if ( !SQLSetConfigMode( ODBC_SYSTEM_DSN ) )
- {
- doPrintInstallerError( __FILE__, __LINE__ );
- fprintf( stderr, "[%s][%d][ERROR] Failed to set config mode.\n",
__FILE__, __LINE__ );
- return 0;
- }
- bReturn = doRemoveDataSourceName();
- SQLSetConfigMode( ODBC_BOTH_DSN );
- default:
- fprintf( stderr, "[%s][%d][ERROR] Missing or invalid object sub-type
specified.\n", __FILE__, __LINE__ );
- return 0;
- }
+ printf("Success\n");
+ rc= 0;
- return bReturn;
+end:
+ x_free(driver);
+ return rc;
}
-/*!
- \brief Remove data source name from ODBC system information.
-*/
-int doRemoveDataSourceName()
+
+/*
+ * Handler for "remove data source" command (-s -r -n drivername)
+ */
+int remove_datasource(DataSource *ds)
{
- if ( SQLRemoveDSNFromIni( pszName ) == FALSE )
- {
- doPrintInstallerError( __FILE__, __LINE__ );
- fprintf( stderr, "[%s][%d][ERROR] Request failed.\n", __FILE__, __LINE__ );
- return 0;
- }
+ /*
+ First check that it exists, because SQLRemoveDSNFromIni
+ returns true, even if it doesn't.
+ */
+ if (ds_exists(ds->name))
+ {
+ fprintf(stderr, "[ERROR] Data source doesn't exist\n");
+ return 1;
+ }
+ if (SQLRemoveDSNFromIniW(ds->name) != TRUE)
+ {
+ print_installer_error();
return 1;
+ }
+
+ printf("Success\n");
+
+ return 0;
}
-#if defined(_DIRECT_)
-/*!
- \brief Call drivers ConfigDSN when we are linked directly to driver.
- \note This needs to be updated to reflect recent code changes.
-*/
-int doConfigDataSource( WORD nRequest )
+/*
+ * Handle driver actions. We setup a data source object to be used
+ * for all actions. Config/scope set+restore is wrapped around the
+ * action.
+ */
+int handle_datasource_action()
{
- char szAttributes[nDataSourceNameAttributesLength + strlen(pszDataSourceName) + 5];
+ int rc= 0;
+ UWORD config_mode= config_set(scope);
+ DataSource *ds= ds_new();
- sprintf( szAttributes, "DSN=%s", pszDataSourceName );
- memcpy( &(szAttributes[strlen(szAttributes) + 1]), pszDataSourceNameAttributes,
nDataSourceNameAttributesLength );
- if ( !ConfigDSN( (HWND)bGUI /* fake window handle */, nRequest, pszDriverName,
szAttributes ) )
+ /* check name is given if needed */
+ switch (action)
+ {
+ case ACTION_ADD:
+ case ACTION_REMOVE:
+ if (!name)
{
- doPrintInstallerError( __FILE__, __LINE__ );
- return 0;
+ fprintf(stderr, "[ERROR] Name missing to add/remove data source\n");
+ rc= 1;
+ goto end;
}
+ }
- return 1;
-}
-#else
-/*!
- \brief Call drivers ConfigDSN without going through the DM.
-*/
-int doConfigDataSource( WORD nRequest )
-{
- int bReturn = FALSE;
- MYODBCUTIL_DRIVER * pDriver = MYODBCUtilAllocDriver();
- MYODBCUTIL_DATASOURCE * pDataSourceGiven = MYODBCUtilAllocDataSource(
MYODBCUTIL_DATASOURCE_MODE_DSN_VIEW );
- MYODBCUTIL_DATASOURCE * pDataSource = MYODBCUtilAllocDataSource(
MYODBCUTIL_DATASOURCE_MODE_DSN_VIEW );
- ConfigDSNFunctor pFunc;
-#if defined(WIN32)
- HINSTANCE hLib = 0;
-#else
- void * hLib = 0;
- void * hLibDrv = 0;
-#endif
- char szDriver[1024];
- char szAttributes[1024];
-
- /* sanity check */
- if ( !pszAttributes )
- {
- fprintf( stderr, "[%s][%d][ERROR] Please provide an attributes string.\n",
__FILE__, __LINE__ );
- goto doConfigDataSourceExit2;
- }
+ /* set name if given */
+ if (name)
+ ds_set_strattr(&ds->name, wname);
- /* parse given attribute string */
- if ( !MYODBCUtilReadDataSourceStr( pDataSourceGiven, MYODBCUTIL_DELIM_SEMI,
pszAttributes ) )
+ /* perform given action */
+ switch (action)
+ {
+ case ACTION_LIST:
+ if (name)
+ rc= list_datasource_details(ds);
+ else
+ rc= list_datasources();
+ break;
+ case ACTION_ADD:
+ if (scope == ODBC_BOTH_DSN)
{
- fprintf( stderr, "[%s][%d][ERROR] Malformed attribute string (%s)\n", __FILE__,
__LINE__, pszAttributes );
- goto doConfigDataSourceExit2;
+ fprintf(stderr, "[ERROR] Adding data source must be either "
+ "user or system scope (not both)\n");
+ rc= 1;
}
-
- /* check that we have min attributes for request */
- if ( nRequest == ODBC_ADD_DSN )
+ else if (!attrstr)
{
- if ( pDataSourceGiven->pszDRIVER )
- {
- /* pull driver from attributes as we can not have it in there for ConfigDSN()
*/
- sprintf( szDriver, "%s", pDataSourceGiven->pszDRIVER );
- _global_free( pDataSourceGiven->pszDRIVER );
- pDataSourceGiven->pszDRIVER = NULL;
- }
- else
- {
- fprintf( stderr, "[%s][%d][WARNING] DRIVER attribute not provided - using
%s.\n", __FILE__, __LINE__, MYODBCINST_DRIVER_NAME );
- sprintf( szDriver, "%s", MYODBCINST_DRIVER_NAME );
- }
+ fprintf(stderr, "[ERROR] Attribute string missing to add data source\n");
+ rc= 1;
}
else
{
- if ( !pDataSourceGiven->pszDSN )
- {
- fprintf( stderr, "[%s][%d][ERROR] Please provide DSN attribute.\n", __FILE__,
__LINE__ );
- goto doConfigDataSourceExit2;
- }
-
- /* get driver name for given dsn */
- if ( !MYODBCUtilReadDataSource( pDataSource, pDataSourceGiven->pszDSN ) )
- {
- fprintf( stderr, "[%s][%d][ERROR] Could not load data source name info
(%s)\n", __FILE__, __LINE__, pDataSourceGiven->pszDSN );
- goto doConfigDataSourceExit2;
- }
-
- sprintf( szDriver, "%s", pDataSource->pszDRIVER );
+ rc= add_datasource(ds, wattrs);
}
+ break;
+ case ACTION_REMOVE:
+ rc= remove_datasource(ds);
+ break;
+ }
- /* get setup library name */
- if ( !MYODBCUtilReadDriver( pDriver, szDriver, NULL ) )
- {
- fprintf( stderr, "[%s][%d][ERROR] Could not load driver info (%s)\n", __FILE__,
__LINE__, szDriver );
- goto doConfigDataSourceExit2;
- }
+end:
+ ds_delete(ds);
+ config_set(config_mode);
+ return rc;
+}
- /* create a NULL delimited set of attributes for ConfigDSN() call */
- MYODBCUtilWriteDataSourceStr( pDataSourceGiven, MYODBCUTIL_DELIM_NULL, szAttributes,
sizeof(szAttributes) - 1 );
-#if defined(WIN32)
- /* load it */
- hLib = LoadLibrary( pDriver->pszSETUP );
- if ( !hLib )
- {
- doPrintLastErrorString();
- fprintf( stderr, "[%s][%d][ERROR] Could not load driver setup library (%s).\n",
__FILE__, __LINE__, pDriver->pszSETUP );
- goto doConfigDataSourceExit2;
- }
+/*
+ * Entry point, parse args and do first set of validation.
+ */
+int main(int argc, char **argv)
+{
+ char *arg;
+ int i;
+ SQLINTEGER convlen;
- /* lookup ConfigDSN */
- pFunc = (ConfigDSNFunctor) GetProcAddress( hLib, "ConfigDSN" );
- if ( !pFunc )
- {
- doPrintLastErrorString();
- fprintf( stderr, "[%s][%d][ERROR] Could not find ConfigDSN in (%s).\n", __FILE__,
__LINE__, pDriver->pszSETUP );
- goto doConfigDataSourceExit1;
- }
-#else
- /* load it */
- lt_dlinit();
+ /* minimum number of args to do anything useful */
+ if (argc < 3)
+ {
+ fprintf(stderr, "[ERROR] Not enough arguments given\n");
+ main_usage();
+ return 1;
+ }
- if ( !(hLibDrv = lt_dlopen( pDriver->pszDRIVER )) )
- {
- fprintf( stderr, "[%s][%d][ERROR] Could not load driver library (%s). Error is
%s\n", __FILE__, __LINE__, pDriver->pszDRIVER, lt_dlerror() );
- goto doConfigDataSourceExit2;
- }
+ /* parse args */
+ for(i= 1; i < argc; ++i)
+ {
+ arg= argv[i];
+ if (*arg == '-')
+ arg++;
- if ( !(hLib = lt_dlopen( pDriver->pszSETUP )) )
+ /* we should be left with a single character option (except scope)
+ * all strings are skipped by the respective option below */
+ if (*arg != OPT_SCOPE && *(arg + 1))
{
- fprintf( stderr, "[%s][%d][ERROR] Could not load driver setup library (%s). Error
is %s\n", __FILE__, __LINE__, pDriver->pszSETUP, lt_dlerror() );
- goto doConfigDataSourceExit2;
+ fprintf(stderr, "[ERROR] Invalid command line option: %s\n", arg);
+ return 1;
}
- /* lookup ConfigDSN */
- pFunc = (ConfigDSNFunctor) lt_dlsym( hLib, "ConfigDSN" );
- if ( !pFunc )
+ switch (*arg)
{
- fprintf( stderr, "[%s][%d][ERROR] Could not find ConfigDSN in (%s). Error is
%s\n", __FILE__, __LINE__, pDriver->pszSETUP, lt_dlerror() );
- goto doConfigDataSourceExit1;
+ case OBJ_DRIVER:
+ case OBJ_DATASOURCE:
+ /* make sure we haven't already assigned the object */
+ if (obj)
+ {
+ object_usage();
+ return 1;
+ }
+ obj= *arg;
+ break;
+ case ACTION_LIST:
+ case ACTION_ADD:
+ case ACTION_REMOVE:
+ if (action)
+ {
+ action_usage();
+ return 1;
+ }
+ action= *arg;
+ break;
+ case OPT_NAME:
+ if (i + 1 == argc || *argv[i + 1] == '-')
+ {
+ fprintf(stderr, "[ERROR] Missing name\n");
+ return 1;
+ }
+ name= argv[++i];
+ break;
+ case OPT_ATTR:
+ if (i + 1 == argc || *argv[i + 1] == '-')
+ {
+ fprintf(stderr, "[ERROR] Missing attribute string\n");
+ return 1;
+ }
+ attrstr= argv[++i];
+ break;
+ case OPT_SCOPE:
+ /* convert to integer */
+ scope= *(++arg) - '0';
+ if (scope < 0 || scope > 2 || *(arg + 1) /* another char exists */)
+ {
+ fprintf(stderr, "[ERROR] Invalid scope: %s\n", arg);
+ return 1;
+ }
+ break;
+ case 'h':
+ /* print usage if -h is given anywhere */
+ main_usage();
+ return 1;
+ default:
+ fprintf(stderr, "[ERROR] Invalid command line option: %s\n", arg);
+ return 1;
}
-#endif
+ }
- /* make call */
- /*!
- \note
+ if (!action)
+ {
+ action_usage();
+ return 1;
+ }
- A fake window handle seems to work for platforms other than Mac OS X :) It will
not be
- used as a window handle - just as a flag to get the GUI.
- */
- if ( !pFunc( (HWND)nWnd /* fake window handle */, nRequest, szDriver, szAttributes )
)
- {
- doPrintInstallerError( __FILE__, __LINE__ );
- goto doConfigDataSourceExit1;
- }
+ /* init libmysqlclient */
+ my_init();
+ utf8_charset_info= get_charset_by_csname("utf8", MYF(MY_CS_PRIMARY),
+ MYF(0));
- bReturn = 1;
+ /* convert to SQLWCHAR for installer API */
+ convlen= SQL_NTS;
+ if (name && !(wname= sqlchar_as_sqlwchar(default_charset_info,
+ name, &convlen, NULL)))
+ {
+ fprintf(stderr, "[ERROR] Name is invalid\n");
+ return 1;
+ }
-doConfigDataSourceExit1:
-#if defined(WIN32)
- FreeLibrary( hLib );
-#else
- lt_dlclose( hLibDrv );
- lt_dlclose( hLib );
-#endif
+ convlen= SQL_NTS;
+ if (attrstr && !(wattrs= sqlchar_as_sqlwchar(default_charset_info,
+ attrstr, &convlen, NULL)))
+ {
+ fprintf(stderr, "[ERROR] Attribute string is invalid\n");
+ return 1;
+ }
-doConfigDataSourceExit2:
- MYODBCUtilFreeDataSource( pDataSource );
- MYODBCUtilFreeDataSource( pDataSourceGiven );
- MYODBCUtilFreeDriver( pDriver );
-
- return bReturn;
+ /* handle appropriate action */
+ switch (obj)
+ {
+ case OBJ_DRIVER:
+ return handle_driver_action();
+ case OBJ_DATASOURCE:
+ return handle_datasource_action();
+ default:
+ object_usage();
+ return 1;
+ }
}
-#endif
Modified: branches/guffert/scripts/macosx/postflight
===================================================================
--- branches/guffert/scripts/macosx/postflight 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/scripts/macosx/postflight 2007-11-19 21:10:00 UTC (rev 877)
@@ -74,10 +74,10 @@
# REGISTER THE DRIVER
# ----------------------------------------------------------------------
echo "Registring driver..."
-$bindir/myodbc3i -a -ds -t"MySQL ODBC 5.1
Driver;Driver=$libdir/libmyodbc5.so;Setup=$libdir/libmyodbc3S.so;" -w0
+$bindir/myodbc-installer -a -d -n "MySQL ODBC 5.1 Driver" -t
"Driver=$libdir/libmyodbc5.so;Setup=$libdir/libmyodbc3S.so;"
# ----------------------------------------------------------------------
# CREATE A SAMPLE DSN
# ----------------------------------------------------------------------
echo "Ensuring sample data source name (myodbc) exists..."
-$bindir/myodbc3i -a -s -t"DSN=myodbc;Driver=MySQL ODBC 5.1 Driver;SERVER=localhost;" -w0
+$bindir/myodbc-installer -a -s -t "DSN=myodbc;Driver=MySQL ODBC 5.1
Driver;SERVER=localhost;"
Modified: branches/guffert/scripts/myodbc3.spec.sh
===================================================================
--- branches/guffert/scripts/myodbc3.spec.sh 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/scripts/myodbc3.spec.sh 2007-11-19 21:10:00 UTC (rev 877)
@@ -132,11 +132,11 @@
# ----------------------------------------------------------------------
%post
-myodbc3i -a -d -t"MySQL ODBC 5.1 Driver;DRIVER=%{_libdir}/libmyodbc5.so"
+myodbc-installer -a -d -n "MySQL ODBC 5.1 Driver" -t "DRIVER=%{_libdir}/libmyodbc5.so"
%post setup
-myodbc3i -r -d -n"MySQL ODBC 5.1 Driver"
-myodbc3i -a -d -t"MySQL ODBC 5.1
Driver;DRIVER=%{_libdir}/libmyodbc5.so;SETUP=%{_libdir}/libmyodbc3S.so"
+myodbc-installer -r -d -n "MySQL ODBC 5.1 Driver"
+myodbc-installer -a -d -n "MySQL ODBC 5.1 Driver" -t
"DRIVER=%{_libdir}/libmyodbc5.so;SETUP=%{_libdir}/libmyodbc3S.so"
# ----------------------------------------------------------------------
# DEREGISTER DRIVER
@@ -144,12 +144,12 @@
# Removing the driver package, we simply orphan any related DSNs
%preun
-myodbc3i -r -d -n"MySQL ODBC 5.1 Driver"
+myodbc-installer -r -d -n "MySQL ODBC 5.1 Driver"
# Removing the setup RPM, downgrade the registration
%preun setup
-myodbc3i -r -d -n"MySQL ODBC 5.1 Driver"
-myodbc3i -a -d -t"MySQL ODBC 5.1 Driver;DRIVER=%{_libdir}/libmyodbc5.so"
+myodbc-installer -r -d -n "MySQL ODBC 5.1 Driver"
+myodbc-installer -a -d -n "MySQL ODBC 5.1 Driver" -t "DRIVER=%{_libdir}/libmyodbc5.so"
##############################################################################
#
@@ -159,7 +159,7 @@
%files
%defattr(-,root,root)
-%{_bindir}/myodbc3i
+%{_bindir}/myodbc-installer
%{_bindir}/myodbc3m
%{_libdir}/libmyodbc5.*
%{_libdir}/libmyodbc5-*
Modified: branches/guffert/util/CMakeLists.txt
===================================================================
--- branches/guffert/util/CMakeLists.txt 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/util/CMakeLists.txt 2007-11-19 21:10:00 UTC (rev 877)
@@ -26,7 +26,7 @@
installer.c
installer.h)
-#IF(USE_LEGACY_ODBC_GUI)
+IF(USE_LEGACY_ODBC_GUI)
SET(myodbc3u_SRCS ${myodbc3u_SRCS}
MYODBCUtilAllocDataSource.c
MYODBCUtilAllocDriver.c
@@ -48,7 +48,7 @@
MYODBCUtilWriteDataSource.c
MYODBCUtilWriteDataSourceStr.c
MYODBCUtilWriteDriver.c)
-#ENDIF(USE_LEGACY_ODBC_GUI)
+ENDIF(USE_LEGACY_ODBC_GUI)
ADD_LIBRARY(myodbc3u STATIC ${myodbc3u_SRCS})
Modified: branches/guffert/util/installer.c
===================================================================
--- branches/guffert/util/installer.c 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/util/installer.c 2007-11-19 21:10:00 UTC (rev 877)
@@ -23,11 +23,13 @@
/*
* Installer wrapper implementations.
*
- * How to add a data-source option:
+ * How to add a data-source parameter:
* Search for DS_PARAM, and follow the code around it
* Add an extra field to the DataSource struct (installer.h)
* Add a default value in ds_new()
* Initialize/destroy them in ds_new/ds_delete
+ * Print the field in myodbc3i.c
+ * Add to the configuration GUIs
*
*/
#include "stringutil.h"
@@ -362,19 +364,18 @@
*/
int driver_to_kvpair_null(Driver *driver, SQLWCHAR *attrs, size_t attrslen)
{
+ *attrs= 0;
attrs+= sqlwcharncat2(attrs, driver->name, &attrslen);
/* append NULL-separator */
- *(attrs++)= 0;
- attrslen--;
+ APPEND_SQLWCHAR(attrs, attrslen, 0);
attrs+= sqlwcharncat2(attrs, W_DRIVER, &attrslen);
APPEND_SQLWCHAR(attrs, attrslen, '=');
attrs+= sqlwcharncat2(attrs, driver->lib, &attrslen);
/* append NULL-separator */
- *(attrs++)= 0;
- attrslen--;
+ APPEND_SQLWCHAR(attrs, attrslen, 0);
if (*driver->setup_lib)
{
@@ -383,8 +384,7 @@
attrs+= sqlwcharncat2(attrs, driver->setup_lib, &attrslen);
/* append NULL-separator */
- *(attrs++)= 0;
- attrslen--;
+ APPEND_SQLWCHAR(attrs, attrslen, 0);
}
if (attrslen--)
*attrs= 0;
Modified: branches/guffert/util/stringutil.c
===================================================================
--- branches/guffert/util/stringutil.c 2007-11-19 07:41:29 UTC (rev 876)
+++ branches/guffert/util/stringutil.c 2007-11-19 21:10:00 UTC (rev 877)
@@ -462,7 +462,8 @@
*used_bytes+= from_cnvres;
*used_chars+= 1;
}
- *errors+= error_count;
+ if (errors)
+ *errors+= error_count;
return (uint32) (to - to_start);
}
| Thread |
|---|
| • Connector/ODBC 3.51 commit: r877 - in branches/guffert: . installer scripts scripts/macosx util | jbalint | 19 Nov |