- DBC_t FAR* pdbc = (DBC_t FAR*)hdbc;
- ENV_t FAR* penv;
- STMT_t FAR* pstmt = NULL;
- STMT_t FAR* tpstmt;
- HPROC hproc;
- RETCODE retcode = SQL_SUCCESS;
-
- DWORD dword;
- int size = 0, len = 0;
- char buf[16] = { '\0' };
-
- if( hdbc == SQL_NULL_HDBC
- || pdbc->henv == SQL_NULL_HENV )
- {
- return SQL_INVALID_HANDLE;
- }
-
- if( cbInfoValueMax < 0 )
- {
- PUSHSQLERR ( pdbc->herr, en_S1090 );
-
- return SQL_ERROR;
- }
-
- if( /* fInfoType < SQL_INFO_FIRST || */
- ( fInfoType > SQL_INFO_LAST
- && fInfoType < SQL_INFO_DRIVER_START ) )
- {
- PUSHSQLERR ( pdbc->herr, en_S1096 );
-
- return SQL_ERROR;
- }
-
- if( fInfoType == SQL_ODBC_VER )
- {
- sprintf( buf, "%02d.%02d",
- (ODBCVER)>>8, 0x00FF&(ODBCVER) );
-
-
- if( rgbInfoValue != NULL
- && cbInfoValueMax > 0 )
- {
- len = STRLEN( buf );
-
- if( len < cbInfoValueMax - 1 )
- {
- len = cbInfoValueMax - 1;
- PUSHSQLERR ( pdbc->herr, en_01004 );
-
- retcode = SQL_SUCCESS_WITH_INFO;
- }
-
- STRNCPY( rgbInfoValue, buf, len );
- ((char FAR*)rgbInfoValue)[len] = '\0';
- }
-
- if( pcbInfoValue != NULL )
- {
- *pcbInfoValue = (SWORD)len;
- }
-
- return retcode;
- }
-
- if( pdbc->state == en_dbc_allocated
- || pdbc->state == en_dbc_needdata )
- {
- PUSHSQLERR ( pdbc->herr, en_08003 );
-
- return SQL_ERROR;
- }
-
- switch( fInfoType )
- {
- case SQL_DRIVER_HDBC:
- dword = (DWORD)(pdbc->dhdbc);
- size = sizeof(dword);
- break;
-
- case SQL_DRIVER_HENV:
- penv = (ENV_t FAR*)(pdbc->henv);
- dword = (DWORD)(penv->dhenv);
- size = sizeof(dword);
- break;
-
- case SQL_DRIVER_HLIB:
- penv = (ENV_t FAR*)(pdbc->henv);
- dword = (DWORD)(penv->hdll);
- size = sizeof(dword);
- break;
-
- case SQL_DRIVER_HSTMT:
- if( rgbInfoValue != NULL )
- {
- pstmt = *((STMT_t FAR**)rgbInfoValue);
- }
-
- for( tpstmt = (STMT_t FAR*)(pdbc->hstmt);
- tpstmt != NULL;
- tpstmt = tpstmt->next )
- {
- if( tpstmt == pstmt )
- {
- break;
- }
- }
-
- if( tpstmt == NULL )
- {
- PUSHSQLERR ( pdbc->herr, en_S1009 );
-
- return SQL_ERROR;
- }
-
- dword = (DWORD)(pstmt->dhstmt);
- size = sizeof(dword);
- break;
-
- default:
- break;
- }
-
- if( size )
- {
- if( rgbInfoValue != NULL )
- {
- *((DWORD*)rgbInfoValue) = dword;
- }
-
- if( pcbInfoValue != NULL )
- {
- *(pcbInfoValue) = (SWORD)size;
- }
-
- return SQL_SUCCESS;
- }
-
- hproc = _iodbcdm_getproc( hdbc, en_GetInfo );
-
- if( hproc == SQL_NULL_HPROC )
- {
- PUSHSQLERR ( pdbc->herr, en_IM001 );
-
- return SQL_ERROR;
- }
-
- CALL_DRIVER ( hdbc, retcode, hproc, en_GetInfo, (
- pdbc->dhdbc,
- fInfoType,
- rgbInfoValue,
- cbInfoValueMax,
- pcbInfoValue ) )
-
-#if 0
- retcode = hproc(pdbc->dhdbc,
- fInfoType,
- rgbInfoValue,
- cbInfoValueMax,
- pcbInfoValue );
-#endif
-
- if( retcode == SQL_ERROR
- && fInfoType == SQL_DRIVER_ODBC_VER )
- {
- STRCPY( buf, "01.00" );
-
- if( rgbInfoValue != NULL
- && cbInfoValueMax > 0 )
- {
- len = STRLEN( buf );
-
- if( len < cbInfoValueMax - 1 )
- {
- len = cbInfoValueMax - 1;
- PUSHSQLERR ( pdbc->herr, en_01004 );
- }
-
- STRNCPY( rgbInfoValue, buf, len );
- ((char FAR*)rgbInfoValue)[len] = '\0';
- }
-
- if( pcbInfoValue != NULL )
- {
- *pcbInfoValue = (SWORD)len;
- }
-
- /* what should we return in this case ???? */
- }
-
- return retcode;
+ DBC_t FAR *pdbc = (DBC_t FAR *) hdbc;
+ ENV_t FAR *penv;
+ STMT_t FAR *pstmt = NULL;
+ STMT_t FAR *tpstmt;
+ HPROC hproc;
+ RETCODE retcode = SQL_SUCCESS;
+
+ DWORD dword;
+ int size = 0, len = 0;
+ char buf[16] = {'\0'};
+
+ if (hdbc == SQL_NULL_HDBC || pdbc->henv == SQL_NULL_HENV)
+ {
+ return SQL_INVALID_HANDLE;
+ }
+
+ if (cbInfoValueMax < 0)
+ {
+ PUSHSQLERR (pdbc->herr, en_S1090);
+
+ return SQL_ERROR;
+ }
+
+ if ( /* fInfoType < SQL_INFO_FIRST || */
+ (fInfoType > SQL_INFO_LAST
+ && fInfoType < SQL_INFO_DRIVER_START))
+ {
+ PUSHSQLERR (pdbc->herr, en_S1096);
+
+ return SQL_ERROR;
+ }
+
+ if (fInfoType == SQL_ODBC_VER)
+ {
+ sprintf (buf, "%02d.%02d",
+ (ODBCVER) >> 8, 0x00FF & (ODBCVER));
+
+
+ if (rgbInfoValue != NULL
+ && cbInfoValueMax > 0)
+ {
+ len = STRLEN (buf);
+
+ if (len < cbInfoValueMax - 1)
+ {
+ len = cbInfoValueMax - 1;
+ PUSHSQLERR (pdbc->herr, en_01004);
+
+ retcode = SQL_SUCCESS_WITH_INFO;
+ }
+
+ STRNCPY (rgbInfoValue, buf, len);
+ ((char FAR *) rgbInfoValue)[len] = '\0';
+ }
+
+ if (pcbInfoValue != NULL)
+ {
+ *pcbInfoValue = (SWORD) len;
+ }
+
+ return retcode;
+ }
+
+ if (pdbc->state == en_dbc_allocated || pdbc->state == en_dbc_needdata)
+ {
+ PUSHSQLERR (pdbc->herr, en_08003);
+
+ return SQL_ERROR;
+ }
+
+ switch (fInfoType)
+ {
+ case SQL_DRIVER_HDBC:
+ dword = (DWORD) (pdbc->dhdbc);
+ size = sizeof (dword);
+ break;
+
+ case SQL_DRIVER_HENV:
+ penv = (ENV_t FAR *) (pdbc->henv);
+ dword = (DWORD) (penv->dhenv);
+ size = sizeof (dword);
+ break;
+
+ case SQL_DRIVER_HLIB:
+ penv = (ENV_t FAR *) (pdbc->henv);
+ dword = (DWORD) (penv->hdll);
+ size = sizeof (dword);
+ break;
+
+ case SQL_DRIVER_HSTMT:
+ if (rgbInfoValue != NULL)
+ {
+ pstmt = *((STMT_t FAR **) rgbInfoValue);
+ }
+
+ for (tpstmt = (STMT_t FAR *) (pdbc->hstmt);
+ tpstmt != NULL;
+ tpstmt = tpstmt->next)
+ {
+ if (tpstmt == pstmt)
+ {
+ break;
+ }
+ }
+
+ if (tpstmt == NULL)
+ {
+ PUSHSQLERR (pdbc->herr, en_S1009);
+
+ return SQL_ERROR;
+ }
+
+ dword = (DWORD) (pstmt->dhstmt);
+ size = sizeof (dword);
+ break;
+
+ default:
+ break;
+ }
+
+ if (size)
+ {
+ if (rgbInfoValue != NULL)
+ {
+ *((DWORD *) rgbInfoValue) = dword;
+ }
+
+ if (pcbInfoValue != NULL)
+ {
+ *(pcbInfoValue) = (SWORD) size;
+ }
+
+ return SQL_SUCCESS;
+ }
+
+ hproc = _iodbcdm_getproc (hdbc, en_GetInfo);
+
+ if (hproc == SQL_NULL_HPROC)
+ {
+ PUSHSQLERR (pdbc->herr, en_IM001);
+
+ return SQL_ERROR;
+ }
+
+ CALL_DRIVER (hdbc, retcode, hproc, en_GetInfo,
+ (pdbc->dhdbc, fInfoType, rgbInfoValue, cbInfoValueMax, pcbInfoValue))
+
+ if (retcode == SQL_ERROR
+ && fInfoType == SQL_DRIVER_ODBC_VER)
+ {
+ STRCPY (buf, "01.00");
+
+ if (rgbInfoValue != NULL
+ && cbInfoValueMax > 0)
+ {
+ len = STRLEN (buf);
+
+ if (len < cbInfoValueMax - 1)
+ {
+ len = cbInfoValueMax - 1;
+ PUSHSQLERR (pdbc->herr, en_01004);
+ }
+
+ STRNCPY (rgbInfoValue, buf, len);
+ ((char FAR *) rgbInfoValue)[len] = '\0';
+ }
+
+ if (pcbInfoValue != NULL)
+ {
+ *pcbInfoValue = (SWORD) len;
+ }
+
+ /* what should we return in this case ???? */
+ }
+
+ return retcode;