Bump for 3.6-28
[LibreOffice.git] / connectivity / source / drivers / odbc / OFunctions.cxx
blobcd1a9d59aa00c8284f2c1d4d24be2f07334509f7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 //--------------------------------------------------------------------------
31 #include "odbc/OFunctions.hxx"
32 #include <osl/process.h>
34 // Implib-Definitionen fuer ODBC-DLL/shared library:
36 namespace connectivity
38 T3SQLAllocHandle pODBC3SQLAllocHandle;
39 T3SQLConnect pODBC3SQLConnect;
40 T3SQLDriverConnect pODBC3SQLDriverConnect;
41 T3SQLBrowseConnect pODBC3SQLBrowseConnect;
42 T3SQLDataSources pODBC3SQLDataSources;
43 T3SQLDrivers pODBC3SQLDrivers;
44 T3SQLGetInfo pODBC3SQLGetInfo;
45 T3SQLGetFunctions pODBC3SQLGetFunctions;
46 T3SQLGetTypeInfo pODBC3SQLGetTypeInfo;
47 T3SQLSetConnectAttr pODBC3SQLSetConnectAttr;
48 T3SQLGetConnectAttr pODBC3SQLGetConnectAttr;
49 T3SQLSetEnvAttr pODBC3SQLSetEnvAttr;
50 T3SQLGetEnvAttr pODBC3SQLGetEnvAttr;
51 T3SQLSetStmtAttr pODBC3SQLSetStmtAttr;
52 T3SQLGetStmtAttr pODBC3SQLGetStmtAttr;
53 T3SQLPrepare pODBC3SQLPrepare;
54 T3SQLBindParameter pODBC3SQLBindParameter;
55 T3SQLSetCursorName pODBC3SQLSetCursorName;
56 T3SQLExecute pODBC3SQLExecute;
57 T3SQLExecDirect pODBC3SQLExecDirect;
58 T3SQLDescribeParam pODBC3SQLDescribeParam;
59 T3SQLNumParams pODBC3SQLNumParams;
60 T3SQLParamData pODBC3SQLParamData;
61 T3SQLPutData pODBC3SQLPutData;
62 T3SQLRowCount pODBC3SQLRowCount;
63 T3SQLNumResultCols pODBC3SQLNumResultCols;
64 T3SQLDescribeCol pODBC3SQLDescribeCol;
65 T3SQLColAttribute pODBC3SQLColAttribute;
66 T3SQLBindCol pODBC3SQLBindCol;
67 T3SQLFetch pODBC3SQLFetch;
68 T3SQLFetchScroll pODBC3SQLFetchScroll;
69 T3SQLGetData pODBC3SQLGetData;
70 T3SQLSetPos pODBC3SQLSetPos;
71 T3SQLBulkOperations pODBC3SQLBulkOperations;
72 T3SQLMoreResults pODBC3SQLMoreResults;
73 T3SQLGetDiagRec pODBC3SQLGetDiagRec;
74 T3SQLColumnPrivileges pODBC3SQLColumnPrivileges;
75 T3SQLColumns pODBC3SQLColumns;
76 T3SQLForeignKeys pODBC3SQLForeignKeys;
77 T3SQLPrimaryKeys pODBC3SQLPrimaryKeys;
78 T3SQLProcedureColumns pODBC3SQLProcedureColumns;
79 T3SQLProcedures pODBC3SQLProcedures;
80 T3SQLSpecialColumns pODBC3SQLSpecialColumns;
81 T3SQLStatistics pODBC3SQLStatistics;
82 T3SQLTablePrivileges pODBC3SQLTablePrivileges;
83 T3SQLTables pODBC3SQLTables;
84 T3SQLFreeStmt pODBC3SQLFreeStmt;
85 T3SQLCloseCursor pODBC3SQLCloseCursor;
86 T3SQLCancel pODBC3SQLCancel;
87 T3SQLEndTran pODBC3SQLEndTran;
88 T3SQLDisconnect pODBC3SQLDisconnect;
89 T3SQLFreeHandle pODBC3SQLFreeHandle;
90 T3SQLGetCursorName pODBC3SQLGetCursorName;
91 T3SQLNativeSql pODBC3SQLNativeSql;
93 sal_Bool LoadFunctions(oslModule pODBCso);
94 // -------------------------------------------------------------------------
95 // Take care of Dynamicly loading of the DLL/shared lib and Addresses:
96 // Returns sal_True at success
97 sal_Bool LoadLibrary_ODBC3(::rtl::OUString &_rPath)
99 static sal_Bool bLoaded = sal_False;
100 static oslModule pODBCso = NULL;
102 if (bLoaded)
103 return sal_True;
104 #ifdef WNT
105 _rPath = ::rtl::OUString("ODBC32.DLL");
106 #endif
107 #ifdef UNX
108 #ifdef MACOSX
109 _rPath = ::rtl::OUString("libiodbc.dylib");
110 #else
111 _rPath = ::rtl::OUString("libodbc.so.1");
112 pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW );
113 if ( !pODBCso )
114 _rPath = ::rtl::OUString("libodbc.so");
115 #endif /* MACOSX */
116 #endif
118 if ( !pODBCso )
119 pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW );
120 if( !pODBCso)
121 return sal_False;
123 return bLoaded = LoadFunctions(pODBCso);
125 // -------------------------------------------------------------------------
127 sal_Bool LoadFunctions(oslModule pODBCso)
130 if( ( pODBC3SQLAllocHandle = (T3SQLAllocHandle)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLAllocHandle").pData )) == NULL )
131 return sal_False;
132 if( ( pODBC3SQLConnect = (T3SQLConnect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLConnect").pData )) == NULL )
133 return sal_False;
134 if( ( pODBC3SQLDriverConnect = (T3SQLDriverConnect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLDriverConnect").pData )) == NULL )
135 return sal_False;
136 if( ( pODBC3SQLBrowseConnect = (T3SQLBrowseConnect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLBrowseConnect").pData )) == NULL )
137 return sal_False;
138 if(( pODBC3SQLDataSources = (T3SQLDataSources)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLDataSources").pData )) == NULL )
139 return sal_False;
140 if(( pODBC3SQLDrivers = (T3SQLDrivers)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLDrivers").pData )) == NULL )
141 return sal_False;
142 if( ( pODBC3SQLGetInfo = (T3SQLGetInfo)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLGetInfo").pData )) == NULL )
143 return sal_False;
144 if(( pODBC3SQLGetFunctions = (T3SQLGetFunctions)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLGetFunctions").pData )) == NULL )
145 return sal_False;
146 if( ( pODBC3SQLGetTypeInfo = (T3SQLGetTypeInfo)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLGetTypeInfo").pData )) == NULL )
147 return sal_False;
148 if( ( pODBC3SQLSetConnectAttr = (T3SQLSetConnectAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLSetConnectAttr").pData )) == NULL )
149 return sal_False;
150 if( ( pODBC3SQLGetConnectAttr = (T3SQLGetConnectAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLGetConnectAttr").pData )) == NULL )
151 return sal_False;
152 if( ( pODBC3SQLSetEnvAttr = (T3SQLSetEnvAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLSetEnvAttr").pData )) == NULL )
153 return sal_False;
154 if( ( pODBC3SQLGetEnvAttr = (T3SQLGetEnvAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLGetEnvAttr").pData )) == NULL )
155 return sal_False;
156 if( ( pODBC3SQLSetStmtAttr = (T3SQLSetStmtAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLSetStmtAttr").pData )) == NULL )
157 return sal_False;
158 if( ( pODBC3SQLGetStmtAttr = (T3SQLGetStmtAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLGetStmtAttr").pData )) == NULL )
159 return sal_False;
160 if( ( pODBC3SQLPrepare = (T3SQLPrepare)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLPrepare").pData )) == NULL )
161 return sal_False;
162 if( ( pODBC3SQLBindParameter = (T3SQLBindParameter)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLBindParameter").pData )) == NULL )
163 return sal_False;
164 if( ( pODBC3SQLSetCursorName = (T3SQLSetCursorName)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLSetCursorName").pData )) == NULL )
165 return sal_False;
166 if( ( pODBC3SQLExecute = (T3SQLExecute)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLExecute").pData )) == NULL )
167 return sal_False;
168 if( ( pODBC3SQLExecDirect = (T3SQLExecDirect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLExecDirect").pData )) == NULL )
169 return sal_False;
170 if( ( pODBC3SQLDescribeParam = (T3SQLDescribeParam)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLDescribeParam").pData )) == NULL )
171 return sal_False;
172 if( ( pODBC3SQLNumParams = (T3SQLNumParams)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLNumParams").pData )) == NULL )
173 return sal_False;
174 if( ( pODBC3SQLParamData = (T3SQLParamData)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLParamData").pData )) == NULL )
175 return sal_False;
176 if( ( pODBC3SQLPutData = (T3SQLPutData)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLPutData").pData )) == NULL )
177 return sal_False;
178 if( ( pODBC3SQLRowCount = (T3SQLRowCount)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLRowCount").pData )) == NULL )
179 return sal_False;
180 if( ( pODBC3SQLNumResultCols = (T3SQLNumResultCols)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLNumResultCols").pData )) == NULL )
181 return sal_False;
182 if( ( pODBC3SQLDescribeCol = (T3SQLDescribeCol)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLDescribeCol").pData )) == NULL )
183 return sal_False;
184 if( ( pODBC3SQLColAttribute = (T3SQLColAttribute)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLColAttribute").pData )) == NULL )
185 return sal_False;
186 if( ( pODBC3SQLBindCol = (T3SQLBindCol)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLBindCol").pData )) == NULL )
187 return sal_False;
188 if( ( pODBC3SQLFetch = (T3SQLFetch)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLFetch").pData )) == NULL )
189 return sal_False;
190 if( ( pODBC3SQLFetchScroll = (T3SQLFetchScroll)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLFetchScroll").pData )) == NULL )
191 return sal_False;
192 if( ( pODBC3SQLGetData = (T3SQLGetData)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLGetData").pData )) == NULL )
193 return sal_False;
194 if( ( pODBC3SQLSetPos = (T3SQLSetPos)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLSetPos").pData )) == NULL )
195 return sal_False;
196 if( ( pODBC3SQLBulkOperations = (T3SQLBulkOperations)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLBulkOperations").pData )) == NULL )
197 return sal_False;
198 if( ( pODBC3SQLMoreResults = (T3SQLMoreResults)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLMoreResults").pData )) == NULL )
199 return sal_False;
200 if( ( pODBC3SQLGetDiagRec = (T3SQLGetDiagRec)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLGetDiagRec").pData )) == NULL )
201 return sal_False;
202 if( ( pODBC3SQLColumnPrivileges = (T3SQLColumnPrivileges)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLColumnPrivileges").pData )) == NULL )
203 return sal_False;
204 if( ( pODBC3SQLColumns = (T3SQLColumns)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLColumns").pData )) == NULL )
205 return sal_False;
206 if( ( pODBC3SQLForeignKeys = (T3SQLForeignKeys)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLForeignKeys").pData )) == NULL )
207 return sal_False;
208 if( ( pODBC3SQLPrimaryKeys = (T3SQLPrimaryKeys)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLPrimaryKeys").pData )) == NULL )
209 return sal_False;
210 if( ( pODBC3SQLProcedureColumns = (T3SQLProcedureColumns)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLProcedureColumns").pData )) == NULL )
211 return sal_False;
212 if( ( pODBC3SQLProcedures = (T3SQLProcedures)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLProcedures").pData )) == NULL )
213 return sal_False;
214 if( ( pODBC3SQLSpecialColumns = (T3SQLSpecialColumns)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLSpecialColumns").pData )) == NULL )
215 return sal_False;
216 if( ( pODBC3SQLStatistics = (T3SQLStatistics)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLStatistics").pData )) == NULL )
217 return sal_False;
218 if( ( pODBC3SQLTablePrivileges = (T3SQLTablePrivileges)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLTablePrivileges").pData )) == NULL )
219 return sal_False;
220 if( ( pODBC3SQLTables = (T3SQLTables)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLTables").pData )) == NULL )
221 return sal_False;
222 if( ( pODBC3SQLFreeStmt = (T3SQLFreeStmt)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLFreeStmt").pData )) == NULL )
223 return sal_False;
224 if( ( pODBC3SQLCloseCursor = (T3SQLCloseCursor)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLCloseCursor").pData )) == NULL )
225 return sal_False;
226 if( ( pODBC3SQLCancel = (T3SQLCancel)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLCancel").pData )) == NULL )
227 return sal_False;
228 if( ( pODBC3SQLEndTran = (T3SQLEndTran)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLEndTran").pData )) == NULL )
229 return sal_False;
230 if( ( pODBC3SQLDisconnect = (T3SQLDisconnect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLDisconnect").pData )) == NULL )
231 return sal_False;
232 if( ( pODBC3SQLFreeHandle = (T3SQLFreeHandle)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLFreeHandle").pData )) == NULL )
233 return sal_False;
234 if( ( pODBC3SQLGetCursorName = (T3SQLGetCursorName)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLGetCursorName").pData )) == NULL )
235 return sal_False;
236 if( ( pODBC3SQLNativeSql = (T3SQLNativeSql)osl_getFunctionSymbol(pODBCso, ::rtl::OUString("SQLNativeSql").pData )) == NULL )
237 return sal_False;
239 return sal_True;
241 // -------------------------------------------------------------------------
247 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */