kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lid...@apache.org
Subject [08/11] kylin git commit: KYLIN-1389 ODBC - Reformatting C++ Code
Date Mon, 01 Feb 2016 09:45:27 GMT
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Driver/KO_CONN.CPP
----------------------------------------------------------------------
diff --git a/odbc/Driver/KO_CONN.CPP b/odbc/Driver/KO_CONN.CPP
index 28642b1..cee9b39 100644
--- a/odbc/Driver/KO_CONN.CPP
+++ b/odbc/Driver/KO_CONN.CPP
@@ -15,8 +15,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- 
- 
+
+
 // ----------------------------------------------------------------------------
 //
 // File:    KO_CONN.CPP
@@ -58,110 +58,126 @@
 INT_PTR CALLBACK DlgDSNCfg1Proc ( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
 
 // ----------------------------- local functions ------------------------------
-static eGoodBad     CreateAndSetConnProp ( pODBCConn pConn, Word pPropID, void* pPropValue );
+static eGoodBad CreateAndSetConnProp ( pODBCConn pConn, Word pPropID, void* pPropValue );
 
-static eGoodBad     PutDataToDlgDSNCfg1 ( pODBCConn pConn, HWND hDlg );
+static eGoodBad PutDataToDlgDSNCfg1 ( pODBCConn pConn, HWND hDlg );
 
-static eGoodBad     GetDataFromDlgDSNCfg1 ( HWND hDlg, pODBCConn pConn );
+static eGoodBad GetDataFromDlgDSNCfg1 ( HWND hDlg, pODBCConn pConn );
 
-static Word         PromptForConnInfo ( SQLHDBC pConn );
+static Word PromptForConnInfo ( SQLHDBC pConn );
 
-static eGoodBad     LoadKeyValuesfromFileDSN ( pODBCConn pConn, CStrPtr pDSNName, Word* pNumPair,
-                                               struct ODBCKV** pKV );
+static eGoodBad LoadKeyValuesfromFileDSN ( pODBCConn pConn, CStrPtr pDSNName, Word* pNumPair,
+                                           struct ODBCKV** pKV );
 
-static bool         AddKVToConnStr ( StrPtr pKey, StrPtr pValue, Word* iPos, StrPtr pStrConn, Word pMaxLen );
-static bool         BuildConnStr ( char* pStrConn, Word pMaxLen, pODBCConn pConn, struct ODBCKV* KVInput,
-                                   Word iKVInputPairs, struct ODBCKV* KVFileDSN, Word iKVFileDSNPairs );
+static bool AddKVToConnStr ( StrPtr pKey, StrPtr pValue, Word* iPos, StrPtr pStrConn, Word pMaxLen );
+static bool BuildConnStr ( char* pStrConn, Word pMaxLen, pODBCConn pConn, struct ODBCKV* KVInput,
+                           Word iKVInputPairs, struct ODBCKV* KVFileDSN, Word iKVFileDSNPairs );
 
-static const char *supportedProtocols[] = { PROTOCOL_HTTPS, PROTOCOL_HTTP };
-static const char *defaultPorts[] = { PORT_HTTPS_DEFAULT, PORT_HTTP_DEFAULT };
+static const char* supportedProtocols[] = { PROTOCOL_HTTPS, PROTOCOL_HTTP };
+static const char* defaultPorts[] = { PORT_HTTPS_DEFAULT, PORT_HTTP_DEFAULT };
 
 // -----------------------------------------------------------------------
 // to set a specified property in the connection structure
 // -----------------------------------------------------------------------
 
-eGoodBad SetConnProp ( pODBCConn pConn, Word pPropID, void* pPropValue ) {
+eGoodBad SetConnProp ( pODBCConn pConn, Word pPropID, void* pPropValue )
+{
     // note
     // this function does not create a copy of char data
     // it just transfers the pointer
     // numeric data is assumed to be a pointer
-    
+
     // check property
-    switch ( pPropID ) {
-        case CONN_PROP_SERVER:
-        
+    switch ( pPropID )
+    {
+        case CONN_PROP_SERVER :
+
             // check if a new value has to be put
-            if ( pPropValue ) {
-                copyTrimmed ( & ( ( char* ) pConn->Server ), ( char* ) pPropValue );
+            if ( pPropValue )
+            {
+                copyTrimmed ( & ( ( char* ) pConn -> Server ), ( char* ) pPropValue );
             }
-            
-            if ( pConn->Server == NULL || strlen ( pConn->Server ) == 0 ) {
+
+            if ( pConn -> Server == NULL || strlen ( pConn -> Server ) == 0 )
+            {
                 __ODBCPopMsg ( "Server cannot be empty" );
                 return BAD;
             }
-            
+
             __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The server is set to %s", pConn->Server ) );
             break;
-            
-        case CONN_PROP_PORT:
-        
+
+        case CONN_PROP_PORT :
+
             // numeric values are passed as pointer to value
             if ( pPropValue )
-            { pConn->ServerPort = * ( ( ULong* ) pPropValue ); }
-            
-            if ( pConn->ServerPort == 0 ) {
+            {
+                pConn -> ServerPort = * ( ( ULong* ) pPropValue );
+            }
+
+            if ( pConn -> ServerPort == 0 )
+            {
                 __ODBCPopMsg ( "ServerPort cannot be 0" );
                 return BAD;
             }
-            
+
             __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The port is set to %d", pConn->ServerPort ) );
             break;
-            
-        case CONN_PROP_UID:
-        
+
+        case CONN_PROP_UID :
+
             // check if a new value has to be put
             if ( pPropValue )
-            { copyTrimmed ( & ( ( char* ) pConn->UserName ), ( char* ) pPropValue ); }
-            
-            if ( pConn->UserName == NULL || strlen ( pConn->UserName ) == 0 ) {
+            {
+                copyTrimmed ( & ( ( char* ) pConn -> UserName ), ( char* ) pPropValue );
+            }
+
+            if ( pConn -> UserName == NULL || strlen ( pConn -> UserName ) == 0 )
+            {
                 __ODBCPopMsg ( "UserName cannot be empty" );
                 return BAD;
             }
-            
+
             __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The uid is set to %s", pConn->UserName ) );
             break;
-            
-        case CONN_PROP_PWD:
-        
+
+        case CONN_PROP_PWD :
+
             // check if a new value has to be put
             if ( pPropValue )
-            { copyTrimmed ( & ( ( char* ) pConn->Password ), ( char* ) pPropValue ); }
-            
-            if ( pConn->Password == NULL || strlen ( pConn->Password ) == 0 ) {
+            {
+                copyTrimmed ( & ( ( char* ) pConn -> Password ), ( char* ) pPropValue );
+            }
+
+            if ( pConn -> Password == NULL || strlen ( pConn -> Password ) == 0 )
+            {
                 __ODBCPopMsg ( "Password cannot be empty" );
                 return BAD;
             }
-            
+
             break;
-            
-        case CONN_PROP_PROJECT:
-        
+
+        case CONN_PROP_PROJECT :
+
             // check if a new value has to be put
             if ( pPropValue )
-            { copyTrimmed ( & ( ( char* ) pConn->Project ), ( char* ) pPropValue ); }
-            
-            if ( pConn->Project == NULL || strlen ( pConn->Project ) == 0 ) {
+            {
+                copyTrimmed ( & ( ( char* ) pConn -> Project ), ( char* ) pPropValue );
+            }
+
+            if ( pConn -> Project == NULL || strlen ( pConn -> Project ) == 0 )
+            {
                 __ODBCPopMsg ( "Project cannot be empty" );
                 return BAD;
             }
-            
+
             break;
-            
-        default:
+
+        default :
             __ODBCPOPMSG ( _ODBCPopMsg ( "Bad connection property" ) );
             return BAD;
     }
-    
+
     return GOOD;
 }
 
@@ -170,45 +186,52 @@ eGoodBad SetConnProp ( pODBCConn pConn, Word pPropID, void* pPropValue ) {
 // to create copy of a value and then set it in the struct
 // -----------------------------------------------------------------------
 
-static eGoodBad CreateAndSetConnProp ( pODBCConn pConn, Word pPropID, void* pPropValue ) {
-    bool    IsPropStr;
-    
+static eGoodBad CreateAndSetConnProp ( pODBCConn pConn, Word pPropID, void* pPropValue )
+{
+    bool IsPropStr;
+
     // precaution
     if ( !pConn )
-    { return BAD; }
-    
+    {
+        return BAD;
+    }
+
     // determine the prop type
-    switch ( pPropID ) {
-        case CONN_PROP_PORT:                // port is stored as a number
+    switch ( pPropID )
+    {
+        case CONN_PROP_PORT : // port is stored as a number
             IsPropStr = FALSE;
             break;
-            
-        default:
+
+        default :
             IsPropStr = TRUE;
             break;
     }
-    
+
     // check property type
-    if ( IsPropStr ) {
-        Word    x;
-        unique_ptr<char[]> s = NULL;
+    if ( IsPropStr )
+    {
+        Word x;
+        unique_ptr <char[]> s = NULL;
         // find length of property
         x = pPropValue ? strlen ( ( StrPtr ) pPropValue ) : 0;
-        
+
         // check if something
-        if ( x > 0 ) {
+        if ( x > 0 )
+        {
             // create copy of property
             s = make_unique_str ( x );
             // store
-            strcpy ( s.get(), ( StrPtr ) pPropValue );
+            strcpy ( s . get (), ( StrPtr ) pPropValue );
         }
-        
+
         // now set the property
-        return SetConnProp ( pConn, pPropID, s.get() );
+        return SetConnProp ( pConn, pPropID, s . get () );
     }
-    
-    else {
-        Long    v;
+
+    else
+    {
+        Long v;
         // convert value to integer
         v = ( pPropValue ) ? atoi ( ( StrPtr ) pPropValue ) : 0;
         // now set the property
@@ -220,146 +243,198 @@ static eGoodBad CreateAndSetConnProp ( pODBCConn pConn, Word pPropID, void* pPro
 // to provide the default data to DSN config dialog 1
 // -----------------------------------------------------------------------
 
-static eGoodBad PutDataToDlgDSNCfg1 ( pODBCConn pConn, HWND hDlg ) {
-    BOOL    x;
-    
+static eGoodBad PutDataToDlgDSNCfg1 ( pODBCConn pConn, HWND hDlg )
+{
+    BOOL x;
+
     // precaution
-    if ( !pConn || !hDlg ) {
+    if ( !pConn || !hDlg )
+    {
         __ODBCPOPMSG ( _ODBCPopMsg ( "PutDataToDlgDSNCfg1 - Bad params" ) );
         return BAD;
     }
-    
+
     // server name/IP
-    if ( pConn->Server )
-    { x = SetDlgItemText ( hDlg, IDC_SERVER, pConn->Server ); }
-    
+    if ( pConn -> Server )
+    {
+        x = SetDlgItemText ( hDlg, IDC_SERVER, pConn -> Server );
+    }
+
     else
-    { x = SetDlgItemText ( hDlg, IDC_SERVER, "" ); }
-    
-    if ( !x )  { return BAD; }
-    
+    {
+        x = SetDlgItemText ( hDlg, IDC_SERVER, "" );
+    }
+
+    if ( !x )
+    {
+        return BAD;
+    }
+
     // server port
-    if ( pConn->ServerPort )
-    { x = SetDlgItemInt ( hDlg, IDC_PORT, pConn->ServerPort, FALSE ); }
-    
+    if ( pConn -> ServerPort )
+    {
+        x = SetDlgItemInt ( hDlg, IDC_PORT, pConn -> ServerPort, FALSE );
+    }
+
     else
-    { x = SetDlgItemInt ( hDlg, IDC_PORT, DEFAULT_PORT, FALSE ); }
-    
-    if ( !x )  { return BAD; }
-    
+    {
+        x = SetDlgItemInt ( hDlg, IDC_PORT, DEFAULT_PORT, FALSE );
+    }
+
+    if ( !x )
+    {
+        return BAD;
+    }
+
     // user name
-    if ( pConn->UserName )
-    { x = SetDlgItemText ( hDlg, IDC_UID, pConn->UserName ); }
-    
+    if ( pConn -> UserName )
+    {
+        x = SetDlgItemText ( hDlg, IDC_UID, pConn -> UserName );
+    }
+
     else
-    { x = SetDlgItemText ( hDlg, IDC_UID, "" ); }
-    
-    if ( !x )  { return BAD; }
-    
+    {
+        x = SetDlgItemText ( hDlg, IDC_UID, "" );
+    }
+
+    if ( !x )
+    {
+        return BAD;
+    }
+
     // password
-    if ( pConn->Password )
-    { x = SetDlgItemText ( hDlg, IDC_PWD, pConn->Password ); }
-    
+    if ( pConn -> Password )
+    {
+        x = SetDlgItemText ( hDlg, IDC_PWD, pConn -> Password );
+    }
+
     else
-    { x = SetDlgItemText ( hDlg, IDC_PWD, "" ); }
-    
-    if ( !x )  { return BAD; }
-    
+    {
+        x = SetDlgItemText ( hDlg, IDC_PWD, "" );
+    }
+
+    if ( !x )
+    {
+        return BAD;
+    }
+
     return GOOD;
 }
 
 
-
 // -----------------------------------------------------------------------
 // to fetch the data from the dialog 1 into the conn-struct
 // -----------------------------------------------------------------------
 
-static eGoodBad GetDataFromDlgDSNCfg1 ( HWND hDlg, pODBCConn pConn ) {
-    Long    x;
-    std::unique_ptr<char[]>  n = NULL;
+static eGoodBad GetDataFromDlgDSNCfg1 ( HWND hDlg, pODBCConn pConn )
+{
+    Long x;
+    std::unique_ptr <char[]> n = NULL;
     eGoodBad status;
-    
+
     // note
     // no error handling is currently being done for
     // GetDlgItemText/GetDlgItemInt/SetConnProp
     // generally should not be a problem
-    
+
     // precaution
-    if ( !pConn || !hDlg ) {
+    if ( !pConn || !hDlg )
+    {
         __ODBCPOPMSG ( _ODBCPopMsg ( "GetDataFromDlgDSNCfg1 - Bad params" ) );
         return BAD;
     }
-    
+
     ////// server name/IP
     // get length of input text
     x = SendDlgItemMessage ( hDlg, IDC_SERVER, EM_LINELENGTH, 0, 0 );
-    
-    if ( x > 0 ) {
-        n = make_unique_str ( x + 8 );								// allocate space for holding the text
-
-		char serverStrBuf[256];						  
-        GetDlgItemText ( hDlg, IDC_SERVER, serverStrBuf, x + 1 );      // get text from dialog
-
-		HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
-		int ItemIndex = SendMessage ( hwndCombo, ( UINT ) CB_GETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
-		
-		strcpy ( n.get(), supportedProtocols[ItemIndex] );
-		strcat ( n.get(), PROTOCOL_SEP );
-		strcat ( n.get(), serverStrBuf );
+
+    if ( x > 0 )
+    {
+        n = make_unique_str ( x + 8 ); // allocate space for holding the text
+
+        char serverStrBuf[256];
+        GetDlgItemText ( hDlg, IDC_SERVER, serverStrBuf, x + 1 ); // get text from dialog
+
+        HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
+        int ItemIndex = SendMessage ( hwndCombo, ( UINT ) CB_GETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
+
+        strcpy ( n . get (), supportedProtocols[ItemIndex] );
+        strcat ( n . get (), PROTOCOL_SEP );
+        strcat ( n . get (), serverStrBuf );
     }
-    
+
     else
-    { n = NULL; }                                           // no input
-    
+    {
+        n = NULL;
+    } // no input
+
     // set value in struct
-    status = SetConnProp ( pConn, CONN_PROP_SERVER, n.get() );
-    
-    if ( status == BAD ) { return BAD; }
-    
+    status = SetConnProp ( pConn, CONN_PROP_SERVER, n . get () );
+
+    if ( status == BAD )
+    {
+        return BAD;
+    }
+
     /////  Port
     // get value
     x = GetDlgItemInt ( hDlg, IDC_PORT, NULL, FALSE );
     // set value in struct
     status = SetConnProp ( pConn, CONN_PROP_PORT, &x );
-    
-    if ( status == BAD ) { return BAD; }
-    
+
+    if ( status == BAD )
+    {
+        return BAD;
+    }
+
     ////// User name
     // get length
     x = SendDlgItemMessage ( hDlg, IDC_UID, EM_LINELENGTH, 0, 0 );
-    
-    if ( x > 0 ) {
+
+    if ( x > 0 )
+    {
         // allocate space
-        n = make_unique_str ( x );                              // allocate space for holding the text
-        GetDlgItemText ( hDlg, IDC_UID, n.get(), x + 1 );
+        n = make_unique_str ( x ); // allocate space for holding the text
+        GetDlgItemText ( hDlg, IDC_UID, n . get (), x + 1 );
     }
-    
+
     else
-    { n = NULL; }
-    
+    {
+        n = NULL;
+    }
+
     // set value in struct
-    status = SetConnProp ( pConn, CONN_PROP_UID, n.get() );
-    
-    if ( status == BAD ) { return BAD; }
-    
+    status = SetConnProp ( pConn, CONN_PROP_UID, n . get () );
+
+    if ( status == BAD )
+    {
+        return BAD;
+    }
+
     ////// Password
     // get length
     x = SendDlgItemMessage ( hDlg, IDC_PWD, EM_LINELENGTH, 0, 0 );
-    
-    if ( x > 0 ) {
+
+    if ( x > 0 )
+    {
         // allocate space
-        n = make_unique_str ( x );                              // allocate space for holding the text
-        GetDlgItemText ( hDlg, IDC_PWD, n.get(), x + 1 );
+        n = make_unique_str ( x ); // allocate space for holding the text
+        GetDlgItemText ( hDlg, IDC_PWD, n . get (), x + 1 );
     }
-    
+
     else
-    { n = NULL; }
-    
+    {
+        n = NULL;
+    }
+
     // set value in struct
-    status = SetConnProp ( pConn, CONN_PROP_PWD, n.get() );
-    
-    if ( status == BAD ) { return BAD; }
-    
+    status = SetConnProp ( pConn, CONN_PROP_PWD, n . get () );
+
+    if ( status == BAD )
+    {
+        return BAD;
+    }
+
     return GOOD;
 }
 
@@ -368,18 +443,21 @@ static eGoodBad GetDataFromDlgDSNCfg1 ( HWND hDlg, pODBCConn pConn ) {
 // call back for DSN config dialog 1
 // --------------------------------------------------------------------------
 
-INT_PTR CALLBACK DlgDSNCfg1Proc ( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
+INT_PTR CALLBACK DlgDSNCfg1Proc ( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
+{
     pODBCConn pgConn = NULL;
     eGoodBad status = GOOD;
     RETCODE ret = SQL_SUCCESS;
-    
-    switch ( uMsg ) {
-        case WM_INITDIALOG: {
-			// init protocol list
-			HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
-            SendMessage(hwndCombo, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)supportedProtocols[0]));
-			SendMessage(hwndCombo, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)supportedProtocols[1]));
-			SendMessage(hwndCombo, CB_SETCURSEL, 0, 0 );
+
+    switch ( uMsg )
+    {
+        case WM_INITDIALOG :
+        {
+            // init protocol list
+            HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
+            SendMessage ( hwndCombo, CB_ADDSTRING, 0, reinterpret_cast <LPARAM> ( ( LPCTSTR )supportedProtocols[0] ) );
+            SendMessage ( hwndCombo, CB_ADDSTRING, 0, reinterpret_cast <LPARAM> ( ( LPCTSTR )supportedProtocols[1] ) );
+            SendMessage ( hwndCombo, CB_SETCURSEL, 0, 0 );
 
             // store the structure for future use
             SetWindowLongPtr ( hDlg, DWLP_USER, lParam );
@@ -387,120 +465,136 @@ INT_PTR CALLBACK DlgDSNCfg1Proc ( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lP
             PutDataToDlgDSNCfg1 ( ( pODBCConn ) lParam, hDlg );
             // set focus automatically
             return TRUE;
-		}
-        case WM_COMMAND:
-            switch ( LOWORD ( wParam ) ) {
-				case IDC_PROTOCOL: {
-					switch ( HIWORD ( wParam ) ) {
-						case CBN_SELCHANGE: {
-							HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
-							int portIndex = SendMessage ( hwndCombo, ( UINT ) CB_GETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
-							if ( SetDlgItemText ( hDlg, IDC_PORT, defaultPorts[portIndex] ) ) { return TRUE; }
-
-							return FALSE;
-						}
-						default:
-							break;
-					}
-					break;
-				}
-
-                case IDC_CONNECT: {
-                        HWND hwndCombo = GetDlgItem ( hDlg, IDC_COMBO1 );
-                        HWND hwndOK = GetDlgItem ( hDlg, IDOK );
-                        // fetch all information from controls & feed to struct
-                        pgConn = ( pODBCConn ) GetWindowLongPtr ( hDlg, DWLP_USER );
-                        status = GetDataFromDlgDSNCfg1 ( hDlg, pgConn );
-                        
-                        if ( status == BAD ) {
-                            //Blank input, already popped message
-                            return FALSE;
-                        }
-                        
-                        ret = TryAuthenticate ( pgConn );
-                        
-                        if ( ret == SQL_ERROR ) {
-                            //validation of data & other prompts goes here
-                            __ODBCPopMsg ( "Username/Password not authorized, or server out of service." );
-                            return FALSE;
-                        }
-                        
-                        //passed verification
-                        EnableWindow ( hwndCombo, TRUE );
-                        
-                        try {
-                            std::vector<string> projects;
-                            restListProjects ( pgConn->Server, pgConn->ServerPort, pgConn->UserName, pgConn->Password, projects );
-                            
-							// reload project list
-							SendMessage ( hwndCombo, CB_RESETCONTENT, 0, 0 );
-                            for ( unsigned int i = 0 ; i < projects.size(); ++i ) {
-                                SendMessage ( hwndCombo, ( UINT ) CB_ADDSTRING, ( WPARAM ) 0, ( LPARAM ) projects.at ( i ).c_str() );
+        }
+        case WM_COMMAND :
+            switch ( LOWORD ( wParam ) )
+            {
+                case IDC_PROTOCOL :
+                {
+                    switch ( HIWORD ( wParam ) )
+                    {
+                        case CBN_SELCHANGE :
+                        {
+                            HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
+                            int portIndex = SendMessage ( hwndCombo, ( UINT ) CB_GETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
+                            if ( SetDlgItemText ( hDlg, IDC_PORT, defaultPorts[portIndex] ) )
+                            {
+                                return TRUE;
                             }
-                            
-                            SendMessage ( hwndCombo, CB_SETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
-                        }
-                        
-                        catch ( exception& e ) {
-                            __ODBCPopMsg ( e.what() );
+
                             return FALSE;
                         }
-                        
-                        EnableWindow ( hwndOK, TRUE );
-                        return TRUE;
+                        default :
+                            break;
                     }
-                    
-                case IDOK: {
-                        pgConn = ( pODBCConn ) GetWindowLongPtr ( hDlg, DWLP_USER );
-                        HWND hwndCombo = GetDlgItem ( hDlg, IDC_COMBO1 );
-                        int ItemIndex = SendMessage ( ( HWND ) hwndCombo, ( UINT ) CB_GETCURSEL,
-                                                      ( WPARAM ) 0, ( LPARAM ) 0 );
-                        TCHAR  projectName[256];
-                        ( TCHAR ) SendMessage ( ( HWND ) hwndCombo, ( UINT ) CB_GETLBTEXT,
-                                                ( WPARAM ) ItemIndex, ( LPARAM ) projectName );
-                        SetConnProp ( pgConn, CONN_PROP_PROJECT, projectName );
-                        //last trial with project given
-                        ret = TryFetchMetadata ( pgConn );
-                        
-                        if ( ret == SQL_ERROR ) {
-                            //validation of data & other prompts goes here
-                            __ODBCPopMsg ( "Something went wrong with your selected project" );
-                            return FALSE;
+                    break;
+                }
+
+                case IDC_CONNECT :
+                {
+                    HWND hwndCombo = GetDlgItem ( hDlg, IDC_COMBO1 );
+                    HWND hwndOK = GetDlgItem ( hDlg, IDOK );
+                    // fetch all information from controls & feed to struct
+                    pgConn = ( pODBCConn ) GetWindowLongPtr ( hDlg, DWLP_USER );
+                    status = GetDataFromDlgDSNCfg1 ( hDlg, pgConn );
+
+                    if ( status == BAD )
+                    {
+                        //Blank input, already popped message
+                        return FALSE;
+                    }
+
+                    ret = TryAuthenticate ( pgConn );
+
+                    if ( ret == SQL_ERROR )
+                    {
+                        //validation of data & other prompts goes here
+                        __ODBCPopMsg ( "Username/Password not authorized, or server out of service." );
+                        return FALSE;
+                    }
+
+                    //passed verification
+                    EnableWindow ( hwndCombo, TRUE );
+
+                    try
+                    {
+                        std::vector <string> projects;
+                        restListProjects ( pgConn -> Server, pgConn -> ServerPort, pgConn -> UserName, pgConn -> Password, projects );
+
+                        // reload project list
+                        SendMessage ( hwndCombo, CB_RESETCONTENT, 0, 0 );
+                        for ( unsigned int i = 0; i < projects . size (); ++i )
+                        {
+                            SendMessage ( hwndCombo, ( UINT ) CB_ADDSTRING, ( WPARAM ) 0, ( LPARAM ) projects . at ( i ) . c_str () );
                         }
-                        
-                        EndDialog ( hDlg, wParam );
-                        return TRUE;
+
+                        SendMessage ( hwndCombo, CB_SETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
                     }
-                    
-                // Fall through, do not break or return
-                case IDCANCEL:
+
+                    catch ( exception& e )
+                    {
+                        __ODBCPopMsg ( e . what () );
+                        return FALSE;
+                    }
+
+                    EnableWindow ( hwndOK, TRUE );
+                    return TRUE;
+                }
+
+                case IDOK :
+                {
+                    pgConn = ( pODBCConn ) GetWindowLongPtr ( hDlg, DWLP_USER );
+                    HWND hwndCombo = GetDlgItem ( hDlg, IDC_COMBO1 );
+                    int ItemIndex = SendMessage ( ( HWND ) hwndCombo, ( UINT ) CB_GETCURSEL,
+                                                  ( WPARAM ) 0, ( LPARAM ) 0 );
+                    TCHAR projectName[256];
+                    ( TCHAR ) SendMessage ( ( HWND ) hwndCombo, ( UINT ) CB_GETLBTEXT,
+                                            ( WPARAM ) ItemIndex, ( LPARAM ) projectName );
+                    SetConnProp ( pgConn, CONN_PROP_PROJECT, projectName );
+                    //last trial with project given
+                    ret = TryFetchMetadata ( pgConn );
+
+                    if ( ret == SQL_ERROR )
+                    {
+                        //validation of data & other prompts goes here
+                        __ODBCPopMsg ( "Something went wrong with your selected project" );
+                        return FALSE;
+                    }
+
+                    EndDialog ( hDlg, wParam );
+                    return TRUE;
+                }
+
+                    // Fall through, do not break or return
+                case IDCANCEL :
                     // indicate end with control id as return value
                     EndDialog ( hDlg, wParam );
                     return TRUE;
             }
     }
-    
+
     return FALSE;
 }
 
 
-
 // -----------------------------------------------------------------------
 // to get connection info from user
 // -----------------------------------------------------------------------
 
-static Word PromptForConnInfo ( SQLHDBC pConn ) {
-    int     i;
+static Word PromptForConnInfo ( SQLHDBC pConn )
+{
+    int i;
     // invoke dialog to fetch info
     i = DialogBoxParam ( ghInstDLL, MAKEINTRESOURCE ( IDD_DSN_CFG1 ), NULL, DlgDSNCfg1Proc, ( LPARAM ) pConn );
-    
+
     // check status
-    switch ( i ) {
-        case IDOK:
-            return 1;           // complete
-            
-        default:
-            return 0;           // user-cancelled
+    switch ( i )
+    {
+        case IDOK :
+            return 1; // complete
+
+        default :
+            return 0; // user-cancelled
     }
 }
 
@@ -509,109 +603,129 @@ static Word PromptForConnInfo ( SQLHDBC pConn ) {
 // to split a given string into key value pairs separated with semi-colon
 // -----------------------------------------------------------------------
 
-eGoodBad CvtStrToKeyValues ( CStrPtr pStr, Word pMaxLen, Word* pNumPair, struct ODBCKV** pKV ) {
-    bool    flgError;
-    Word    x;
-    Word    pairs;
-    Word    i, len;
-    struct ODBCKV*    kvtemp;
-    struct ODBCKV*    kv;
+eGoodBad CvtStrToKeyValues ( CStrPtr pStr, Word pMaxLen, Word* pNumPair, struct ODBCKV** pKV )
+{
+    bool flgError;
+    Word x;
+    Word pairs;
+    Word i, len;
+    struct ODBCKV* kvtemp;
+    struct ODBCKV* kv;
     // caller safe
-    *pNumPair   = 0;
-    *pKV        = NULL;
+    *pNumPair = 0;
+    *pKV = NULL;
     // local initializations
-    kvtemp  = NULL;
-    kv      = NULL;
-    
+    kvtemp = NULL;
+    kv = NULL;
+
     // main loop to split the strings into key values
-    for ( pairs = 0, i = 0, len = ( pMaxLen > 0 ) ? pMaxLen : strlen ( pStr ), flgError = FALSE; i < len &&
-            !flgError; pairs ++ ) {
+    for ( pairs = 0 , i = 0 , len = ( pMaxLen > 0 ) ? pMaxLen : strlen ( pStr ) , flgError = FALSE; i < len &&
+          !flgError; pairs ++ )
+    {
         // find the length of key
-        for ( x = 0; pStr[i] != '=' && i < len; x ++, i ++ );
-        
+        for ( x = 0; pStr[i] != '=' && i < len; x ++ , i ++ );
+
         // check if a valid key found
-        if ( x <= 0 ) {
-            flgError = TRUE;                // error condition
+        if ( x <= 0 )
+        {
+            flgError = TRUE; // error condition
             continue;
         }
-        
+
         // allocate a new record ie key-value if required
-        if ( kv == NULL || pairs % KV_BLOCK_SIZE == 0 ) {
+        if ( kv == NULL || pairs % KV_BLOCK_SIZE == 0 )
+        {
             // allocate more records
-            kvtemp = new struct ODBCKV[pairs + KV_BLOCK_SIZE];
-            memset ( kvtemp, 0, sizeof ( struct ODBCKV ) * ( pairs + KV_BLOCK_SIZE ) );
-            
+            kvtemp = new struct ODBCKV[pairs + KV_BLOCK_SIZE ];
+            memset ( kvtemp, 0, sizeof ( struct ODBCKV) * ( pairs + KV_BLOCK_SIZE ) );
+
             // transfer the old ones into this new one
-            if ( kv ) {
-                memcpy ( kvtemp, kv, sizeof ( struct ODBCKV ) *pairs );
+            if ( kv )
+            {
+                memcpy ( kvtemp, kv, sizeof ( struct ODBCKV) * pairs );
                 delete[] kv;
                 kv = NULL;
             }
-            
+
             // now start using the new one
-            kv      = kvtemp;
-            kvtemp  = NULL;
+            kv = kvtemp;
+            kvtemp = NULL;
         }
-        
+
         // create key in current row
-        kv[pairs].key = new Char[x + 1];
+        kv[pairs] . key = new Char[x + 1];
         // put key
-        strncpy ( kv[pairs].key, pStr + ( i - x ), x );
-        kv[pairs].key[x] = 0;
+        strncpy ( kv[pairs] . key, pStr + ( i - x ), x );
+        kv[pairs] . key[x] = 0;
         // move ahead to ignore equals sign
         ++ i;
-        
+
         // find the length of value
-        if ( strcmp ( kv[pairs].key, "PWD" ) != 0 ) {
-            for ( x = 0;  pStr[i] != ';' && i < len; x ++, i ++ ) ;
+        if ( strcmp ( kv[pairs] . key, "PWD" ) != 0 )
+        {
+            for ( x = 0; pStr[i] != ';' && i < len; x ++ , i ++ );
         }
-        
-        else {
+
+        else
+        {
             //There may exist ; in PWD
-            for ( x = 0;  i < len; x ++, i ++ ) {
+            for ( x = 0; i < len; x ++ , i ++ )
+            {
                 if ( strnicmp ( &pStr[i], ";SERVER=", 8 ) == 0 )
-                { break; }
+                {
+                    break;
+                }
             }
         }
-        
+
         // check if a non-empty value found
-        if ( x > 0 ) {
+        if ( x > 0 )
+        {
             // create value in current row
-            kv[pairs].value = new Char[x + 1];
+            kv[pairs] . value = new Char[x + 1];
             // put value
-            strncpy ( kv[pairs].value, pStr + ( i - x ), x );
-            kv[pairs].value[x] = 0;
+            strncpy ( kv[pairs] . value, pStr + ( i - x ), x );
+            kv[pairs] . value[x] = 0;
         }
-        
+
         // move ahead to ignore the semi-colon at end of key-value
         ++ i;
     }
-    
+
     // check for error condition
-    if ( flgError ) {
+    if ( flgError )
+    {
         // clean up
-        if ( kv ) {
+        if ( kv )
+        {
             delete[] kv;
             kv = NULL;
         }
-        
-        return BAD;                // error condition
+
+        return BAD; // error condition
     }
-    
-    else {
-        *pNumPair   = pairs;
-        *pKV        = kv;
+
+    else
+    {
+        *pNumPair = pairs;
+        *pKV = kv;
         return GOOD;
     }
 }
 
-void        FreeGenODBCKeyValues ( ODBCKV* keyvalues, int pairs ) {
-    for ( int i = 0 ; i < pairs; ++i ) {
-        if ( keyvalues[i].key )
-        { delete[] keyvalues[i].key ; }
-        
-        if ( keyvalues[i].value )
-        { delete[] keyvalues[i].value; }
+void FreeGenODBCKeyValues ( ODBCKV* keyvalues, int pairs )
+{
+    for ( int i = 0; i < pairs; ++i )
+    {
+        if ( keyvalues[i] . key )
+        {
+            delete[] keyvalues[i] . key ;
+        }
+
+        if ( keyvalues[i] . value )
+        {
+            delete[] keyvalues[i] . value;
+        }
     }
 }
 
@@ -620,30 +734,41 @@ void        FreeGenODBCKeyValues ( ODBCKV* keyvalues, int pairs ) {
 // to find a particular key and/or value in key-value pair list
 // -----------------------------------------------------------------------
 
-bool FindInKeyValues ( CStrPtr pKey, CStrPtr pValue, struct ODBCKV* pKV, Word pItems, Word* pPosition ) {
-    Word    i;
-    bool    flgMatch;
-    
+bool FindInKeyValues ( CStrPtr pKey, CStrPtr pValue, struct ODBCKV* pKV, Word pItems, Word* pPosition )
+{
+    Word i;
+    bool flgMatch;
+
     // loop to traverse the list
-    for ( i = 0, flgMatch = FALSE; i < pItems; i ++ ) {
+    for ( i = 0 , flgMatch = FALSE; i < pItems; i ++ )
+    {
         // match key
-        flgMatch = ( pKey && _stricmp ( pKey, pKV[i].key ) == 0 );
-        
+        flgMatch = ( pKey && _stricmp ( pKey, pKV[i] . key ) == 0 );
+
         // match value
-        if ( pValue && pKV[i].value )
-        { flgMatch = ( _stricmp ( pValue, pKV[i].value ) == 0 ); }
-        
+        if ( pValue && pKV[i] . value )
+        {
+            flgMatch = ( _stricmp ( pValue, pKV[i] . value ) == 0 );
+        }
+
         // break if match
-        if ( flgMatch ) { break; }
+        if ( flgMatch )
+        {
+            break;
+        }
     }
-    
+
     // check if found
-    if ( flgMatch ) {
-        if ( pPosition )  { *pPosition = i; }
-        
+    if ( flgMatch )
+    {
+        if ( pPosition )
+        {
+            *pPosition = i;
+        }
+
         return TRUE;
     }
-    
+
     return FALSE;
 }
 
@@ -653,7 +778,8 @@ bool FindInKeyValues ( CStrPtr pKey, CStrPtr pValue, struct ODBCKV* pKV, Word pI
 // -----------------------------------------------------------------------
 
 static eGoodBad LoadKeyValuesfromFileDSN ( pODBCConn pConn, CStrPtr pDSNName, Word* pNumPair,
-                                           struct ODBCKV** pKV ) {
+                                           struct ODBCKV** pKV )
+{
     //Never called
     throw - 1;
 }
@@ -663,30 +789,36 @@ static eGoodBad LoadKeyValuesfromFileDSN ( pODBCConn pConn, CStrPtr pDSNName, Wo
 // to add a key-value pair to specified conn string
 // -----------------------------------------------------------------------
 
-static bool AddKVToConnStr ( StrPtr pKey, StrPtr pValue, Word* iPos, StrPtr pStrConn, Word pMaxLen ) {
-    Word    i, j;
-    
+static bool AddKVToConnStr ( StrPtr pKey, StrPtr pValue, Word* iPos, StrPtr pStrConn, Word pMaxLen )
+{
+    Word i, j;
+
     // precaution
     if ( !pKey )
-    { return FALSE; }
-    
+    {
+        return FALSE;
+    }
+
     // get length of key and value
     i = strlen ( pKey );
     j = ( pValue ) ? strlen ( pValue ) : 0;
-    
+
     // check if both can be added along with equal sign & semi-colon
-    if ( *iPos + i + j + 2 <= pMaxLen ) {
+    if ( *iPos + i + j + 2 <= pMaxLen )
+    {
         strcat ( pStrConn, pKey );
         strcat ( pStrConn, "=" );
-        
+
         if ( pValue )
-        { strcat ( pStrConn, pValue ); }
-        
+        {
+            strcat ( pStrConn, pValue );
+        }
+
         strcat ( pStrConn, ";" );
-        ( *iPos ) = ( *iPos ) + i + j + 2;  // re-position
+        ( *iPos ) = ( *iPos ) + i + j + 2; // re-position
         return TRUE;
     }
-    
+
     return FALSE;
 }
 
@@ -696,321 +828,384 @@ static bool AddKVToConnStr ( StrPtr pKey, StrPtr pValue, Word* iPos, StrPtr pStr
 // -----------------------------------------------------------------------
 
 static bool BuildConnStr ( char* pStrConn, Word pMaxLen, pODBCConn pConn, struct ODBCKV* KVInput,
-                           Word iKVInputPairs, struct ODBCKV* KVFileDSN, Word iKVFileDSNPairs ) {
-    Word    iPos = 0;
-    Char    p[32];                              // arbitary for string port number as string
+                           Word iKVInputPairs, struct ODBCKV* KVFileDSN, Word iKVFileDSNPairs )
+{
+    Word iPos = 0;
+    Char p[32]; // arbitary for string port number as string
     // initializations
     memset ( pStrConn, 0, pMaxLen );
     // convert port number to string
-    _itoa ( pConn->ServerPort, p, 10 );
-    
+    _itoa ( pConn -> ServerPort, p, 10 );
+
     // transfer all strings from struct
-    if ( !AddKVToConnStr ( "DRIVER", "{KylinODBCDriver}", &iPos, pStrConn, pMaxLen ) ) {
+    if ( !AddKVToConnStr ( "DRIVER", "{KylinODBCDriver}", &iPos, pStrConn, pMaxLen ) )
+    {
         __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "AddKVToConnStr failed in %s", "Driver" ) );
         return FALSE;
     }
-    
-    if ( !AddKVToConnStr ( "SERVER", pConn->Server, &iPos, pStrConn, pMaxLen ) ) {
+
+    if ( !AddKVToConnStr ( "SERVER", pConn -> Server, &iPos, pStrConn, pMaxLen ) )
+    {
         __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "AddKVToConnStr failed in %s", "Server" ) );
         return FALSE;
     }
-    
-    if ( !AddKVToConnStr ( "PROJECT", pConn->Project, &iPos, pStrConn, pMaxLen ) ) {
+
+    if ( !AddKVToConnStr ( "PROJECT", pConn -> Project, &iPos, pStrConn, pMaxLen ) )
+    {
         __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "AddKVToConnStr failed in %s", "Project" ) );
         return FALSE;
     }
-    
-    if ( !AddKVToConnStr ( "PORT", p, &iPos, pStrConn, pMaxLen ) ) {
+
+    if ( !AddKVToConnStr ( "PORT", p, &iPos, pStrConn, pMaxLen ) )
+    {
         __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "AddKVToConnStr failed in %s", "Port" ) );
         return FALSE;
     }
-    
-    if ( !AddKVToConnStr ( "UID", pConn->UserName, &iPos, pStrConn, pMaxLen ) ) {
+
+    if ( !AddKVToConnStr ( "UID", pConn -> UserName, &iPos, pStrConn, pMaxLen ) )
+    {
         __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "AddKVToConnStr failed in %s", "Uid" ) );
         return FALSE;
     }
-    
-    if ( !AddKVToConnStr ( "PWD", pConn->Password, &iPos, pStrConn, pMaxLen ) ) {
+
+    if ( !AddKVToConnStr ( "PWD", pConn -> Password, &iPos, pStrConn, pMaxLen ) )
+    {
         __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "AddKVToConnStr failed in %s", "Pwd" ) );
         return FALSE;
     }
-    
+
     return TRUE;
 }
 
 // -----------------------------------------------------------------------
 // to connect to the driver
 // -----------------------------------------------------------------------
-RETCODE SQL_API SQLDriverConnectW ( SQLHDBC            hdbc,
-                                    SQLHWND             hwnd,
-                                    SQLWCHAR*           szConnStrIn,
-                                    SQLSMALLINT         cchConnStrIn,
-                                    SQLWCHAR*           szConnStrOut,
-                                    SQLSMALLINT         cchConnStrOutMax,
-                                    SQLSMALLINT*        pcchConnStrOut,
-                                    SQLUSMALLINT        fDriverCompletion ) {
+RETCODE SQL_API SQLDriverConnectW ( SQLHDBC hdbc,
+                                    SQLHWND hwnd,
+                                    SQLWCHAR* szConnStrIn,
+                                    SQLSMALLINT cchConnStrIn,
+                                    SQLWCHAR* szConnStrOut,
+                                    SQLSMALLINT cchConnStrOutMax,
+                                    SQLSMALLINT* pcchConnStrOut,
+                                    SQLUSMALLINT fDriverCompletion )
+{
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLDriverConnectW called, cchConnStrIn %d, cchConnStrOutMax %d, wcslen %d",
-                              cchConnStrIn, cchConnStrOutMax, wcslen ( szConnStrIn ) ) );
+        cchConnStrIn, cchConnStrOutMax, wcslen ( szConnStrIn ) ) );
     int inStrLength = wcslen ( szConnStrIn ) + 1;
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The inStr Length is : %d", inStrLength ) );
-    unique_ptr<char[]> pInStr ( new char[inStrLength] );
-    unique_ptr<char[]> pOutStr ( new char[cchConnStrOutMax + 1] );
-    wchar2char ( szConnStrIn, pInStr.get(), inStrLength );
+    unique_ptr <char[]> pInStr ( new char[inStrLength] );
+    unique_ptr <char[]> pOutStr ( new char[cchConnStrOutMax + 1] );
+    wchar2char ( szConnStrIn, pInStr . get (), inStrLength );
     //__ODBCLOG(_ODBCLogMsg(LogLevel_DEBUG,"The inStr is : %s",pInStr.get()));
-    SQLSMALLINT outStrLength = 0 ;
-    RETCODE code = SQLDriverConnect ( hdbc, hwnd, ( SQLCHAR* ) pInStr.get(), cchConnStrIn, ( SQLCHAR* ) pOutStr.get(),
+    SQLSMALLINT outStrLength = 0;
+    RETCODE code = SQLDriverConnect ( hdbc, hwnd, ( SQLCHAR* ) pInStr . get (), cchConnStrIn, ( SQLCHAR* ) pOutStr . get (),
                                       cchConnStrOutMax, &outStrLength, fDriverCompletion );
-                                      
-    if ( code == SQL_ERROR ) {
+
+    if ( code == SQL_ERROR )
+    {
         return code;
     }
-    
+
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "pcchConnStrOut null? %d, cchConnStrOutMax > 0 ? %d, szConnStrOut null? %d",
-                              pcchConnStrOut == NULL, cchConnStrOutMax > 0 , szConnStrOut == NULL ) );
-                              
-    if ( cchConnStrOutMax > 0 && pcchConnStrOut && szConnStrOut ) {
-        char2wchar ( pOutStr.get(), szConnStrOut, ( int ) cchConnStrOutMax );
+        pcchConnStrOut == NULL, cchConnStrOutMax > 0 , szConnStrOut == NULL ) );
+
+    if ( cchConnStrOutMax > 0 && pcchConnStrOut && szConnStrOut )
+    {
+        char2wchar ( pOutStr . get (), szConnStrOut, ( int ) cchConnStrOutMax );
         *pcchConnStrOut = wcslen ( szConnStrOut );
         __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "(W)The Length of Out Conn Str is %d", *pcchConnStrOut ) );
     }
-    
+
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "the ret code is %d", code ) );
     return code;
 }
 
-RETCODE SQL_API SQLDriverConnect ( SQLHDBC         pConn,
-                                   SQLHWND         pWndHandle,
-                                   SQLCHAR*        pInConnStr,
-                                   SQLSMALLINT     pInConnStrLen,
-                                   SQLCHAR*        pOutConnStr,
-                                   SQLSMALLINT     pOutConnStrLen,
-                                   SQLSMALLINT*    pOutConnStrLenPtr,
-                                   SQLUSMALLINT    pDriverCompletion ) {
+RETCODE SQL_API SQLDriverConnect ( SQLHDBC pConn,
+                                   SQLHWND pWndHandle,
+                                   SQLCHAR* pInConnStr,
+                                   SQLSMALLINT pInConnStrLen,
+                                   SQLCHAR* pOutConnStr,
+                                   SQLSMALLINT pOutConnStrLen,
+                                   SQLSMALLINT* pOutConnStrLenPtr,
+                                   SQLUSMALLINT pDriverCompletion )
+{
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The window handle is %d, the driver completion flag is %d", pWndHandle,
-                              pDriverCompletion ) );
+        pDriverCompletion ) );
     pODBCConn pgConn = ( pODBCConn ) pConn;
-    bool    f;
-    bool    flgDriver, flgDSN;                                  // flags for knowing if these key present in string
-    bool    flgServer, flgPort, flgUID, flgPWD, flgProj;         // flags for knowing if these key present in string
-    Word    i, n;
-    Word    iKVInputPairs;             // no of key value pairs as input
-    Word    iDriverPos, iDSNPos;                    // ??? can be eliminated by optimization of code
-    Word    iServerPos, iPortPos, iUIDPos, iPWDPos, iProjPos;     // ??? can be eliminated by optimization of code
-    struct ODBCKV* KVInput;                    // key value as input via  function param
-    struct ODBCKV* KV;                         // generic, temp
-    
-    if ( !pInConnStr ) {
+    bool f;
+    bool flgDriver, flgDSN; // flags for knowing if these key present in string
+    bool flgServer, flgPort, flgUID, flgPWD, flgProj; // flags for knowing if these key present in string
+    Word i, n;
+    Word iKVInputPairs; // no of key value pairs as input
+    Word iDriverPos, iDSNPos; // ??? can be eliminated by optimization of code
+    Word iServerPos, iPortPos, iUIDPos, iPWDPos, iProjPos; // ??? can be eliminated by optimization of code
+    struct ODBCKV* KVInput; // key value as input via  function param
+    struct ODBCKV* KV; // generic, temp
+
+    if ( !pInConnStr )
+    {
         __ODBCPOPMSG ( _ODBCPopMsg ( "SQLDriverConnect: pInConnStr is required" ) );
         return SQL_ERROR;
     }
-    
-    else {
+
+    else
+    {
         //__ODBCLOG(_ODBCLogMsg(LogLevel_DEBUG,"The passed-in Connection Str is %s",(char*)pInConnStr));
     }
-    
+
     __CHK_HANDLE ( pConn, SQL_HANDLE_DBC, SQL_ERROR );
     _SQLFreeDiag ( _DIAGCONN ( pConn ) );
-    
+
     // caller safe
-    if ( pOutConnStr ) { *pOutConnStr = 0; }
-    
-    if ( pOutConnStrLenPtr ) { *pOutConnStrLenPtr = 0; }
-    
+    if ( pOutConnStr )
+    {
+        *pOutConnStr = 0;
+    }
+
+    if ( pOutConnStrLenPtr )
+    {
+        *pOutConnStrLenPtr = 0;
+    }
+
     // initializations
-    KVInput     = NULL;
-    flgServer   = FALSE;
-    flgPort     = FALSE;
-    flgUID      = FALSE;
-    flgPWD      = FALSE;
-    flgProj     = FALSE;
-    
+    KVInput = NULL;
+    flgServer = FALSE;
+    flgPort = FALSE;
+    flgUID = FALSE;
+    flgPWD = FALSE;
+    flgProj = FALSE;
+
     // check if an in-string has been specified
-    if ( pInConnStr ) {
+    if ( pInConnStr )
+    {
         __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "Parsing the in str" ) );
-        
+
         // split into key-value pairs
-        if ( CvtStrToKeyValues ( ( StrPtr ) pInConnStr, pInConnStrLen, &iKVInputPairs, &KVInput ) != GOOD ) {
+        if ( CvtStrToKeyValues ( ( StrPtr ) pInConnStr, pInConnStrLen, &iKVInputPairs, &KVInput ) != GOOD )
+        {
             return SQL_ERROR;
         }
-        
+
         // first check if dsn keyword is present
         flgDSN = FindInKeyValues ( "DSN", NULL, KVInput, iKVInputPairs, &iDSNPos );
         // look for driver only if DSN is absent else Driver is always ignored
         flgDriver = ( flgDSN ) ? FALSE : FindInKeyValues ( "DRIVER", NULL, KVInput, iKVInputPairs, &iDriverPos );
-        
+
         // if DSN is to be used, fetch its set of key values
-        if ( flgDSN ) {
+        if ( flgDSN )
+        {
             __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The in str is a dsn string" ) );
             //connect by dsn
             SetCurrentDSN ( ( char* ) pInConnStr, "SQLDriverConnect" );
-            
-            if ( LoadODBCINIDataToConn ( pgConn ) != GOOD ) {
+
+            if ( LoadODBCINIDataToConn ( pgConn ) != GOOD )
+            {
                 return SQL_ERROR;
             }
         }
-        
-        else if ( flgDriver ) {
+
+        else if ( flgDriver )
+        {
             __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The in str is a driver string" ) );
             /************* debug
                 for (  i = 0, n = iKVInputPairs, KV = KVInput; i < n; i++ )
                 fprintf ( stderr, "Index: %d, Key: %s, Value: %s\n", i, KV[i].key ? KV[i].key : "(nokey)", KV[i].value ? KV[i].value : "(no value)" );
             *********/
-            
+
             // loop to parse both input key-values and DSN key-values & feed into struct
-            for ( i = 0, n = iKVInputPairs, KV = KVInput; i < n; i++ ) {
-                if ( !flgServer ) {
+            for ( i = 0 , n = iKVInputPairs , KV = KVInput; i < n; i++ )
+            {
+                if ( !flgServer )
+                {
                     flgServer = FindInKeyValues ( "SERVER", NULL, KV, n, &iServerPos );
-                    
-                    if ( flgServer ) { CreateAndSetConnProp ( ( pODBCConn ) pConn, CONN_PROP_SERVER, KV[iServerPos].value ); }
+
+                    if ( flgServer )
+                    {
+                        CreateAndSetConnProp ( ( pODBCConn ) pConn, CONN_PROP_SERVER, KV[iServerPos] . value );
+                    }
                 }
-                
-                if ( !flgPort ) {
+
+                if ( !flgPort )
+                {
                     flgPort = FindInKeyValues ( "PORT", NULL, KV, n, &iPortPos );
-                    
-                    if ( flgPort )  { CreateAndSetConnProp ( ( pODBCConn ) pConn, CONN_PROP_PORT, KV[iPortPos].value ); }
+
+                    if ( flgPort )
+                    {
+                        CreateAndSetConnProp ( ( pODBCConn ) pConn, CONN_PROP_PORT, KV[iPortPos] . value );
+                    }
                 }
-                
-                if ( !flgUID ) {
+
+                if ( !flgUID )
+                {
                     flgUID = FindInKeyValues ( "UID", NULL, KV, n, &iUIDPos );
-                    
-                    if ( flgUID ) {
-                        CreateAndSetConnProp ( ( pODBCConn ) pConn, CONN_PROP_UID, KV[iUIDPos].value );
+
+                    if ( flgUID )
+                    {
+                        CreateAndSetConnProp ( ( pODBCConn ) pConn, CONN_PROP_UID, KV[iUIDPos] . value );
                         __ODBCLOG ( _ODBCLogMsg ( LogLevel_INFO, "Log in as User : %s ", KV[iUIDPos].value ) );
                     }
                 }
-                
-                if ( !flgPWD ) {
+
+                if ( !flgPWD )
+                {
                     flgPWD = FindInKeyValues ( "PWD", NULL, KV, n, &iPWDPos );
-                    
-                    if ( flgPWD )  { CreateAndSetConnProp ( ( pODBCConn ) pConn, CONN_PROP_PWD, KV[iPWDPos].value ); }
+
+                    if ( flgPWD )
+                    {
+                        CreateAndSetConnProp ( ( pODBCConn ) pConn, CONN_PROP_PWD, KV[iPWDPos] . value );
+                    }
                 }
-                
-                if ( !flgProj ) {
+
+                if ( !flgProj )
+                {
                     flgProj = FindInKeyValues ( "PROJECT", NULL, KV, n, &iProjPos );
-                    
-                    if ( flgProj )  { CreateAndSetConnProp ( ( pODBCConn ) pConn, CONN_PROP_PROJECT, KV[iProjPos].value ); }
+
+                    if ( flgProj )
+                    {
+                        CreateAndSetConnProp ( ( pODBCConn ) pConn, CONN_PROP_PROJECT, KV[iProjPos] . value );
+                    }
                 }
             }
         }
-        
-        else {
+
+        else
+        {
             _SQLPutDiagRow ( SQL_HANDLE_DBC, pConn, "SQLDriverConnectW", "HY000", 1045, "Only DSN or driver connect is allowed" );
             __ODBCPOPMSG ( _ODBCPopMsg ( "Only DSN or driver connect is allowed, instead of %s", pInConnStr ) );
             return SQL_ERROR;
         }
-        
+
         FreeGenODBCKeyValues ( KVInput, iKVInputPairs );
         delete[] KVInput;
     }
-    
-    else if ( pDriverCompletion == SQL_DRIVER_NOPROMPT ) {  // check if no-prompt forced
+
+    else if ( pDriverCompletion == SQL_DRIVER_NOPROMPT )
+    { // check if no-prompt forced
         __ODBCPOPMSG ( _ODBCPopMsg ( "No connection string && no prompt specified" ) );
         _SQLPutDiagRow ( SQL_HANDLE_DBC, pConn, "SQLDriverConnectW", "HY000", 1045,
-                         "Access denied. (using UID: NO , using password: NO)" );
+                                       "Access denied. (using UID: NO , using password: NO)" );
         return SQL_ERROR;
     }
-    
+
     RETCODE ret;
-    
+
     // check if prompt required ie any info is missing
-    if ( flgDriver && ( !flgServer || !flgPort || !flgUID || !flgPWD || !flgProj ) ) {
+    if ( flgDriver && ( !flgServer || !flgPort || !flgUID || !flgPWD || !flgProj ) )
+    {
         __ODBCLOG ( _ODBCLogMsg ( LogLevel_INFO, "Connection info imcomplete, prompt for input..." ) );
-        
-        if ( flgUID && !flgPWD &&  pDriverCompletion == SQL_DRIVER_NOPROMPT ) {
+
+        if ( flgUID && !flgPWD && pDriverCompletion == SQL_DRIVER_NOPROMPT )
+        {
             _SQLPutDiagRow ( SQL_HANDLE_DBC, pConn, "SQLDriverConnectW", "HY000", 1045,
-                             "Access denied for user 'root'@'kylin-tableau-clean.com' (using password: NO)" );
+                                           "Access denied for user 'root'@'kylin-tableau-clean.com' (using password: NO)" );
             __ODBCLOG ( _ODBCLogMsg ( LogLevel_ERROR,
-                                      "UID present but PWD absent, guessing it's on Tableau Server, return SQL ERROR" ) );
+                "UID present but PWD absent, guessing it's on Tableau Server, return SQL ERROR" ) );
             return SQL_ERROR;
         }
-        
+
         //connect by driver
         // fetch entire connection information thru dialogs
-        switch ( PromptForConnInfo ( pConn ) ) {
-            case 0:         // user-cancelled
+        switch ( PromptForConnInfo ( pConn ) )
+        {
+            case 0 : // user-cancelled
                 return SQL_NO_DATA_FOUND;
-                
-            default:
+
+            default :
                 break;
         }
-        
+
         ret = SQL_SUCCESS;
     }
-    
-    else {
+
+    else
+    {
         ret = TryFetchMetadata ( pgConn ) ;
-        
-        if ( ret == SQL_ERROR ) {
+
+        if ( ret == SQL_ERROR )
+        {
             return ret;
         }
     }
-    
+
     // OUT CONN STRING
     // build the out-connection string if required
-    if ( pOutConnStr && pOutConnStrLen > 0 && pOutConnStrLenPtr ) {
-        if ( flgDriver ) {
+    if ( pOutConnStr && pOutConnStrLen > 0 && pOutConnStrLenPtr )
+    {
+        if ( flgDriver )
+        {
             __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "Building out str..." ) );
             // build the out conn string using key value pairs
             f = BuildConnStr ( ( StrPtr ) pOutConnStr, pOutConnStrLen, ( pODBCConn ) pConn, NULL, 0, NULL, 0 );
-            
-            if ( !f ) {
+
+            if ( !f )
+            {
                 _SQLPutDiagRow ( SQL_HANDLE_DBC, pConn, "SQLDriverConnectW", "HY000", 1045, "Out connection string not complete" );
             }
         }
-        
-        else {
+
+        else
+        {
             __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "Copy in str to out str" ) );
             strcpy ( ( char* ) pOutConnStr, ( char* ) pInConnStr );
         }
-        
+
         *pOutConnStrLenPtr = strlen ( ( StrPtr ) pOutConnStr );
         __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The Length of Out Conn Str is %d", *pOutConnStrLenPtr ) );
     }
-    
-    else {
+
+    else
+    {
         __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "skip writing to the out put string" ) );
     }
-    
+
     return ret;
 }
 
 
-RETCODE   TryFetchMetadata ( pODBCConn pgConn ) {
+RETCODE TryFetchMetadata ( pODBCConn pgConn )
+{
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "start loading metadata..." ) );
-    
-    try {
-        pgConn->meta = std::move ( restGetMeta ( pgConn->Server, pgConn->ServerPort, pgConn->UserName, pgConn->Password,
-                                                 pgConn->Project ) );
+
+    try
+    {
+        pgConn -> meta = std::move ( restGetMeta ( pgConn -> Server, pgConn -> ServerPort, pgConn -> UserName, pgConn -> Password,
+                                                   pgConn -> Project ) );
     }
-    
-    catch ( const exception& e ) {
+
+    catch ( const exception& e )
+    {
         __ODBCLOG ( _ODBCLogMsg ( LogLevel_ERROR, "The REST request failed to get metadata" ) );
         __ODBCLOG ( _ODBCLogMsg ( LogLevel_ERROR, e.what() ) );
         _SQLPutDiagRow ( SQL_HANDLE_DBC, pgConn, "SQLDriverConnect", "HY000", 1045, "Access denied. (using password: NO)" );
         return SQL_ERROR;
     }
-    
+
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "End loading metadata" ) );
     return SQL_SUCCESS;
 }
 
-RETCODE   TryAuthenticate ( pODBCConn pgConn ) {
+RETCODE TryAuthenticate ( pODBCConn pgConn )
+{
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "Start authenticating.." ) );
-    
-    try {
-        bool authenticated = restAuthenticate ( pgConn->Server, pgConn->ServerPort, pgConn->UserName, pgConn->Password );
-        
+
+    try
+    {
+        bool authenticated = restAuthenticate ( pgConn -> Server, pgConn -> ServerPort, pgConn -> UserName, pgConn -> Password );
+
         if ( !authenticated )
-        { throw exception ( "Username/Password incorrect." ); }
+        {
+            throw exception ( "Username/Password incorrect." );
+        }
     }
-    
-    catch ( const exception& e ) {
+
+    catch ( const exception& e )
+    {
         __ODBCLOG ( _ODBCLogMsg ( LogLevel_ERROR, "The REST request failed to authenticate." ) );
         __ODBCLOG ( _ODBCLogMsg ( LogLevel_ERROR, e.what() ) );
         _SQLPutDiagRow ( SQL_HANDLE_DBC, pgConn, "SQLDriverConnect", "HY000", 1045, "Access denied. (using password: NO)" );
         return SQL_ERROR;
     }
-    
+
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "End authenticating" ) );
     return SQL_SUCCESS;
 }
@@ -1019,13 +1214,14 @@ RETCODE   TryAuthenticate ( pODBCConn pgConn ) {
 // to connect to the server using standard parameters
 // -----------------------------------------------------------------------
 
-RETCODE SQL_API SQLConnect ( SQLHDBC     pConn,
-                             SQLCHAR*    pServerName,
+RETCODE SQL_API SQLConnect ( SQLHDBC pConn,
+                             SQLCHAR* pServerName,
                              SQLSMALLINT pServerNameLen,
-                             SQLCHAR*    pUserName,
+                             SQLCHAR* pUserName,
                              SQLSMALLINT pUserNameLen,
-                             SQLCHAR*    pPassword,
-                             SQLSMALLINT pPasswordLen ) {
+                             SQLCHAR* pPassword,
+                             SQLSMALLINT pPasswordLen )
+{
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLConnect called" ) );
     __CHK_HANDLE ( pConn, SQL_HANDLE_DBC, SQL_ERROR );
     __ODBCPOPMSG ( _ODBCPopMsg ( "SQLConnect - not implemented, use SQLDriverConnect" ) );
@@ -1034,14 +1230,15 @@ RETCODE SQL_API SQLConnect ( SQLHDBC     pConn,
     return ( SQL_SUCCESS );
 }
 
-SQLRETURN SQL_API SQLConnectW ( SQLHDBC             hdbc,
+SQLRETURN SQL_API SQLConnectW ( SQLHDBC hdbc,
                                 SQLWCHAR* szDSN,
-                                SQLSMALLINT         cchDSN,
+                                SQLSMALLINT cchDSN,
                                 SQLWCHAR* szUID,
-                                SQLSMALLINT         cchUID,
+                                SQLSMALLINT cchUID,
                                 SQLWCHAR* szAuthStr,
-                                SQLSMALLINT         cchAuthStr
-                              ) {
+                                SQLSMALLINT cchAuthStr
+)
+{
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLConnectW called" ) );
     __CHK_HANDLE ( hdbc, SQL_HANDLE_DBC, SQL_ERROR );
     __ODBCPOPMSG ( _ODBCPopMsg ( "SQLConnectW - not implemented, use SQLDriverConnectW" ) );
@@ -1051,18 +1248,19 @@ SQLRETURN SQL_API SQLConnectW ( SQLHDBC             hdbc,
 }
 
 
-
 // -----------------------------------------------------------------------
 // to connect in multiple iterations
 // -----------------------------------------------------------------------
 
-RETCODE SQL_API SQLBrowseConnect ( SQLHDBC         pConn,
-                                   SQLCHAR*        InConnectionString,
-                                   SQLSMALLINT     StringLength1,
-                                   SQLCHAR*        OutConnectionString,
-                                   SQLSMALLINT     BufferLength,
-                                   SQLSMALLINT*    StringLength2Ptr ) {
+RETCODE SQL_API SQLBrowseConnect ( SQLHDBC pConn,
+                                   SQLCHAR* InConnectionString,
+                                   SQLSMALLINT StringLength1,
+                                   SQLCHAR* OutConnectionString,
+                                   SQLSMALLINT BufferLength,
+                                   SQLSMALLINT* StringLength2Ptr )
+{
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLBrowseConnect called" ) );
     __ODBCPOPMSG ( _ODBCPopMsg ( "SQLBrowseConnect - not implemented, use SQLDriverConnect" ) );
     return SQL_ERROR;
-}
\ No newline at end of file
+}
+

http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Driver/KO_CTLG.CPP
----------------------------------------------------------------------
diff --git a/odbc/Driver/KO_CTLG.CPP b/odbc/Driver/KO_CTLG.CPP
index dc23551..7206ec1 100644
--- a/odbc/Driver/KO_CTLG.CPP
+++ b/odbc/Driver/KO_CTLG.CPP
@@ -15,8 +15,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- 
- 
+
+
 // ----------------------------------------------------------------------------
 //
 // File:    KO_CTLG.CPP
@@ -46,49 +46,51 @@
 #include "stdafx.h"
 
 
-
 // -----------------------------------------------------------------------
 // to get list of catalog(database), schema(users), tables(tables)
 // ------------------------------------------------------------------------
 
-RETCODE SQL_API SQLTablesW ( SQLHSTMT        pStmt,
-                             SQLWCHAR*        pCatalogName,
-                             SQLSMALLINT     pCatalogNameSize,
-                             SQLWCHAR*        pSchemaName,
-                             SQLSMALLINT     pSchemaNameSize,
-                             SQLWCHAR*        pTableName,
-                             SQLSMALLINT     pTableNameSize,
-                             SQLWCHAR*        pTableType,
-                             SQLSMALLINT     pTableTypeSize ) {
+RETCODE SQL_API SQLTablesW ( SQLHSTMT pStmt,
+                             SQLWCHAR* pCatalogName,
+                             SQLSMALLINT pCatalogNameSize,
+                             SQLWCHAR* pSchemaName,
+                             SQLSMALLINT pSchemaNameSize,
+                             SQLWCHAR* pTableName,
+                             SQLSMALLINT pTableNameSize,
+                             SQLWCHAR* pTableType,
+                             SQLSMALLINT pTableTypeSize )
+{
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLTablesW is called " ) );
-    unique_ptr<char[]> p1 ( wchar2char ( pCatalogName ) );
-    unique_ptr<char[]> p2 ( wchar2char ( pSchemaName ) );
-    unique_ptr<char[]> p3 ( wchar2char ( pTableName ) );
-    unique_ptr<char[]> p4 ( wchar2char ( pTableType ) );
-    return SQLTables ( pStmt, ( SQLCHAR* )  p1.get(), pCatalogNameSize, ( SQLCHAR* ) p2.get(), pSchemaNameSize,
-                       ( SQLCHAR* )  p3.get(), pTableNameSize, ( SQLCHAR* ) p4.get(), pTableTypeSize );
+    unique_ptr <char[]> p1 ( wchar2char ( pCatalogName ) );
+    unique_ptr <char[]> p2 ( wchar2char ( pSchemaName ) );
+    unique_ptr <char[]> p3 ( wchar2char ( pTableName ) );
+    unique_ptr <char[]> p4 ( wchar2char ( pTableType ) );
+    return SQLTables ( pStmt, ( SQLCHAR* ) p1 . get (), pCatalogNameSize, ( SQLCHAR* ) p2 . get (), pSchemaNameSize,
+                       ( SQLCHAR* ) p3 . get (), pTableNameSize, ( SQLCHAR* ) p4 . get (), pTableTypeSize );
 }
 
-RETCODE SQL_API SQLTables ( SQLHSTMT        pStmt,
-                            SQLCHAR*        pCatalogName,
-                            SQLSMALLINT     pCatalogNameSize,
-                            SQLCHAR*        pSchemaName,
-                            SQLSMALLINT     pSchemaNameSize,
-                            SQLCHAR*        pTableName,
-                            SQLSMALLINT     pTableNameSize,
-                            SQLCHAR*        pTableType,
-                            SQLSMALLINT     pTableTypeSize ) {
+RETCODE SQL_API SQLTables ( SQLHSTMT pStmt,
+                            SQLCHAR* pCatalogName,
+                            SQLSMALLINT pCatalogNameSize,
+                            SQLCHAR* pSchemaName,
+                            SQLSMALLINT pSchemaNameSize,
+                            SQLCHAR* pTableName,
+                            SQLSMALLINT pTableNameSize,
+                            SQLCHAR* pTableType,
+                            SQLSMALLINT pTableTypeSize )
+{
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLTables: Ctlg: %s, %d, Schema: %s, %d, Table: %s,%d, Type: %s, %d",
-                              pCatalogName, pCatalogNameSize, pSchemaName, pSchemaNameSize, pTableName, pTableNameSize, pTableType,
-                              pTableTypeSize ) );
+        pCatalogName, pCatalogNameSize, pSchemaName, pSchemaNameSize, pTableName, pTableNameSize, pTableType,
+        pTableTypeSize ) );
     __CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
     _SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
-    std::unique_ptr<SQLResponse> p = SQLResponse::MakeResp4SQLTables ( ( ( pODBCStmt ) pStmt )->Conn->meta.get() );
-    
-    if ( PutRespToStmt ( ( pODBCStmt ) pStmt, std::move ( p ) ) != GOOD ) {
+    std::unique_ptr <SQLResponse> p = SQLResponse::MakeResp4SQLTables ( ( ( pODBCStmt ) pStmt ) -> Conn -> meta . get () );
+
+    if ( PutRespToStmt ( ( pODBCStmt ) pStmt, std::move ( p ) ) != GOOD )
+    {
         return SQL_ERROR;
     }
-    
+
     return SQL_SUCCESS;
 }
 
@@ -96,49 +98,52 @@ RETCODE SQL_API SQLTables ( SQLHSTMT        pStmt,
 // to get the list of column names in specified tables
 // ------------------------------------------------------------------------
 
-RETCODE SQL_API SQLColumnsW ( SQLHSTMT        pStmt,
-                              SQLWCHAR*        pCtlgName,
-                              SQLSMALLINT     pCtlgNameLen,
-                              SQLWCHAR*        pSchemaName,
-                              SQLSMALLINT     pSchemaNameLen,
-                              SQLWCHAR*        pTableName,
-                              SQLSMALLINT     pTableNameLen,
-                              SQLWCHAR*        pColumnName,
-                              SQLSMALLINT     pColumnNameLen ) {
+RETCODE SQL_API SQLColumnsW ( SQLHSTMT pStmt,
+                              SQLWCHAR* pCtlgName,
+                              SQLSMALLINT pCtlgNameLen,
+                              SQLWCHAR* pSchemaName,
+                              SQLSMALLINT pSchemaNameLen,
+                              SQLWCHAR* pTableName,
+                              SQLSMALLINT pTableNameLen,
+                              SQLWCHAR* pColumnName,
+                              SQLSMALLINT pColumnNameLen )
+{
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLColumnsW is called" ) );
-    unique_ptr<char[]> p1 ( wchar2char ( pCtlgName ) );
-    unique_ptr<char[]> p2 ( wchar2char ( pSchemaName ) );
-    unique_ptr<char[]> p3 ( wchar2char ( pTableName ) );
-    unique_ptr<char[]> p4 ( wchar2char ( pColumnName ) );
-    return SQLColumns ( pStmt, ( SQLCHAR* ) p1.get(), pCtlgNameLen, ( SQLCHAR* )  p2.get(), pSchemaNameLen,
-                        ( SQLCHAR* )    p3.get(), pTableNameLen, ( SQLCHAR* ) p4.get(), pColumnNameLen );
+    unique_ptr <char[]> p1 ( wchar2char ( pCtlgName ) );
+    unique_ptr <char[]> p2 ( wchar2char ( pSchemaName ) );
+    unique_ptr <char[]> p3 ( wchar2char ( pTableName ) );
+    unique_ptr <char[]> p4 ( wchar2char ( pColumnName ) );
+    return SQLColumns ( pStmt, ( SQLCHAR* ) p1 . get (), pCtlgNameLen, ( SQLCHAR* ) p2 . get (), pSchemaNameLen,
+                        ( SQLCHAR* ) p3 . get (), pTableNameLen, ( SQLCHAR* ) p4 . get (), pColumnNameLen );
 }
 
-RETCODE SQL_API SQLColumns ( SQLHSTMT        pStmt,
-                             SQLCHAR*        pCtlgName,
-                             SQLSMALLINT     pCtlgNameLen,
-                             SQLCHAR*        pSchemaName,
-                             SQLSMALLINT     pSchemaNameLen,
-                             SQLCHAR*        pTableName,
-                             SQLSMALLINT     pTableNameLen,
-                             SQLCHAR*        pColumnName,
-                             SQLSMALLINT     pColumnNameLen ) {
+RETCODE SQL_API SQLColumns ( SQLHSTMT pStmt,
+                             SQLCHAR* pCtlgName,
+                             SQLSMALLINT pCtlgNameLen,
+                             SQLCHAR* pSchemaName,
+                             SQLSMALLINT pSchemaNameLen,
+                             SQLCHAR* pTableName,
+                             SQLSMALLINT pTableNameLen,
+                             SQLCHAR* pColumnName,
+                             SQLSMALLINT pColumnNameLen )
+{
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLColumns called, Ctlg: %s, %d. Schema: %s, %d, Table: %s, %d, Col: %s, %d",
-                              pCtlgName, pCtlgNameLen, pSchemaName, pSchemaNameLen, pTableName, pTableNameLen, pColumnName, pColumnNameLen ) );
+        pCtlgName, pCtlgNameLen, pSchemaName, pSchemaNameLen, pTableName, pTableNameLen, pColumnName, pColumnNameLen ) );
     __CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
     _SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
 
-	// Some application will bring '\\' into table name
-	remove_char(( char* )pTableName, '\\');
+    // Some application will bring '\\' into table name
+    remove_char ( ( char* )pTableName, '\\' );
 
     // feed stmt structure with response
-    std::unique_ptr<SQLResponse> p = SQLResponse::MakeResp4SQLColumns ( ( ( pODBCStmt ) pStmt )->Conn->meta.get(),
-                                     ( char* ) pTableName, ( char* ) pColumnName );
-                                     
-    if ( PutRespToStmt ( ( pODBCStmt ) pStmt, std::move ( p ) ) != GOOD ) {
+    std::unique_ptr <SQLResponse> p = SQLResponse::MakeResp4SQLColumns ( ( ( pODBCStmt ) pStmt ) -> Conn -> meta . get (),
+                                                                         ( char* ) pTableName, ( char* ) pColumnName );
+
+    if ( PutRespToStmt ( ( pODBCStmt ) pStmt, std::move ( p ) ) != GOOD )
+    {
         return SQL_ERROR;
     }
-    
+
     return SQL_SUCCESS;
 }
 
@@ -146,16 +151,16 @@ RETCODE SQL_API SQLColumns ( SQLHSTMT        pStmt,
 // to get the list of column names which make a row unqiue or r updateable
 // ------------------------------------------------------------------------
 
-SQLRETURN SQL_API SQLSpecialColumns ( SQLHSTMT        pStmt,
-                                      SQLUSMALLINT    pIdentifierType,
-                                      SQLCHAR*        pCtlgName,
-                                      SQLSMALLINT     pCtlgNameLen,
-                                      SQLCHAR*        pSchemaName,
-                                      SQLSMALLINT     pSchemaNameLen,
-                                      SQLCHAR*        pTableName,
-                                      SQLSMALLINT     pTableNameLen,
-                                      SQLUSMALLINT    pScope,
-                                      SQLUSMALLINT    pNullable )
+SQLRETURN SQL_API SQLSpecialColumns ( SQLHSTMT pStmt,
+                                      SQLUSMALLINT pIdentifierType,
+                                      SQLCHAR* pCtlgName,
+                                      SQLSMALLINT pCtlgNameLen,
+                                      SQLCHAR* pSchemaName,
+                                      SQLSMALLINT pSchemaNameLen,
+                                      SQLCHAR* pTableName,
+                                      SQLSMALLINT pTableNameLen,
+                                      SQLUSMALLINT pScope,
+                                      SQLUSMALLINT pNullable )
 
 {
     // note
@@ -168,7 +173,7 @@ SQLRETURN SQL_API SQLSpecialColumns ( SQLHSTMT        pStmt,
     // SQL_SCOPE_TRANSACTION
     // SQL_SCOPE_SESSION
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLSpecialColumns called, Ctlg: %s, %d. Schema: %s, %d, Table: %s, %d",
-                              pCtlgName, pCtlgNameLen, pSchemaName, pSchemaNameLen, pTableName, pTableNameLen ) );
+        pCtlgName, pCtlgNameLen, pSchemaName, pSchemaNameLen, pTableName, pTableNameLen ) );
     __ODBCPOPMSG ( _ODBCPopMsg ( "SQLSpecialColumns not implemented" ) );
     return SQL_ERROR;
 }
@@ -177,15 +182,16 @@ SQLRETURN SQL_API SQLSpecialColumns ( SQLHSTMT        pStmt,
 // to get table and/or index statistics
 // ------------------------------------------------------------------------
 
-RETCODE SQL_API SQLStatistics ( SQLHSTMT        pStmt,
-                                SQLCHAR*        pCtlgName,
-                                SQLSMALLINT     pCtlgNameLen,
-                                SQLCHAR*        pSchemaName,
-                                SQLSMALLINT     pSchemaNameLen,
-                                SQLCHAR*        pTableName,
-                                SQLSMALLINT     pTableNameLen,
-                                SQLUSMALLINT    pUnique,
-                                SQLUSMALLINT    pReserved ) {
+RETCODE SQL_API SQLStatistics ( SQLHSTMT pStmt,
+                                SQLCHAR* pCtlgName,
+                                SQLSMALLINT pCtlgNameLen,
+                                SQLCHAR* pSchemaName,
+                                SQLSMALLINT pSchemaNameLen,
+                                SQLCHAR* pTableName,
+                                SQLSMALLINT pTableNameLen,
+                                SQLUSMALLINT pUnique,
+                                SQLUSMALLINT pReserved )
+{
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLStatistics called" ) );
     __ODBCPOPMSG ( _ODBCPopMsg ( "SQLStatistics not implemented" ) );
     return SQL_ERROR;
@@ -194,95 +200,101 @@ RETCODE SQL_API SQLStatistics ( SQLHSTMT        pStmt,
 // -----------------------------------------------------------------------
 // to get columns which make up the p-keys
 // ------------------------------------------------------------------------
-RETCODE SQL_API SQLPrimaryKeysW ( SQLHSTMT    pStmt,
-                                  SQLWCHAR*    pCtlgName,
+RETCODE SQL_API SQLPrimaryKeysW ( SQLHSTMT pStmt,
+                                  SQLWCHAR* pCtlgName,
                                   SQLSMALLINT pCtlgNameLen,
-                                  SQLWCHAR*    pSchemaName,
+                                  SQLWCHAR* pSchemaName,
                                   SQLSMALLINT pSchemaNameLen,
-                                  SQLWCHAR*    pTableName,
-                                  SQLSMALLINT pTableNameLen ) {
+                                  SQLWCHAR* pTableName,
+                                  SQLSMALLINT pTableNameLen )
+{
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLPrimaryKeysW called" ) );
     return SQLPrimaryKeys ( pStmt, NULL, NULL, NULL, NULL, NULL, NULL );
 }
 
 
-RETCODE SQL_API SQLPrimaryKeys ( SQLHSTMT    pStmt,
-                                 SQLCHAR*    pCtlgName,
+RETCODE SQL_API SQLPrimaryKeys ( SQLHSTMT pStmt,
+                                 SQLCHAR* pCtlgName,
                                  SQLSMALLINT pCtlgNameLen,
-                                 SQLCHAR*    pSchemaName,
+                                 SQLCHAR* pSchemaName,
                                  SQLSMALLINT pSchemaNameLen,
-                                 SQLCHAR*    pTableName,
-                                 SQLSMALLINT pTableNameLen ) {
+                                 SQLCHAR* pTableName,
+                                 SQLSMALLINT pTableNameLen )
+{
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLPrimaryKeys called" ) );
-    std::unique_ptr<SQLResponse> p ( new SQLResponse() );
-    
-    if ( PutRespToStmt ( ( pODBCStmt ) pStmt, std::move ( p ) ) != GOOD ) {
+    std::unique_ptr <SQLResponse> p ( new SQLResponse () );
+
+    if ( PutRespToStmt ( ( pODBCStmt ) pStmt, std::move ( p ) ) != GOOD )
+    {
         return SQL_ERROR;
     }
-    
+
     return SQL_SUCCESS;
 }
 
 // -----------------------------------------------------------------------
 // to get foreign key information
 // ------------------------------------------------------------------------
-RETCODE SQL_API SQLForeignKeysW ( SQLHSTMT        pStmt,
-                                  SQLWCHAR*        pPKCtlgName,
-                                  SQLSMALLINT     pPKCtlgNameLen,
-                                  SQLWCHAR*        pPKSchemaName,
-                                  SQLSMALLINT     pPKSchemaNameLen,
-                                  SQLWCHAR*        pPKTableName,
-                                  SQLSMALLINT     pPKTableNameLen,
-                                  SQLWCHAR*        pFKCtlgName,
-                                  SQLSMALLINT     pFKCtlgNameLen,
-                                  SQLWCHAR*        pFKSchemaName,
-                                  SQLSMALLINT     pFKSchemaNameLen,
-                                  SQLWCHAR*        pFKTableName,
-                                  SQLSMALLINT     pFKTableNameLen ) {
+RETCODE SQL_API SQLForeignKeysW ( SQLHSTMT pStmt,
+                                  SQLWCHAR* pPKCtlgName,
+                                  SQLSMALLINT pPKCtlgNameLen,
+                                  SQLWCHAR* pPKSchemaName,
+                                  SQLSMALLINT pPKSchemaNameLen,
+                                  SQLWCHAR* pPKTableName,
+                                  SQLSMALLINT pPKTableNameLen,
+                                  SQLWCHAR* pFKCtlgName,
+                                  SQLSMALLINT pFKCtlgNameLen,
+                                  SQLWCHAR* pFKSchemaName,
+                                  SQLSMALLINT pFKSchemaNameLen,
+                                  SQLWCHAR* pFKTableName,
+                                  SQLSMALLINT pFKTableNameLen )
+{
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLForeignKeysW called" ) );
-    unique_ptr<char[]> p1 ( wchar2char ( pPKCtlgName ) );
-    unique_ptr<char[]> p2 ( wchar2char ( pPKSchemaName ) );
-    unique_ptr<char[]> p3 ( wchar2char ( pPKTableName ) );
-    unique_ptr<char[]> p4 ( wchar2char ( pFKCtlgName ) );
-    unique_ptr<char[]> p5 ( wchar2char ( pFKSchemaName ) );
-    unique_ptr<char[]> p6 ( wchar2char ( pFKTableName ) );
+    unique_ptr <char[]> p1 ( wchar2char ( pPKCtlgName ) );
+    unique_ptr <char[]> p2 ( wchar2char ( pPKSchemaName ) );
+    unique_ptr <char[]> p3 ( wchar2char ( pPKTableName ) );
+    unique_ptr <char[]> p4 ( wchar2char ( pFKCtlgName ) );
+    unique_ptr <char[]> p5 ( wchar2char ( pFKSchemaName ) );
+    unique_ptr <char[]> p6 ( wchar2char ( pFKTableName ) );
     return SQLForeignKeys ( pStmt,
-                            ( SQLCHAR* ) p1.get(),
+                            ( SQLCHAR* ) p1 . get (),
                             pPKCtlgNameLen,
-                            ( SQLCHAR* ) p2.get(),
+                            ( SQLCHAR* ) p2 . get (),
                             pPKSchemaNameLen,
-                            ( SQLCHAR* ) p3.get(),
+                            ( SQLCHAR* ) p3 . get (),
                             pPKTableNameLen,
-                            ( SQLCHAR* ) p4.get(),
+                            ( SQLCHAR* ) p4 . get (),
                             pFKCtlgNameLen,
-                            ( SQLCHAR* ) p5.get(),
+                            ( SQLCHAR* ) p5 . get (),
                             pFKSchemaNameLen,
-                            ( SQLCHAR* ) p6.get(),
+                            ( SQLCHAR* ) p6 . get (),
                             pFKTableNameLen );
 }
 
-RETCODE SQL_API SQLForeignKeys ( SQLHSTMT        pStmt,
-                                 SQLCHAR*        pPKCtlgName,
-                                 SQLSMALLINT     pPKCtlgNameLen,
-                                 SQLCHAR*        pPKSchemaName,
-                                 SQLSMALLINT     pPKSchemaNameLen,
-                                 SQLCHAR*        pPKTableName,
-                                 SQLSMALLINT     pPKTableNameLen,
-                                 SQLCHAR*        pFKCtlgName,
-                                 SQLSMALLINT     pFKCtlgNameLen,
-                                 SQLCHAR*        pFKSchemaName,
-                                 SQLSMALLINT     pFKSchemaNameLen,
-                                 SQLCHAR*        pFKTableName,
-                                 SQLSMALLINT     pFKTableNameLen ) {
+RETCODE SQL_API SQLForeignKeys ( SQLHSTMT pStmt,
+                                 SQLCHAR* pPKCtlgName,
+                                 SQLSMALLINT pPKCtlgNameLen,
+                                 SQLCHAR* pPKSchemaName,
+                                 SQLSMALLINT pPKSchemaNameLen,
+                                 SQLCHAR* pPKTableName,
+                                 SQLSMALLINT pPKTableNameLen,
+                                 SQLCHAR* pFKCtlgName,
+                                 SQLSMALLINT pFKCtlgNameLen,
+                                 SQLCHAR* pFKSchemaName,
+                                 SQLSMALLINT pFKSchemaNameLen,
+                                 SQLCHAR* pFKTableName,
+                                 SQLSMALLINT pFKTableNameLen )
+{
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG,
-                              "SQLForeignKeys called pPKCtlgName: %s, pPKSchemaName : %s, pPKTableName: %s, pFKCtlgName: %s, pFKSchemaName: %s, pFKTableName: %s",
-                              pPKCtlgName, pPKSchemaName, pPKTableName, pFKCtlgName, pFKSchemaName, pFKTableName ) );
-    std::unique_ptr<SQLResponse> p ( new SQLResponse() );
-    
-    if ( PutRespToStmt ( ( pODBCStmt ) pStmt, std::move ( p ) ) != GOOD ) {
+        "SQLForeignKeys called pPKCtlgName: %s, pPKSchemaName : %s, pPKTableName: %s, pFKCtlgName: %s, pFKSchemaName: %s, pFKTableName: %s",
+        pPKCtlgName, pPKSchemaName, pPKTableName, pFKCtlgName, pFKSchemaName, pFKTableName ) );
+    std::unique_ptr <SQLResponse> p ( new SQLResponse () );
+
+    if ( PutRespToStmt ( ( pODBCStmt ) pStmt, std::move ( p ) ) != GOOD )
+    {
         return SQL_ERROR;
     }
-    
+
     return SQL_SUCCESS;
 }
 
@@ -291,13 +303,13 @@ RETCODE SQL_API SQLForeignKeys ( SQLHSTMT        pStmt,
 // to get a list of tables and the privileges associated with each table
 // ------------------------------------------------------------------------
 
-RETCODE SQL_API SQLTablePrivileges ( SQLHSTMT        pStmt,
-                                     SQLCHAR*        pCtlgName,
-                                     SQLSMALLINT     pCtlgNameLen,
-                                     SQLCHAR*        pSchemaName,
-                                     SQLSMALLINT     pSchemaNameLen,
-                                     SQLCHAR*        pTableName,
-                                     SQLSMALLINT     pTableNameLen )
+RETCODE SQL_API SQLTablePrivileges ( SQLHSTMT pStmt,
+                                     SQLCHAR* pCtlgName,
+                                     SQLSMALLINT pCtlgNameLen,
+                                     SQLCHAR* pSchemaName,
+                                     SQLSMALLINT pSchemaNameLen,
+                                     SQLCHAR* pTableName,
+                                     SQLSMALLINT pTableNameLen )
 
 {
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLTablePrivileges called" ) );
@@ -309,15 +321,16 @@ RETCODE SQL_API SQLTablePrivileges ( SQLHSTMT        pStmt,
 // to get a list of columns and associated privileges for the specified table
 // ------------------------------------------------------------------------
 
-RETCODE SQL_API SQLColumnPrivileges ( SQLHSTMT        pStmt,
-                                      SQLCHAR*        pCtlgName,
-                                      SQLSMALLINT     pCtlgNameLen,
-                                      SQLCHAR*        pSchemaName,
-                                      SQLSMALLINT     pSchemaNameLen,
-                                      SQLCHAR*        pTableName,
-                                      SQLSMALLINT     pTableNameLen,
-                                      SQLCHAR*        pColumnName,
-                                      SQLSMALLINT     pColumnNameLen ) {
+RETCODE SQL_API SQLColumnPrivileges ( SQLHSTMT pStmt,
+                                      SQLCHAR* pCtlgName,
+                                      SQLSMALLINT pCtlgNameLen,
+                                      SQLCHAR* pSchemaName,
+                                      SQLSMALLINT pSchemaNameLen,
+                                      SQLCHAR* pTableName,
+                                      SQLSMALLINT pTableNameLen,
+                                      SQLCHAR* pColumnName,
+                                      SQLSMALLINT pColumnNameLen )
+{
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLColumnPrivileges called" ) );
     __ODBCPOPMSG ( _ODBCPopMsg ( "SQLColumnPrivileges not implemented" ) );
     return SQL_ERROR;
@@ -329,13 +342,14 @@ RETCODE SQL_API SQLColumnPrivileges ( SQLHSTMT        pStmt,
 // ------------------------------------------------------------------------
 
 
-RETCODE SQL_API SQLProcedures ( SQLHSTMT        pStmt,
-                                SQLCHAR*        pCtlgName,
-                                SQLSMALLINT     pCtlgNameLen,
-                                SQLCHAR*        pSchemaName,
-                                SQLSMALLINT     pSchemaNameLen,
-                                SQLCHAR*        pProcName,
-                                SQLSMALLINT     pProcNameLen ) {
+RETCODE SQL_API SQLProcedures ( SQLHSTMT pStmt,
+                                SQLCHAR* pCtlgName,
+                                SQLSMALLINT pCtlgNameLen,
+                                SQLCHAR* pSchemaName,
+                                SQLSMALLINT pSchemaNameLen,
+                                SQLCHAR* pProcName,
+                                SQLSMALLINT pProcNameLen )
+{
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLProcedures called" ) );
     __ODBCPOPMSG ( _ODBCPopMsg ( "SQLProcedures not implemented" ) );
     return SQL_ERROR;
@@ -346,18 +360,18 @@ RETCODE SQL_API SQLProcedures ( SQLHSTMT        pStmt,
 // to get a list of procedure names stored in a specific data source
 // ------------------------------------------------------------------------
 
-RETCODE SQL_API SQLProcedureColumns ( SQLHSTMT        pStmt,
-                                      SQLCHAR*        pCtlgName,
-                                      SQLSMALLINT     pCtlgNameLen,
-                                      SQLCHAR*        pSchemaName,
-                                      SQLSMALLINT     pSchemaNameLen,
-                                      SQLCHAR*        pProcName,
-                                      SQLSMALLINT     pProcNameLen,
-                                      SQLCHAR*        pColumnName,
-                                      SQLSMALLINT     pColumnNameLen ) {
+RETCODE SQL_API SQLProcedureColumns ( SQLHSTMT pStmt,
+                                      SQLCHAR* pCtlgName,
+                                      SQLSMALLINT pCtlgNameLen,
+                                      SQLCHAR* pSchemaName,
+                                      SQLSMALLINT pSchemaNameLen,
+                                      SQLCHAR* pProcName,
+                                      SQLSMALLINT pProcNameLen,
+                                      SQLCHAR* pColumnName,
+                                      SQLSMALLINT pColumnNameLen )
+{
     __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLProceduresColumns called" ) );
     __ODBCPOPMSG ( _ODBCPopMsg ( "SQLProceduresColumns not implemented" ) );
     return SQL_ERROR;
 }
 
-


Mime
View raw message