FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node-sqlanywhere/src/sacapidll.cpp at master · JFLeblay/node-sqlanywhere · GitHub
JFLeblay
/
node-sqlanywhere
Public
forked from
sqlanywhere/node-sqlanywhere
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
node-sqlanywhere
/
src
/
sacapidll.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
205 lines (190 loc) · 6.81 KB
Breadcrumbs
node-sqlanywhere
/
src
/
sacapidll.cpp
Copy path
File metadata and controls
205 lines (190 loc) · 6.81 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
//
***************************************************************************
//
Copyright (c) 2021 SAP SE or an SAP affiliate company. All rights reserved.
//
***************************************************************************
//
//
Licensed under the Apache License, Version 2.0 (the "License");
//
you may not use this file except in compliance with the License.
//
You may obtain a copy of the License at
//
//
http://www.apache.org/licenses/LICENSE-2.0
//
//
Unless required by applicable law or agreed to in writing, software
//
distributed under the License is distributed on an "AS IS" BASIS,
//
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
//
See the License for the specific language governing permissions and
//
limitations under the License.
//
//
While not a requirement of the license, if you do modify this file, we
//
would appreciate hearing about it. Please email
//
sqlany_interfaces@sap.com
//
//
***************************************************************************
#
include
<
string.h
>
#
include
<
stdlib.h
>
#
include
<
stdio.h
>
#
if
defined( _WIN32 )
#
include
<
windows.h
>
#
define
DEFAULT_LIBRARY_NAME
"
dbcapi.dll
"
#
else
#
include
<
dlfcn.h
>
/*
assume we are running on a UNIX platform
*/
#
if
defined( __APPLE__ )
#
define
LIB_EXT
"
dylib
"
#
else
#
define
LIB_EXT
"
so
"
#
endif
#
if
defined( _REENTRANT ) || defined( _THREAD_SAFE ) \
||
defined
( __USE_REENTRANT )
/*
if building a thread-safe library, we need to load
the thread-safe dbcapi library
*/
#
define
DEFAULT_LIBRARY_NAME
"
libdbcapi_r.
"
LIB_EXT
#
else
#
define
DEFAULT_LIBRARY_NAME
"
libdbcapi.
"
LIB_EXT
#
endif
#
endif
#
include
"
sacapidll.h
"
static
void
*
loadLibrary
(
const
char
* name )
/*
***********************************
*/
{
void
* handle;
#
if
defined( _WIN32 )
handle =
LoadLibrary
( name );
#
else
handle =
dlopen
( name,
RTLD_LAZY
);
#
endif
return
handle;
}
static
void
unloadLibrary
(
void
* handle )
/*
********************************
*/
{
#
if
defined( _WIN32 )
FreeLibrary
( (
HMODULE
)handle );
#
else
dlclose
( handle );
#
endif
}
static
void
*
findSymbol
(
void
* dll_handle,
const
char
* name )
/*
*****************************************************
*/
{
#
if
defined( _WIN32 )
return
GetProcAddress
( (
HMODULE
)dll_handle, name );
#
else
return
dlsym
( dll_handle, name );
#
endif
}
#
define
LookupSymbol
(
api, sym
) \
api->sym = (sym ## _func)findSymbol( api->dll_handle, #sym );
#
define
LookupSymbolAndCheck
(
api, sym
) \
api->sym = (sym ## _func)findSymbol( api->dll_handle, #sym ); \
if
( api->sym ==
NULL
) { \
unloadLibrary
( api->
dll_handle
); \
return
0
; \
}
int
sqlany_initialize_interface
( SQLAnywhereInterface * api,
const
char
* path )
/*
*****************************************************************************
*/
{
char
* env;
memset
( api,
0
,
sizeof
(*api));
if
( path !=
NULL
) {
api->
dll_handle
=
loadLibrary
( path );
if
( api->
dll_handle
!=
NULL
) {
goto
loaded;
}
}
env =
getenv
(
"
SQLANY_API_DLL
"
);
if
( env !=
NULL
) {
api->
dll_handle
=
loadLibrary
( env );
if
( api->
dll_handle
!=
NULL
) {
goto
loaded;
}
}
api->
dll_handle
=
loadLibrary
(
DEFAULT_LIBRARY_NAME
);
if
( api->
dll_handle
!=
NULL
) {
goto
loaded;
}
return
0
;
loaded:
LookupSymbolAndCheck
( api, sqlany_init );
LookupSymbolAndCheck
( api, sqlany_fini );
LookupSymbolAndCheck
( api, sqlany_new_connection );
LookupSymbolAndCheck
( api, sqlany_free_connection );
LookupSymbolAndCheck
( api, sqlany_make_connection );
LookupSymbolAndCheck
( api, sqlany_connect );
LookupSymbolAndCheck
( api, sqlany_disconnect );
LookupSymbolAndCheck
( api, sqlany_execute_immediate );
LookupSymbolAndCheck
( api, sqlany_prepare );
LookupSymbolAndCheck
( api, sqlany_free_stmt );
LookupSymbolAndCheck
( api, sqlany_num_params );
LookupSymbolAndCheck
( api, sqlany_describe_bind_param );
LookupSymbolAndCheck
( api, sqlany_bind_param );
LookupSymbolAndCheck
( api, sqlany_send_param_data );
LookupSymbolAndCheck
( api, sqlany_reset );
LookupSymbolAndCheck
( api, sqlany_get_bind_param_info );
LookupSymbolAndCheck
( api, sqlany_execute );
LookupSymbolAndCheck
( api, sqlany_execute_direct );
LookupSymbolAndCheck
( api, sqlany_fetch_absolute );
LookupSymbolAndCheck
( api, sqlany_fetch_next );
LookupSymbolAndCheck
( api, sqlany_get_next_result );
LookupSymbolAndCheck
( api, sqlany_affected_rows );
LookupSymbolAndCheck
( api, sqlany_num_cols );
LookupSymbolAndCheck
( api, sqlany_num_rows );
LookupSymbolAndCheck
( api, sqlany_get_column );
LookupSymbolAndCheck
( api, sqlany_get_data );
LookupSymbolAndCheck
( api, sqlany_get_data_info );
LookupSymbolAndCheck
( api, sqlany_get_column_info );
LookupSymbolAndCheck
( api, sqlany_commit );
LookupSymbolAndCheck
( api, sqlany_rollback );
LookupSymbolAndCheck
( api, sqlany_client_version );
LookupSymbolAndCheck
( api, sqlany_error );
LookupSymbolAndCheck
( api, sqlany_sqlstate );
LookupSymbolAndCheck
( api, sqlany_clear_error );
#
if
_SACAPI_VERSION+0 >= SQLANY_API_VERSION_2
/*
We don't report an error if we don't find the v2 entry points.
That allows the calling app to revert to v1
*/
LookupSymbol
( api, sqlany_init_ex );
LookupSymbol
( api, sqlany_fini_ex );
LookupSymbol
( api, sqlany_new_connection_ex );
LookupSymbol
( api, sqlany_make_connection_ex );
LookupSymbol
( api, sqlany_client_version_ex );
LookupSymbolAndCheck
( api, sqlany_cancel );
#
endif
#
if
_SACAPI_VERSION+0 >= SQLANY_API_VERSION_3
/*
We don't report an error if we don't find the v3 entry points.
That allows the calling app to revert to v1
*/
LookupSymbol
( api, sqlany_register_callback );
#
endif
#
if
_SACAPI_VERSION+0 >= SQLANY_API_VERSION_4
/*
We don't report an error if we don't find the v4 entry points.
That allows the calling app to revert to v1
*/
LookupSymbol
( api, sqlany_set_batch_size );
LookupSymbol
( api, sqlany_set_param_bind_type );
LookupSymbol
( api, sqlany_get_batch_size );
LookupSymbol
( api, sqlany_set_rowset_size );
LookupSymbol
( api, sqlany_get_rowset_size );
LookupSymbol
( api, sqlany_set_column_bind_type );
LookupSymbol
( api, sqlany_bind_column );
LookupSymbol
( api, sqlany_clear_column_bindings );
LookupSymbol
( api, sqlany_fetched_rows );
LookupSymbol
( api, sqlany_set_rowset_pos );
#
endif
#
if
_SACAPI_VERSION+0 >= SQLANY_API_VERSION_5
LookupSymbol
( api, sqlany_reset_param_data );
LookupSymbol
( api, sqlany_error_length );
#
endif
api->
initialized
=
1
;
return
1
;
}
#
undef
LookupSymbolAndCheck
void
sqlany_finalize_interface
( SQLAnywhereInterface * api )
/*
*********************************************************
*/
{
if
( !api->
initialized
) {
return
;
}
unloadLibrary
( api->
dll_handle
);
memset
( api,
0
,
sizeof
(*api));
}
Back
|
FazBrowse Home
|
New Git URL