DCL
4.0
Loading...
Searching...
No Matches
OciModuleMain.cpp
Go to the documentation of this file.
1
#include <
dcl/Config.h
>
2
3
#ifdef _MSC_VER
4
#pragma comment(lib, "oci.lib")
5
#endif
6
7
#include <oci.h>
8
9
#include <locale.h>
10
#include <
dcl/_stdlib.h
>
11
12
#include <
dcl/Object.h
>
13
#if __DCL_HAVE_ALLOC_DEBUG
14
#undef __DCL_ALLOC_LEVEL
15
#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
16
#endif
17
18
#include <
dcl/String.h
>
19
#include <
dcl/SQLCore.h
>
20
21
#include "
OciConnection.h
"
22
23
#if __DCL_HAVE_THIS_FILE__
24
#undef __THIS_FILE__
25
static
const
wchar_t
__THIS_FILE__
[] =
__T
(
"dcl/sql/OciModuleMain.cpp"
);
26
#endif
27
28
/*
29
#ifdef _WINDOWS
30
BOOL APIENTRY DllMain( HANDLE hModule,
31
DWORD ul_reason_for_call,
32
LPVOID lpReserved
33
)
34
{
35
switch (ul_reason_for_call)
36
{
37
case DLL_PROCESS_ATTACH:
38
case DLL_PROCESS_DETACH:
39
return TRUE;
40
case DLL_THREAD_ATTACH:
41
case DLL_THREAD_DETACH:
42
break;
43
}
44
return FALSE;
45
}
46
#endif
47
*/
48
49
__DCL_BEGIN_NAMESPACE
50
51
static
const
wchar_t
* _serverTitle =
__T
(
"OracleDb"
);
52
53
SQL::Connection
*
CreateConnectionInstance
()
54
{
55
// cerr << "createDatabaseObject IB\n";
56
return
(
new
OciConnection
(_serverTitle));
57
}
58
59
bool
ModuleInitialize
()
60
{
61
// https://docs.oracle.com/cd/B13789_01/server.101/b10749/ch7progr.htm#1006615
62
// When the NLS_LANG Character Set is UTF8 or AL32UTF8 in OCI
63
64
const
char
* envUTF8 =
"AMERICAN_AMERICA.UTF8"
;
65
char
* lang = getenv(
"LANG"
);
66
if
(!lang) {
67
lang = setlocale(LC_ALL,
""
);
68
}
69
if
(lang) {
70
ByteString s = ByteString(lang).toLowerCase();
71
if
(s.contains(
"ko"
) || s.contains(
"kr"
)) {
72
envUTF8 =
"KOREAN_KOREA.UTF8"
;
73
}
74
}
75
76
return
setenv(
"NLS_LANG"
, envUTF8,
true
) == 0;
77
}
78
79
bool
ModuleCleanup
()
80
{
81
sword status = ::OCITerminate(OCI_DEFAULT);
82
/*
83
if (status != OCI_SUCCESS)
84
{
85
setErrorMessage(status, NULL, __LINE__);
86
return false;
87
}
88
*/
89
if
(status != OCI_SUCCESS)
90
return
false
;
91
92
return
true
;
93
}
94
95
extern
"C"
96
{
97
DCL_DSO_EXPORT
98
SQL::DRIVER_MODULE
DCL_DSO_ENTRY_POINT
=
99
{
100
// DCL common members
101
sizeof
(
SQL::DRIVER_MODULE
),
// structure size
102
DCL_VERSION
,
103
__T
(
__TIMESTAMP__
),
104
DCL_BUILD_FLAG
,
105
DCL_SQL_DRIVER_MODULE
,
// module type
106
__T
(
"DCL SQL Driver for Oracle Database Server"
),
107
108
// private members
109
DCL_SQL_VERSION
,
110
_serverTitle,
111
__T
(
"4.0.0.0"
),
112
ModuleInitialize
,
113
ModuleCleanup
,
114
CreateConnectionInstance
115
};
116
117
}
118
119
__DCL_END_NAMESPACE
_stdlib.h
__THIS_FILE__
#define __THIS_FILE__
Definition
_trace.h:14
Config.h
__TIMESTAMP__
#define __TIMESTAMP__
Definition
Config.h:215
DCL_DSO_ENTRY_POINT
#define DCL_DSO_ENTRY_POINT
Definition
Config.h:393
DCL_BUILD_FLAG
#define DCL_BUILD_FLAG
Definition
Config.h:399
DCL_SQL_DRIVER_MODULE
#define DCL_SQL_DRIVER_MODULE
Definition
Config.h:390
DCL_SQL_VERSION
#define DCL_SQL_VERSION
Definition
Config.h:381
DCL_VERSION
#define DCL_VERSION
Definition
Config.h:376
DCL_DSO_EXPORT
#define DCL_DSO_EXPORT
Definition
Config.h:111
ModuleInitialize
bool ModuleInitialize()
Definition
IFXModuleMain.cpp:84
ModuleCleanup
bool ModuleCleanup()
Definition
IFXModuleMain.cpp:120
CreateConnectionInstance
SQL::Connection * CreateConnectionInstance()
Definition
IFXModuleMain.cpp:79
Object.h
__T
#define __T(str)
Definition
Object.h:44
OciConnection.h
ModuleInitialize
bool ModuleInitialize()
Definition
OciModuleMain.cpp:59
ModuleCleanup
bool ModuleCleanup()
Definition
OciModuleMain.cpp:79
CreateConnectionInstance
SQL::Connection * CreateConnectionInstance()
Definition
OciModuleMain.cpp:53
SQLCore.h
String.h
OciConnection
Definition
OciConnection.h:12
SQL::Connection
Definition
SQLCore.h:310
SQL::DRIVER_MODULE
Definition
SQLCore.h:408
src
SQLOracleDb
OciModuleMain.cpp
Generated by
1.14.0