bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / odbc / OFunctions.cxx
blob9e3c1893b8c7fbcc085f1d7d3fcfc4c3c1e9315d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <odbc/OFunctions.hxx>
21 #include <osl/process.h>
23 // Implib definitions for ODBC-DLL/shared library:
25 namespace connectivity
27 T3SQLAllocHandle pODBC3SQLAllocHandle;
28 T3SQLConnect pODBC3SQLConnect;
29 T3SQLDriverConnect pODBC3SQLDriverConnect;
30 T3SQLBrowseConnect pODBC3SQLBrowseConnect;
31 T3SQLDataSources pODBC3SQLDataSources;
32 T3SQLDrivers pODBC3SQLDrivers;
33 T3SQLGetInfo pODBC3SQLGetInfo;
34 T3SQLGetFunctions pODBC3SQLGetFunctions;
35 T3SQLGetTypeInfo pODBC3SQLGetTypeInfo;
36 T3SQLSetConnectAttr pODBC3SQLSetConnectAttr;
37 T3SQLGetConnectAttr pODBC3SQLGetConnectAttr;
38 T3SQLSetEnvAttr pODBC3SQLSetEnvAttr;
39 T3SQLGetEnvAttr pODBC3SQLGetEnvAttr;
40 T3SQLSetStmtAttr pODBC3SQLSetStmtAttr;
41 T3SQLGetStmtAttr pODBC3SQLGetStmtAttr;
42 T3SQLPrepare pODBC3SQLPrepare;
43 T3SQLBindParameter pODBC3SQLBindParameter;
44 T3SQLSetCursorName pODBC3SQLSetCursorName;
45 T3SQLExecute pODBC3SQLExecute;
46 T3SQLExecDirect pODBC3SQLExecDirect;
47 T3SQLDescribeParam pODBC3SQLDescribeParam;
48 T3SQLNumParams pODBC3SQLNumParams;
49 T3SQLParamData pODBC3SQLParamData;
50 T3SQLPutData pODBC3SQLPutData;
51 T3SQLRowCount pODBC3SQLRowCount;
52 T3SQLNumResultCols pODBC3SQLNumResultCols;
53 T3SQLDescribeCol pODBC3SQLDescribeCol;
54 T3SQLColAttribute pODBC3SQLColAttribute;
55 T3SQLBindCol pODBC3SQLBindCol;
56 T3SQLFetch pODBC3SQLFetch;
57 T3SQLFetchScroll pODBC3SQLFetchScroll;
58 T3SQLGetData pODBC3SQLGetData;
59 T3SQLSetPos pODBC3SQLSetPos;
60 T3SQLBulkOperations pODBC3SQLBulkOperations;
61 T3SQLMoreResults pODBC3SQLMoreResults;
62 T3SQLGetDiagRec pODBC3SQLGetDiagRec;
63 T3SQLColumnPrivileges pODBC3SQLColumnPrivileges;
64 T3SQLColumns pODBC3SQLColumns;
65 T3SQLForeignKeys pODBC3SQLForeignKeys;
66 T3SQLPrimaryKeys pODBC3SQLPrimaryKeys;
67 T3SQLProcedureColumns pODBC3SQLProcedureColumns;
68 T3SQLProcedures pODBC3SQLProcedures;
69 T3SQLSpecialColumns pODBC3SQLSpecialColumns;
70 T3SQLStatistics pODBC3SQLStatistics;
71 T3SQLTablePrivileges pODBC3SQLTablePrivileges;
72 T3SQLTables pODBC3SQLTables;
73 T3SQLFreeStmt pODBC3SQLFreeStmt;
74 T3SQLCloseCursor pODBC3SQLCloseCursor;
75 T3SQLCancel pODBC3SQLCancel;
76 T3SQLEndTran pODBC3SQLEndTran;
77 T3SQLDisconnect pODBC3SQLDisconnect;
78 T3SQLFreeHandle pODBC3SQLFreeHandle;
79 T3SQLGetCursorName pODBC3SQLGetCursorName;
80 T3SQLNativeSql pODBC3SQLNativeSql;
82 static bool LoadFunctions(oslModule pODBCso);
84 // Take care of Dynamically loading of the DLL/shared lib and Addresses:
85 // Returns sal_True at success
86 bool LoadLibrary_ODBC3(OUString &_rPath)
88 static bool bLoaded = false;
89 static oslModule pODBCso = nullptr;
91 if (bLoaded)
92 return true;
93 #ifndef DISABLE_DYNLOADING
94 #ifdef _WIN32
95 _rPath = "ODBC32.DLL";
96 #endif
97 #ifdef UNX
98 #ifdef MACOSX
99 _rPath = "libiodbc.dylib";
100 #else
101 _rPath = "libodbc.so.1";
102 pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW );
103 if ( !pODBCso )
104 _rPath = "libodbc.so";
105 #endif /* MACOSX */
106 #endif
108 if ( !pODBCso )
109 pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW );
110 #endif
111 if( !pODBCso)
112 return false;
114 return bLoaded = LoadFunctions(pODBCso);
118 bool LoadFunctions(oslModule pODBCso)
121 if( ( pODBC3SQLAllocHandle = reinterpret_cast<T3SQLAllocHandle>(osl_getFunctionSymbol(pODBCso, OUString("SQLAllocHandle").pData ))) == nullptr )
122 return false;
123 if( ( pODBC3SQLConnect = reinterpret_cast<T3SQLConnect>(osl_getFunctionSymbol(pODBCso, OUString("SQLConnect").pData ))) == nullptr )
124 return false;
125 if( ( pODBC3SQLDriverConnect = reinterpret_cast<T3SQLDriverConnect>(osl_getFunctionSymbol(pODBCso, OUString("SQLDriverConnect").pData ))) == nullptr )
126 return false;
127 if( ( pODBC3SQLBrowseConnect = reinterpret_cast<T3SQLBrowseConnect>(osl_getFunctionSymbol(pODBCso, OUString("SQLBrowseConnect").pData ))) == nullptr )
128 return false;
129 if(( pODBC3SQLDataSources = reinterpret_cast<T3SQLDataSources>(osl_getFunctionSymbol(pODBCso, OUString("SQLDataSources").pData ))) == nullptr )
130 return false;
131 if(( pODBC3SQLDrivers = reinterpret_cast<T3SQLDrivers>(osl_getFunctionSymbol(pODBCso, OUString("SQLDrivers").pData ))) == nullptr )
132 return false;
133 if( ( pODBC3SQLGetInfo = reinterpret_cast<T3SQLGetInfo>(osl_getFunctionSymbol(pODBCso, OUString("SQLGetInfo").pData ))) == nullptr )
134 return false;
135 if(( pODBC3SQLGetFunctions = reinterpret_cast<T3SQLGetFunctions>(osl_getFunctionSymbol(pODBCso, OUString("SQLGetFunctions").pData ))) == nullptr )
136 return false;
137 if( ( pODBC3SQLGetTypeInfo = reinterpret_cast<T3SQLGetTypeInfo>(osl_getFunctionSymbol(pODBCso, OUString("SQLGetTypeInfo").pData ))) == nullptr )
138 return false;
139 if( ( pODBC3SQLSetConnectAttr = reinterpret_cast<T3SQLSetConnectAttr>(osl_getFunctionSymbol(pODBCso, OUString("SQLSetConnectAttr").pData ))) == nullptr )
140 return false;
141 if( ( pODBC3SQLGetConnectAttr = reinterpret_cast<T3SQLGetConnectAttr>(osl_getFunctionSymbol(pODBCso, OUString("SQLGetConnectAttr").pData ))) == nullptr )
142 return false;
143 if( ( pODBC3SQLSetEnvAttr = reinterpret_cast<T3SQLSetEnvAttr>(osl_getFunctionSymbol(pODBCso, OUString("SQLSetEnvAttr").pData ))) == nullptr )
144 return false;
145 if( ( pODBC3SQLGetEnvAttr = reinterpret_cast<T3SQLGetEnvAttr>(osl_getFunctionSymbol(pODBCso, OUString("SQLGetEnvAttr").pData ))) == nullptr )
146 return false;
147 if( ( pODBC3SQLSetStmtAttr = reinterpret_cast<T3SQLSetStmtAttr>(osl_getFunctionSymbol(pODBCso, OUString("SQLSetStmtAttr").pData ))) == nullptr )
148 return false;
149 if( ( pODBC3SQLGetStmtAttr = reinterpret_cast<T3SQLGetStmtAttr>(osl_getFunctionSymbol(pODBCso, OUString("SQLGetStmtAttr").pData ))) == nullptr )
150 return false;
151 if( ( pODBC3SQLPrepare = reinterpret_cast<T3SQLPrepare>(osl_getFunctionSymbol(pODBCso, OUString("SQLPrepare").pData ))) == nullptr )
152 return false;
153 if( ( pODBC3SQLBindParameter = reinterpret_cast<T3SQLBindParameter>(osl_getFunctionSymbol(pODBCso, OUString("SQLBindParameter").pData ))) == nullptr )
154 return false;
155 if( ( pODBC3SQLSetCursorName = reinterpret_cast<T3SQLSetCursorName>(osl_getFunctionSymbol(pODBCso, OUString("SQLSetCursorName").pData ))) == nullptr )
156 return false;
157 if( ( pODBC3SQLExecute = reinterpret_cast<T3SQLExecute>(osl_getFunctionSymbol(pODBCso, OUString("SQLExecute").pData ))) == nullptr )
158 return false;
159 if( ( pODBC3SQLExecDirect = reinterpret_cast<T3SQLExecDirect>(osl_getFunctionSymbol(pODBCso, OUString("SQLExecDirect").pData ))) == nullptr )
160 return false;
161 if( ( pODBC3SQLDescribeParam = reinterpret_cast<T3SQLDescribeParam>(osl_getFunctionSymbol(pODBCso, OUString("SQLDescribeParam").pData ))) == nullptr )
162 return false;
163 if( ( pODBC3SQLNumParams = reinterpret_cast<T3SQLNumParams>(osl_getFunctionSymbol(pODBCso, OUString("SQLNumParams").pData ))) == nullptr )
164 return false;
165 if( ( pODBC3SQLParamData = reinterpret_cast<T3SQLParamData>(osl_getFunctionSymbol(pODBCso, OUString("SQLParamData").pData ))) == nullptr )
166 return false;
167 if( ( pODBC3SQLPutData = reinterpret_cast<T3SQLPutData>(osl_getFunctionSymbol(pODBCso, OUString("SQLPutData").pData ))) == nullptr )
168 return false;
169 if( ( pODBC3SQLRowCount = reinterpret_cast<T3SQLRowCount>(osl_getFunctionSymbol(pODBCso, OUString("SQLRowCount").pData ))) == nullptr )
170 return false;
171 if( ( pODBC3SQLNumResultCols = reinterpret_cast<T3SQLNumResultCols>(osl_getFunctionSymbol(pODBCso, OUString("SQLNumResultCols").pData ))) == nullptr )
172 return false;
173 if( ( pODBC3SQLDescribeCol = reinterpret_cast<T3SQLDescribeCol>(osl_getFunctionSymbol(pODBCso, OUString("SQLDescribeCol").pData ))) == nullptr )
174 return false;
175 if( ( pODBC3SQLColAttribute = reinterpret_cast<T3SQLColAttribute>(osl_getFunctionSymbol(pODBCso, OUString("SQLColAttribute").pData ))) == nullptr )
176 return false;
177 if( ( pODBC3SQLBindCol = reinterpret_cast<T3SQLBindCol>(osl_getFunctionSymbol(pODBCso, OUString("SQLBindCol").pData ))) == nullptr )
178 return false;
179 if( ( pODBC3SQLFetch = reinterpret_cast<T3SQLFetch>(osl_getFunctionSymbol(pODBCso, OUString("SQLFetch").pData ))) == nullptr )
180 return false;
181 if( ( pODBC3SQLFetchScroll = reinterpret_cast<T3SQLFetchScroll>(osl_getFunctionSymbol(pODBCso, OUString("SQLFetchScroll").pData ))) == nullptr )
182 return false;
183 if( ( pODBC3SQLGetData = reinterpret_cast<T3SQLGetData>(osl_getFunctionSymbol(pODBCso, OUString("SQLGetData").pData ))) == nullptr )
184 return false;
185 if( ( pODBC3SQLSetPos = reinterpret_cast<T3SQLSetPos>(osl_getFunctionSymbol(pODBCso, OUString("SQLSetPos").pData ))) == nullptr )
186 return false;
187 if( ( pODBC3SQLBulkOperations = reinterpret_cast<T3SQLBulkOperations>(osl_getFunctionSymbol(pODBCso, OUString("SQLBulkOperations").pData ))) == nullptr )
188 return false;
189 if( ( pODBC3SQLMoreResults = reinterpret_cast<T3SQLMoreResults>(osl_getFunctionSymbol(pODBCso, OUString("SQLMoreResults").pData ))) == nullptr )
190 return false;
191 if( ( pODBC3SQLGetDiagRec = reinterpret_cast<T3SQLGetDiagRec>(osl_getFunctionSymbol(pODBCso, OUString("SQLGetDiagRec").pData ))) == nullptr )
192 return false;
193 if( ( pODBC3SQLColumnPrivileges = reinterpret_cast<T3SQLColumnPrivileges>(osl_getFunctionSymbol(pODBCso, OUString("SQLColumnPrivileges").pData ))) == nullptr )
194 return false;
195 if( ( pODBC3SQLColumns = reinterpret_cast<T3SQLColumns>(osl_getFunctionSymbol(pODBCso, OUString("SQLColumns").pData ))) == nullptr )
196 return false;
197 if( ( pODBC3SQLForeignKeys = reinterpret_cast<T3SQLForeignKeys>(osl_getFunctionSymbol(pODBCso, OUString("SQLForeignKeys").pData ))) == nullptr )
198 return false;
199 if( ( pODBC3SQLPrimaryKeys = reinterpret_cast<T3SQLPrimaryKeys>(osl_getFunctionSymbol(pODBCso, OUString("SQLPrimaryKeys").pData ))) == nullptr )
200 return false;
201 if( ( pODBC3SQLProcedureColumns = reinterpret_cast<T3SQLProcedureColumns>(osl_getFunctionSymbol(pODBCso, OUString("SQLProcedureColumns").pData ))) == nullptr )
202 return false;
203 if( ( pODBC3SQLProcedures = reinterpret_cast<T3SQLProcedures>(osl_getFunctionSymbol(pODBCso, OUString("SQLProcedures").pData ))) == nullptr )
204 return false;
205 if( ( pODBC3SQLSpecialColumns = reinterpret_cast<T3SQLSpecialColumns>(osl_getFunctionSymbol(pODBCso, OUString("SQLSpecialColumns").pData ))) == nullptr )
206 return false;
207 if( ( pODBC3SQLStatistics = reinterpret_cast<T3SQLStatistics>(osl_getFunctionSymbol(pODBCso, OUString("SQLStatistics").pData ))) == nullptr )
208 return false;
209 if( ( pODBC3SQLTablePrivileges = reinterpret_cast<T3SQLTablePrivileges>(osl_getFunctionSymbol(pODBCso, OUString("SQLTablePrivileges").pData ))) == nullptr )
210 return false;
211 if( ( pODBC3SQLTables = reinterpret_cast<T3SQLTables>(osl_getFunctionSymbol(pODBCso, OUString("SQLTables").pData ))) == nullptr )
212 return false;
213 if( ( pODBC3SQLFreeStmt = reinterpret_cast<T3SQLFreeStmt>(osl_getFunctionSymbol(pODBCso, OUString("SQLFreeStmt").pData ))) == nullptr )
214 return false;
215 if( ( pODBC3SQLCloseCursor = reinterpret_cast<T3SQLCloseCursor>(osl_getFunctionSymbol(pODBCso, OUString("SQLCloseCursor").pData ))) == nullptr )
216 return false;
217 if( ( pODBC3SQLCancel = reinterpret_cast<T3SQLCancel>(osl_getFunctionSymbol(pODBCso, OUString("SQLCancel").pData ))) == nullptr )
218 return false;
219 if( ( pODBC3SQLEndTran = reinterpret_cast<T3SQLEndTran>(osl_getFunctionSymbol(pODBCso, OUString("SQLEndTran").pData ))) == nullptr )
220 return false;
221 if( ( pODBC3SQLDisconnect = reinterpret_cast<T3SQLDisconnect>(osl_getFunctionSymbol(pODBCso, OUString("SQLDisconnect").pData ))) == nullptr )
222 return false;
223 if( ( pODBC3SQLFreeHandle = reinterpret_cast<T3SQLFreeHandle>(osl_getFunctionSymbol(pODBCso, OUString("SQLFreeHandle").pData ))) == nullptr )
224 return false;
225 if( ( pODBC3SQLGetCursorName = reinterpret_cast<T3SQLGetCursorName>(osl_getFunctionSymbol(pODBCso, OUString("SQLGetCursorName").pData ))) == nullptr )
226 return false;
227 if( ( pODBC3SQLNativeSql = reinterpret_cast<T3SQLNativeSql>(osl_getFunctionSymbol(pODBCso, OUString("SQLNativeSql").pData ))) == nullptr )
228 return false;
230 return true;
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */