merge the formfield patch from ooo-build
[ooovba.git] / connectivity / source / drivers / odbc / OFunctions.cxx
blob7a3cef288becfea3fe88f2ef8fd0b047c4b27851
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: OFunctions.cxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
34 //--------------------------------------------------------------------------
35 #include "odbc/OFunctions.hxx"
36 #include <osl/process.h>
38 // Implib-Definitionen fuer ODBC-DLL/shared library:
40 namespace connectivity
42 T3SQLAllocHandle pODBC3SQLAllocHandle;
43 T3SQLConnect pODBC3SQLConnect;
44 T3SQLDriverConnect pODBC3SQLDriverConnect;
45 T3SQLBrowseConnect pODBC3SQLBrowseConnect;
46 T3SQLDataSources pODBC3SQLDataSources;
47 T3SQLDrivers pODBC3SQLDrivers;
48 T3SQLGetInfo pODBC3SQLGetInfo;
49 T3SQLGetFunctions pODBC3SQLGetFunctions;
50 T3SQLGetTypeInfo pODBC3SQLGetTypeInfo;
51 T3SQLSetConnectAttr pODBC3SQLSetConnectAttr;
52 T3SQLGetConnectAttr pODBC3SQLGetConnectAttr;
53 T3SQLSetEnvAttr pODBC3SQLSetEnvAttr;
54 T3SQLGetEnvAttr pODBC3SQLGetEnvAttr;
55 T3SQLSetStmtAttr pODBC3SQLSetStmtAttr;
56 T3SQLGetStmtAttr pODBC3SQLGetStmtAttr;
57 //T3SQLSetDescField pODBC3SQLSetDescField;
58 //T3SQLGetDescField pODBC3SQLGetDescField;
59 //T3SQLGetDescRec pODBC3SQLGetDescRec;
60 //T3SQLSetDescRec pODBC3SQLSetDescRec;
61 T3SQLPrepare pODBC3SQLPrepare;
62 T3SQLBindParameter pODBC3SQLBindParameter;
63 //T3SQLGetCursorName pODBC3SQLGetCursorName;
64 T3SQLSetCursorName pODBC3SQLSetCursorName;
65 T3SQLExecute pODBC3SQLExecute;
66 T3SQLExecDirect pODBC3SQLExecDirect;
67 //T3SQLNativeSql pODBC3SQLNativeSql;
68 T3SQLDescribeParam pODBC3SQLDescribeParam;
69 T3SQLNumParams pODBC3SQLNumParams;
70 T3SQLParamData pODBC3SQLParamData;
71 T3SQLPutData pODBC3SQLPutData;
72 T3SQLRowCount pODBC3SQLRowCount;
73 T3SQLNumResultCols pODBC3SQLNumResultCols;
74 T3SQLDescribeCol pODBC3SQLDescribeCol;
75 T3SQLColAttribute pODBC3SQLColAttribute;
76 T3SQLBindCol pODBC3SQLBindCol;
77 T3SQLFetch pODBC3SQLFetch;
78 T3SQLFetchScroll pODBC3SQLFetchScroll;
79 T3SQLGetData pODBC3SQLGetData;
80 T3SQLSetPos pODBC3SQLSetPos;
81 T3SQLBulkOperations pODBC3SQLBulkOperations;
82 T3SQLMoreResults pODBC3SQLMoreResults;
83 //T3SQLGetDiagField pODBC3SQLGetDiagField;
84 T3SQLGetDiagRec pODBC3SQLGetDiagRec;
85 T3SQLColumnPrivileges pODBC3SQLColumnPrivileges;
86 T3SQLColumns pODBC3SQLColumns;
87 T3SQLForeignKeys pODBC3SQLForeignKeys;
88 T3SQLPrimaryKeys pODBC3SQLPrimaryKeys;
89 T3SQLProcedureColumns pODBC3SQLProcedureColumns;
90 T3SQLProcedures pODBC3SQLProcedures;
91 T3SQLSpecialColumns pODBC3SQLSpecialColumns;
92 T3SQLStatistics pODBC3SQLStatistics;
93 T3SQLTablePrivileges pODBC3SQLTablePrivileges;
94 T3SQLTables pODBC3SQLTables;
95 T3SQLFreeStmt pODBC3SQLFreeStmt;
96 T3SQLCloseCursor pODBC3SQLCloseCursor;
97 T3SQLCancel pODBC3SQLCancel;
98 T3SQLEndTran pODBC3SQLEndTran;
99 T3SQLDisconnect pODBC3SQLDisconnect;
100 T3SQLFreeHandle pODBC3SQLFreeHandle;
101 T3SQLGetCursorName pODBC3SQLGetCursorName;
102 T3SQLNativeSql pODBC3SQLNativeSql;
104 sal_Bool LoadFunctions(oslModule pODBCso);
105 // -------------------------------------------------------------------------
106 // Dynamisches Laden der DLL/shared lib und Adressen der Funktionen besorgen:
107 // Liefert sal_True bei Erfolg.
108 sal_Bool LoadLibrary_ODBC3(::rtl::OUString &_rPath)
110 static sal_Bool bLoaded = sal_False;
111 static oslModule pODBCso = NULL;
113 if (bLoaded)
114 return sal_True;
115 #ifdef WIN
116 _rPath = ::rtl::OUString::createFromAscii("ODBC.DLL");
118 #endif
119 #ifdef WNT
120 _rPath = ::rtl::OUString::createFromAscii("ODBC32.DLL");
121 #endif
122 #ifdef UNX
123 #ifdef MACOSX
124 _rPath = ::rtl::OUString::createFromAscii("libiodbc.dylib");
125 #else
126 _rPath = ::rtl::OUString::createFromAscii("libodbc.so.1");
127 pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW );
128 if ( !pODBCso )
129 _rPath = ::rtl::OUString::createFromAscii("libodbc.so");
130 #endif /* MACOSX */
131 #endif
132 #ifdef OS2
133 _rPath = ::rtl::OUString::createFromAscii("ODBC");
134 #endif
136 if ( !pODBCso )
137 pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW );
138 if( !pODBCso)
139 #ifdef OS2
141 delete pODBCso;
142 _rPath = ::rtl::OUString::createFromAscii("WOD402");
143 pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW );
144 if( !pODBCso)
145 return sal_False;
147 #else
148 return sal_False;
149 #endif
151 return bLoaded = LoadFunctions(pODBCso);
153 // -------------------------------------------------------------------------
155 sal_Bool LoadFunctions(oslModule pODBCso)
158 if( ( pODBC3SQLAllocHandle = (T3SQLAllocHandle)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLAllocHandle").pData )) == NULL )
159 return sal_False;
160 if( ( pODBC3SQLConnect = (T3SQLConnect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLConnect").pData )) == NULL )
161 return sal_False;
162 if( ( pODBC3SQLDriverConnect = (T3SQLDriverConnect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDriverConnect").pData )) == NULL )
163 return sal_False;
164 if( ( pODBC3SQLBrowseConnect = (T3SQLBrowseConnect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLBrowseConnect").pData )) == NULL )
165 return sal_False;
166 if(( pODBC3SQLDataSources = (T3SQLDataSources)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDataSources").pData )) == NULL )
167 return sal_False;
168 if(( pODBC3SQLDrivers = (T3SQLDrivers)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDrivers").pData )) == NULL )
169 return sal_False;
170 if( ( pODBC3SQLGetInfo = (T3SQLGetInfo)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetInfo").pData )) == NULL )
171 return sal_False;
172 if(( pODBC3SQLGetFunctions = (T3SQLGetFunctions)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetFunctions").pData )) == NULL )
173 return sal_False;
174 if( ( pODBC3SQLGetTypeInfo = (T3SQLGetTypeInfo)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetTypeInfo").pData )) == NULL )
175 return sal_False;
176 if( ( pODBC3SQLSetConnectAttr = (T3SQLSetConnectAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetConnectAttr").pData )) == NULL )
177 return sal_False;
178 if( ( pODBC3SQLGetConnectAttr = (T3SQLGetConnectAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetConnectAttr").pData )) == NULL )
179 return sal_False;
180 if( ( pODBC3SQLSetEnvAttr = (T3SQLSetEnvAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetEnvAttr").pData )) == NULL )
181 return sal_False;
182 if( ( pODBC3SQLGetEnvAttr = (T3SQLGetEnvAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetEnvAttr").pData )) == NULL )
183 return sal_False;
184 if( ( pODBC3SQLSetStmtAttr = (T3SQLSetStmtAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetStmtAttr").pData )) == NULL )
185 return sal_False;
186 if( ( pODBC3SQLGetStmtAttr = (T3SQLGetStmtAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetStmtAttr").pData )) == NULL )
187 return sal_False;
188 /*if( ( pODBC3SQLSetDescField = (T3SQLSetDescField)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetDescField").pData )) == NULL )
189 return sal_False;
190 if( ( pODBC3SQLGetDescField = (T3SQLGetDescField)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetDescField").pData )) == NULL )
191 return sal_False;*/
192 /*if( ( pODBC3SQLGetDescRec = (T3SQLGetDescRec)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetDescRec").pData )) == NULL )
193 return sal_False;
194 if( ( pODBC3SQLSetDescRec = (T3SQLSetDescRec)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetDescRec").pData )) == NULL )
195 return sal_False;*/
196 if( ( pODBC3SQLPrepare = (T3SQLPrepare)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLPrepare").pData )) == NULL )
197 return sal_False;
198 if( ( pODBC3SQLBindParameter = (T3SQLBindParameter)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLBindParameter").pData )) == NULL )
199 return sal_False;
200 // if( ( pODBC3SQLGetCursorName = (T3SQLGetCursorName)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetCursorName").pData )) == NULL )
201 // return sal_False;
202 if( ( pODBC3SQLSetCursorName = (T3SQLSetCursorName)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetCursorName").pData )) == NULL )
203 return sal_False;
204 if( ( pODBC3SQLExecute = (T3SQLExecute)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLExecute").pData )) == NULL )
205 return sal_False;
206 if( ( pODBC3SQLExecDirect = (T3SQLExecDirect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLExecDirect").pData )) == NULL )
207 return sal_False;
208 /*if( ( pODBC3SQLNativeSql = (T3SQLNativeSql)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLNativeSql").pData )) == NULL )
209 return sal_False;*/
210 if( ( pODBC3SQLDescribeParam = (T3SQLDescribeParam)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDescribeParam").pData )) == NULL )
211 return sal_False;
212 if( ( pODBC3SQLNumParams = (T3SQLNumParams)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLNumParams").pData )) == NULL )
213 return sal_False;
214 if( ( pODBC3SQLParamData = (T3SQLParamData)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLParamData").pData )) == NULL )
215 return sal_False;
216 if( ( pODBC3SQLPutData = (T3SQLPutData)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLPutData").pData )) == NULL )
217 return sal_False;
218 if( ( pODBC3SQLRowCount = (T3SQLRowCount)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLRowCount").pData )) == NULL )
219 return sal_False;
220 if( ( pODBC3SQLNumResultCols = (T3SQLNumResultCols)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLNumResultCols").pData )) == NULL )
221 return sal_False;
222 if( ( pODBC3SQLDescribeCol = (T3SQLDescribeCol)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDescribeCol").pData )) == NULL )
223 return sal_False;
224 if( ( pODBC3SQLColAttribute = (T3SQLColAttribute)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLColAttribute").pData )) == NULL )
225 return sal_False;
226 if( ( pODBC3SQLBindCol = (T3SQLBindCol)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLBindCol").pData )) == NULL )
227 return sal_False;
228 if( ( pODBC3SQLFetch = (T3SQLFetch)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLFetch").pData )) == NULL )
229 return sal_False;
230 if( ( pODBC3SQLFetchScroll = (T3SQLFetchScroll)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLFetchScroll").pData )) == NULL )
231 return sal_False;
232 if( ( pODBC3SQLGetData = (T3SQLGetData)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetData").pData )) == NULL )
233 return sal_False;
234 if( ( pODBC3SQLSetPos = (T3SQLSetPos)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetPos").pData )) == NULL )
235 return sal_False;
236 if( ( pODBC3SQLBulkOperations = (T3SQLBulkOperations)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLBulkOperations").pData )) == NULL )
237 return sal_False;
238 if( ( pODBC3SQLMoreResults = (T3SQLMoreResults)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLMoreResults").pData )) == NULL )
239 return sal_False;
240 /*if( ( pODBC3SQLGetDiagField = (T3SQLGetDiagField)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetDiagField").pData )) == NULL )
241 return sal_False;*/
242 if( ( pODBC3SQLGetDiagRec = (T3SQLGetDiagRec)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetDiagRec").pData )) == NULL )
243 return sal_False;
244 if( ( pODBC3SQLColumnPrivileges = (T3SQLColumnPrivileges)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLColumnPrivileges").pData )) == NULL )
245 return sal_False;
246 if( ( pODBC3SQLColumns = (T3SQLColumns)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLColumns").pData )) == NULL )
247 return sal_False;
248 if( ( pODBC3SQLForeignKeys = (T3SQLForeignKeys)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLForeignKeys").pData )) == NULL )
249 return sal_False;
250 if( ( pODBC3SQLPrimaryKeys = (T3SQLPrimaryKeys)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLPrimaryKeys").pData )) == NULL )
251 return sal_False;
252 if( ( pODBC3SQLProcedureColumns = (T3SQLProcedureColumns)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLProcedureColumns").pData )) == NULL )
253 return sal_False;
254 if( ( pODBC3SQLProcedures = (T3SQLProcedures)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLProcedures").pData )) == NULL )
255 return sal_False;
256 if( ( pODBC3SQLSpecialColumns = (T3SQLSpecialColumns)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSpecialColumns").pData )) == NULL )
257 return sal_False;
258 if( ( pODBC3SQLStatistics = (T3SQLStatistics)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLStatistics").pData )) == NULL )
259 return sal_False;
260 if( ( pODBC3SQLTablePrivileges = (T3SQLTablePrivileges)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLTablePrivileges").pData )) == NULL )
261 return sal_False;
262 if( ( pODBC3SQLTables = (T3SQLTables)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLTables").pData )) == NULL )
263 return sal_False;
264 if( ( pODBC3SQLFreeStmt = (T3SQLFreeStmt)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLFreeStmt").pData )) == NULL )
265 return sal_False;
266 if( ( pODBC3SQLCloseCursor = (T3SQLCloseCursor)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLCloseCursor").pData )) == NULL )
267 return sal_False;
268 if( ( pODBC3SQLCancel = (T3SQLCancel)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLCancel").pData )) == NULL )
269 return sal_False;
270 if( ( pODBC3SQLEndTran = (T3SQLEndTran)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLEndTran").pData )) == NULL )
271 return sal_False;
272 if( ( pODBC3SQLDisconnect = (T3SQLDisconnect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDisconnect").pData )) == NULL )
273 return sal_False;
274 if( ( pODBC3SQLFreeHandle = (T3SQLFreeHandle)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLFreeHandle").pData )) == NULL )
275 return sal_False;
276 if( ( pODBC3SQLGetCursorName = (T3SQLGetCursorName)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetCursorName").pData )) == NULL )
277 return sal_False;
278 if( ( pODBC3SQLNativeSql = (T3SQLNativeSql)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLNativeSql").pData )) == NULL )
279 return sal_False;
281 return sal_True;
283 // -------------------------------------------------------------------------