List:Commits« Previous MessageNext Message »
From:pharvey Date:December 29 2005 4:08am
Subject:Connector/ODBC 5 commit: r20 - / MYODBCC/include MYODBCDbg/MYODBCDbgTest MYODBCDbg/include MYODBCIns/MYODBCInsLib MYODBCIns/MYODBCInsTest MYODBCIns/in...
View as plain text  
Modified:
   MYODBCC/include/MYODBCC.h
   MYODBCDbg/MYODBCDbgTest/MYODBCDbgTest.cpp
   MYODBCDbg/include/MYODBCDbg.h
   MYODBCIns/MYODBCInsLib/MYODBCIns.cpp
   MYODBCIns/MYODBCInsLib/MYODBCInsDataSource.cpp
   MYODBCIns/MYODBCInsLib/MYODBCInsDriver.cpp
   MYODBCIns/MYODBCInsLib/MYODBCInsDriverConnect.cpp
   MYODBCIns/MYODBCInsTest/MYODBCInsTest.cpp
   MYODBCIns/include/MYODBCIns.h
   MYODBCIns/include/MYODBCInsDriver.h
   root.pro
Log:
UNICODE:
- more improvements to MYODBCDbg to make handling unicode better
- a few more enhancements to MYODBCIns including better post-build testing
- next; MYODBCDia (objectify and make unicode enabled)

Modified: MYODBCC/include/MYODBCC.h
===================================================================
--- MYODBCC/include/MYODBCC.h	2005-12-28 07:30:09 UTC (rev 19)
+++ MYODBCC/include/MYODBCC.h	2005-12-29 04:08:17 UTC (rev 20)
@@ -460,7 +460,7 @@
 */
 #define MYODBCCAssert(a1)\
 {\
-    MYODBCCfprintf( stderr, L"[ASSERT][%s][%d] %s\n", __FILE__, __LINE__, a1 );\
+    MYODBCCfprintf( stderr, _T"[ASSERT][%s][%d] %s\n", TEXT(__FILE__), __LINE__, a1 );\
     exit( 1 );\
 }
 
@@ -481,13 +481,13 @@
                   (LPTSTR)&pszError,\
                   0,\
                   NULL );\
-    MYODBCCfprintf( stderr, L"[%s][%d] %d: %s\n", __FILE__, __LINE__, nError, pszError
);\
+    MYODBCCfprintf( stderr, _T"[%s][%d] %d: %s\n", TEXT(__FILE__), __LINE__, nError,
pszError );\
     LocalFree( pszError );\
 }
 #else
 #define MYODBCCPrintLastError()\
 {\
-    MYODBCCfprintf( stderr, L"[%s][%d] %d: %s\n", __FILE__, __LINE__, xxxx, xxxx );\
+    MYODBCCfprintf( stderr, _T"[%s][%d] %d: %s\n", TEXT(__FILE__), __LINE__, xxxx, xxxx
);\
 }
 #endif
 

Modified: MYODBCDbg/MYODBCDbgTest/MYODBCDbgTest.cpp
===================================================================
--- MYODBCDbg/MYODBCDbgTest/MYODBCDbgTest.cpp	2005-12-28 07:30:09 UTC (rev 19)
+++ MYODBCDbg/MYODBCDbgTest/MYODBCDbgTest.cpp	2005-12-29 04:08:17 UTC (rev 20)
@@ -58,11 +58,11 @@
 
     MYODBCDbgEnter();
 
-    MYODBCDbgPrint( "" );
-    MYODBCDbgPrint( "Got here" );
-    MYODBCDbgPrint2( "gpMYODBCDbg = %d", n )
-    MYODBCDbgError( "Ooops" );
-    MYODBCDbgWarning( "That smarts");
+    MYODBCDbgInfo( "", "" );
+    MYODBCDbgInfo( "Got here", "" );
+    MYODBCDbgInfo( "gpMYODBCDbg = %1", n )
+    MYODBCDbgError( "Ooops", "" );
+    MYODBCDbgWarning( "That smarts", "" );
 
     MYODBCDbgReturn( SQL_SUCCESS );
 }
@@ -88,8 +88,8 @@
     int n;
     int nReturn = 0;
 
-//    MYODBCDbgInit( stdout );
-    MYODBCDbgInit( &stringOutput );
+    MYODBCDbgInit( stdout );
+//    MYODBCDbgInit( &stringOutput );
 
     for ( n = 0; tests[n].name; n++ )
     {

Modified: MYODBCDbg/include/MYODBCDbg.h
===================================================================
--- MYODBCDbg/include/MYODBCDbg.h	2005-12-28 07:30:09 UTC (rev 19)
+++ MYODBCDbg/include/MYODBCDbg.h	2005-12-29 04:08:17 UTC (rev 20)
@@ -125,46 +125,48 @@
             
     \sa     MYODBCDbgEnter MYODBCDbgReturn            
 */
-#define MYODBCDbgPrint(A)\
+#define MYODBCDbgInfo(A,B)\
 {\
 if ( gpMYODBCDbg )\
 {\
-    QString stringMessage; \
-    stringMessage.sprintf( "%s:%d: %s\n\t\t[INFO   ] " A, __FILE__, __LINE__,
__FUNCTION__ ); \
-    *gpMYODBCDbg << stringMessage << endl; \
+    QString stringHeader = QString( "%1:%2: %3 [INFO   ] " )\
+                            .arg( __FILE__ )\
+                            .arg( __LINE__ )\
+                            .arg( __FUNCTION__ );\
+    QString stringMessage = QString( A )\
+                            .arg( B );\
+    *gpMYODBCDbg << stringHeader << stringMessage << endl;\
 }\
 }
 
-#define MYODBCDbgPrint2(A,B)\
+#define MYODBCDbgError(A,B)\
 {\
 if ( gpMYODBCDbg )\
 {\
-    QString stringMessage; \
-    stringMessage.sprintf( "%s:%d: %s\n\t\t[INFO   ] " A, __FILE__, __LINE__,
__FUNCTION__, B ); \
-    *gpMYODBCDbg << stringMessage << endl; \
+    QString stringHeader = QString( "%1:%2: %3 [ERROR  ] " )\
+                            .arg( __FILE__ )\
+                            .arg( __LINE__ )\
+                            .arg( __FUNCTION__ );\
+    QString stringMessage = QString( A )\
+                            .arg( B );\
+    *gpMYODBCDbg << stringHeader << stringMessage << endl;\
 }\
 }
 
-#define MYODBCDbgError(A)\
+#define MYODBCDbgWarning(A,B)\
 {\
 if ( gpMYODBCDbg )\
 {\
-    QString stringMessage; \
-    stringMessage.sprintf( "%s:%d: %s\n\t\t[ERROR  ] " A, __FILE__, __LINE__,
__FUNCTION__ ); \
-    *gpMYODBCDbg << stringMessage << endl; \
+    QString stringHeader = QString( "%1:%2: %3 [WARNING] " )\
+                            .arg( __FILE__ )\
+                            .arg( __LINE__ )\
+                            .arg( __FUNCTION__ );\
+    QString stringMessage = QString( A )\
+                            .arg( B );\
+    *gpMYODBCDbg << stringHeader << stringMessage << endl;\
 }\
 }
 
-#define MYODBCDbgWarning(A)\
-{\
-if ( gpMYODBCDbg )\
-{\
-    QString stringMessage; \
-    stringMessage.sprintf( "%s:%d: %s\n\t\t[WARNING] " A, __FILE__, __LINE__,
__FUNCTION__ ); \
-    *gpMYODBCDbg << stringMessage << endl; \
-}\
-}
-
 /*! 
     \brief  Provides debug info indicating function exit.
     
@@ -181,10 +183,9 @@
 #define MYODBCDbgInit(A)     {}
 #define MYODBCDbgFini()      {}
 #define MYODBCDbgEnter()     {}
-#define MYODBCDbgPrint(A)    {}
-#define MYODBCDbgPrint2(A,B) {}
-#define MYODBCDbgError(A)    {}
-#define MYODBCDbgWarning(A)  {}
+#define MYODBCDbgInfo(A,B)   {}
+#define MYODBCDbgError(A,B)  {}
+#define MYODBCDbgWarning(A,B){}
 #define MYODBCDbgReturn(A) return(A)
 #endif
 

Modified: MYODBCIns/MYODBCInsLib/MYODBCIns.cpp
===================================================================
--- MYODBCIns/MYODBCInsLib/MYODBCIns.cpp	2005-12-28 07:30:09 UTC (rev 19)
+++ MYODBCIns/MYODBCInsLib/MYODBCIns.cpp	2005-12-29 04:08:17 UTC (rev 20)
@@ -59,7 +59,7 @@
     nChars = ( SQLGetInstalledDrivers( szBuffer, sizeof(szBuffer) / sizeof(SQLWCHAR),
NULL ) ? 1 : 0 );
     if ( nChars < 1 )
     {
-        MYODBCCfprintf( stderr, L"[%s][%d][INFO] Call returned no data. Could be an error
or just no data to return.\n", __FILE__, __LINE__ );
+        MYODBCCfprintf( stderr, L"[%s][%d][INFO] Call returned no data. Could be an error
or just no data to return.\n", TEXT(__FILE__), __LINE__ );
         return stringlistFriendlyNames;
     }
 
@@ -126,6 +126,23 @@
     return stringlistFriendlyNames;
 }
 
+QString MYODBCIns::getDefaultInstallLocation()
+{
+    QString     stringDefaultInstallLocation;
+    SQLWCHAR    szPathOut[1024];
+    WORD        nPathOutLength  = 0;
+    DWORD       nUsageCount     = 0;
+    SQLWCHAR *  pszAttributes   = MYODBCInsDriver::getAttributesNullDelim( "bogusname",
"bogusdriver", "bogussetup" );
+    BOOL        bRetCode        = SQLInstallDriverEx( pszAttributes, NULL, szPathOut,
sizeof(szPathOut) / sizeof(SQLWCHAR), &nPathOutLength, ODBC_INSTALL_INQUIRY,
&nUsageCount );
+
+    MYODBCCFree( pszAttributes );
+
+    if ( bRetCode )
+        stringDefaultInstallLocation = QString::fromUtf16( szPathOut );
+
+    return stringDefaultInstallLocation;
+}
+
 RETCODE MYODBCIns::getError( WORD nError, DWORD *pnErrorCode, QString &stringMessage
)
 {
     SQLWCHAR    szMessage[32000];
@@ -134,7 +151,7 @@
     RETCODE     nRetCode = SQLInstallerError( nError, pnErrorCode, szMessage,
sizeof(szMessage) / sizeof(SQLWCHAR), &nMessageLen );
 
     if ( SQL_SUCCEEDED(nRetCode) )
-        stringMessage = QString::fromStdWString( szMessage );
+        stringMessage = QString::fromUtf16( szMessage );
 
     return nRetCode;
 }
@@ -147,9 +164,12 @@
     RETCODE nRetCode = getError( nError, &nErrorCode, stringMessage );
 
     if ( SQL_SUCCEEDED(nRetCode) )
-        stringMessageEnhanced = QString( "%1 (%2)" )
+    {
+        stringMessageEnhanced = QString( "[%1][%2] %3" )
+                                .arg( getErrorString( nErrorCode ) )
                                 .arg( nErrorCode )
                                 .arg( stringMessage );
+    }
 
     return stringMessageEnhanced;
 }
@@ -170,6 +190,60 @@
     return stringlistErrors;
 }
 
+QString MYODBCIns::getErrorString( WORD nError )
+{
+    switch ( nError )
+    {
+        case ODBC_ERROR_GENERAL_ERR: 
+            return "ODBC_ERROR_GENERAL_ERR";
+        case ODBC_ERROR_INVALID_BUFF_LEN: 
+            return "ODBC_ERROR_INVALID_BUFF_LEN";
+        case ODBC_ERROR_INVALID_HWND: 
+            return "ODBC_ERROR_INVALID_HWND";
+        case ODBC_ERROR_INVALID_STR: 
+            return "ODBC_ERROR_INVALID_STR";
+        case ODBC_ERROR_INVALID_REQUEST_TYPE: 
+            return "ODBC_ERROR_INVALID_REQUEST_TYPE";
+        case ODBC_ERROR_COMPONENT_NOT_FOUND: 
+            return "ODBC_ERROR_COMPONENT_NOT_FOUND";
+        case ODBC_ERROR_INVALID_NAME: 
+            return "ODBC_ERROR_INVALID_NAME";
+        case ODBC_ERROR_INVALID_KEYWORD_VALUE: 
+            return "ODBC_ERROR_INVALID_KEYWORD_VALUE";
+        case ODBC_ERROR_INVALID_DSN: 
+            return "ODBC_ERROR_INVALID_DSN";
+        case ODBC_ERROR_INVALID_INF: 
+            return "ODBC_ERROR_INVALID_INF";
+        case ODBC_ERROR_REQUEST_FAILED: 
+            return "ODBC_ERROR_REQUEST_FAILED";
+        case ODBC_ERROR_INVALID_PATH: 
+            return "ODBC_ERROR_INVALID_PATH";
+        case ODBC_ERROR_LOAD_LIB_FAILED: 
+            return "ODBC_ERROR_LOAD_LIB_FAILED";
+        case ODBC_ERROR_INVALID_PARAM_SEQUENCE: 
+            return "ODBC_ERROR_INVALID_PARAM_SEQUENCE";
+        case ODBC_ERROR_INVALID_LOG_FILE: 
+            return "ODBC_ERROR_INVALID_LOG_FILE";
+        case ODBC_ERROR_USER_CANCELED: 
+            return "ODBC_ERROR_USER_CANCELED";
+        case ODBC_ERROR_USAGE_UPDATE_FAILED: 
+            return "ODBC_ERROR_USAGE_UPDATE_FAILED";
+        case ODBC_ERROR_CREATE_DSN_FAILED: 
+            return "ODBC_ERROR_CREATE_DSN_FAILED";
+        case ODBC_ERROR_WRITING_SYSINFO_FAILED: 
+            return "ODBC_ERROR_WRITING_SYSINFO_FAILED";
+        case ODBC_ERROR_REMOVE_DSN_FAILED: 
+            return "ODBC_ERROR_REMOVE_DSN_FAILED";
+        case ODBC_ERROR_OUT_OF_MEM: 
+            return "ODBC_ERROR_OUT_OF_MEM";
+        case ODBC_ERROR_OUTPUT_STRING_TRUNCATED: 
+            return "ODBC_ERROR_OUTPUT_STRING_TRUNCATED";
+    }
+
+    return "unknown";
+}
+
+
 bool MYODBCIns::isExistsDataSourceName( const QString &stringDataSourceName,
MYODBC_INS_DATASOURCE_SCOPE nScope )
 {
     SQLWCHAR    szSectionNames[SQL_MAX_DSN_LENGTH * MYODBC_INS_MAX_DSN_NAMES];
@@ -217,7 +291,7 @@
     pszSectionName = szSectionNames;
     while( *pszSectionName )
     {
-        QString stringSectionName( QString::fromStdWString( pszSectionName ) );
+        QString stringSectionName( QString::fromUtf16( pszSectionName ) );
 
         if ( QString::localeAwareCompare( stringSectionName.toUpper(),
stringDataSourceName.toUpper() ) == 0 )
         {

Modified: MYODBCIns/MYODBCInsLib/MYODBCInsDataSource.cpp
===================================================================
--- MYODBCIns/MYODBCInsLib/MYODBCInsDataSource.cpp	2005-12-28 07:30:09 UTC (rev 19)
+++ MYODBCIns/MYODBCInsLib/MYODBCInsDataSource.cpp	2005-12-29 04:08:17 UTC (rev 20)
@@ -255,15 +255,11 @@
     while ( *pszEntryName )
     {
         *szValue = '\0';
-#if defined(WIN32)
-        if ( SQLGetPrivateProfileString( stringDataSourceName.utf16(), pszEntryName,
NULL, szValue, sizeof( szValue ) / sizeof(SQLWCHAR), L"ODBC.INI" ) > 0 )
-#else
         if ( SQLGetPrivateProfileString( stringDataSourceName.utf16(), pszEntryName, L"",
szValue, sizeof( szValue ) / sizeof(SQLWCHAR), L"ODBC.INI" ) > 0 )
-#endif
         {
-            QString stringEntryName( QString::fromStdWString( pszEntryName ) );
+            QString stringEntryName( QString::fromUtf16( pszEntryName ) );
             QString stringEntryNameUpper = stringEntryName.toUpper();
-            QString stringValue( QString::fromStdWString( szValue ) );
+            QString stringValue( QString::fromUtf16( szValue ) );
 
             /*!
                 \internal ODBC Rule
@@ -278,74 +274,74 @@
             if ( QString::localeAwareCompare( stringEntryNameUpper, "DATABASE" ) == 0 ||
QString::localeAwareCompare( stringEntryNameUpper, "DB" ) == 0 )
             {
                 if ( stringDATABASE.isNull() )
-                    stringDATABASE = QString::fromStdWString( szValue );
+                    stringDATABASE = QString::fromUtf16( szValue );
             }
             else if ( QString::localeAwareCompare( stringEntryNameUpper, "DESCRIPTION" )
== 0 || QString::localeAwareCompare( stringEntryNameUpper, "DESC" ) == 0 )
             {
                 if ( stringDESCRIPTION.isNull() )
-                    stringDESCRIPTION = QString::fromStdWString( szValue );
+                    stringDESCRIPTION = QString::fromUtf16( szValue );
             }
             else if ( QString::localeAwareCompare( stringEntryNameUpper, "DRIVER" ) == 0
)
             {
 #if defined(WIN32)
                 if ( stringDriverFileName.isEmpty() )
-                    stringDriverFileName = QString::fromStdWString( szValue );
+                    stringDriverFileName = QString::fromUtf16( szValue );
 #else
                 if ( *szValue == '/' )
                 {
                     if ( stringDriverFileName.isEmpty() )
-                        stringDriverFileName = QString::fromStdWString( szValue );
+                        stringDriverFileName = QString::fromUtf16( szValue );
                 }
                 else
                 {
                     if ( stringDRIVER.isEmpty() )
-                        stringDRIVER = QString::fromStdWString( szValue );
+                        stringDRIVER = QString::fromUtf16( szValue );
                 }
 #endif
             }
             else if ( QString::localeAwareCompare( stringEntryNameUpper, "OPTION" ) == 0
)
             {    
                 if ( stringOPTION.isNull() )
-                    stringOPTION = QString::fromStdWString( szValue );
+                    stringOPTION = QString::fromUtf16( szValue );
             }
             else if ( QString::localeAwareCompare( stringEntryNameUpper, "PWD" ) == 0 ||
QString::localeAwareCompare( stringEntryNameUpper, "PASSWORD" ) == 0 )
             {    
                 if ( stringPASSWORD.isNull() )
-                    stringPASSWORD = QString::fromStdWString( szValue );
+                    stringPASSWORD = QString::fromUtf16( szValue );
             }
             else if ( QString::localeAwareCompare( stringEntryNameUpper, "PORT" ) == 0 )
             {    
                 if ( stringPORT.isNull() )
-                    stringPORT = QString::fromStdWString( szValue );
+                    stringPORT = QString::fromUtf16( szValue );
             }
             else if ( QString::localeAwareCompare( stringEntryNameUpper, "SERVER" ) == 0
)
             {    
                 if ( stringSERVER.isNull() )
-                    stringSERVER = QString::fromStdWString( szValue );
+                    stringSERVER = QString::fromUtf16( szValue );
             }
             else if ( QString::localeAwareCompare( stringEntryNameUpper, "SOCKET" ) == 0
)
             {    
                 if ( stringSOCKET.isNull() )
-                    stringSOCKET = QString::fromStdWString( szValue );
+                    stringSOCKET = QString::fromUtf16( szValue );
             }
             else if ( QString::localeAwareCompare( stringEntryNameUpper, "STMT" ) == 0 )
             {    
                 if ( stringSTMT.isNull() )
-                    stringSTMT = QString::fromStdWString( szValue );
+                    stringSTMT = QString::fromUtf16( szValue );
             }
             else if ( QString::localeAwareCompare( stringEntryNameUpper, "UID" ) == 0 ||
QString::localeAwareCompare( stringEntryNameUpper, "USER" ) == 0 )
             {    
                 if ( stringUSER.isNull() )
-                    stringUSER = QString::fromStdWString( szValue );
+                    stringUSER = QString::fromUtf16( szValue );
             }
             else
             {
                 /* What the ? */
-                MYODBCCfprintf( stderr, L"[%s][%d][ERROR] Unknown attribute (%s).\n",
__FILE__, __LINE__, pszEntryName );
+                MYODBCCfprintf( stderr, L"\n[%s][%d][ERROR] Unknown attribute (%s).\n",
TEXT(__FILE__), __LINE__, pszEntryName );
             }
         }
         else
-            MYODBCCfprintf( stderr, L"[%s][%d][WARNING] Failed to get value for attribute
(%s).\n", __FILE__, __LINE__, pszEntryName );
+            MYODBCCfprintf( stderr, L"\n[%s][%d][WARNING] Failed to get value for
attribute (%s).\n", TEXT(__FILE__), __LINE__, pszEntryName );
 
         pszEntryName += MYODBCCstrlen( pszEntryName ) + 1;
     } /* while */
@@ -360,14 +356,14 @@
         pszEntryName = szEntryNames;
         while ( *pszEntryName )
         {
-            QString stringEntryName( QString::fromStdWString( pszEntryName ) );
+            QString stringEntryName( QString::fromUtf16( pszEntryName ) );
             *szValue = '\0';
             if ( SQLGetPrivateProfileString( MYODBC_INS_ODBCINI_HEADER_SECTION,
pszEntryName, NULL, szValue, sizeof(szValue) / sizeof(SQLWCHAR), L"ODBC.INI" ) > 0 )
             {
 
                 if ( QString::localeAwareCompare( stringEntryName.toUpper(),
stringDataSourceName.toUpper() ) == 0 )
                 {
-                    stringDRIVER = QString::fromStdWString( szValue );
+                    stringDRIVER = QString::fromUtf16( szValue );
                     break;
                 }
             }

Modified: MYODBCIns/MYODBCInsLib/MYODBCInsDriver.cpp
===================================================================
--- MYODBCIns/MYODBCInsLib/MYODBCInsDriver.cpp	2005-12-28 07:30:09 UTC (rev 19)
+++ MYODBCIns/MYODBCInsLib/MYODBCInsDriver.cpp	2005-12-29 04:08:17 UTC (rev 20)
@@ -62,6 +62,41 @@
     return stringSETUP;
 }
 
+SQLWCHAR *MYODBCInsDriver::getAttributesNullDelim( const QString &stringFriendlyName,
const QString &stringDRIVER, const QString &stringSETUP )
+{
+    int         nBuffer     = (stringFriendlyName.length() + stringDRIVER.length() +
stringSETUP.length() + 20) * sizeof(SQLWCHAR);
+    SQLWCHAR *  pszBuffer   = (SQLWCHAR*)MYODBCCMalloc( nBuffer );
+    SQLWCHAR *  pcInsertPos = pszBuffer;
+
+    /* friendly name */
+    MYODBCCMemCpy( pcInsertPos, stringFriendlyName.utf16(), (stringFriendlyName.length()
+ 1) * sizeof(SQLWCHAR) );
+    pcInsertPos += stringFriendlyName.length() + 1;
+
+    /* DRIVER */
+    MYODBCCMemCpy( pcInsertPos, L"DRIVER=", 7 * sizeof(SQLWCHAR) );
+    pcInsertPos += 7;
+
+    MYODBCCMemCpy( pcInsertPos, stringDRIVER.utf16(), (stringDRIVER.length() + 1) *
sizeof(SQLWCHAR) );
+    pcInsertPos += stringDRIVER.length() + 1;
+
+    /* SETUP */
+    MYODBCCMemCpy( pcInsertPos, L"SETUP=", 6 * sizeof(SQLWCHAR) );
+    pcInsertPos += 6;
+
+    MYODBCCMemCpy( pcInsertPos, stringSETUP.utf16(), stringSETUP.length() *
sizeof(SQLWCHAR) );
+    pcInsertPos += stringSETUP.length() + 1;
+
+    /* we have terminated keyword/value pairs with null now extra null to terminate the
whole thing */
+    *pcInsertPos = '\0';
+
+    return pszBuffer;
+}
+
+SQLWCHAR *MYODBCInsDriver::getAttributesNullDelim()
+{
+    return getAttributesNullDelim( stringFriendlyName, stringDRIVER, stringSETUP );
+}
+
 bool MYODBCInsDriver::doRead( const QString &stringFriendlyName )
 {
     SQLWCHAR    szEntryNames[SQL_MAX_DSN_LENGTH * MYODBC_INS_MAX_DSN_NAMES];
@@ -79,7 +114,7 @@
     if ( nChars < 1 )
     {
         if ( MYODBCIns::setError( "data source name not found" ) != SQL_SUCCESS )
-            MYODBCCfprintf( stderr, L"[PAH][%s][%d]\n", __FILE__, __LINE__ );
+            MYODBCCfprintf( stderr, L"[PAH][%s][%d]\n", TEXT(__FILE__), __LINE__ );
         return false;
     }
 
@@ -97,17 +132,17 @@
         *szValue = '\0';
         if ( SQLGetPrivateProfileString( stringFriendlyName.utf16(), pszEntryName, L"",
szValue, sizeof(szValue) / sizeof(SQLWCHAR), L"ODBCINST.INI" ) > 0 )
         {
-            QString stringEntryName = QString::fromStdWString( pszEntryName );
+            QString stringEntryName = QString::fromUtf16( pszEntryName );
 
             if ( QString::localeAwareCompare( stringEntryName.toUpper(), "DRIVER" ) == 0
)
             {
                 if ( stringDRIVER.isEmpty() )
-                    stringDRIVER = QString::fromStdWString( szValue );
+                    stringDRIVER = QString::fromUtf16( szValue );
             }
             else if ( QString::localeAwareCompare( stringEntryName.toUpper(), "SETUP" )
== 0 )
             {
                 if ( stringSETUP.isEmpty() )
-                    stringSETUP = QString::fromStdWString( szValue );
+                    stringSETUP = QString::fromUtf16( szValue );
             }
             else
             {
@@ -122,17 +157,15 @@
 
 bool MYODBCInsDriver::doWrite()
 {
-    if ( !stringFriendlyName.isEmpty() && 
-         !SQLWritePrivateProfileString( stringFriendlyName.utf16(), NULL, NULL,
L"ODBCINST.INI" ) )
-        return false;
-    if ( !stringDRIVER.isEmpty() &&
-         !SQLWritePrivateProfileString( stringFriendlyName.utf16(), L"DRIVER",
stringDRIVER.utf16(), L"ODBCINST.INI" ) )
-        return false;
-    if ( !stringSETUP.isEmpty() &&
-         !SQLWritePrivateProfileString( stringFriendlyName.utf16(), L"SETUP",
stringSETUP.utf16(), L"ODBCINST.INI" ) )
-        return false;
+    SQLWCHAR    szPathOut[1024];
+    WORD        nPathOutLength  = 0;
+    DWORD       nUsageCount     = 0;
+    SQLWCHAR *  pszAttributes   = getAttributesNullDelim();
+    BOOL        bRetCode        = SQLInstallDriverEx( pszAttributes, NULL, szPathOut,
sizeof(szPathOut) / sizeof(SQLWCHAR), &nPathOutLength, ODBC_INSTALL_COMPLETE,
&nUsageCount );
 
-    return true;
+    MYODBCCFree( pszAttributes );
+
+    return bRetCode;
 }
 
 void MYODBCInsDriver::doClear()

Modified: MYODBCIns/MYODBCInsLib/MYODBCInsDriverConnect.cpp
===================================================================
--- MYODBCIns/MYODBCInsLib/MYODBCInsDriverConnect.cpp	2005-12-28 07:30:09 UTC (rev 19)
+++ MYODBCIns/MYODBCInsLib/MYODBCInsDriverConnect.cpp	2005-12-29 04:08:17 UTC (rev 20)
@@ -183,7 +183,7 @@
                 }
                 break;
             default:
-                MYODBCCfprintf( stderr, L"[%s][%d][ERROR] Unhandled state.\n", __FILE__,
__LINE__ );
+                MYODBCCfprintf( stderr, L"[%s][%d][ERROR] Unhandled state.\n",
TEXT(__FILE__), __LINE__ );
                 return false;
         }
 

Modified: MYODBCIns/MYODBCInsTest/MYODBCInsTest.cpp
===================================================================
--- MYODBCIns/MYODBCInsTest/MYODBCInsTest.cpp	2005-12-28 07:30:09 UTC (rev 19)
+++ MYODBCIns/MYODBCInsTest/MYODBCInsTest.cpp	2005-12-29 04:08:17 UTC (rev 20)
@@ -6,6 +6,23 @@
     int (*pfunc)();
 } TEST;
 
+#define FILE_SEP "\\"
+
+#define TEST_DRIVERNAME "mytestDRIVER"
+#define TEST_DSN "mytestDSN"
+#define TEST_DRIVER "odbcjt32.dll"
+#define TEST_SETUP "odbcjt32.dll"
+#define TEST_DATABASE "mytestDATABASE"
+#define TEST_DESCRIPTION "mytestDESCRIPTION"
+#define TEST_OPTION "3"
+#define TEST_PASSWORD "mytestPASSWORD"
+#define TEST_PORT "99"
+#define TEST_SERVER "mytestSERVER"
+#define TEST_SOCKET "100"
+#define TEST_STMT ""
+#define TEST_USER QString::null
+
+/* store some output here so we can check results in later funcs */
 QString stringOutput;
 
 /* create new DRIVER */
@@ -13,13 +30,21 @@
 {
     MYODBCInsDriver driver;
 
-    driver.setFriendlyName( "mytestDRIVER" );
-    driver.setDRIVER( "mytestDriver.so" );
-    driver.setSETUP( "mytestSetup.so" );
+    driver.setFriendlyName( TEST_DRIVERNAME );
+    driver.setDRIVER( TEST_DRIVER );
+    driver.setSETUP( TEST_SETUP );
 
     if ( !driver.doWrite() )
     {
-        MYODBCDbgPrint2( "%s", MYODBCIns::getErrors().join( "\n" ).toStdWString() );
+        QStringList stringlist = MYODBCIns::getErrors();
+        if ( stringlist.isEmpty() )
+        {
+            MYODBCDbgError( "Unknown error writing driver information.%1", "" );
+        }
+        else
+        {
+            MYODBCDbgError( "%1", stringlist.join( "\n" ) );
+        }
         return 0;
     }
 
@@ -33,17 +58,18 @@
 int test2()
 {
     MYODBCInsDriver driver;
+    QString         stringDefaultInstallLocation =
MYODBCIns::getDefaultInstallLocation();
 
-    if ( !driver.doRead( "mytestDRIVER" ) )
+    if ( !driver.doRead( TEST_DRIVERNAME ) )
     {
         QStringList stringlist = MYODBCIns::getErrors();
         if ( stringlist.isEmpty() )
         {
-            MYODBCDbgPrint( "Unknown error" );
+            MYODBCDbgError( "Unknown error reading driver information.%1", "" );
         }
         else
         {
-            MYODBCDbgPrint2( "%s", MYODBCIns::getErrors().join( "\n" ).toStdWString() );
+            MYODBCDbgError( "%1", stringlist.join( "\n" ) );
         }
         return 0;
     }
@@ -53,8 +79,13 @@
 //    QTextStream textstream( stderr );
     textstream << driver;
 
-    if ( stringResult != stringOutput )
+    if ( driver.getFriendlyName() != TEST_DRIVERNAME ||
+         driver.getDRIVER() != stringDefaultInstallLocation + FILE_SEP + TEST_DRIVER ||
+         driver.getSETUP() != stringDefaultInstallLocation + FILE_SEP + TEST_SETUP )
     {
+        MYODBCDbgError( "Have prepended %1 to file names but driver information is not
the same...", stringDefaultInstallLocation );
+        MYODBCDbgError( "\nWrote:\n%1", stringOutput );
+        MYODBCDbgError( "\nRead :\n%1", stringResult );
         return 0;
     }
 
@@ -64,31 +95,45 @@
 /* create new DSN */
 int test3()
 {
+    /* its an error if it already exists... */
     QStringList stringlistDataSourceNames = MYODBCIns::getDataSourceNames(
MYODBC_INS_DATASOURCE_SCOPE_USER );
 
-    if ( stringlistDataSourceNames.contains( "mytestDSN" ) )
+    if ( stringlistDataSourceNames.contains( TEST_DSN ) )
+    {
+        MYODBCDbgError( "%1 already exists.", TEST_DSN );
         return 0;
+    }
 
     MYODBCInsDataSource datasource( MYODBC_INS_DATASOURCE_MODE_DSN_ADD );
 
     datasource.setScope( MYODBC_INS_DATASOURCE_SCOPE_USER );
-    datasource.setDATABASE( "mytestDATABASE" );
-    datasource.setDESCRIPTION( "mytestDESCRIPTION" );
-    datasource.setDRIVER( "mytestDRIVER" );
-    datasource.setDriverFileName( "mytestDriver.so" );
-    datasource.setDSN( "mytestDSN" );
-    datasource.setOPTION( "3" );
-    datasource.setPASSWORD( "mytestPASSWORD" );
-    datasource.setPORT( "99" );
-    datasource.setSERVER( "mytestSERVER" );
-    datasource.setSOCKET( "100" );
-    datasource.setSTMT( "" );
+    datasource.setDATABASE( TEST_DATABASE );
+    datasource.setDESCRIPTION( TEST_DESCRIPTION );
+    datasource.setDRIVER( TEST_DRIVERNAME );
+    datasource.setDriverFileName( TEST_DRIVER );
+    datasource.setDSN( TEST_DSN );
+    datasource.setOPTION( TEST_OPTION );
+    datasource.setPASSWORD( TEST_PASSWORD );
+    datasource.setPORT( TEST_PORT );
+    datasource.setSERVER( TEST_SERVER );
+    datasource.setSOCKET( TEST_SOCKET );
+    datasource.setSTMT( TEST_STMT );
 
     if ( !datasource.doWrite() )
     {
+        QStringList stringlist = MYODBCIns::getErrors();
+        if ( stringlist.isEmpty() )
+        {
+            MYODBCDbgError( "Unknown error writing data source %1.", TEST_DSN );
+        }
+        else
+        {
+            MYODBCDbgError( "%1", stringlist.join( "\n" ) );
+        }
         return 0;
     }
 
+    stringOutput = QString::null;
     QTextStream textstream( &stringOutput );
     textstream << datasource;
 
@@ -99,17 +144,45 @@
 int test4()
 {
     MYODBCInsDataSource datasource( MYODBC_INS_DATASOURCE_MODE_DSN_EDIT );
+    QString             stringDefaultInstallLocation =
MYODBCIns::getDefaultInstallLocation();
 
     datasource.setScope( MYODBC_INS_DATASOURCE_SCOPE_USER );
-    if ( !datasource.doRead( "mytestDSN" ) )
+    if ( !datasource.doRead( TEST_DSN ) )
+    {
+        QStringList stringlist = MYODBCIns::getErrors();
+        if ( stringlist.isEmpty() )
+        {
+            MYODBCDbgError( "Unknown error reading data source %1. It may not exist.",
TEST_DSN );
+        }
+        else
+        {
+            MYODBCDbgError( "%1", stringlist.join( "\n" ) );
+        }
         return 0;
+    }
 
     QString     stringResult;
     QTextStream textstream( &stringResult );
     textstream << datasource;
 
-    if ( stringResult != stringOutput )
+    if ( datasource.getDATABASE() != TEST_DATABASE ||
+         datasource.getDESCRIPTION() != TEST_DESCRIPTION ||
+         datasource.getDRIVER() != TEST_DRIVERNAME ||
+         datasource.getDriverFileName() != stringDefaultInstallLocation + FILE_SEP +
TEST_DRIVER ||
+         datasource.getDSN() != TEST_DSN ||
+         datasource.getOPTION() != TEST_OPTION ||
+         datasource.getPASSWORD() != TEST_PASSWORD ||
+         datasource.getPORT() != TEST_PORT ||
+         datasource.getSERVER() != TEST_SERVER ||
+         datasource.getSOCKET() != TEST_SOCKET ||
+         datasource.getSTMT() != TEST_STMT ||
+         datasource.getUSER() != TEST_USER ) 
+    {
+        MYODBCDbgError( "Have prepended %1 to file name but data source information is
not the same...", stringDefaultInstallLocation );
+        MYODBCDbgError( "\nWrote:\n%1", stringOutput );
+        MYODBCDbgError( "\nRead :\n%1", stringResult );
         return 0;
+    }
 
     return 1;
 }
@@ -117,8 +190,19 @@
 /* delete DSN */
 int test5()
 {
-    if ( !MYODBCInsDataSource::doDelete( "mytestDSN" ) )
+    if ( !MYODBCInsDataSource::doDelete( TEST_DSN ) )
+    {
+        QStringList stringlist = MYODBCIns::getErrors();
+        if ( stringlist.isEmpty() )
+        {
+            MYODBCDbgError( "Unknown error while deleting %1.", TEST_DSN );
+        }
+        else
+        {
+            MYODBCDbgError( "%1", stringlist.join( "\n" ) );
+        }
         return 0;
+    }
 
     return 1;
 }
@@ -128,8 +212,11 @@
 {
     QStringList stringlistDataSourceNames = MYODBCIns::getDataSourceNames(
MYODBC_INS_DATASOURCE_SCOPE_USER );
 
-    if ( stringlistDataSourceNames.contains( "mytestDSN" ) )
+    if ( stringlistDataSourceNames.contains( TEST_DSN ) )
+    {
+        MYODBCDbgError( "Failed to delete %1.", TEST_DSN );
         return 0;
+    }
 
     return 1;
 }
@@ -139,11 +226,22 @@
 {
     DWORD nUsage = 0;
 
-    if ( !MYODBCInsDriver::doDelete( "mytestDRIVER", true, &nUsage ) )
+    if ( !MYODBCInsDriver::doDelete( TEST_DRIVERNAME, true, &nUsage ) )
+    {
+        QStringList stringlist = MYODBCIns::getErrors();
+        if ( stringlist.isEmpty() )
+        {
+            MYODBCDbgError( "Unknown error while deleting %1.", TEST_DRIVERNAME );
+        }
+        else
+        {
+            MYODBCDbgError( "%1", stringlist.join( "\n" ) );
+        }
         return 0;
+    }
 
     if ( nUsage != 0 )
-        return 0;
+        MYODBCDbgWarning( "Usage count should be 0 but is %1.", nUsage );
 
     return 1;
 }
@@ -153,8 +251,11 @@
 {
     QStringList stringlistDriverNames = MYODBCIns::getDriverNames();
 
-    if ( stringlistDriverNames.contains( "mytestDRIVER" ) )
+    if ( stringlistDriverNames.contains( TEST_DRIVERNAME ) )
+    {
+        MYODBCDbgError( "Failed to delete %1.", TEST_DRIVERNAME );
         return 0;
+    }
 
     return 1;
 }

Modified: MYODBCIns/include/MYODBCIns.h
===================================================================
--- MYODBCIns/include/MYODBCIns.h	2005-12-28 07:30:09 UTC (rev 19)
+++ MYODBCIns/include/MYODBCIns.h	2005-12-29 04:08:17 UTC (rev 20)
@@ -12,10 +12,12 @@
 
     static QStringList getDriverNames();
     static QStringList getDataSourceNames( MYODBC_INS_DATASOURCE_SCOPE nScope );
+    static QString getDefaultInstallLocation();
     static RETCODE getError( WORD nError, DWORD *pnErrorCode, QString &stringMessage
);
     static QString getError( WORD nError );
     static QStringList getErrors();
-
+    static QString getErrorString( WORD nError );
+    
     static bool isExistsDataSourceName( const QString &stringDataSourceName,
MYODBC_INS_DATASOURCE_SCOPE nScope );
 
 };

Modified: MYODBCIns/include/MYODBCInsDriver.h
===================================================================
--- MYODBCIns/include/MYODBCInsDriver.h	2005-12-28 07:30:09 UTC (rev 19)
+++ MYODBCIns/include/MYODBCInsDriver.h	2005-12-29 04:08:17 UTC (rev 20)
@@ -19,6 +19,8 @@
     QString getFriendlyName();
     QString getDRIVER();
     QString getSETUP();
+    static SQLWCHAR *getAttributesNullDelim( const QString &stringFriendlyName, const
QString &stringDRIVER, const QString &stringSETUP );
+    SQLWCHAR *getAttributesNullDelim();
 
     bool doRead( const QString &stringFriendlyName );
     bool doWrite();

Modified: root.pro
===================================================================
--- root.pro	2005-12-28 07:30:09 UTC (rev 19)
+++ root.pro	2005-12-29 04:08:17 UTC (rev 20)
@@ -48,9 +48,9 @@
 		MYODBCDbg \
 #		MYODBCRtti (nothing to build here) \
 		MYODBCTst \
-		MYODBCIns
+		MYODBCIns \
 #		MYODBCSetup \
-#		MYODBCDia \
+		MYODBCDia
 #		MYODBCDes \
 #        	MYODBCRes \
 #		MYODBCDrv \

Thread
Connector/ODBC 5 commit: r20 - / MYODBCC/include MYODBCDbg/MYODBCDbgTest MYODBCDbg/include MYODBCIns/MYODBCInsLib MYODBCIns/MYODBCInsTest MYODBCIns/in...pharvey29 Dec