diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 8b2e78dcb6d..0928651b670 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -45,122 +45,133 @@ #include "sqltypes.h" #include "sqlext.h" -#include "proxyodbc.h" - static BOOL ODBC_LoadDriverManager(void); static BOOL ODBC_LoadDMFunctions(void); WINE_DEFAULT_DEBUG_CHANNEL(odbc); -static const DM_FUNC template_func[] = -{ - /* 00 */ { SQL_API_SQLALLOCCONNECT, "SQLAllocConnect", SQLAllocConnect, NULL, NULL }, - /* 01 */ { SQL_API_SQLALLOCENV, "SQLAllocEnv", SQLAllocEnv, NULL, NULL }, - /* 02 */ { SQL_API_SQLALLOCHANDLE, "SQLAllocHandle", SQLAllocHandle, NULL, NULL }, - /* 03 */ { SQL_API_SQLALLOCSTMT, "SQLAllocStmt", SQLAllocStmt, NULL, NULL }, - /* 04 */ { SQL_API_SQLALLOCHANDLESTD, "SQLAllocHandleStd", SQLAllocHandleStd, NULL, NULL }, - /* 05 */ { SQL_API_SQLBINDCOL, "SQLBindCol", SQLBindCol, NULL, NULL }, - /* 06 */ { SQL_API_SQLBINDPARAM, "SQLBindParam", SQLBindParam, NULL, NULL }, - /* 07 */ { SQL_API_SQLBINDPARAMETER, "SQLBindParameter", SQLBindParameter, NULL, NULL }, - /* 08 */ { SQL_API_SQLBROWSECONNECT, "SQLBrowseConnect", SQLBrowseConnect, NULL, NULL }, - /* 09 */ { SQL_API_SQLBULKOPERATIONS, "SQLBulkOperations", SQLBulkOperations, NULL, NULL }, - /* 10 */ { SQL_API_SQLCANCEL, "SQLCancel", SQLCancel, NULL, NULL }, - /* 11 */ { SQL_API_SQLCLOSECURSOR, "SQLCloseCursor", SQLCloseCursor, NULL, NULL }, - /* 12 */ { SQL_API_SQLCOLATTRIBUTE, "SQLColAttribute", SQLColAttribute, NULL, NULL }, - /* 13 */ { SQL_API_SQLCOLATTRIBUTES, "SQLColAttributes", SQLColAttributes, NULL, NULL }, - /* 14 */ { SQL_API_SQLCOLUMNPRIVILEGES, "SQLColumnPrivileges", SQLColumnPrivileges, NULL, NULL }, - /* 15 */ { SQL_API_SQLCOLUMNS, "SQLColumns", SQLColumns, NULL, NULL }, - /* 16 */ { SQL_API_SQLCONNECT, "SQLConnect", SQLConnect, NULL, NULL }, - /* 17 */ { SQL_API_SQLCOPYDESC, "SQLCopyDesc", SQLCopyDesc, NULL, NULL }, - /* 18 */ { SQL_API_SQLDATASOURCES, "SQLDataSources", SQLDataSources, NULL, NULL }, - /* 19 */ { SQL_API_SQLDESCRIBECOL, "SQLDescribeCol", SQLDescribeCol, NULL, NULL }, - /* 20 */ { SQL_API_SQLDESCRIBEPARAM, "SQLDescribeParam", SQLDescribeParam, NULL, NULL }, - /* 21 */ { SQL_API_SQLDISCONNECT, "SQLDisconnect", SQLDisconnect, NULL, NULL }, - /* 22 */ { SQL_API_SQLDRIVERCONNECT, "SQLDriverConnect", SQLDriverConnect, NULL, NULL }, - /* 23 */ { SQL_API_SQLDRIVERS, "SQLDrivers", SQLDrivers, NULL, NULL }, - /* 24 */ { SQL_API_SQLENDTRAN, "SQLEndTran", SQLEndTran, NULL, NULL }, - /* 25 */ { SQL_API_SQLERROR, "SQLError", SQLError, NULL, NULL }, - /* 26 */ { SQL_API_SQLEXECDIRECT, "SQLExecDirect", SQLExecDirect, NULL, NULL }, - /* 27 */ { SQL_API_SQLEXECUTE, "SQLExecute", SQLExecute, NULL, NULL }, - /* 28 */ { SQL_API_SQLEXTENDEDFETCH, "SQLExtendedFetch", SQLExtendedFetch, NULL, NULL }, - /* 29 */ { SQL_API_SQLFETCH, "SQLFetch", SQLFetch, NULL, NULL }, - /* 30 */ { SQL_API_SQLFETCHSCROLL, "SQLFetchScroll", SQLFetchScroll, NULL, NULL }, - /* 31 */ { SQL_API_SQLFOREIGNKEYS, "SQLForeignKeys", SQLForeignKeys, NULL, NULL }, - /* 32 */ { SQL_API_SQLFREEENV, "SQLFreeEnv", SQLFreeEnv, NULL, NULL }, - /* 33 */ { SQL_API_SQLFREEHANDLE, "SQLFreeHandle", SQLFreeHandle, NULL, NULL }, - /* 34 */ { SQL_API_SQLFREESTMT, "SQLFreeStmt", SQLFreeStmt, NULL, NULL }, - /* 35 */ { SQL_API_SQLFREECONNECT, "SQLFreeConnect", SQLFreeConnect, NULL, NULL }, - /* 36 */ { SQL_API_SQLGETCONNECTATTR, "SQLGetConnectAttr", SQLGetConnectAttr, NULL, NULL }, - /* 37 */ { SQL_API_SQLGETCONNECTOPTION, "SQLGetConnectOption", SQLGetConnectOption, NULL, NULL }, - /* 38 */ { SQL_API_SQLGETCURSORNAME, "SQLGetCursorName", SQLGetCursorName, NULL, NULL }, - /* 39 */ { SQL_API_SQLGETDATA, "SQLGetData", SQLGetData, NULL, NULL }, - /* 40 */ { SQL_API_SQLGETDESCFIELD, "SQLGetDescField", SQLGetDescField, NULL, NULL }, - /* 41 */ { SQL_API_SQLGETDESCREC, "SQLGetDescRec", SQLGetDescRec, NULL, NULL }, - /* 42 */ { SQL_API_SQLGETDIAGFIELD, "SQLGetDiagField", SQLGetDiagField, NULL, NULL }, - /* 43 */ { SQL_API_SQLGETENVATTR, "SQLGetEnvAttr", SQLGetEnvAttr, NULL, NULL }, - /* 44 */ { SQL_API_SQLGETFUNCTIONS, "SQLGetFunctions", SQLGetFunctions, NULL, NULL }, - /* 45 */ { SQL_API_SQLGETINFO, "SQLGetInfo", SQLGetInfo, NULL, NULL }, - /* 46 */ { SQL_API_SQLGETSTMTATTR, "SQLGetStmtAttr", SQLGetStmtAttr, NULL, NULL }, - /* 47 */ { SQL_API_SQLGETSTMTOPTION, "SQLGetStmtOption", SQLGetStmtOption, NULL, NULL }, - /* 48 */ { SQL_API_SQLGETTYPEINFO, "SQLGetTypeInfo", SQLGetTypeInfo, NULL, NULL }, - /* 49 */ { SQL_API_SQLMORERESULTS, "SQLMoreResults", SQLMoreResults, NULL, NULL }, - /* 50 */ { SQL_API_SQLNATIVESQL, "SQLNativeSql", SQLNativeSql, NULL, NULL }, - /* 51 */ { SQL_API_SQLNUMPARAMS, "SQLNumParams", SQLNumParams, NULL, NULL }, - /* 52 */ { SQL_API_SQLNUMRESULTCOLS, "SQLNumResultCols", SQLNumResultCols, NULL, NULL }, - /* 53 */ { SQL_API_SQLPARAMDATA, "SQLParamData", SQLParamData, NULL, NULL }, - /* 54 */ { SQL_API_SQLPARAMOPTIONS, "SQLParamOptions", SQLParamOptions, NULL, NULL }, - /* 55 */ { SQL_API_SQLPREPARE, "SQLPrepare", SQLPrepare, NULL, NULL }, - /* 56 */ { SQL_API_SQLPRIMARYKEYS, "SQLPrimaryKeys", SQLPrimaryKeys, NULL, NULL }, - /* 57 */ { SQL_API_SQLPROCEDURECOLUMNS, "SQLProcedureColumns", SQLProcedureColumns, NULL, NULL }, - /* 58 */ { SQL_API_SQLPROCEDURES, "SQLProcedures", SQLProcedures, NULL, NULL }, - /* 59 */ { SQL_API_SQLPUTDATA, "SQLPutData", SQLPutData, NULL, NULL }, - /* 60 */ { SQL_API_SQLROWCOUNT, "SQLRowCount", SQLRowCount, NULL, NULL }, - /* 61 */ { SQL_API_SQLSETCONNECTATTR, "SQLSetConnectAttr", SQLSetConnectAttr, NULL, NULL }, - /* 62 */ { SQL_API_SQLSETCONNECTOPTION, "SQLSetConnectOption", SQLSetConnectOption, NULL, NULL }, - /* 63 */ { SQL_API_SQLSETCURSORNAME, "SQLSetCursorName", SQLSetCursorName, NULL, NULL }, - /* 64 */ { SQL_API_SQLSETDESCFIELD, "SQLSetDescField", SQLSetDescField, NULL, NULL }, - /* 65 */ { SQL_API_SQLSETDESCREC, "SQLSetDescRec", SQLSetDescRec, NULL, NULL }, - /* 66 */ { SQL_API_SQLSETENVATTR, "SQLSetEnvAttr", SQLSetEnvAttr, NULL, NULL }, - /* 67 */ { SQL_API_SQLSETPARAM, "SQLSetParam", SQLSetParam, NULL, NULL }, - /* 68 */ { SQL_API_SQLSETPOS, "SQLSetPos", SQLSetPos, NULL, NULL }, - /* 69 */ { SQL_API_SQLSETSCROLLOPTIONS, "SQLSetScrollOptions", SQLSetScrollOptions, NULL, NULL }, - /* 70 */ { SQL_API_SQLSETSTMTATTR, "SQLSetStmtAttr", SQLSetStmtAttr, NULL, NULL }, - /* 71 */ { SQL_API_SQLSETSTMTOPTION, "SQLSetStmtOption", SQLSetStmtOption, NULL, NULL }, - /* 72 */ { SQL_API_SQLSPECIALCOLUMNS, "SQLSpecialColumns", SQLSpecialColumns, NULL, NULL }, - /* 73 */ { SQL_API_SQLSTATISTICS, "SQLStatistics", SQLStatistics, NULL, NULL }, - /* 74 */ { SQL_API_SQLTABLEPRIVILEGES, "SQLTablePrivileges", SQLTablePrivileges, NULL, NULL }, - /* 75 */ { SQL_API_SQLTABLES, "SQLTables", SQLTables, NULL, NULL }, - /* 76 */ { SQL_API_SQLTRANSACT, "SQLTransact", SQLTransact, NULL, NULL }, - /* 77 */ { SQL_API_SQLGETDIAGREC, "SQLGetDiagRec", SQLGetDiagRec, NULL, NULL }, -}; +static SQLRETURN (*pSQLAllocConnect)(SQLHENV,SQLHDBC*); +static SQLRETURN (*pSQLAllocEnv)(SQLHENV*); +static SQLRETURN (*pSQLAllocHandle)(SQLSMALLINT,SQLHANDLE,SQLHANDLE*); +static SQLRETURN (*pSQLAllocHandleStd)(SQLSMALLINT,SQLHANDLE,SQLHANDLE*); +static SQLRETURN (*pSQLAllocStmt)(SQLHDBC,SQLHSTMT*); +static SQLRETURN (*pSQLBindCol)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +static SQLRETURN (*pSQLBindParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLUINTEGER,SQLSMALLINT,SQLPOINTER,SQLINTEGER*); +static SQLRETURN (*pSQLBindParameter)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLUINTEGER,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +static SQLRETURN (*pSQLBrowseConnect)(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +static SQLRETURN (*pSQLBrowseConnectW)(SQLHDBC,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*); +static SQLRETURN (*pSQLBulkOperations)(SQLHSTMT,SQLSMALLINT); +static SQLRETURN (*pSQLCancel)(SQLHSTMT); +static SQLRETURN (*pSQLCloseCursor)(SQLHSTMT); +static SQLRETURN (*pSQLColAttribute)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER); +static SQLRETURN (*pSQLColAttributeW)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER); +static SQLRETURN (*pSQLColAttributes)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLINTEGER*); +static SQLRETURN (*pSQLColAttributesW)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER); +static SQLRETURN (*pSQLColumnPrivileges)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +static SQLRETURN (*pSQLColumnPrivilegesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +static SQLRETURN (*pSQLColumns)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +static SQLRETURN (*pSQLColumnsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +static SQLRETURN (*pSQLConnect)(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +static SQLRETURN (*pSQLConnectW)(SQLHDBC,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +static SQLRETURN (*pSQLCopyDesc)(SQLHDESC,SQLHDESC); +static SQLRETURN (*pSQLDataSources)(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +static SQLRETURN (*pSQLDataSourcesW)(SQLHENV,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*); +static SQLRETURN (*pSQLDescribeCol)(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLUINTEGER*,SQLSMALLINT*,SQLSMALLINT*); +static SQLRETURN (*pSQLDescribeColW)(SQLHSTMT,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLULEN*,SQLSMALLINT*,SQLSMALLINT*); +static SQLRETURN (*pSQLDescribeParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT*,SQLUINTEGER*,SQLSMALLINT*,SQLSMALLINT*); +static SQLRETURN (*pSQLDisconnect)(SQLHDBC); +static SQLRETURN (*pSQLDriverConnect)(SQLHDBC,SQLHWND,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT); +static SQLRETURN (*pSQLDriverConnectW)(SQLHDBC,SQLHWND,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT); +static SQLRETURN (*pSQLDrivers)(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +static SQLRETURN (*pSQLDriversW)(SQLHENV,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*); +static SQLRETURN (*pSQLEndTran)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT); +static SQLRETURN (*pSQLError)(SQLHENV,SQLHDBC,SQLHSTMT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +static SQLRETURN (*pSQLErrorW)(SQLHENV,SQLHDBC,SQLHSTMT,SQLWCHAR*,SQLINTEGER*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*); +static SQLRETURN (*pSQLExecDirect)(SQLHSTMT,SQLCHAR*,SQLINTEGER); +static SQLRETURN (*pSQLExecDirectW)(SQLHSTMT,SQLWCHAR*,SQLINTEGER); +static SQLRETURN (*pSQLExecute)(SQLHSTMT); +static SQLRETURN (*pSQLExtendedFetch)(SQLHSTMT,SQLUSMALLINT,SQLINTEGER,SQLUINTEGER*,SQLUSMALLINT*); +static SQLRETURN (*pSQLFetch)(SQLHSTMT); +static SQLRETURN (*pSQLFetchScroll)(SQLHSTMT,SQLSMALLINT,SQLINTEGER); +static SQLRETURN (*pSQLForeignKeys)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +static SQLRETURN (*pSQLForeignKeysW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +static SQLRETURN (*pSQLFreeConnect)(SQLHDBC); +static SQLRETURN (*pSQLFreeEnv)(SQLHENV); +static SQLRETURN (*pSQLFreeHandle)(SQLSMALLINT,SQLHANDLE); +static SQLRETURN (*pSQLFreeStmt)(SQLHSTMT,SQLUSMALLINT); +static SQLRETURN (*pSQLGetConnectAttr)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +static SQLRETURN (*pSQLGetConnectAttrW)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +static SQLRETURN (*pSQLGetConnectOption)(SQLHDBC,SQLUSMALLINT,SQLPOINTER); +static SQLRETURN (*pSQLGetConnectOptionW)(SQLHDBC,SQLUSMALLINT,SQLPOINTER); +static SQLRETURN (*pSQLGetCursorName)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +static SQLRETURN (*pSQLGetCursorNameW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*); +static SQLRETURN (*pSQLGetData)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +static SQLRETURN (*pSQLGetDescField)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +static SQLRETURN (*pSQLGetDescFieldW)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +static SQLRETURN (*pSQLGetDescRec)(SQLHDESC,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*,SQLINTEGER*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*); +static SQLRETURN (*pSQLGetDescRecW)(SQLHDESC,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*,SQLLEN*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*); +static SQLRETURN (*pSQLGetDiagField)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*); +static SQLRETURN (*pSQLGetDiagFieldW)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*); +static SQLRETURN (*pSQLGetDiagRec)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +static SQLRETURN (*pSQLGetDiagRecW)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLWCHAR*,SQLINTEGER*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*); +static SQLRETURN (*pSQLGetEnvAttr)(SQLHENV,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +static SQLRETURN (*pSQLGetFunctions)(SQLHDBC,SQLUSMALLINT,SQLUSMALLINT*); +static SQLRETURN (*pSQLGetInfo)(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*); +static SQLRETURN (*pSQLGetInfoW)(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*); +static SQLRETURN (*pSQLGetStmtAttr)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +static SQLRETURN (*pSQLGetStmtAttrW)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +static SQLRETURN (*pSQLGetStmtOption)(SQLHSTMT,SQLUSMALLINT,SQLPOINTER); +static SQLRETURN (*pSQLGetTypeInfo)(SQLHSTMT,SQLSMALLINT); +static SQLRETURN (*pSQLGetTypeInfoW)(SQLHSTMT,SQLSMALLINT); +static SQLRETURN (*pSQLMoreResults)(SQLHSTMT); +static SQLRETURN (*pSQLNativeSql)(SQLHDBC,SQLCHAR*,SQLINTEGER,SQLCHAR*,SQLINTEGER,SQLINTEGER*); +static SQLRETURN (*pSQLNativeSqlW)(SQLHDBC,SQLWCHAR*,SQLINTEGER,SQLWCHAR*,SQLINTEGER,SQLINTEGER*); +static SQLRETURN (*pSQLNumParams)(SQLHSTMT,SQLSMALLINT*); +static SQLRETURN (*pSQLNumResultCols)(SQLHSTMT,SQLSMALLINT*); +static SQLRETURN (*pSQLParamData)(SQLHSTMT,SQLPOINTER*); +static SQLRETURN (*pSQLParamOptions)(SQLHSTMT,SQLUINTEGER,SQLUINTEGER*); +static SQLRETURN (*pSQLPrepare)(SQLHSTMT,SQLCHAR*,SQLINTEGER); +static SQLRETURN (*pSQLPrepareW)(SQLHSTMT,SQLWCHAR*,SQLINTEGER); +static SQLRETURN (*pSQLPrimaryKeys)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +static SQLRETURN (*pSQLPrimaryKeysW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +static SQLRETURN (*pSQLProcedureColumns)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +static SQLRETURN (*pSQLProcedureColumnsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +static SQLRETURN (*pSQLProcedures)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +static SQLRETURN (*pSQLProceduresW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +static SQLRETURN (*pSQLPutData)(SQLHSTMT,SQLPOINTER,SQLINTEGER); +static SQLRETURN (*pSQLRowCount)(SQLHSTMT,SQLINTEGER*); +static SQLRETURN (*pSQLSetConnectAttr)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER); +static SQLRETURN (*pSQLSetConnectAttrW)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER); +static SQLRETURN (*pSQLSetConnectOption)(SQLHDBC,SQLUSMALLINT,SQLUINTEGER); +static SQLRETURN (*pSQLSetConnectOptionW)(SQLHDBC,SQLUSMALLINT,SQLULEN); +static SQLRETURN (*pSQLSetCursorName)(SQLHSTMT,SQLCHAR*,SQLSMALLINT); +static SQLRETURN (*pSQLSetCursorNameW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT); +static SQLRETURN (*pSQLSetDescField)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER); +static SQLRETURN (*pSQLSetDescFieldW)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER); +static SQLRETURN (*pSQLSetDescRec)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLINTEGER,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER*,SQLINTEGER*); +static SQLRETURN (*pSQLSetEnvAttr)(SQLHENV,SQLINTEGER,SQLPOINTER,SQLINTEGER); +static SQLRETURN (*pSQLSetParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLUINTEGER,SQLSMALLINT,SQLPOINTER,SQLINTEGER*); +static SQLRETURN (*pSQLSetPos)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLUSMALLINT); +static SQLRETURN (*pSQLSetScrollOptions)(SQLHSTMT,SQLUSMALLINT,SQLINTEGER,SQLUSMALLINT); +static SQLRETURN (*pSQLSetStmtAttr)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER); +static SQLRETURN (*pSQLSetStmtAttrW)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER); +static SQLRETURN (*pSQLSetStmtOption)(SQLHSTMT,SQLUSMALLINT,SQLUINTEGER); +static SQLRETURN (*pSQLSpecialColumns)(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT); +static SQLRETURN (*pSQLSpecialColumnsW)(SQLHSTMT,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT); +static SQLRETURN (*pSQLStatistics)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT); +static SQLRETURN (*pSQLStatisticsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT); +static SQLRETURN (*pSQLTablePrivileges)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +static SQLRETURN (*pSQLTablePrivilegesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +static SQLRETURN (*pSQLTables)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +static SQLRETURN (*pSQLTablesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +static SQLRETURN (*pSQLTransact)(SQLHENV,SQLHDBC,SQLUSMALLINT); -static PROXYHANDLE gProxyHandle; +#define ERROR_FREE 0 +#define ERROR_SQLERROR 1 +#define ERROR_LIBRARY_NOT_FOUND 2 -/* What is the difference between these two (dmHandle cf READY_AND_dmHandle)? When does one use one and when the other? */ - -#define CHECK_dmHandle() \ -{ \ - if (gProxyHandle.dmHandle == NULL) \ - { \ - TRACE ("Not ready\n"); \ - return SQL_ERROR; \ - } \ -} - -#define CHECK_READY_AND_dmHandle() \ -{ \ - if (!gProxyHandle.bFunctionReady || gProxyHandle.dmHandle == NULL) \ - { \ - TRACE ("Not ready\n"); \ - return SQL_ERROR; \ - } \ -} - -static SQLRETURN SQLDummyFunc(void) -{ - TRACE("SQLDummyFunc:\n"); - return SQL_SUCCESS; -} +static void *dmHandle; +static int nErrorType; /*********************************************************************** * ODBC_ReplicateODBCInstToRegistry @@ -466,7 +477,6 @@ static void ODBC_ReplicateToRegistry (void) BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { - int i; TRACE("Initializing or Finalizing proxy ODBC: %p,%x,%p\n", hinstDLL, fdwReason, lpvReserved); if (fdwReason == DLL_PROCESS_ATTACH) @@ -482,18 +492,10 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) else if (fdwReason == DLL_PROCESS_DETACH) { TRACE("Unloading ODBC...\n"); - if (gProxyHandle.bFunctionReady) + if (dmHandle) { - for ( i = 0; i < NUM_SQLFUNC; i ++ ) - { - gProxyHandle.functions[i].func = SQLDummyFunc; - } - } - - if (gProxyHandle.dmHandle) - { - wine_dlclose(gProxyHandle.dmHandle,NULL,0); - gProxyHandle.dmHandle = NULL; + wine_dlclose(dmHandle,NULL,0); + dmHandle = NULL; } } @@ -517,23 +519,21 @@ static BOOL ODBC_LoadDriverManager(void) TRACE("\n"); - gProxyHandle.bFunctionReady = FALSE; - #ifdef SONAME_LIBODBC if (!s || !s[0]) s = SONAME_LIBODBC; #endif if (!s || !s[0]) goto failed; - gProxyHandle.dmHandle = wine_dlopen(s, RTLD_LAZY | RTLD_GLOBAL, error, sizeof(error)); + dmHandle = wine_dlopen(s, RTLD_LAZY | RTLD_GLOBAL, error, sizeof(error)); - if (gProxyHandle.dmHandle != NULL) + if (dmHandle != NULL) { - gProxyHandle.nErrorType = ERROR_FREE; + nErrorType = ERROR_FREE; return TRUE; } failed: WARN("failed to open library %s: %s\n", debugstr_a(s), error); - gProxyHandle.nErrorType = ERROR_LIBRARY_NOT_FOUND; + nErrorType = ERROR_LIBRARY_NOT_FOUND; return FALSE; } @@ -550,45 +550,131 @@ failed: static BOOL ODBC_LoadDMFunctions(void) { - int i; char error[256]; - if (gProxyHandle.dmHandle == NULL) + if (dmHandle == NULL) return FALSE; - for ( i = 0; i < NUM_SQLFUNC; i ++ ) - { - char * pFuncNameW; +#define LOAD_FUNC(name) \ + if ((p##name = wine_dlsym( dmHandle, #name, error, sizeof(error) ))); \ + else WARN( "Failed to load %s: %s\n", #name, error ) - gProxyHandle.functions[i] = template_func[i]; - gProxyHandle.functions[i].func = wine_dlsym(gProxyHandle.dmHandle, - gProxyHandle.functions[i].name, error, sizeof(error)); - - if (error[0]) - { - ERR("Failed to load function %s\n",gProxyHandle.functions[i].name); - gProxyHandle.functions[i].func = SQLDummyFunc; - } - else - { - /* Build Unicode function name for this function */ - pFuncNameW = HeapAlloc(GetProcessHeap(), 0, strlen(gProxyHandle.functions[i].name) + 2); - strcpy(pFuncNameW, gProxyHandle.functions[i].name); - pFuncNameW[strlen(gProxyHandle.functions[i].name) + 1] = '\0'; - pFuncNameW[strlen(gProxyHandle.functions[i].name)] = 'W'; - - gProxyHandle.functions[i].funcW = wine_dlsym(gProxyHandle.dmHandle, - pFuncNameW, error, sizeof(error)); - if (error[0]) - { -/* TRACE("Failed to load function %s, possibly no Unicode version is required\n", pFuncNameW); */ - gProxyHandle.functions[i].funcW = NULL; - } - HeapFree(GetProcessHeap(), 0, pFuncNameW); - } - } - - gProxyHandle.bFunctionReady = TRUE; + LOAD_FUNC(SQLAllocConnect); + LOAD_FUNC(SQLAllocEnv); + LOAD_FUNC(SQLAllocHandle); + LOAD_FUNC(SQLAllocHandleStd); + LOAD_FUNC(SQLAllocStmt); + LOAD_FUNC(SQLBindCol); + LOAD_FUNC(SQLBindParam); + LOAD_FUNC(SQLBindParameter); + LOAD_FUNC(SQLBrowseConnect); + LOAD_FUNC(SQLBrowseConnectW); + LOAD_FUNC(SQLBulkOperations); + LOAD_FUNC(SQLCancel); + LOAD_FUNC(SQLCloseCursor); + LOAD_FUNC(SQLColAttribute); + LOAD_FUNC(SQLColAttributeW); + LOAD_FUNC(SQLColAttributes); + LOAD_FUNC(SQLColAttributesW); + LOAD_FUNC(SQLColumnPrivileges); + LOAD_FUNC(SQLColumnPrivilegesW); + LOAD_FUNC(SQLColumns); + LOAD_FUNC(SQLColumnsW); + LOAD_FUNC(SQLConnect); + LOAD_FUNC(SQLConnectW); + LOAD_FUNC(SQLCopyDesc); + LOAD_FUNC(SQLDataSources); + LOAD_FUNC(SQLDataSourcesW); + LOAD_FUNC(SQLDescribeCol); + LOAD_FUNC(SQLDescribeColW); + LOAD_FUNC(SQLDescribeParam); + LOAD_FUNC(SQLDisconnect); + LOAD_FUNC(SQLDriverConnect); + LOAD_FUNC(SQLDriverConnectW); + LOAD_FUNC(SQLDrivers); + LOAD_FUNC(SQLDriversW); + LOAD_FUNC(SQLEndTran); + LOAD_FUNC(SQLError); + LOAD_FUNC(SQLErrorW); + LOAD_FUNC(SQLExecDirect); + LOAD_FUNC(SQLExecDirectW); + LOAD_FUNC(SQLExecute); + LOAD_FUNC(SQLExtendedFetch); + LOAD_FUNC(SQLFetch); + LOAD_FUNC(SQLFetchScroll); + LOAD_FUNC(SQLForeignKeys); + LOAD_FUNC(SQLForeignKeysW); + LOAD_FUNC(SQLFreeConnect); + LOAD_FUNC(SQLFreeEnv); + LOAD_FUNC(SQLFreeHandle); + LOAD_FUNC(SQLFreeStmt); + LOAD_FUNC(SQLGetConnectAttr); + LOAD_FUNC(SQLGetConnectAttrW); + LOAD_FUNC(SQLGetConnectOption); + LOAD_FUNC(SQLGetConnectOptionW); + LOAD_FUNC(SQLGetCursorName); + LOAD_FUNC(SQLGetCursorNameW); + LOAD_FUNC(SQLGetData); + LOAD_FUNC(SQLGetDescField); + LOAD_FUNC(SQLGetDescFieldW); + LOAD_FUNC(SQLGetDescRec); + LOAD_FUNC(SQLGetDescRecW); + LOAD_FUNC(SQLGetDiagField); + LOAD_FUNC(SQLGetDiagFieldW); + LOAD_FUNC(SQLGetDiagRec); + LOAD_FUNC(SQLGetDiagRecW); + LOAD_FUNC(SQLGetEnvAttr); + LOAD_FUNC(SQLGetFunctions); + LOAD_FUNC(SQLGetInfo); + LOAD_FUNC(SQLGetInfoW); + LOAD_FUNC(SQLGetStmtAttr); + LOAD_FUNC(SQLGetStmtAttrW); + LOAD_FUNC(SQLGetStmtOption); + LOAD_FUNC(SQLGetTypeInfo); + LOAD_FUNC(SQLGetTypeInfoW); + LOAD_FUNC(SQLMoreResults); + LOAD_FUNC(SQLNativeSql); + LOAD_FUNC(SQLNativeSqlW); + LOAD_FUNC(SQLNumParams); + LOAD_FUNC(SQLNumResultCols); + LOAD_FUNC(SQLParamData); + LOAD_FUNC(SQLParamOptions); + LOAD_FUNC(SQLPrepare); + LOAD_FUNC(SQLPrepareW); + LOAD_FUNC(SQLPrimaryKeys); + LOAD_FUNC(SQLPrimaryKeysW); + LOAD_FUNC(SQLProcedureColumns); + LOAD_FUNC(SQLProcedureColumnsW); + LOAD_FUNC(SQLProcedures); + LOAD_FUNC(SQLProceduresW); + LOAD_FUNC(SQLPutData); + LOAD_FUNC(SQLRowCount); + LOAD_FUNC(SQLSetConnectAttr); + LOAD_FUNC(SQLSetConnectAttrW); + LOAD_FUNC(SQLSetConnectOption); + LOAD_FUNC(SQLSetConnectOptionW); + LOAD_FUNC(SQLSetCursorName); + LOAD_FUNC(SQLSetCursorNameW); + LOAD_FUNC(SQLSetDescField); + LOAD_FUNC(SQLSetDescFieldW); + LOAD_FUNC(SQLSetDescRec); + LOAD_FUNC(SQLSetEnvAttr); + LOAD_FUNC(SQLSetParam); + LOAD_FUNC(SQLSetPos); + LOAD_FUNC(SQLSetScrollOptions); + LOAD_FUNC(SQLSetStmtAttr); + LOAD_FUNC(SQLSetStmtAttrW); + LOAD_FUNC(SQLSetStmtOption); + LOAD_FUNC(SQLSpecialColumns); + LOAD_FUNC(SQLSpecialColumnsW); + LOAD_FUNC(SQLStatistics); + LOAD_FUNC(SQLStatisticsW); + LOAD_FUNC(SQLTablePrivileges); + LOAD_FUNC(SQLTablePrivilegesW); + LOAD_FUNC(SQLTables); + LOAD_FUNC(SQLTablesW); + LOAD_FUNC(SQLTransact); +#undef LOAD_FUNC return TRUE; } @@ -602,16 +688,14 @@ SQLRETURN WINAPI SQLAllocConnect(SQLHENV EnvironmentHandle, SQLHDBC *ConnectionH SQLRETURN ret; TRACE("Env=%lx\n",EnvironmentHandle); - if (!gProxyHandle.bFunctionReady || gProxyHandle.dmHandle == NULL) + if (!pSQLAllocConnect) { *ConnectionHandle = SQL_NULL_HDBC; TRACE("Not ready\n"); return SQL_ERROR; } - assert(gProxyHandle.functions[SQLAPI_INDEX_SQLALLOCCONNECT].func); - ret=(gProxyHandle.functions[SQLAPI_INDEX_SQLALLOCCONNECT].func) - (EnvironmentHandle, ConnectionHandle); + ret = pSQLAllocConnect(EnvironmentHandle, ConnectionHandle); TRACE("Returns ret=%d, Handle %lx\n",ret, *ConnectionHandle); return ret; } @@ -625,15 +709,14 @@ SQLRETURN WINAPI SQLAllocEnv(SQLHENV *EnvironmentHandle) SQLRETURN ret; TRACE("\n"); - if (!gProxyHandle.bFunctionReady || gProxyHandle.dmHandle == NULL) + if (!pSQLAllocEnv) { *EnvironmentHandle = SQL_NULL_HENV; TRACE("Not ready\n"); return SQL_ERROR; } - assert(gProxyHandle.functions[SQLAPI_INDEX_SQLALLOCENV].func); - ret=(gProxyHandle.functions[SQLAPI_INDEX_SQLALLOCENV].func) (EnvironmentHandle); + ret = pSQLAllocEnv(EnvironmentHandle); TRACE("Returns ret=%d, Env=%lx\n",ret, *EnvironmentHandle); return ret; } @@ -647,9 +730,9 @@ SQLRETURN WINAPI SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, S SQLRETURN ret; TRACE("(Type=%d, Handle=%lx)\n",HandleType,InputHandle); - if (!gProxyHandle.bFunctionReady || gProxyHandle.dmHandle == NULL) + if (!pSQLAllocHandle) { - if (gProxyHandle.nErrorType == ERROR_LIBRARY_NOT_FOUND) + if (nErrorType == ERROR_LIBRARY_NOT_FOUND) WARN("ProxyODBC: Cannot load ODBC driver manager library.\n"); if (HandleType == SQL_HANDLE_ENV) @@ -665,9 +748,7 @@ SQLRETURN WINAPI SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, S return SQL_ERROR; } - assert(gProxyHandle.functions[SQLAPI_INDEX_SQLALLOCHANDLE].func); - ret=(gProxyHandle.functions[SQLAPI_INDEX_SQLALLOCHANDLE].func) - (HandleType, InputHandle, OutputHandle); + ret = pSQLAllocHandle(HandleType, InputHandle, OutputHandle); TRACE("Returns ret=%d, Handle=%lx\n",ret, *OutputHandle); return ret; } @@ -682,16 +763,14 @@ SQLRETURN WINAPI SQLAllocStmt(SQLHDBC ConnectionHandle, SQLHSTMT *StatementHandl TRACE("(Connection=%lx)\n",ConnectionHandle); - if (!gProxyHandle.bFunctionReady || gProxyHandle.dmHandle == NULL) + if (!pSQLAllocStmt) { *StatementHandle = SQL_NULL_HSTMT; TRACE ("Not ready\n"); return SQL_ERROR; } - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLALLOCSTMT].func); - ret=(gProxyHandle.functions[SQLAPI_INDEX_SQLALLOCSTMT].func) - (ConnectionHandle, StatementHandle); + ret = pSQLAllocStmt(ConnectionHandle, StatementHandle); TRACE ("Returns ret=%d, Handle=%lx\n", ret, *StatementHandle); return ret; } @@ -701,13 +780,13 @@ SQLRETURN WINAPI SQLAllocStmt(SQLHDBC ConnectionHandle, SQLHSTMT *StatementHandl * SQLAllocHandleStd [ODBC32.077] */ SQLRETURN WINAPI SQLAllocHandleStd( SQLSMALLINT HandleType, - SQLHANDLE InputHandle, SQLHANDLE *OutputHandle) + SQLHANDLE InputHandle, SQLHANDLE *OutputHandle) { TRACE("ProxyODBC: SQLAllocHandleStd.\n"); - if (!gProxyHandle.bFunctionReady || gProxyHandle.dmHandle == NULL) + if (!pSQLAllocHandleStd) { - if (gProxyHandle.nErrorType == ERROR_LIBRARY_NOT_FOUND) + if (nErrorType == ERROR_LIBRARY_NOT_FOUND) WARN("ProxyODBC: Cannot load ODBC driver manager library.\n"); if (HandleType == SQL_HANDLE_ENV) @@ -722,9 +801,7 @@ SQLRETURN WINAPI SQLAllocHandleStd( SQLSMALLINT HandleType, return SQL_ERROR; } - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLALLOCHANDLESTD].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLALLOCHANDLESTD].func) - (HandleType, InputHandle, OutputHandle); + return pSQLAllocHandleStd(HandleType, InputHandle, OutputHandle); } @@ -738,16 +815,14 @@ SQLRETURN WINAPI SQLBindCol(SQLHSTMT StatementHandle, { TRACE("\n"); - if (!gProxyHandle.bFunctionReady || gProxyHandle.dmHandle == NULL) + if (!pSQLBindCol) { TRACE ("Not ready\n"); return SQL_ERROR; } - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLBINDCOL].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLBINDCOL].func) - (StatementHandle, ColumnNumber, TargetType, - TargetValue, BufferLength, StrLen_or_Ind); + return pSQLBindCol(StatementHandle, ColumnNumber, TargetType, + TargetValue, BufferLength, StrLen_or_Ind); } @@ -762,12 +837,10 @@ SQLRETURN WINAPI SQLBindParam(SQLHSTMT StatementHandle, { TRACE("\n"); - CHECK_READY_AND_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLBINDPARAM].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLBINDPARAM].func) - (StatementHandle, ParameterNumber, ValueType, - ParameterScale, ParameterValue, StrLen_or_Ind); + if (!pSQLBindParam) return SQL_ERROR; + return pSQLBindParam(StatementHandle, ParameterNumber, ValueType, + ParameterType, LengthPrecision, ParameterScale, + ParameterValue, StrLen_or_Ind); } @@ -778,10 +851,8 @@ SQLRETURN WINAPI SQLCancel(SQLHSTMT StatementHandle) { TRACE("\n"); - CHECK_READY_AND_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLCANCEL].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLCANCEL].func) (StatementHandle); + if (!pSQLCancel) return SQL_ERROR; + return pSQLCancel(StatementHandle); } @@ -793,10 +864,9 @@ SQLRETURN WINAPI SQLCloseCursor(SQLHSTMT StatementHandle) SQLRETURN ret; TRACE("(Handle=%lx)\n",StatementHandle); - CHECK_READY_AND_dmHandle(); + if (!pSQLCloseCursor) return SQL_ERROR; - assert(gProxyHandle.functions[SQLAPI_INDEX_SQLCLOSECURSOR].func); - ret=(gProxyHandle.functions[SQLAPI_INDEX_SQLCLOSECURSOR].func) (StatementHandle); + ret = pSQLCloseCursor(StatementHandle); TRACE("returns %d\n",ret); return ret; } @@ -812,12 +882,9 @@ SQLRETURN WINAPI SQLColAttribute (SQLHSTMT StatementHandle, { TRACE("\n"); - CHECK_READY_AND_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLCOLATTRIBUTE].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLCOLATTRIBUTE].func) - (StatementHandle, ColumnNumber, FieldIdentifier, - CharacterAttribute, BufferLength, StringLength, NumericAttribute); + if (!pSQLColAttribute) return SQL_ERROR; + return pSQLColAttribute(StatementHandle, ColumnNumber, FieldIdentifier, + CharacterAttribute, BufferLength, StringLength, NumericAttribute); } @@ -832,12 +899,9 @@ SQLRETURN WINAPI SQLColumns(SQLHSTMT StatementHandle, { TRACE("\n"); - CHECK_READY_AND_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLCOLUMNS].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLCOLUMNS].func) - (StatementHandle, CatalogName, NameLength1, - SchemaName, NameLength2, TableName, NameLength3, ColumnName, NameLength4); + if (!pSQLColumns) return SQL_ERROR; + return pSQLColumns(StatementHandle, CatalogName, NameLength1, + SchemaName, NameLength2, TableName, NameLength3, ColumnName, NameLength4); } @@ -852,15 +916,10 @@ SQLRETURN WINAPI SQLConnect(SQLHDBC ConnectionHandle, SQLRETURN ret; TRACE("(Server=%.*s)\n",NameLength1, ServerName); - CHECK_READY_AND_dmHandle(); + if (!pSQLConnect) return SQL_ERROR; - strcpy( (LPSTR)gProxyHandle.ServerName, (LPSTR)ServerName ); - strcpy( (LPSTR)gProxyHandle.UserName, (LPSTR)UserName ); - - assert(gProxyHandle.functions[SQLAPI_INDEX_SQLCONNECT].func); - ret=(gProxyHandle.functions[SQLAPI_INDEX_SQLCONNECT].func) - (ConnectionHandle, ServerName, NameLength1, - UserName, NameLength2, Authentication, NameLength3); + ret = pSQLConnect(ConnectionHandle, ServerName, NameLength1, + UserName, NameLength2, Authentication, NameLength3); TRACE("returns %d\n",ret); return ret; @@ -874,11 +933,8 @@ SQLRETURN WINAPI SQLCopyDesc(SQLHDESC SourceDescHandle, SQLHDESC TargetDescHandl { TRACE("\n"); - CHECK_READY_AND_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLCOPYDESC].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLCOPYDESC].func) - (SourceDescHandle, TargetDescHandle); + if (!pSQLCopyDesc) return SQL_ERROR; + return pSQLCopyDesc(SourceDescHandle, TargetDescHandle); } @@ -895,16 +951,10 @@ SQLRETURN WINAPI SQLDataSources(SQLHENV EnvironmentHandle, TRACE("EnvironmentHandle = %p\n", (LPVOID)EnvironmentHandle); - if (!gProxyHandle.bFunctionReady || gProxyHandle.dmHandle == NULL) - { - ERR("Error: empty dm handle (gProxyHandle.dmHandle == NULL)\n"); - return SQL_ERROR; - } + if (!pSQLDataSources) return SQL_ERROR; - assert(gProxyHandle.functions[SQLAPI_INDEX_SQLDATASOURCES].func); - ret = (gProxyHandle.functions[SQLAPI_INDEX_SQLDATASOURCES].func) - (EnvironmentHandle, Direction, ServerName, - BufferLength1, NameLength1, Description, BufferLength2, NameLength2); + ret = pSQLDataSources(EnvironmentHandle, Direction, ServerName, + BufferLength1, NameLength1, Description, BufferLength2, NameLength2); if (TRACE_ON(odbc)) { @@ -931,12 +981,9 @@ SQLRETURN WINAPI SQLDescribeCol(SQLHSTMT StatementHandle, { TRACE("\n"); - CHECK_READY_AND_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLDESCRIBECOL].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLDESCRIBECOL].func) - (StatementHandle, ColumnNumber, ColumnName, - BufferLength, NameLength, DataType, ColumnSize, DecimalDigits, Nullable); + if (!pSQLDescribeCol) return SQL_ERROR; + return pSQLDescribeCol(StatementHandle, ColumnNumber, ColumnName, + BufferLength, NameLength, DataType, ColumnSize, DecimalDigits, Nullable); } @@ -948,13 +995,9 @@ SQLRETURN WINAPI SQLDisconnect(SQLHDBC ConnectionHandle) SQLRETURN ret; TRACE("(Handle=%lx)\n", ConnectionHandle); - CHECK_READY_AND_dmHandle(); + if (!pSQLDisconnect) return SQL_ERROR; - gProxyHandle.ServerName[0] = '\0'; - gProxyHandle.UserName[0] = '\0'; - - assert(gProxyHandle.functions[SQLAPI_INDEX_SQLDISCONNECT].func); - ret = (gProxyHandle.functions[SQLAPI_INDEX_SQLDISCONNECT].func) (ConnectionHandle); + ret = pSQLDisconnect(ConnectionHandle); TRACE("returns %d\n",ret); return ret; } @@ -967,10 +1010,8 @@ SQLRETURN WINAPI SQLEndTran(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLIN { TRACE("\n"); - CHECK_READY_AND_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLENDTRAN].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLENDTRAN].func) (HandleType, Handle, CompletionType); + if (!pSQLEndTran) return SQL_ERROR; + return pSQLEndTran(HandleType, Handle, CompletionType); } @@ -985,12 +1026,9 @@ SQLRETURN WINAPI SQLError(SQLHENV EnvironmentHandle, { TRACE("\n"); - CHECK_READY_AND_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLERROR].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLERROR].func) - (EnvironmentHandle, ConnectionHandle, StatementHandle, - Sqlstate, NativeError, MessageText, BufferLength, TextLength); + if (!pSQLError) return SQL_ERROR; + return pSQLError(EnvironmentHandle, ConnectionHandle, StatementHandle, + Sqlstate, NativeError, MessageText, BufferLength, TextLength); } @@ -1001,11 +1039,8 @@ SQLRETURN WINAPI SQLExecDirect(SQLHSTMT StatementHandle, SQLCHAR *StatementText, { TRACE("\n"); - CHECK_READY_AND_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLEXECDIRECT].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLEXECDIRECT].func) - (StatementHandle, StatementText, TextLength); + if (!pSQLExecDirect) return SQL_ERROR; + return pSQLExecDirect(StatementHandle, StatementText, TextLength); } @@ -1016,10 +1051,8 @@ SQLRETURN WINAPI SQLExecute(SQLHSTMT StatementHandle) { TRACE("\n"); - CHECK_READY_AND_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLEXECUTE].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLEXECUTE].func) (StatementHandle); + if (!pSQLExecute) return SQL_ERROR; + return pSQLExecute(StatementHandle); } @@ -1030,10 +1063,8 @@ SQLRETURN WINAPI SQLFetch(SQLHSTMT StatementHandle) { TRACE("\n"); - CHECK_READY_AND_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLFETCH].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLFETCH].func) (StatementHandle); + if (!pSQLFetch) return SQL_ERROR; + return pSQLFetch(StatementHandle); } @@ -1044,11 +1075,8 @@ SQLRETURN WINAPI SQLFetchScroll(SQLHSTMT StatementHandle, SQLSMALLINT FetchOrien { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLFETCHSCROLL].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLFETCHSCROLL].func) - (StatementHandle, FetchOrientation, FetchOffset); + if (!pSQLFetchScroll) return SQL_ERROR; + return pSQLFetchScroll(StatementHandle, FetchOrientation, FetchOffset); } @@ -1060,10 +1088,9 @@ SQLRETURN WINAPI SQLFreeConnect(SQLHDBC ConnectionHandle) SQLRETURN ret; TRACE("(Handle=%lx)\n",ConnectionHandle); - CHECK_dmHandle(); + if (!pSQLFreeConnect) return SQL_ERROR; - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLFREECONNECT].func); - ret=(gProxyHandle.functions[SQLAPI_INDEX_SQLFREECONNECT].func) (ConnectionHandle); + ret = pSQLFreeConnect(ConnectionHandle); TRACE("Returns %d\n",ret); return ret; } @@ -1077,10 +1104,9 @@ SQLRETURN WINAPI SQLFreeEnv(SQLHENV EnvironmentHandle) SQLRETURN ret; TRACE("(Env=%lx)\n",EnvironmentHandle); - CHECK_dmHandle(); + if (!pSQLFreeEnv) return SQL_ERROR; - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLFREEENV].func); - ret = (gProxyHandle.functions[SQLAPI_INDEX_SQLFREEENV].func) (EnvironmentHandle); + ret = pSQLFreeEnv(EnvironmentHandle); TRACE("Returns %d\n",ret); return ret; } @@ -1094,11 +1120,9 @@ SQLRETURN WINAPI SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle) SQLRETURN ret; TRACE("(Type=%d, Handle=%lx)\n",HandleType,Handle); - CHECK_dmHandle(); + if (!pSQLFreeHandle) return SQL_ERROR; - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLFREEHANDLE].func); - ret = (gProxyHandle.functions[SQLAPI_INDEX_SQLFREEHANDLE].func) - (HandleType, Handle); + ret = pSQLFreeHandle(HandleType, Handle); TRACE ("Returns %d\n",ret); return ret; } @@ -1112,11 +1136,9 @@ SQLRETURN WINAPI SQLFreeStmt(SQLHSTMT StatementHandle, SQLUSMALLINT Option) SQLRETURN ret; TRACE("(Handle %lx, Option=%d)\n",StatementHandle, Option); - CHECK_dmHandle(); + if (!pSQLFreeStmt) return SQL_ERROR; - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLFREESTMT].func); - ret=(gProxyHandle.functions[SQLAPI_INDEX_SQLFREESTMT].func) - (StatementHandle, Option); + ret = pSQLFreeStmt(StatementHandle, Option); TRACE("Returns %d\n",ret); return ret; } @@ -1131,12 +1153,9 @@ SQLRETURN WINAPI SQLGetConnectAttr(SQLHDBC ConnectionHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETCONNECTATTR].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETCONNECTATTR].func) - (ConnectionHandle, Attribute, Value, - BufferLength, StringLength); + if (!pSQLGetConnectAttr) return SQL_ERROR; + return pSQLGetConnectAttr(ConnectionHandle, Attribute, Value, + BufferLength, StringLength); } @@ -1147,11 +1166,8 @@ SQLRETURN WINAPI SQLGetConnectOption(SQLHDBC ConnectionHandle, SQLUSMALLINT Opti { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETCONNECTOPTION].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETCONNECTOPTION].func) - (ConnectionHandle, Option, Value); + if (!pSQLGetConnectOption) return SQL_ERROR; + return pSQLGetConnectOption(ConnectionHandle, Option, Value); } @@ -1164,11 +1180,8 @@ SQLRETURN WINAPI SQLGetCursorName(SQLHSTMT StatementHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETCURSORNAME].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETCURSORNAME].func) - (StatementHandle, CursorName, BufferLength, NameLength); + if (!pSQLGetCursorName) return SQL_ERROR; + return pSQLGetCursorName(StatementHandle, CursorName, BufferLength, NameLength); } @@ -1182,12 +1195,9 @@ SQLRETURN WINAPI SQLGetData(SQLHSTMT StatementHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETDATA].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETDATA].func) - (StatementHandle, ColumnNumber, TargetType, - TargetValue, BufferLength, StrLen_or_Ind); + if (!pSQLGetData) return SQL_ERROR; + return pSQLGetData(StatementHandle, ColumnNumber, TargetType, + TargetValue, BufferLength, StrLen_or_Ind); } @@ -1201,12 +1211,9 @@ SQLRETURN WINAPI SQLGetDescField(SQLHDESC DescriptorHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETDESCFIELD].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETDESCFIELD].func) - (DescriptorHandle, RecNumber, FieldIdentifier, - Value, BufferLength, StringLength); + if (!pSQLGetDescField) return SQL_ERROR; + return pSQLGetDescField(DescriptorHandle, RecNumber, FieldIdentifier, + Value, BufferLength, StringLength); } @@ -1222,12 +1229,9 @@ SQLRETURN WINAPI SQLGetDescRec(SQLHDESC DescriptorHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETDESCREC].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETDESCREC].func) - (DescriptorHandle, RecNumber, Name, BufferLength, - StringLength, Type, SubType, Length, Precision, Scale, Nullable); + if (!pSQLGetDescRec) return SQL_ERROR; + return pSQLGetDescRec(DescriptorHandle, RecNumber, Name, BufferLength, + StringLength, Type, SubType, Length, Precision, Scale, Nullable); } @@ -1241,12 +1245,9 @@ SQLRETURN WINAPI SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETDIAGFIELD].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETDIAGFIELD].func) - (HandleType, Handle, RecNumber, DiagIdentifier, - DiagInfo, BufferLength, StringLength); + if (!pSQLGetDiagField) return SQL_ERROR; + return pSQLGetDiagField(HandleType, Handle, RecNumber, DiagIdentifier, + DiagInfo, BufferLength, StringLength); } @@ -1260,12 +1261,9 @@ SQLRETURN WINAPI SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETDIAGREC].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETDIAGREC].func) - (HandleType, Handle, RecNumber, Sqlstate, NativeError, - MessageText, BufferLength, TextLength); + if (!pSQLGetDiagRec) return SQL_ERROR; + return pSQLGetDiagRec(HandleType, Handle, RecNumber, Sqlstate, NativeError, + MessageText, BufferLength, TextLength); } @@ -1278,11 +1276,8 @@ SQLRETURN WINAPI SQLGetEnvAttr(SQLHENV EnvironmentHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETENVATTR].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETENVATTR].func) - (EnvironmentHandle, Attribute, Value, BufferLength, StringLength); + if (!pSQLGetEnvAttr) return SQL_ERROR; + return pSQLGetEnvAttr(EnvironmentHandle, Attribute, Value, BufferLength, StringLength); } @@ -1293,11 +1288,8 @@ SQLRETURN WINAPI SQLGetFunctions(SQLHDBC ConnectionHandle, SQLUSMALLINT Function { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETFUNCTIONS].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETFUNCTIONS].func) - (ConnectionHandle, FunctionId, Supported); + if (!pSQLGetFunctions) return SQL_ERROR; + return pSQLGetFunctions(ConnectionHandle, FunctionId, Supported); } @@ -1310,11 +1302,8 @@ SQLRETURN WINAPI SQLGetInfo(SQLHDBC ConnectionHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETINFO].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETINFO].func) - (ConnectionHandle, InfoType, InfoValue, BufferLength, StringLength); + if (!pSQLGetInfo) return SQL_ERROR; + return pSQLGetInfo(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLength); } @@ -1327,11 +1316,8 @@ SQLRETURN WINAPI SQLGetStmtAttr(SQLHSTMT StatementHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETSTMTATTR].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETSTMTATTR].func) - (StatementHandle, Attribute, Value, BufferLength, StringLength); + if (!pSQLGetStmtAttr) return SQL_ERROR; + return pSQLGetStmtAttr(StatementHandle, Attribute, Value, BufferLength, StringLength); } @@ -1342,11 +1328,8 @@ SQLRETURN WINAPI SQLGetStmtOption(SQLHSTMT StatementHandle, SQLUSMALLINT Option, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETSTMTOPTION].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETSTMTOPTION].func) - (StatementHandle, Option, Value); + if (!pSQLGetStmtOption) return SQL_ERROR; + return pSQLGetStmtOption(StatementHandle, Option, Value); } @@ -1357,11 +1340,8 @@ SQLRETURN WINAPI SQLGetTypeInfo(SQLHSTMT StatementHandle, SQLSMALLINT DataType) { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETTYPEINFO].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETTYPEINFO].func) - (StatementHandle, DataType); + if (!pSQLGetTypeInfo) return SQL_ERROR; + return pSQLGetTypeInfo(StatementHandle, DataType); } @@ -1372,11 +1352,8 @@ SQLRETURN WINAPI SQLNumResultCols(SQLHSTMT StatementHandle, SQLSMALLINT *ColumnC { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLNUMRESULTCOLS].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLNUMRESULTCOLS].func) - (StatementHandle, ColumnCount); + if (!pSQLNumResultCols) return SQL_ERROR; + return pSQLNumResultCols(StatementHandle, ColumnCount); } @@ -1387,11 +1364,8 @@ SQLRETURN WINAPI SQLParamData(SQLHSTMT StatementHandle, SQLPOINTER *Value) { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLPARAMDATA].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLPARAMDATA].func) - (StatementHandle, Value); + if (!pSQLParamData) return SQL_ERROR; + return pSQLParamData(StatementHandle, Value); } @@ -1402,11 +1376,8 @@ SQLRETURN WINAPI SQLPrepare(SQLHSTMT StatementHandle, SQLCHAR *StatementText, SQ { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLPREPARE].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLPREPARE].func) - (StatementHandle, StatementText, TextLength); + if (!pSQLPrepare) return SQL_ERROR; + return pSQLPrepare(StatementHandle, StatementText, TextLength); } @@ -1417,11 +1388,8 @@ SQLRETURN WINAPI SQLPutData(SQLHSTMT StatementHandle, SQLPOINTER Data, SQLINTEGE { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLPUTDATA].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLPUTDATA].func) - (StatementHandle, Data, StrLen_or_Ind); + if (!pSQLPutData) return SQL_ERROR; + return pSQLPutData(StatementHandle, Data, StrLen_or_Ind); } @@ -1432,11 +1400,8 @@ SQLRETURN WINAPI SQLRowCount(SQLHSTMT StatementHandle, SQLINTEGER *RowCount) { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLROWCOUNT].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLROWCOUNT].func) - (StatementHandle, RowCount); + if (!pSQLRowCount) return SQL_ERROR; + return pSQLRowCount(StatementHandle, RowCount); } @@ -1448,11 +1413,8 @@ SQLRETURN WINAPI SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribut { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLSETCONNECTATTR].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLSETCONNECTATTR].func) - (ConnectionHandle, Attribute, Value, StringLength); + if (!pSQLSetConnectAttr) return SQL_ERROR; + return pSQLSetConnectAttr(ConnectionHandle, Attribute, Value, StringLength); } @@ -1463,11 +1425,8 @@ SQLRETURN WINAPI SQLSetConnectOption(SQLHDBC ConnectionHandle, SQLUSMALLINT Opti { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLSETCONNECTOPTION].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLSETCONNECTOPTION].func) - (ConnectionHandle, Option, Value); + if (!pSQLSetConnectOption) return SQL_ERROR; + return pSQLSetConnectOption(ConnectionHandle, Option, Value); } @@ -1478,11 +1437,8 @@ SQLRETURN WINAPI SQLSetCursorName(SQLHSTMT StatementHandle, SQLCHAR *CursorName, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLSETCURSORNAME].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLSETCURSORNAME].func) - (StatementHandle, CursorName, NameLength); + if (!pSQLSetCursorName) return SQL_ERROR; + return pSQLSetCursorName(StatementHandle, CursorName, NameLength); } @@ -1495,11 +1451,8 @@ SQLRETURN WINAPI SQLSetDescField(SQLHDESC DescriptorHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLSETDESCFIELD].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLSETDESCFIELD].func) - (DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength); + if (!pSQLSetDescField) return SQL_ERROR; + return pSQLSetDescField(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength); } @@ -1515,12 +1468,9 @@ SQLRETURN WINAPI SQLSetDescRec(SQLHDESC DescriptorHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLSETDESCREC].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLSETDESCREC].func) - (DescriptorHandle, RecNumber, Type, SubType, Length, - Precision, Scale, Data, StringLength, Indicator); + if (!pSQLSetDescRec) return SQL_ERROR; + return pSQLSetDescRec(DescriptorHandle, RecNumber, Type, SubType, Length, + Precision, Scale, Data, StringLength, Indicator); } @@ -1533,11 +1483,8 @@ SQLRETURN WINAPI SQLSetEnvAttr(SQLHENV EnvironmentHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLSETENVATTR].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLSETENVATTR].func) - (EnvironmentHandle, Attribute, Value, StringLength); + if (!pSQLSetEnvAttr) return SQL_ERROR; + return pSQLSetEnvAttr(EnvironmentHandle, Attribute, Value, StringLength); } @@ -1552,12 +1499,9 @@ SQLRETURN WINAPI SQLSetParam(SQLHSTMT StatementHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLSETPARAM].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLSETPARAM].func) - (StatementHandle, ParameterNumber, ValueType, ParameterType, LengthPrecision, - ParameterScale, ParameterValue, StrLen_or_Ind); + if (!pSQLSetParam) return SQL_ERROR; + return pSQLSetParam(StatementHandle, ParameterNumber, ValueType, ParameterType, LengthPrecision, + ParameterScale, ParameterValue, StrLen_or_Ind); } @@ -1570,11 +1514,8 @@ SQLRETURN WINAPI SQLSetStmtAttr(SQLHSTMT StatementHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLSETSTMTATTR].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLSETSTMTATTR].func) - (StatementHandle, Attribute, Value, StringLength); + if (!pSQLSetStmtAttr) return SQL_ERROR; + return pSQLSetStmtAttr(StatementHandle, Attribute, Value, StringLength); } @@ -1585,11 +1526,8 @@ SQLRETURN WINAPI SQLSetStmtOption(SQLHSTMT StatementHandle, SQLUSMALLINT Option, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLSETSTMTOPTION].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLSETSTMTOPTION].func) - (StatementHandle, Option, Value); + if (!pSQLSetStmtOption) return SQL_ERROR; + return pSQLSetStmtOption(StatementHandle, Option, Value); } @@ -1604,12 +1542,9 @@ SQLRETURN WINAPI SQLSpecialColumns(SQLHSTMT StatementHandle, SQLUSMALLINT Nullable) { - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLSPECIALCOLUMNS].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLSPECIALCOLUMNS].func) - (StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName, - NameLength2, TableName, NameLength3, Scope, Nullable); + if (!pSQLSpecialColumns) return SQL_ERROR; + return pSQLSpecialColumns(StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName, + NameLength2, TableName, NameLength3, Scope, Nullable); } @@ -1624,12 +1559,9 @@ SQLRETURN WINAPI SQLStatistics(SQLHSTMT StatementHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLSTATISTICS].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLSTATISTICS].func) - (StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2, - TableName, NameLength3, Unique, Reserved); + if (!pSQLStatistics) return SQL_ERROR; + return pSQLStatistics(StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2, + TableName, NameLength3, Unique, Reserved); } @@ -1644,12 +1576,9 @@ SQLRETURN WINAPI SQLTables(SQLHSTMT StatementHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLTABLES].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLTABLES].func) - (StatementHandle, CatalogName, NameLength1, - SchemaName, NameLength2, TableName, NameLength3, TableType, NameLength4); + if (!pSQLTables) return SQL_ERROR; + return pSQLTables(StatementHandle, CatalogName, NameLength1, + SchemaName, NameLength2, TableName, NameLength3, TableType, NameLength4); } @@ -1661,11 +1590,8 @@ SQLRETURN WINAPI SQLTransact(SQLHENV EnvironmentHandle, SQLHDBC ConnectionHandle { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLTRANSACT].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLTRANSACT].func) - (EnvironmentHandle, ConnectionHandle, CompletionType); + if (!pSQLTransact) return SQL_ERROR; + return pSQLTransact(EnvironmentHandle, ConnectionHandle, CompletionType); } @@ -1682,11 +1608,8 @@ SQLRETURN WINAPI SQLBrowseConnect( { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLBROWSECONNECT].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLBROWSECONNECT].func) - (hdbc, szConnStrIn, cbConnStrIn, szConnStrOut, cbConnStrOutMax, pcbConnStrOut); + if (!pSQLBrowseConnect) return SQL_ERROR; + return pSQLBrowseConnect(hdbc, szConnStrIn, cbConnStrIn, szConnStrOut, cbConnStrOutMax, pcbConnStrOut); } @@ -1699,11 +1622,8 @@ SQLRETURN WINAPI SQLBulkOperations( { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLBULKOPERATIONS].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLBULKOPERATIONS].func) - (StatementHandle, Operation); + if (!pSQLBulkOperations) return SQL_ERROR; + return pSQLBulkOperations(StatementHandle, Operation); } @@ -1721,11 +1641,8 @@ SQLRETURN WINAPI SQLColAttributes( { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLCOLATTRIBUTES].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLCOLATTRIBUTES].func) - (hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc); + if (!pSQLColAttributes) return SQL_ERROR; + return pSQLColAttributes(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc); } @@ -1745,12 +1662,9 @@ SQLRETURN WINAPI SQLColumnPrivileges( { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLCOLUMNPRIVILEGES].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLCOLUMNPRIVILEGES].func) - (hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, - szTableName, cbTableName, szColumnName, cbColumnName); + if (!pSQLColumnPrivileges) return SQL_ERROR; + return pSQLColumnPrivileges(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, + szTableName, cbTableName, szColumnName, cbColumnName); } @@ -1767,11 +1681,8 @@ SQLRETURN WINAPI SQLDescribeParam( { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLDESCRIBEPARAM].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLDESCRIBEPARAM].func) - (hstmt, ipar, pfSqlType, pcbParamDef, pibScale, pfNullable); + if (!pSQLDescribeParam) return SQL_ERROR; + return pSQLDescribeParam(hstmt, ipar, pfSqlType, pcbParamDef, pibScale, pfNullable); } @@ -1787,11 +1698,8 @@ SQLRETURN WINAPI SQLExtendedFetch( { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLEXTENDEDFETCH].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLEXTENDEDFETCH].func) - (hstmt, fFetchType, irow, pcrow, rgfRowStatus); + if (!pSQLExtendedFetch) return SQL_ERROR; + return pSQLExtendedFetch(hstmt, fFetchType, irow, pcrow, rgfRowStatus); } @@ -1815,13 +1723,10 @@ SQLRETURN WINAPI SQLForeignKeys( { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLFOREIGNKEYS].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLFOREIGNKEYS].func) - (hstmt, szPkCatalogName, cbPkCatalogName, szPkSchemaName, cbPkSchemaName, - szPkTableName, cbPkTableName, szFkCatalogName, cbFkCatalogName, szFkSchemaName, - cbFkSchemaName, szFkTableName, cbFkTableName); + if (!pSQLForeignKeys) return SQL_ERROR; + return pSQLForeignKeys(hstmt, szPkCatalogName, cbPkCatalogName, szPkSchemaName, cbPkSchemaName, + szPkTableName, cbPkTableName, szFkCatalogName, cbFkCatalogName, + szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName); } @@ -1832,10 +1737,8 @@ SQLRETURN WINAPI SQLMoreResults(SQLHSTMT hstmt) { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLMORERESULTS].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLMORERESULTS].func) (hstmt); + if (!pSQLMoreResults) return SQL_ERROR; + return pSQLMoreResults(hstmt); } @@ -1852,11 +1755,8 @@ SQLRETURN WINAPI SQLNativeSql( { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLNATIVESQL].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLNATIVESQL].func) - (hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr, cbSqlStrMax, pcbSqlStr); + if (!pSQLNativeSql) return SQL_ERROR; + return pSQLNativeSql(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr, cbSqlStrMax, pcbSqlStr); } @@ -1869,10 +1769,8 @@ SQLRETURN WINAPI SQLNumParams( { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLNUMPARAMS].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLNUMPARAMS].func) (hstmt, pcpar); + if (!pSQLNumParams) return SQL_ERROR; + return pSQLNumParams(hstmt, pcpar); } @@ -1886,10 +1784,8 @@ SQLRETURN WINAPI SQLParamOptions( { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLPARAMOPTIONS].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLPARAMOPTIONS].func) (hstmt, crow, pirow); + if (!pSQLParamOptions) return SQL_ERROR; + return pSQLParamOptions(hstmt, crow, pirow); } @@ -1907,12 +1803,9 @@ SQLRETURN WINAPI SQLPrimaryKeys( { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLPRIMARYKEYS].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLPRIMARYKEYS].func) - (hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, - szTableName, cbTableName); + if (!pSQLPrimaryKeys) return SQL_ERROR; + return pSQLPrimaryKeys(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, + szTableName, cbTableName); } @@ -1932,12 +1825,9 @@ SQLRETURN WINAPI SQLProcedureColumns( { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLPROCEDURECOLUMNS].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLPROCEDURECOLUMNS].func) - (hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, - szProcName, cbProcName, szColumnName, cbColumnName); + if (!pSQLProcedureColumns) return SQL_ERROR; + return pSQLProcedureColumns(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, + szProcName, cbProcName, szColumnName, cbColumnName); } @@ -1955,12 +1845,9 @@ SQLRETURN WINAPI SQLProcedures( { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLPROCEDURES].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLPROCEDURES].func) - (hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, - szProcName, cbProcName); + if (!pSQLProcedures) return SQL_ERROR; + return pSQLProcedures(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, + szProcName, cbProcName); } @@ -1975,11 +1862,8 @@ SQLRETURN WINAPI SQLSetPos( { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLSETPOS].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLSETPOS].func) - (hstmt, irow, fOption, fLock); + if (!pSQLSetPos) return SQL_ERROR; + return pSQLSetPos(hstmt, irow, fOption, fLock); } @@ -1997,12 +1881,9 @@ SQLRETURN WINAPI SQLTablePrivileges( { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLTABLEPRIVILEGES].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLTABLEPRIVILEGES].func) - (hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, - szTableName, cbTableName); + if (!pSQLTablePrivileges) return SQL_ERROR; + return pSQLTablePrivileges(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, + szTableName, cbTableName); } @@ -2021,12 +1902,9 @@ SQLRETURN WINAPI SQLDrivers( { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLDRIVERS].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLDRIVERS].func) - (henv, fDirection, szDriverDesc, cbDriverDescMax, pcbDriverDesc, - szDriverAttributes, cbDriverAttrMax, pcbDriverAttr); + if (!pSQLDrivers) return SQL_ERROR; + return pSQLDrivers(henv, fDirection, szDriverDesc, cbDriverDescMax, pcbDriverDesc, + szDriverAttributes, cbDriverAttrMax, pcbDriverAttr); } @@ -2047,12 +1925,9 @@ SQLRETURN WINAPI SQLBindParameter( { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLBINDPARAMETER].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLBINDPARAMETER].func) - (hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, - rgbValue, cbValueMax, pcbValue); + if (!pSQLBindParameter) return SQL_ERROR; + return pSQLBindParameter(hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, + rgbValue, cbValueMax, pcbValue); } @@ -2071,12 +1946,9 @@ SQLRETURN WINAPI SQLDriverConnect( { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLDRIVERCONNECT].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLDRIVERCONNECT].func) - (hdbc, hwnd, conn_str_in, len_conn_str_in, conn_str_out, - conn_str_out_max, ptr_conn_str_out, driver_completion); + if (!pSQLDriverConnect) return SQL_ERROR; + return pSQLDriverConnect(hdbc, hwnd, conn_str_in, len_conn_str_in, conn_str_out, + conn_str_out_max, ptr_conn_str_out, driver_completion); } @@ -2091,11 +1963,8 @@ SQLRETURN WINAPI SQLSetScrollOptions( { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLSETSCROLLOPTIONS].func); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLSETSCROLLOPTIONS].func) - (statement_handle, f_concurrency, crow_keyset, crow_rowset); + if (!pSQLSetScrollOptions) return SQL_ERROR; + return pSQLSetScrollOptions(statement_handle, f_concurrency, crow_keyset, crow_rowset); } static int SQLColAttributes_KnownStringAttribute(SQLUSMALLINT fDescType) @@ -2145,10 +2014,9 @@ SQLRETURN WINAPI SQLColAttributesW( TRACE("hstmt=0x%08lx icol=%d fDescType=%d rgbDesc=%p cbDescMax=%d pcbDesc=%p pfDesc=%p\n", hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc); - CHECK_dmHandle(); - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLCOLATTRIBUTES].funcW); - iResult = (gProxyHandle.functions[SQLAPI_INDEX_SQLCOLATTRIBUTES].funcW) - (hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc); + if (!pSQLColAttributesW) return SQL_ERROR; + + iResult = pSQLColAttributesW(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc); if (iResult == SQL_SUCCESS && rgbDesc != NULL && SQLColAttributes_KnownStringAttribute(fDescType)) { /* TRACE("Dumping values fetched via SQLColAttributesW:\n"); @@ -2174,23 +2042,10 @@ SQLRETURN WINAPI SQLConnectW(SQLHDBC ConnectionHandle, SQLRETURN ret; TRACE("(Server=%.*s)\n",NameLength1+3, debugstr_w(ServerName)); - CHECK_READY_AND_dmHandle(); + if (!pSQLConnectW) return SQL_ERROR; - WideCharToMultiByte( - CP_UTF8, 0, - ServerName, NameLength1, - gProxyHandle.ServerName, sizeof(gProxyHandle.ServerName), - NULL, NULL); - WideCharToMultiByte( - CP_UTF8, 0, - UserName, NameLength2, - gProxyHandle.UserName, sizeof(gProxyHandle.UserName), - NULL, NULL); - - assert(gProxyHandle.functions[SQLAPI_INDEX_SQLCONNECT].funcW); - ret=(gProxyHandle.functions[SQLAPI_INDEX_SQLCONNECT].funcW) - (ConnectionHandle, ServerName, NameLength1, - UserName, NameLength2, Authentication, NameLength3); + ret = pSQLConnectW(ConnectionHandle, ServerName, NameLength1, + UserName, NameLength2, Authentication, NameLength3); TRACE("returns %d\n",ret); return ret; @@ -2208,12 +2063,11 @@ SQLRETURN WINAPI SQLDescribeColW(SQLHSTMT StatementHandle, SQLRETURN iResult; TRACE("\n"); - CHECK_READY_AND_dmHandle(); + if (!pSQLDescribeColW) return SQL_ERROR; - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLDESCRIBECOL].funcW); - iResult = (gProxyHandle.functions[SQLAPI_INDEX_SQLDESCRIBECOL].funcW) - (StatementHandle, ColumnNumber, ColumnName, - BufferLength, NameLength, DataType, ColumnSize, DecimalDigits, Nullable); + iResult = pSQLDescribeColW(StatementHandle, ColumnNumber, ColumnName, + BufferLength, NameLength, DataType, ColumnSize, + DecimalDigits, Nullable); if (iResult >= 0) { TRACE("Successfully recovered the following column information:\n"); TRACE("\tRequested column index: %d\n", ColumnNumber); @@ -2237,12 +2091,9 @@ SQLRETURN WINAPI SQLErrorW(SQLHENV EnvironmentHandle, { TRACE("\n"); - CHECK_READY_AND_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLERROR].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLERROR].funcW) - (EnvironmentHandle, ConnectionHandle, StatementHandle, - Sqlstate, NativeError, MessageText, BufferLength, TextLength); + if (!pSQLErrorW) return SQL_ERROR; + return pSQLErrorW(EnvironmentHandle, ConnectionHandle, StatementHandle, + Sqlstate, NativeError, MessageText, BufferLength, TextLength); } /************************************************************************* @@ -2253,11 +2104,8 @@ SQLRETURN WINAPI SQLExecDirectW(SQLHSTMT StatementHandle, { TRACE("\n"); - CHECK_READY_AND_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLEXECDIRECT].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLEXECDIRECT].funcW) - (StatementHandle, StatementText, TextLength); + if (!pSQLExecDirectW) return SQL_ERROR; + return pSQLExecDirectW(StatementHandle, StatementText, TextLength); } /************************************************************************* @@ -2269,11 +2117,8 @@ SQLRETURN WINAPI SQLGetCursorNameW(SQLHSTMT StatementHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETCURSORNAME].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETCURSORNAME].funcW) - (StatementHandle, CursorName, BufferLength, NameLength); + if (!pSQLGetCursorNameW) return SQL_ERROR; + return pSQLGetCursorNameW(StatementHandle, CursorName, BufferLength, NameLength); } /************************************************************************* @@ -2284,11 +2129,8 @@ SQLRETURN WINAPI SQLPrepareW(SQLHSTMT StatementHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLPREPARE].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLPREPARE].funcW) - (StatementHandle, StatementText, TextLength); + if (!pSQLPrepareW) return SQL_ERROR; + return pSQLPrepareW(StatementHandle, StatementText, TextLength); } /************************************************************************* @@ -2298,11 +2140,8 @@ SQLRETURN WINAPI SQLSetCursorNameW(SQLHSTMT StatementHandle, WCHAR *CursorName, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLSETCURSORNAME].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLSETCURSORNAME].funcW) - (StatementHandle, CursorName, NameLength); + if (!pSQLSetCursorNameW) return SQL_ERROR; + return pSQLSetCursorNameW(StatementHandle, CursorName, NameLength); } /************************************************************************* @@ -2319,12 +2158,10 @@ SQLRETURN WINAPI SQLColAttributeW (SQLHSTMT StatementHandle, StatementHandle, ColumnNumber, FieldIdentifier, CharacterAttribute, BufferLength, StringLength, NumericAttribute); - CHECK_READY_AND_dmHandle(); + if (!pSQLColAttributeW) return SQL_ERROR; - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLCOLATTRIBUTE].funcW); - iResult = (gProxyHandle.functions[SQLAPI_INDEX_SQLCOLATTRIBUTE].funcW) - (StatementHandle, ColumnNumber, FieldIdentifier, - CharacterAttribute, BufferLength, StringLength, NumericAttribute); + iResult = pSQLColAttributeW(StatementHandle, ColumnNumber, FieldIdentifier, + CharacterAttribute, BufferLength, StringLength, NumericAttribute); if (iResult == SQL_SUCCESS && CharacterAttribute != NULL && SQLColAttributes_KnownStringAttribute(FieldIdentifier)) { /* TRACE("Dumping values fetched via SQLColAttributeW:\n"); @@ -2348,12 +2185,9 @@ SQLRETURN WINAPI SQLGetConnectAttrW(SQLHDBC ConnectionHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETCONNECTATTR].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETCONNECTATTR].funcW) - (ConnectionHandle, Attribute, Value, - BufferLength, StringLength); + if (!pSQLGetConnectAttrW) return SQL_ERROR; + return pSQLGetConnectAttrW(ConnectionHandle, Attribute, Value, + BufferLength, StringLength); } /************************************************************************* @@ -2366,12 +2200,9 @@ SQLRETURN WINAPI SQLGetDescFieldW(SQLHDESC DescriptorHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETDESCFIELD].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETDESCFIELD].funcW) - (DescriptorHandle, RecNumber, FieldIdentifier, - Value, BufferLength, StringLength); + if (!pSQLGetDescFieldW) return SQL_ERROR; + return pSQLGetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier, + Value, BufferLength, StringLength); } /************************************************************************* @@ -2386,12 +2217,9 @@ SQLRETURN WINAPI SQLGetDescRecW(SQLHDESC DescriptorHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETDESCREC].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETDESCREC].funcW) - (DescriptorHandle, RecNumber, Name, BufferLength, - StringLength, Type, SubType, Length, Precision, Scale, Nullable); + if (!pSQLGetDescRecW) return SQL_ERROR; + return pSQLGetDescRecW(DescriptorHandle, RecNumber, Name, BufferLength, + StringLength, Type, SubType, Length, Precision, Scale, Nullable); } /************************************************************************* @@ -2404,12 +2232,9 @@ SQLRETURN WINAPI SQLGetDiagFieldW(SQLSMALLINT HandleType, SQLHANDLE Handle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETDIAGFIELD].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETDIAGFIELD].funcW) - (HandleType, Handle, RecNumber, DiagIdentifier, - DiagInfo, BufferLength, StringLength); + if (!pSQLGetDiagFieldW) return SQL_ERROR; + return pSQLGetDiagFieldW(HandleType, Handle, RecNumber, DiagIdentifier, + DiagInfo, BufferLength, StringLength); } /************************************************************************* @@ -2422,12 +2247,9 @@ SQLRETURN WINAPI SQLGetDiagRecW(SQLSMALLINT HandleType, SQLHANDLE Handle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETDIAGREC].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETDIAGREC].funcW) - (HandleType, Handle, RecNumber, Sqlstate, NativeError, - MessageText, BufferLength, TextLength); + if (!pSQLGetDiagRecW) return SQL_ERROR; + return pSQLGetDiagRecW(HandleType, Handle, RecNumber, Sqlstate, NativeError, + MessageText, BufferLength, TextLength); } /************************************************************************* @@ -2451,11 +2273,8 @@ SQLRETURN WINAPI SQLGetStmtAttrW(SQLHSTMT StatementHandle, iResult = SQL_ERROR; */ } else { - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETSTMTATTR].funcW); - iResult = (gProxyHandle.functions[SQLAPI_INDEX_SQLGETSTMTATTR].funcW) - (StatementHandle, Attribute, Value, BufferLength, StringLength); + if (!pSQLGetStmtAttrW) return SQL_ERROR; + iResult = pSQLGetStmtAttrW(StatementHandle, Attribute, Value, BufferLength, StringLength); TRACE("returning %d...\n", iResult); } return iResult; @@ -2469,11 +2288,8 @@ SQLRETURN WINAPI SQLSetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribu { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLSETCONNECTATTR].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLSETCONNECTATTR].funcW) - (ConnectionHandle, Attribute, Value, StringLength); + if (!pSQLSetConnectAttrW) return SQL_ERROR; + return pSQLSetConnectAttrW(ConnectionHandle, Attribute, Value, StringLength); } /************************************************************************* @@ -2487,12 +2303,9 @@ SQLRETURN WINAPI SQLColumnsW(SQLHSTMT StatementHandle, { TRACE("\n"); - CHECK_READY_AND_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLCOLUMNS].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLCOLUMNS].funcW) - (StatementHandle, CatalogName, NameLength1, - SchemaName, NameLength2, TableName, NameLength3, ColumnName, NameLength4); + if (!pSQLColumnsW) return SQL_ERROR; + return pSQLColumnsW(StatementHandle, CatalogName, NameLength1, + SchemaName, NameLength2, TableName, NameLength3, ColumnName, NameLength4); } /************************************************************************* @@ -2510,12 +2323,9 @@ SQLRETURN WINAPI SQLDriverConnectW( { TRACE("ConnStrIn (%d bytes) --> %s\n", len_conn_str_in, debugstr_w(conn_str_in)); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLDRIVERCONNECT].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLDRIVERCONNECT].funcW) - (hdbc, hwnd, conn_str_in, len_conn_str_in, conn_str_out, - conn_str_out_max, ptr_conn_str_out, driver_completion); + if (!pSQLDriverConnectW) return SQL_ERROR; + return pSQLDriverConnectW(hdbc, hwnd, conn_str_in, len_conn_str_in, conn_str_out, + conn_str_out_max, ptr_conn_str_out, driver_completion); } /************************************************************************* @@ -2525,11 +2335,8 @@ SQLRETURN WINAPI SQLGetConnectOptionW(SQLHDBC ConnectionHandle, SQLUSMALLINT Opt { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETCONNECTOPTION].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETCONNECTOPTION].funcW) - (ConnectionHandle, Option, Value); + if (!pSQLGetConnectOptionW) return SQL_ERROR; + return pSQLGetConnectOptionW(ConnectionHandle, Option, Value); } /************************************************************************* @@ -2546,11 +2353,8 @@ SQLRETURN WINAPI SQLGetInfoW(SQLHDBC ConnectionHandle, WARN("Unexpected NULL in InfoValue address\n"); iResult = SQL_ERROR; } else { - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETINFO].funcW); - iResult = (gProxyHandle.functions[SQLAPI_INDEX_SQLGETINFO].funcW) - (ConnectionHandle, InfoType, InfoValue, BufferLength, StringLength); + if (!pSQLGetInfoW) return SQL_ERROR; + iResult = pSQLGetInfoW(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLength); TRACE("returning %d...\n", iResult); } return iResult; @@ -2563,11 +2367,8 @@ SQLRETURN WINAPI SQLGetTypeInfoW(SQLHSTMT StatementHandle, SQLSMALLINT DataType) { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLGETTYPEINFO].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLGETTYPEINFO].funcW) - (StatementHandle, DataType); + if (!pSQLGetTypeInfoW) return SQL_ERROR; + return pSQLGetTypeInfoW(StatementHandle, DataType); } /************************************************************************* @@ -2577,68 +2378,55 @@ SQLRETURN WINAPI SQLSetConnectOptionW(SQLHDBC ConnectionHandle, SQLUSMALLINT Opt { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLSETCONNECTOPTION].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLSETCONNECTOPTION].funcW) - (ConnectionHandle, Option, Value); + if (!pSQLSetConnectOptionW) return SQL_ERROR; + return pSQLSetConnectOptionW(ConnectionHandle, Option, Value); } /************************************************************************* * SQLSpecialColumnsW [ODBC32.152] */ SQLRETURN WINAPI SQLSpecialColumnsW(SQLHSTMT StatementHandle, - SQLUSMALLINT IdentifierType, SQLCHAR *CatalogName, - SQLSMALLINT NameLength1, SQLCHAR *SchemaName, - SQLSMALLINT NameLength2, SQLCHAR *TableName, + SQLUSMALLINT IdentifierType, SQLWCHAR *CatalogName, + SQLSMALLINT NameLength1, SQLWCHAR *SchemaName, + SQLSMALLINT NameLength2, SQLWCHAR *TableName, SQLSMALLINT NameLength3, SQLUSMALLINT Scope, SQLUSMALLINT Nullable) { - - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLSPECIALCOLUMNS].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLSPECIALCOLUMNS].funcW) - (StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName, - NameLength2, TableName, NameLength3, Scope, Nullable); + if (!pSQLSpecialColumnsW) return SQL_ERROR; + return pSQLSpecialColumnsW(StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName, + NameLength2, TableName, NameLength3, Scope, Nullable); } /************************************************************************* * SQLStatisticsW [ODBC32.153] */ SQLRETURN WINAPI SQLStatisticsW(SQLHSTMT StatementHandle, - SQLCHAR *CatalogName, SQLSMALLINT NameLength1, - SQLCHAR *SchemaName, SQLSMALLINT NameLength2, - SQLCHAR *TableName, SQLSMALLINT NameLength3, + SQLWCHAR *CatalogName, SQLSMALLINT NameLength1, + SQLWCHAR *SchemaName, SQLSMALLINT NameLength2, + SQLWCHAR *TableName, SQLSMALLINT NameLength3, SQLUSMALLINT Unique, SQLUSMALLINT Reserved) { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLSTATISTICS].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLSTATISTICS].funcW) - (StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2, - TableName, NameLength3, Unique, Reserved); + if (!pSQLStatisticsW) return SQL_ERROR; + return pSQLStatisticsW(StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2, + TableName, NameLength3, Unique, Reserved); } /************************************************************************* * SQLTablesW [ODBC32.154] */ SQLRETURN WINAPI SQLTablesW(SQLHSTMT StatementHandle, - SQLCHAR *CatalogName, SQLSMALLINT NameLength1, - SQLCHAR *SchemaName, SQLSMALLINT NameLength2, - SQLCHAR *TableName, SQLSMALLINT NameLength3, - SQLCHAR *TableType, SQLSMALLINT NameLength4) + SQLWCHAR *CatalogName, SQLSMALLINT NameLength1, + SQLWCHAR *SchemaName, SQLSMALLINT NameLength2, + SQLWCHAR *TableName, SQLSMALLINT NameLength3, + SQLWCHAR *TableType, SQLSMALLINT NameLength4) { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLTABLES].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLTABLES].funcW) - (StatementHandle, CatalogName, NameLength1, - SchemaName, NameLength2, TableName, NameLength3, TableType, NameLength4); + if (!pSQLTablesW) return SQL_ERROR; + return pSQLTablesW(StatementHandle, CatalogName, NameLength1, + SchemaName, NameLength2, TableName, NameLength3, TableType, NameLength4); } /************************************************************************* @@ -2646,19 +2434,17 @@ SQLRETURN WINAPI SQLTablesW(SQLHSTMT StatementHandle, */ SQLRETURN WINAPI SQLBrowseConnectW( SQLHDBC hdbc, - SQLCHAR *szConnStrIn, + SQLWCHAR *szConnStrIn, SQLSMALLINT cbConnStrIn, - SQLCHAR *szConnStrOut, + SQLWCHAR *szConnStrOut, SQLSMALLINT cbConnStrOutMax, SQLSMALLINT *pcbConnStrOut) { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLBROWSECONNECT].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLBROWSECONNECT].funcW) - (hdbc, szConnStrIn, cbConnStrIn, szConnStrOut, cbConnStrOutMax, pcbConnStrOut); + if (!pSQLBrowseConnectW) return SQL_ERROR; + return pSQLBrowseConnectW(hdbc, szConnStrIn, cbConnStrIn, szConnStrOut, + cbConnStrOutMax, pcbConnStrOut); } /************************************************************************* @@ -2666,23 +2452,20 @@ SQLRETURN WINAPI SQLBrowseConnectW( */ SQLRETURN WINAPI SQLColumnPrivilegesW( SQLHSTMT hstmt, - SQLCHAR *szCatalogName, + SQLWCHAR *szCatalogName, SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, + SQLWCHAR *szSchemaName, SQLSMALLINT cbSchemaName, - SQLCHAR *szTableName, + SQLWCHAR *szTableName, SQLSMALLINT cbTableName, - SQLCHAR *szColumnName, + SQLWCHAR *szColumnName, SQLSMALLINT cbColumnName) { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLCOLUMNPRIVILEGES].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLCOLUMNPRIVILEGES].funcW) - (hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, - szTableName, cbTableName, szColumnName, cbColumnName); + if (!pSQLColumnPrivilegesW) return SQL_ERROR; + return pSQLColumnPrivilegesW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, + szTableName, cbTableName, szColumnName, cbColumnName); } /************************************************************************* @@ -2698,16 +2481,10 @@ SQLRETURN WINAPI SQLDataSourcesW(SQLHENV EnvironmentHandle, TRACE("EnvironmentHandle = %p\n", (LPVOID)EnvironmentHandle); - if (!gProxyHandle.bFunctionReady || gProxyHandle.dmHandle == NULL) - { - ERR("Error: empty dm handle (gProxyHandle.dmHandle == NULL)\n"); - return SQL_ERROR; - } + if (!pSQLDataSourcesW) return SQL_ERROR; - assert(gProxyHandle.functions[SQLAPI_INDEX_SQLDATASOURCES].funcW); - ret = (gProxyHandle.functions[SQLAPI_INDEX_SQLDATASOURCES].funcW) - (EnvironmentHandle, Direction, ServerName, - BufferLength1, NameLength1, Description, BufferLength2, NameLength2); + ret = pSQLDataSourcesW(EnvironmentHandle, Direction, ServerName, + BufferLength1, NameLength1, Description, BufferLength2, NameLength2); if (TRACE_ON(odbc)) { @@ -2727,28 +2504,25 @@ SQLRETURN WINAPI SQLDataSourcesW(SQLHENV EnvironmentHandle, */ SQLRETURN WINAPI SQLForeignKeysW( SQLHSTMT hstmt, - SQLCHAR *szPkCatalogName, + SQLWCHAR *szPkCatalogName, SQLSMALLINT cbPkCatalogName, - SQLCHAR *szPkSchemaName, + SQLWCHAR *szPkSchemaName, SQLSMALLINT cbPkSchemaName, - SQLCHAR *szPkTableName, + SQLWCHAR *szPkTableName, SQLSMALLINT cbPkTableName, - SQLCHAR *szFkCatalogName, + SQLWCHAR *szFkCatalogName, SQLSMALLINT cbFkCatalogName, - SQLCHAR *szFkSchemaName, + SQLWCHAR *szFkSchemaName, SQLSMALLINT cbFkSchemaName, - SQLCHAR *szFkTableName, + SQLWCHAR *szFkTableName, SQLSMALLINT cbFkTableName) { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLFOREIGNKEYS].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLFOREIGNKEYS].funcW) - (hstmt, szPkCatalogName, cbPkCatalogName, szPkSchemaName, cbPkSchemaName, - szPkTableName, cbPkTableName, szFkCatalogName, cbFkCatalogName, szFkSchemaName, - cbFkSchemaName, szFkTableName, cbFkTableName); + if (!pSQLForeignKeysW) return SQL_ERROR; + return pSQLForeignKeysW(hstmt, szPkCatalogName, cbPkCatalogName, szPkSchemaName, cbPkSchemaName, + szPkTableName, cbPkTableName, szFkCatalogName, cbFkCatalogName, + szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName); } /************************************************************************* @@ -2756,19 +2530,16 @@ SQLRETURN WINAPI SQLForeignKeysW( */ SQLRETURN WINAPI SQLNativeSqlW( SQLHDBC hdbc, - SQLCHAR *szSqlStrIn, + SQLWCHAR *szSqlStrIn, SQLINTEGER cbSqlStrIn, - SQLCHAR *szSqlStr, + SQLWCHAR *szSqlStr, SQLINTEGER cbSqlStrMax, SQLINTEGER *pcbSqlStr) { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLNATIVESQL].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLNATIVESQL].funcW) - (hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr, cbSqlStrMax, pcbSqlStr); + if (!pSQLNativeSqlW) return SQL_ERROR; + return pSQLNativeSqlW(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr, cbSqlStrMax, pcbSqlStr); } /************************************************************************* @@ -2776,21 +2547,18 @@ SQLRETURN WINAPI SQLNativeSqlW( */ SQLRETURN WINAPI SQLPrimaryKeysW( SQLHSTMT hstmt, - SQLCHAR *szCatalogName, + SQLWCHAR *szCatalogName, SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, + SQLWCHAR *szSchemaName, SQLSMALLINT cbSchemaName, - SQLCHAR *szTableName, + SQLWCHAR *szTableName, SQLSMALLINT cbTableName) { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLPRIMARYKEYS].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLPRIMARYKEYS].funcW) - (hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, - szTableName, cbTableName); + if (!pSQLPrimaryKeysW) return SQL_ERROR; + return pSQLPrimaryKeysW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, + szTableName, cbTableName); } /************************************************************************* @@ -2798,23 +2566,20 @@ SQLRETURN WINAPI SQLPrimaryKeysW( */ SQLRETURN WINAPI SQLProcedureColumnsW( SQLHSTMT hstmt, - SQLCHAR *szCatalogName, + SQLWCHAR *szCatalogName, SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, + SQLWCHAR *szSchemaName, SQLSMALLINT cbSchemaName, - SQLCHAR *szProcName, + SQLWCHAR *szProcName, SQLSMALLINT cbProcName, - SQLCHAR *szColumnName, + SQLWCHAR *szColumnName, SQLSMALLINT cbColumnName) { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLPROCEDURECOLUMNS].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLPROCEDURECOLUMNS].funcW) - (hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, - szProcName, cbProcName, szColumnName, cbColumnName); + if (!pSQLProcedureColumnsW) return SQL_ERROR; + return pSQLProcedureColumnsW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, + szProcName, cbProcName, szColumnName, cbColumnName); } /************************************************************************* @@ -2822,21 +2587,18 @@ SQLRETURN WINAPI SQLProcedureColumnsW( */ SQLRETURN WINAPI SQLProceduresW( SQLHSTMT hstmt, - SQLCHAR *szCatalogName, + SQLWCHAR *szCatalogName, SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, + SQLWCHAR *szSchemaName, SQLSMALLINT cbSchemaName, - SQLCHAR *szProcName, + SQLWCHAR *szProcName, SQLSMALLINT cbProcName) { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLPROCEDURES].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLPROCEDURES].funcW) - (hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, - szProcName, cbProcName); + if (!pSQLProceduresW) return SQL_ERROR; + return pSQLProceduresW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, + szProcName, cbProcName); } /************************************************************************* @@ -2844,21 +2606,18 @@ SQLRETURN WINAPI SQLProceduresW( */ SQLRETURN WINAPI SQLTablePrivilegesW( SQLHSTMT hstmt, - SQLCHAR *szCatalogName, + SQLWCHAR *szCatalogName, SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, + SQLWCHAR *szSchemaName, SQLSMALLINT cbSchemaName, - SQLCHAR *szTableName, + SQLWCHAR *szTableName, SQLSMALLINT cbTableName) { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLTABLEPRIVILEGES].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLTABLEPRIVILEGES].funcW) - (hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, - szTableName, cbTableName); + if (!pSQLTablePrivilegesW) return SQL_ERROR; + return pSQLTablePrivilegesW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, + szTableName, cbTableName); } /************************************************************************* @@ -2867,21 +2626,18 @@ SQLRETURN WINAPI SQLTablePrivilegesW( SQLRETURN WINAPI SQLDriversW( SQLHENV henv, SQLUSMALLINT fDirection, - SQLCHAR *szDriverDesc, + SQLWCHAR *szDriverDesc, SQLSMALLINT cbDriverDescMax, SQLSMALLINT *pcbDriverDesc, - SQLCHAR *szDriverAttributes, + SQLWCHAR *szDriverAttributes, SQLSMALLINT cbDriverAttrMax, SQLSMALLINT *pcbDriverAttr) { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLDRIVERS].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLDRIVERS].funcW) - (henv, fDirection, szDriverDesc, cbDriverDescMax, pcbDriverDesc, - szDriverAttributes, cbDriverAttrMax, pcbDriverAttr); + if (!pSQLDriversW) return SQL_ERROR; + return pSQLDriversW(henv, fDirection, szDriverDesc, cbDriverDescMax, pcbDriverDesc, + szDriverAttributes, cbDriverAttrMax, pcbDriverAttr); } /************************************************************************* @@ -2893,11 +2649,8 @@ SQLRETURN WINAPI SQLSetDescFieldW(SQLHDESC DescriptorHandle, { TRACE("\n"); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLSETDESCFIELD].funcW); - return (gProxyHandle.functions[SQLAPI_INDEX_SQLSETDESCFIELD].funcW) - (DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength); + if (!pSQLSetDescFieldW) return SQL_ERROR; + return pSQLSetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength); } /************************************************************************* @@ -2911,11 +2664,8 @@ SQLRETURN WINAPI SQLSetStmtAttrW(SQLHSTMT StatementHandle, TRACE("Attribute = (%02ld) Value = %p StringLength = (%ld)\n", Attribute, Value, StringLength); - CHECK_dmHandle(); - - assert (gProxyHandle.functions[SQLAPI_INDEX_SQLSETSTMTATTR].funcW); - iResult = (gProxyHandle.functions[SQLAPI_INDEX_SQLSETSTMTATTR].funcW) - (StatementHandle, Attribute, Value, StringLength); + if (!pSQLSetStmtAttrW) return SQL_ERROR; + iResult = pSQLSetStmtAttrW(StatementHandle, Attribute, Value, StringLength); if (iResult == SQL_ERROR && (Attribute == SQL_ROWSET_SIZE || Attribute == SQL_ATTR_ROW_ARRAY_SIZE)) { TRACE("CHEAT: returning SQL_SUCCESS to ADO...\n"); iResult = SQL_SUCCESS; diff --git a/dlls/odbc32/proxyodbc.h b/dlls/odbc32/proxyodbc.h deleted file mode 100644 index bcd73da9602..00000000000 --- a/dlls/odbc32/proxyodbc.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright 1999 Xiang Li, Corel Corporation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef _PROXYMANAGER_H -#define _PROXYMANAGER_H - -#define NUM_SQLFUNC 78 -#define ERROR_FREE 0 -#define ERROR_SQLERROR 1 -#define ERROR_LIBRARY_NOT_FOUND 2 -#define ERROR_FUNCTIONS_NOT_LOADED 3 - -#define ODBCVER 0x0351 - -typedef struct dm_func /* driver manager functions */ -{ - int ordinal; - const char *name; - void *d_func; - SQLRETURN (*func)(); - SQLRETURN (*funcW)(); -} DM_FUNC; - -typedef struct proxyhandle -{ - void *dmHandle; /* driver manager handle */ - BOOL isWindowsDriver; /* is driver a Windows version*/ - BOOL bCallbackReady; /* procs taken from Windows driver placed in driver manager as callbacks */ - BOOL bFunctionReady; - int nErrorType; - DM_FUNC functions[NUM_SQLFUNC]; /* entry point for driver manager functions */ - char driverLibName[200]; /* ODBC driver SO name */ - char ServerName[200]; /* keep server name */ - char UserName[50]; /* keep username */ -} PROXYHANDLE; - -#define /* 00 */ SQLAPI_INDEX_SQLALLOCCONNECT 0 -#define /* 01 */ SQLAPI_INDEX_SQLALLOCENV 1 -#define /* 02 */ SQLAPI_INDEX_SQLALLOCHANDLE 2 -#define /* 03 */ SQLAPI_INDEX_SQLALLOCSTMT 3 -#define /* 04 */ SQLAPI_INDEX_SQLALLOCHANDLESTD 4 -#define /* 05 */ SQLAPI_INDEX_SQLBINDCOL 5 -#define /* 06 */ SQLAPI_INDEX_SQLBINDPARAM 6 -#define /* 07 */ SQLAPI_INDEX_SQLBINDPARAMETER 7 -#define /* 08 */ SQLAPI_INDEX_SQLBROWSECONNECT 8 -#define /* 09 */ SQLAPI_INDEX_SQLBULKOPERATIONS 9 -#define /* 10 */ SQLAPI_INDEX_SQLCANCEL 10 -#define /* 11 */ SQLAPI_INDEX_SQLCLOSECURSOR 11 -#define /* 12 */ SQLAPI_INDEX_SQLCOLATTRIBUTE 12 -#define /* 13 */ SQLAPI_INDEX_SQLCOLATTRIBUTES 13 -#define /* 14 */ SQLAPI_INDEX_SQLCOLUMNPRIVILEGES 14 -#define /* 15 */ SQLAPI_INDEX_SQLCOLUMNS 15 -#define /* 16 */ SQLAPI_INDEX_SQLCONNECT 16 -#define /* 17 */ SQLAPI_INDEX_SQLCOPYDESC 17 -#define /* 18 */ SQLAPI_INDEX_SQLDATASOURCES 18 -#define /* 19 */ SQLAPI_INDEX_SQLDESCRIBECOL 19 -#define /* 20 */ SQLAPI_INDEX_SQLDESCRIBEPARAM 20 -#define /* 21 */ SQLAPI_INDEX_SQLDISCONNECT 21 -#define /* 22 */ SQLAPI_INDEX_SQLDRIVERCONNECT 22 -#define /* 23 */ SQLAPI_INDEX_SQLDRIVERS 23 -#define /* 24 */ SQLAPI_INDEX_SQLENDTRAN 24 -#define /* 25 */ SQLAPI_INDEX_SQLERROR 25 -#define /* 26 */ SQLAPI_INDEX_SQLEXECDIRECT 26 -#define /* 27 */ SQLAPI_INDEX_SQLEXECUTE 27 -#define /* 28 */ SQLAPI_INDEX_SQLEXTENDEDFETCH 28 -#define /* 29 */ SQLAPI_INDEX_SQLFETCH 29 -#define /* 30 */ SQLAPI_INDEX_SQLFETCHSCROLL 30 -#define /* 31 */ SQLAPI_INDEX_SQLFOREIGNKEYS 31 -#define /* 32 */ SQLAPI_INDEX_SQLFREEENV 32 -#define /* 33 */ SQLAPI_INDEX_SQLFREEHANDLE 33 -#define /* 34 */ SQLAPI_INDEX_SQLFREESTMT 34 -#define /* 35 */ SQLAPI_INDEX_SQLFREECONNECT 35 -#define /* 36 */ SQLAPI_INDEX_SQLGETCONNECTATTR 36 -#define /* 37 */ SQLAPI_INDEX_SQLGETCONNECTOPTION 37 -#define /* 38 */ SQLAPI_INDEX_SQLGETCURSORNAME 38 -#define /* 39 */ SQLAPI_INDEX_SQLGETDATA 39 -#define /* 40 */ SQLAPI_INDEX_SQLGETDESCFIELD 40 -#define /* 41 */ SQLAPI_INDEX_SQLGETDESCREC 41 -#define /* 42 */ SQLAPI_INDEX_SQLGETDIAGFIELD 42 -#define /* 43 */ SQLAPI_INDEX_SQLGETENVATTR 43 -#define /* 44 */ SQLAPI_INDEX_SQLGETFUNCTIONS 44 -#define /* 45 */ SQLAPI_INDEX_SQLGETINFO 45 -#define /* 46 */ SQLAPI_INDEX_SQLGETSTMTATTR 46 -#define /* 47 */ SQLAPI_INDEX_SQLGETSTMTOPTION 47 -#define /* 48 */ SQLAPI_INDEX_SQLGETTYPEINFO 48 -#define /* 49 */ SQLAPI_INDEX_SQLMORERESULTS 49 -#define /* 50 */ SQLAPI_INDEX_SQLNATIVESQL 50 -#define /* 51 */ SQLAPI_INDEX_SQLNUMPARAMS 51 -#define /* 52 */ SQLAPI_INDEX_SQLNUMRESULTCOLS 52 -#define /* 53 */ SQLAPI_INDEX_SQLPARAMDATA 53 -#define /* 54 */ SQLAPI_INDEX_SQLPARAMOPTIONS 54 -#define /* 55 */ SQLAPI_INDEX_SQLPREPARE 55 -#define /* 56 */ SQLAPI_INDEX_SQLPRIMARYKEYS 56 -#define /* 57 */ SQLAPI_INDEX_SQLPROCEDURECOLUMNS 57 -#define /* 58 */ SQLAPI_INDEX_SQLPROCEDURES 58 -#define /* 59 */ SQLAPI_INDEX_SQLPUTDATA 59 -#define /* 60 */ SQLAPI_INDEX_SQLROWCOUNT 60 -#define /* 61 */ SQLAPI_INDEX_SQLSETCONNECTATTR 61 -#define /* 62 */ SQLAPI_INDEX_SQLSETCONNECTOPTION 62 -#define /* 63 */ SQLAPI_INDEX_SQLSETCURSORNAME 63 -#define /* 64 */ SQLAPI_INDEX_SQLSETDESCFIELD 64 -#define /* 65 */ SQLAPI_INDEX_SQLSETDESCREC 65 -#define /* 66 */ SQLAPI_INDEX_SQLSETENVATTR 66 -#define /* 67 */ SQLAPI_INDEX_SQLSETPARAM 67 -#define /* 68 */ SQLAPI_INDEX_SQLSETPOS 68 -#define /* 69 */ SQLAPI_INDEX_SQLSETSCROLLOPTIONS 69 -#define /* 70 */ SQLAPI_INDEX_SQLSETSTMTATTR 70 -#define /* 71 */ SQLAPI_INDEX_SQLSETSTMTOPTION 71 -#define /* 72 */ SQLAPI_INDEX_SQLSPECIALCOLUMNS 72 -#define /* 73 */ SQLAPI_INDEX_SQLSTATISTICS 73 -#define /* 74 */ SQLAPI_INDEX_SQLTABLEPRIVILEGES 74 -#define /* 75 */ SQLAPI_INDEX_SQLTABLES 75 -#define /* 76 */ SQLAPI_INDEX_SQLTRANSACT 76 -#define /* 77 */ SQLAPI_INDEX_SQLGETDIAGREC 77 - -#endif diff --git a/include/sqltypes.h b/include/sqltypes.h index 6f1d25fbb3d..5c8f3ca7b9a 100644 --- a/include/sqltypes.h +++ b/include/sqltypes.h @@ -101,6 +101,16 @@ typedef void* PTR; typedef signed short RETCODE; typedef void* SQLHWND; +#ifdef _WIN64 +typedef INT64 SQLLEN; +typedef UINT64 SQLULEN; +typedef UINT64 SQLSETPOSIROW; +#else +#define SQLLEN SQLINTEGER +#define SQLULEN SQLUINTEGER +#define SQLSETPOSIROW SQLUSMALLINT +#endif + typedef SQLHANDLE HENV; typedef SQLHANDLE HDBC; typedef SQLHANDLE HSTMT;