Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "odbc/OFunctions.hxx"
21 : #include <osl/process.h>
22 :
23 : // Implib-Definitionen fuer ODBC-DLL/shared library:
24 :
25 : namespace connectivity
26 : {
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;
81 :
82 : sal_Bool LoadFunctions(oslModule pODBCso);
83 :
84 : // Take care of Dynamicly loading of the DLL/shared lib and Addresses:
85 : // Returns sal_True at success
86 0 : sal_Bool LoadLibrary_ODBC3(OUString &_rPath)
87 : {
88 : static sal_Bool bLoaded = sal_False;
89 : static oslModule pODBCso = NULL;
90 :
91 0 : if (bLoaded)
92 0 : return sal_True;
93 : #ifdef WNT
94 : _rPath = "ODBC32.DLL";
95 : #endif
96 : #ifdef UNX
97 : #ifdef MACOSX
98 : _rPath = "libiodbc.dylib";
99 : #else
100 0 : _rPath = "libodbc.so.1";
101 0 : pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW );
102 0 : if ( !pODBCso )
103 0 : _rPath = "libodbc.so";
104 : #endif /* MACOSX */
105 : #endif
106 :
107 0 : if ( !pODBCso )
108 0 : pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW );
109 0 : if( !pODBCso)
110 0 : return sal_False;
111 :
112 0 : return bLoaded = LoadFunctions(pODBCso);
113 : }
114 :
115 :
116 0 : sal_Bool LoadFunctions(oslModule pODBCso)
117 : {
118 :
119 0 : if( ( pODBC3SQLAllocHandle = (T3SQLAllocHandle)osl_getFunctionSymbol(pODBCso, OUString("SQLAllocHandle").pData )) == NULL )
120 0 : return sal_False;
121 0 : if( ( pODBC3SQLConnect = (T3SQLConnect)osl_getFunctionSymbol(pODBCso, OUString("SQLConnect").pData )) == NULL )
122 0 : return sal_False;
123 0 : if( ( pODBC3SQLDriverConnect = (T3SQLDriverConnect)osl_getFunctionSymbol(pODBCso, OUString("SQLDriverConnect").pData )) == NULL )
124 0 : return sal_False;
125 0 : if( ( pODBC3SQLBrowseConnect = (T3SQLBrowseConnect)osl_getFunctionSymbol(pODBCso, OUString("SQLBrowseConnect").pData )) == NULL )
126 0 : return sal_False;
127 0 : if(( pODBC3SQLDataSources = (T3SQLDataSources)osl_getFunctionSymbol(pODBCso, OUString("SQLDataSources").pData )) == NULL )
128 0 : return sal_False;
129 0 : if(( pODBC3SQLDrivers = (T3SQLDrivers)osl_getFunctionSymbol(pODBCso, OUString("SQLDrivers").pData )) == NULL )
130 0 : return sal_False;
131 0 : if( ( pODBC3SQLGetInfo = (T3SQLGetInfo)osl_getFunctionSymbol(pODBCso, OUString("SQLGetInfo").pData )) == NULL )
132 0 : return sal_False;
133 0 : if(( pODBC3SQLGetFunctions = (T3SQLGetFunctions)osl_getFunctionSymbol(pODBCso, OUString("SQLGetFunctions").pData )) == NULL )
134 0 : return sal_False;
135 0 : if( ( pODBC3SQLGetTypeInfo = (T3SQLGetTypeInfo)osl_getFunctionSymbol(pODBCso, OUString("SQLGetTypeInfo").pData )) == NULL )
136 0 : return sal_False;
137 0 : if( ( pODBC3SQLSetConnectAttr = (T3SQLSetConnectAttr)osl_getFunctionSymbol(pODBCso, OUString("SQLSetConnectAttr").pData )) == NULL )
138 0 : return sal_False;
139 0 : if( ( pODBC3SQLGetConnectAttr = (T3SQLGetConnectAttr)osl_getFunctionSymbol(pODBCso, OUString("SQLGetConnectAttr").pData )) == NULL )
140 0 : return sal_False;
141 0 : if( ( pODBC3SQLSetEnvAttr = (T3SQLSetEnvAttr)osl_getFunctionSymbol(pODBCso, OUString("SQLSetEnvAttr").pData )) == NULL )
142 0 : return sal_False;
143 0 : if( ( pODBC3SQLGetEnvAttr = (T3SQLGetEnvAttr)osl_getFunctionSymbol(pODBCso, OUString("SQLGetEnvAttr").pData )) == NULL )
144 0 : return sal_False;
145 0 : if( ( pODBC3SQLSetStmtAttr = (T3SQLSetStmtAttr)osl_getFunctionSymbol(pODBCso, OUString("SQLSetStmtAttr").pData )) == NULL )
146 0 : return sal_False;
147 0 : if( ( pODBC3SQLGetStmtAttr = (T3SQLGetStmtAttr)osl_getFunctionSymbol(pODBCso, OUString("SQLGetStmtAttr").pData )) == NULL )
148 0 : return sal_False;
149 0 : if( ( pODBC3SQLPrepare = (T3SQLPrepare)osl_getFunctionSymbol(pODBCso, OUString("SQLPrepare").pData )) == NULL )
150 0 : return sal_False;
151 0 : if( ( pODBC3SQLBindParameter = (T3SQLBindParameter)osl_getFunctionSymbol(pODBCso, OUString("SQLBindParameter").pData )) == NULL )
152 0 : return sal_False;
153 0 : if( ( pODBC3SQLSetCursorName = (T3SQLSetCursorName)osl_getFunctionSymbol(pODBCso, OUString("SQLSetCursorName").pData )) == NULL )
154 0 : return sal_False;
155 0 : if( ( pODBC3SQLExecute = (T3SQLExecute)osl_getFunctionSymbol(pODBCso, OUString("SQLExecute").pData )) == NULL )
156 0 : return sal_False;
157 0 : if( ( pODBC3SQLExecDirect = (T3SQLExecDirect)osl_getFunctionSymbol(pODBCso, OUString("SQLExecDirect").pData )) == NULL )
158 0 : return sal_False;
159 0 : if( ( pODBC3SQLDescribeParam = (T3SQLDescribeParam)osl_getFunctionSymbol(pODBCso, OUString("SQLDescribeParam").pData )) == NULL )
160 0 : return sal_False;
161 0 : if( ( pODBC3SQLNumParams = (T3SQLNumParams)osl_getFunctionSymbol(pODBCso, OUString("SQLNumParams").pData )) == NULL )
162 0 : return sal_False;
163 0 : if( ( pODBC3SQLParamData = (T3SQLParamData)osl_getFunctionSymbol(pODBCso, OUString("SQLParamData").pData )) == NULL )
164 0 : return sal_False;
165 0 : if( ( pODBC3SQLPutData = (T3SQLPutData)osl_getFunctionSymbol(pODBCso, OUString("SQLPutData").pData )) == NULL )
166 0 : return sal_False;
167 0 : if( ( pODBC3SQLRowCount = (T3SQLRowCount)osl_getFunctionSymbol(pODBCso, OUString("SQLRowCount").pData )) == NULL )
168 0 : return sal_False;
169 0 : if( ( pODBC3SQLNumResultCols = (T3SQLNumResultCols)osl_getFunctionSymbol(pODBCso, OUString("SQLNumResultCols").pData )) == NULL )
170 0 : return sal_False;
171 0 : if( ( pODBC3SQLDescribeCol = (T3SQLDescribeCol)osl_getFunctionSymbol(pODBCso, OUString("SQLDescribeCol").pData )) == NULL )
172 0 : return sal_False;
173 0 : if( ( pODBC3SQLColAttribute = (T3SQLColAttribute)osl_getFunctionSymbol(pODBCso, OUString("SQLColAttribute").pData )) == NULL )
174 0 : return sal_False;
175 0 : if( ( pODBC3SQLBindCol = (T3SQLBindCol)osl_getFunctionSymbol(pODBCso, OUString("SQLBindCol").pData )) == NULL )
176 0 : return sal_False;
177 0 : if( ( pODBC3SQLFetch = (T3SQLFetch)osl_getFunctionSymbol(pODBCso, OUString("SQLFetch").pData )) == NULL )
178 0 : return sal_False;
179 0 : if( ( pODBC3SQLFetchScroll = (T3SQLFetchScroll)osl_getFunctionSymbol(pODBCso, OUString("SQLFetchScroll").pData )) == NULL )
180 0 : return sal_False;
181 0 : if( ( pODBC3SQLGetData = (T3SQLGetData)osl_getFunctionSymbol(pODBCso, OUString("SQLGetData").pData )) == NULL )
182 0 : return sal_False;
183 0 : if( ( pODBC3SQLSetPos = (T3SQLSetPos)osl_getFunctionSymbol(pODBCso, OUString("SQLSetPos").pData )) == NULL )
184 0 : return sal_False;
185 0 : if( ( pODBC3SQLBulkOperations = (T3SQLBulkOperations)osl_getFunctionSymbol(pODBCso, OUString("SQLBulkOperations").pData )) == NULL )
186 0 : return sal_False;
187 0 : if( ( pODBC3SQLMoreResults = (T3SQLMoreResults)osl_getFunctionSymbol(pODBCso, OUString("SQLMoreResults").pData )) == NULL )
188 0 : return sal_False;
189 0 : if( ( pODBC3SQLGetDiagRec = (T3SQLGetDiagRec)osl_getFunctionSymbol(pODBCso, OUString("SQLGetDiagRec").pData )) == NULL )
190 0 : return sal_False;
191 0 : if( ( pODBC3SQLColumnPrivileges = (T3SQLColumnPrivileges)osl_getFunctionSymbol(pODBCso, OUString("SQLColumnPrivileges").pData )) == NULL )
192 0 : return sal_False;
193 0 : if( ( pODBC3SQLColumns = (T3SQLColumns)osl_getFunctionSymbol(pODBCso, OUString("SQLColumns").pData )) == NULL )
194 0 : return sal_False;
195 0 : if( ( pODBC3SQLForeignKeys = (T3SQLForeignKeys)osl_getFunctionSymbol(pODBCso, OUString("SQLForeignKeys").pData )) == NULL )
196 0 : return sal_False;
197 0 : if( ( pODBC3SQLPrimaryKeys = (T3SQLPrimaryKeys)osl_getFunctionSymbol(pODBCso, OUString("SQLPrimaryKeys").pData )) == NULL )
198 0 : return sal_False;
199 0 : if( ( pODBC3SQLProcedureColumns = (T3SQLProcedureColumns)osl_getFunctionSymbol(pODBCso, OUString("SQLProcedureColumns").pData )) == NULL )
200 0 : return sal_False;
201 0 : if( ( pODBC3SQLProcedures = (T3SQLProcedures)osl_getFunctionSymbol(pODBCso, OUString("SQLProcedures").pData )) == NULL )
202 0 : return sal_False;
203 0 : if( ( pODBC3SQLSpecialColumns = (T3SQLSpecialColumns)osl_getFunctionSymbol(pODBCso, OUString("SQLSpecialColumns").pData )) == NULL )
204 0 : return sal_False;
205 0 : if( ( pODBC3SQLStatistics = (T3SQLStatistics)osl_getFunctionSymbol(pODBCso, OUString("SQLStatistics").pData )) == NULL )
206 0 : return sal_False;
207 0 : if( ( pODBC3SQLTablePrivileges = (T3SQLTablePrivileges)osl_getFunctionSymbol(pODBCso, OUString("SQLTablePrivileges").pData )) == NULL )
208 0 : return sal_False;
209 0 : if( ( pODBC3SQLTables = (T3SQLTables)osl_getFunctionSymbol(pODBCso, OUString("SQLTables").pData )) == NULL )
210 0 : return sal_False;
211 0 : if( ( pODBC3SQLFreeStmt = (T3SQLFreeStmt)osl_getFunctionSymbol(pODBCso, OUString("SQLFreeStmt").pData )) == NULL )
212 0 : return sal_False;
213 0 : if( ( pODBC3SQLCloseCursor = (T3SQLCloseCursor)osl_getFunctionSymbol(pODBCso, OUString("SQLCloseCursor").pData )) == NULL )
214 0 : return sal_False;
215 0 : if( ( pODBC3SQLCancel = (T3SQLCancel)osl_getFunctionSymbol(pODBCso, OUString("SQLCancel").pData )) == NULL )
216 0 : return sal_False;
217 0 : if( ( pODBC3SQLEndTran = (T3SQLEndTran)osl_getFunctionSymbol(pODBCso, OUString("SQLEndTran").pData )) == NULL )
218 0 : return sal_False;
219 0 : if( ( pODBC3SQLDisconnect = (T3SQLDisconnect)osl_getFunctionSymbol(pODBCso, OUString("SQLDisconnect").pData )) == NULL )
220 0 : return sal_False;
221 0 : if( ( pODBC3SQLFreeHandle = (T3SQLFreeHandle)osl_getFunctionSymbol(pODBCso, OUString("SQLFreeHandle").pData )) == NULL )
222 0 : return sal_False;
223 0 : if( ( pODBC3SQLGetCursorName = (T3SQLGetCursorName)osl_getFunctionSymbol(pODBCso, OUString("SQLGetCursorName").pData )) == NULL )
224 0 : return sal_False;
225 0 : if( ( pODBC3SQLNativeSql = (T3SQLNativeSql)osl_getFunctionSymbol(pODBCso, OUString("SQLNativeSql").pData )) == NULL )
226 0 : return sal_False;
227 :
228 0 : return sal_True;
229 : }
230 :
231 :
232 : }
233 :
234 :
235 :
236 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|