DCL 3.7.4
Loading...
Searching...
No Matches
IFXModuleMain.cpp
Go to the documentation of this file.
1#include <dcl/Config.h>
2
3#ifdef _MSC_VER
4 #pragma comment(lib, "igl4n304.lib")
5 #pragma comment(lib, "iglxn304.lib")
6 #pragma comment(lib, "igo4n304.lib")
7 #pragma comment(lib, "isqlt09a.lib")
8#endif
9
10#include <string.h> // strchr
11#include <locale.h> // setlocale
12#include <dcl/_stdlib.h> // setenv
13
14#include <dcl/Object.h>
15#if __DCL_HAVE_ALLOC_DEBUG
16#undef __DCL_ALLOC_LEVEL
17#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
18#endif
19
20#include <dcl/SQLCore.h>
21#include "IFXConnection.h"
22#include "IFXUtils.h"
23
24#define __TRACE_THIS 0
25#if __TRACE_THIS
26#define __DCL_TRACE0_N __DCL_TRACE0
27#define __DCL_TRACE1_N __DCL_TRACE1
28#define __DCL_TRACE2_N __DCL_TRACE2
29#define __DCL_TRACE3_N __DCL_TRACE3
30#define __DCL_TRACE4_N __DCL_TRACE4
31#else
32#define __DCL_TRACE0_N(fmt)
33#define __DCL_TRACE1_N(fmt, arg)
34#define __DCL_TRACE2_N(fmt, arg1, arg2)
35#define __DCL_TRACE3_N(fmt, arg1, arg2, arg3)
36#define __DCL_TRACE4_N(fmt, arg1, arg2, arg3, arg4)
37#endif
38
39#if __DCL_HAVE_THIS_FILE__
40#undef __THIS_FILE__
41static const char_t __THIS_FILE__[] = __T("dcl/sql/IFXModuleMain.cpp");
42#endif
43
44/*
45#ifdef _WINDOWS
46BOOL APIENTRY DllMain( HANDLE hModule,
47 DWORD ul_reason_for_call,
48 LPVOID lpReserved
49)
50{
51 switch (ul_reason_for_call) {
52 case DLL_PROCESS_ATTACH:
53 case DLL_PROCESS_DETACH:
54 return TRUE;
55 case DLL_THREAD_ATTACH:
56 case DLL_THREAD_DETACH:
57 break;
58 }
59 return FALSE;
60}
61#endif
62*/
63
64#ifdef __DCL_DEBUG
65#if defined(_WINDOWS) && defined(_DEBUG)
66 typedef void (* __ndebug_free__)(void*);
67
68 static HMODULE __hMSVCRT_DLL = NULL;
69 static __ndebug_free__ __pfn_free = NULL;
70
71 void ndebug_free(void* p)
72 {
73 __DCL_ASSERT(__pfn_free != NULL);
74 __pfn_free(p);
75 }
76#else
77 void ndebug_free(void* _pv)
78 {
79 #ifdef __DCL_DEBUG_FREE
80 #undef free
81 #endif
82 free(_pv);
83 #ifdef __DCL_DEBUG_FREE
84 #define free __DCL_DEBUG_FREE
85 #endif
86 }
87#endif // _WINDOWS
88#endif
89
90__DCL_BEGIN_NAMESPACE
91
92static const wchar_t* _serverTitle = __T("INFORMIX");
93
95{
96 return new IFXConnection(_serverTitle);
97}
98
100{
101 const char* langUTF8 = "en_US.UTF8";
102 char* lang = getenv("LANG");
103 if (!lang) {
104 // current locale
105 lang = setlocale(LC_CTYPE, NULL);
106 }
107 if (lang) {
108 ByteString lang_ = ByteString(lang);
109 ByteString lower = lang_.toLowerCase();
110 if (lower.contains("ko") || lower.contains("kr")) {
111 langUTF8 = "ko_KR.UTF8";
112 }
113 }
114 __DCL_TRACE1_N(L"setenv CLIENT_LOCALE=[%hs]\n", langUTF8);
115 if (setenv("CLIENT_LOCALE", langUTF8, 1)) {
116 return false;
117 }
118
119#if defined(__DCL_DEBUG) && defined(_DEBUG) && defined(_WINDOWS)
120 __hMSVCRT_DLL = ::LoadLibrary("MSVCRT.DLL");
121 if (!__hMSVCRT_DLL) {
122 return false;
123 }
124
125 __pfn_free = (__ndebug_free__)
126 ::GetProcAddress(__hMSVCRT_DLL, "free");
127 if (!__pfn_free) {
128 ::FreeLibrary(__hMSVCRT_DLL);
129 __hMSVCRT_DLL = NULL;
130 return false;
131 }
132#endif
133
134 return true;
135}
136
138{
139#if defined(__DCL_DEBUG) && defined(_DEBUG) && defined(_WINDOWS)
140 if (__hMSVCRT_DLL) {
141 ::FreeLibrary(__hMSVCRT_DLL);
142 __hMSVCRT_DLL = NULL;
143 }
144#endif
145 return true;
146}
147
148extern "C"
149{
152{
153 // DCL common members
154 sizeof(SQL::DRIVER_MODULE), // structure size
158 DCL_SQL_DRIVER_MODULE, // module type
159 __T("DCL SQL Adapter for IBM Informix Database Server"),
160
161 // private members
163 _serverTitle,
168};
169
170}
171
172__DCL_END_NAMESPACE
173
174#ifdef __WINNT_NEW_DELETE_OVERRIDE
175#undef new
176__WINNT_NEW_DELETE_OVERRIDE
177#endif
#define __THIS_FILE__
Definition _trace.h:14
#define NULL
Definition Config.h:312
#define DCL_DSO_ENTRY_POINT
Definition Config.h:356
#define DCL_BUILD_FLAG
Definition Config.h:362
#define DCL_SQL_DRIVER_MODULE
Definition Config.h:353
wchar_t char_t
Definition Config.h:247
#define DCL_DSO_EXPORT
Definition Config.h:99
bool ModuleInitialize()
#define __DCL_TRACE1_N(fmt, arg)
bool ModuleCleanup()
SQL::Connection * CreateConnectionInstance()
#define ndebug_free(_p)
Definition IFXUtils.h:23
#define __DCL_ASSERT(expr)
Definition Object.h:394
#define __T(str)
Definition Object.h:60
#define DCL_SQL_VERSION
#define __BUILD_TIMESTAMP__
#define DCL_VERSION
#define DCL_SQL_VERSION_STRING