Added:
trunk/MYODBCSetup/MYODBCSetupLib/ConfigDSNW.c
Removed:
trunk/MYODBCSetup/MYODBCSetupLib/ConfigDSN.c
Modified:
trunk/MYODBCC/MYODBCCLib/MYODBCC.cpp
trunk/MYODBCC/include/MYODBCC.h
trunk/MYODBCIns/include/MYODBCIns.h
trunk/MYODBCSetup/MYODBCSetupLib/MYODBCSetupLib.pro
trunk/MYODBCSetup/MYODBCSetupLib/MYODBCSetupLib.vpj
Log:
Modified: trunk/MYODBCC/MYODBCCLib/MYODBCC.cpp
===================================================================
--- trunk/MYODBCC/MYODBCCLib/MYODBCC.cpp 2006-06-19 04:52:15 UTC (rev 351)
+++ trunk/MYODBCC/MYODBCCLib/MYODBCC.cpp 2006-06-19 18:57:16 UTC (rev 352)
@@ -50,6 +50,15 @@
}
#endif
+int MYODBCC::getKeywordValuesLength( LPCWSTR pszzKeywordValues )
+{
+ WCHAR *pc = pszzKeywordValues;
+
+ for ( ; pc[0] || pc[1]; pc++ ) {}
+
+ return (pc - pszzKeywordValues);
+}
+
QString MYODBCC::getConnectAttrString( SQLINTEGER nAttribute )
{
switch ( nAttribute )
Modified: trunk/MYODBCC/include/MYODBCC.h
===================================================================
--- trunk/MYODBCC/include/MYODBCC.h 2006-06-19 04:52:15 UTC (rev 351)
+++ trunk/MYODBCC/include/MYODBCC.h 2006-06-19 18:57:16 UTC (rev 352)
@@ -146,6 +146,8 @@
*/
static size_t getStrLen( const SQLWCHAR *psz, size_t nMaxChars );
+ static int getKeywordValuesLength( LPCWSTR pszKeywordValues );
+
/*!
\name Get string version of a numeric "#define"
Modified: trunk/MYODBCIns/include/MYODBCIns.h
===================================================================
--- trunk/MYODBCIns/include/MYODBCIns.h 2006-06-19 04:52:15 UTC (rev 351)
+++ trunk/MYODBCIns/include/MYODBCIns.h 2006-06-19 18:57:16 UTC (rev 352)
@@ -136,8 +136,6 @@
*/
static BOOLEAN MYODBCIns::getKeywordValues( QHash<QString,QString>
*phashKeywordValues, const QString &stringKeywordValues, DELIM nDelim = DELIM_BOTH );
- static BOOLEAN MYODBCIns::getKeywordValues( QHash<QString,QString>
*phashKeywordValues, const QString &stringKeywordValues, DELIM nDelim = DELIM_BOTH );
-
/*!
\brief Get the error stored at location nError.
Deleted: trunk/MYODBCSetup/MYODBCSetupLib/ConfigDSN.c
===================================================================
--- trunk/MYODBCSetup/MYODBCSetupLib/ConfigDSN.c 2006-06-19 04:52:15 UTC (rev 351)
+++ trunk/MYODBCSetup/MYODBCSetupLib/ConfigDSN.c 2006-06-19 18:57:16 UTC (rev 352)
@@ -1,117 +0,0 @@
-#include "MYODBCSetup.h"
-
-/*!
- \brief Add, edit, or remove a Data Source Name (DSN).
-
- This function should be called from the ODBC Administrator
- program when our driver is being used during a request to
- add, edit or remove a DSN. This allows us to do driver
- specific stuff such as use our dialogs to work with our
- driver.
-
- This function is also a viable entry point and a public API
- for use by special function code such as an installer or an
- application which has embedded the driver functionality.
-
- \param hWnd Window handle to use as the parent window for any dialogs
this function may
- invoke to support the request.
- \param nRequest The type of request;
- - ODBC_ADD_DSN
- - ODBC_CONFIG_DSN
- - ODBC_REMOVE_DSN
- \param pszDriver Friendly driver name such as "MySQL Connector/ODBC v5".
- \param pszAttributes A list of key-value (KEY=VALUE) pairs where each key-value
pair is delimited by a
- null (including the last one) and the entire list is
terminated by a null (so list
- ends with 2 nulls).
-
- \return BOOL
-
- \retval TRUE Request succeeded.
- \retval FALSE Request failed for some reason - caller can use
SQLInstallerError() to get details.
-*/
-BOOL INSTAPI ConfigDSNW( HWND hWnd, WORD nRequest, LPCWSTR pszDriver, LPCWSTR
pszAttributes )
-{
-
- MYODBCInsDataSource datasource();
-
-
- QHash<QString,QString> hashKeywordValues;
-
- if ( !MYODBCIns::getKeywordValues( &hashKeywordValues, pszAttributes,
MYODBCIns::DELIM_BOTH ) )
- MYODBCDbgReturn3( "%d", false );
-
- datasource.setAttributes( MYODBCIns::getKeywordValues(
-
-++++++++++++++
- MYODBCUTIL_DATASOURCE * pDataSource = MYODBCUtilAllocDataSource(
MYODBCUTIL_DATASOURCE_MODE_DSN_VIEW );
- BOOL bReturn = FALSE;
-
- /*
- \note unixODBC
-
- In some cases on unixODBC a semi-colon will be used
- to indicate the end of name/value pair. This is like
- in SQLDriverConnect(). This is incorrect but we try
- to simply ignore semi-colon and hope rest of format
- is ok.
-
- So we should call this with MYODBCUTIL_DELIM_NULL but we use
- MYODBCUTIL_DELIM_BOTH instead.
-
- This was tested with pszAttributes "DSN=test;".
- */
- if ( !MYODBCUtilReadDataSourceStr( pDataSource, MYODBCUTIL_DELIM_BOTH, pszAttributes
) )
- {
- SQLPostInstallerError( ODBC_ERROR_INVALID_KEYWORD_VALUE, "Data Source string
seems invalid." );
- goto exitConfigDSN;
- }
-
- /*!
- ODBC RULE
-
- DRIVER is not a valid attribute for ConfigDSN().
- Also; ConfigDSN may not delete or change the value of the Driver keyword...
- when ODBC_CONFIG_DSN.
- */
- if ( pDataSource->pszDRIVER )
- {
- SQLPostInstallerError( ODBC_ERROR_INVALID_KEYWORD_VALUE, "DRIVER is an invalid
attribute." );
- goto exitConfigDSN;
- }
-
- /*!
- ODBC RULE
-
- Driver description (usually the name of the associated DBMS) presented to users
- instead of the physical driver name.
- */
- if ( !pszDriver || !(*pszDriver) )
- {
- SQLPostInstallerError( ODBC_ERROR_INVALID_KEYWORD_VALUE, "Need driver name." );
- goto exitConfigDSN;
- }
-
- pDataSource->pszDRIVER = (char *)strdup( pszDriver );
-
- switch ( nRequest )
- {
- case ODBC_ADD_DSN:
- bReturn = MYODBCSetupConfigDSNAdd( hWnd, pDataSource );
- break;
- case ODBC_CONFIG_DSN:
- bReturn = MYODBCSetupConfigDSNEdit( hWnd, pDataSource );
- break;
- case ODBC_REMOVE_DSN:
- bReturn = MYODBCSetupConfigDSNRemove( pDataSource );
- break;
- default:
- SQLPostInstallerError( ODBC_ERROR_INVALID_REQUEST_TYPE, "Invalid request." );
- }
-
-exitConfigDSN:
- MYODBCUtilFreeDataSource( pDataSource );
- return bReturn;
-}
-
-
-
Copied: trunk/MYODBCSetup/MYODBCSetupLib/ConfigDSNW.c (from rev 351,
trunk/MYODBCSetup/MYODBCSetupLib/ConfigDSN.c)
===================================================================
--- trunk/MYODBCSetup/MYODBCSetupLib/ConfigDSN.c 2006-06-19 04:52:15 UTC (rev 351)
+++ trunk/MYODBCSetup/MYODBCSetupLib/ConfigDSNW.c 2006-06-19 18:57:16 UTC (rev 352)
@@ -0,0 +1,108 @@
+#include "MYODBCSetup.h"
+
+/*!
+ \brief Add, edit, or remove a Data Source Name (DSN).
+
+ This function should be called from the ODBC Administrator
+ program when our driver is being used during a request to
+ add, edit or remove a DSN. This allows us to do driver
+ specific stuff such as use our dialogs to work with our
+ driver.
+
+ This function is also a viable entry point and a public API
+ for use by special function code such as an installer or an
+ application which has embedded the driver functionality.
+
+ \param hWnd Window handle to use as the parent window for any dialogs
this function may
+ invoke to support the request.
+ \param nRequest The type of request;
+ - ODBC_ADD_DSN
+ - ODBC_CONFIG_DSN
+ - ODBC_REMOVE_DSN
+ \param pszDriver Friendly driver name such as "MySQL Connector/ODBC v5".
+ \param pszAttributes A list of key-value (KEY=VALUE) pairs where each key-value
pair is delimited by a
+ null (including the last one) and the entire list is
terminated by a null (so list
+ ends with 2 nulls).
+
+ \return BOOL
+
+ \retval TRUE Request succeeded.
+ \retval FALSE Request failed for some reason - caller can use
SQLInstallerError() to get details.
+*/
+BOOL INSTAPI ConfigDSNW( HWND hWnd, WORD nRequest, LPCWSTR pszDriver, LPCWSTR
pszzAttributes )
+{
+ MYODBCDbgEnter();
+
+ /*!
+ \internal ODBC RULE
+
+ ConfigDSN receives connection information from the installer DLL as a list of
+ attributes in the form of keyword-value pairs. Each pair is terminated with a
+ null byte, and the entire list is terminated with a null byte.
+ */
+ QHash<QString,QString> hashKeywordValues;
+ if ( !MYODBCIns::getKeywordValues( &hashKeywordValues, QString::fromUtf16(
pszzAttributes, MYODBCC::getKeywordValuesLength( pszAttributes ) + 1 ),
MYODBCIns::DELIM_NULL ) )
+ {
+ MYODBCIns::setError( "Data Source string seems invalid.",
ODBC_ERROR_INVALID_KEYWORD_VALUE );
+ MYODBCDbgReturn3( "%d", false );
+ }
+
+ /*!
+ \internal ODBC RULE
+
+ DRIVER is not a valid attribute for ConfigDSN().
+ Also; ConfigDSN may not delete or change the value of the Driver keyword...
+ when ODBC_CONFIG_DSN.
+ */
+ if ( hashKeywordValues.contains( "DRIVER" ) )
+ {
+ MYODBCIns::setError( "DRIVER is an invalid attribute.",
ODBC_ERROR_INVALID_KEYWORD_VALUE );
+ MYODBCDbgReturn3( "%d", false );
+ }
+
+ /* get keyword-values into our datasource object */
+ MYODBCInsDataSource datasource();
+ datasource.setScope( MYODBCInsDataSource::DATASOURCE_SCOPE_BOTH );
+ if ( !datasource.setAttributes( &hashKeywordValues ) )
+ MYODBCDbgReturn3( "%d", false );
+
+ datasource.setDRIVER( QString::fromUtf16( pszDriver ) );
+
+ /*!
+ ODBC RULE
+
+ Driver description (usually the name of the associated DBMS) presented to users
+ instead of the physical driver name.
+ */
+ if ( datasource.getDRIVER().isEmpty() )
+ {
+ SQLPostInstallerError( ODBC_ERROR_INVALID_KEYWORD_VALUE, "Need driver name." );
+ MYODBCDbgReturn3( "%d", false );
+ }
+
+ /* process request */
+ switch ( nRequest )
+ {
+ case ODBC_ADD_DSN:
+ datasource.setMode( MYODBCInsDataSource::DATASOURCE_MODE_DSN_ADD );
+ /* bReturn = MYODBCSetupConfigDSNAdd( hWnd, pDataSource ); */
+ break;
+ case ODBC_CONFIG_DSN:
+ datasource.setMode( MYODBCInsDataSource::DATASOURCE_MODE_DSN_EDIT );
+ /* bReturn = MYODBCSetupConfigDSNEdit( hWnd, pDataSource ); */
+ break;
+ case ODBC_REMOVE_DSN:
+
+ datasource.setMode( MYODBCInsDataSource::DATASOURCE_MODE_DSN_EDIT );
+ /* bReturn = MYODBCSetupConfigDSNRemove( pDataSource ); */
+ break;
+ default:
+ MYODBCIns::setError( "Invalid request.", ODBC_ERROR_INVALID_REQUEST_TYPE );
+ MYODBCDbgReturn3( "%d", false );
+ }
+
+ MYODBCDbgReturn3( "%d", true );
+}
+
+
+
Modified: trunk/MYODBCSetup/MYODBCSetupLib/MYODBCSetupLib.pro
===================================================================
--- trunk/MYODBCSetup/MYODBCSetupLib/MYODBCSetupLib.pro 2006-06-19 04:52:15 UTC (rev 351)
+++ trunk/MYODBCSetup/MYODBCSetupLib/MYODBCSetupLib.pro 2006-06-19 18:57:16 UTC (rev 352)
@@ -43,7 +43,7 @@
MYODBCSetup.h
# MYODBCSetupDataSourceDialog.h
SOURCES = \
- ConfigDSN.c
+ ConfigDSNW.c
# MYODBCSetupConfigDSNAdd.c \
# MYODBCSetupConfigDSNEdit.c \
# MYODBCSetupConfigDSNRemove.c \
Modified: trunk/MYODBCSetup/MYODBCSetupLib/MYODBCSetupLib.vpj
===================================================================
--- trunk/MYODBCSetup/MYODBCSetupLib/MYODBCSetupLib.vpj 2006-06-19 04:52:15 UTC (rev 351)
+++ trunk/MYODBCSetup/MYODBCSetupLib/MYODBCSetupLib.vpj 2006-06-19 18:57:16 UTC (rev 352)
@@ -184,6 +184,7 @@
<Folder
Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl">
+ <F N="ConfigDSNW.c"/>
<F N="MYODBCSetup.rc"/>
<F N="MYODBCSetupConfigDSNAdd.c"/>
<F N="MYODBCSetupConfigDSNEdit.c"/>
| Thread |
|---|
| • Connector/ODBC 5 commit: r352 - in trunk: MYODBCC/MYODBCCLib MYODBCC/include MYODBCIns/include MYODBCSetup/MYODBCSetupLib | pharvey | 19 Jun |