DCL 4.0
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 <locale.h>
11#include <dcl/_stdlib.h>
12
13#include <dcl/Object.h>
14#if __DCL_HAVE_ALLOC_DEBUG
15#undef __DCL_ALLOC_LEVEL
16#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
17#endif
18
19#include <dcl/SQLCore.h>
20#include "IFXConnection.h"
21#include "IFXUtils.h"
22
23#ifdef __DCL_HAVE_THIS_FILE__
24#undef __THIS_FILE__
25static const wchar_t __THIS_FILE__[] = __T("dcl/sql/IFXModuleMain.cpp");
26#endif
27
28/*
29#ifdef _WINDOWS
30BOOL 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#ifdef __DCL_DEBUG
50#if defined(_WINDOWS) && defined(_DEBUG)
51 typedef void (* __ndebug_free__)(void*);
52
53 static HMODULE __hMSVCRT_DLL = NULL;
54 static __ndebug_free__ __pfn_free = NULL;
55
56 void ndebug_free(void* p)
57 {
58 __DCL_ASSERT(__pfn_free != NULL);
59 __pfn_free(p);
60 }
61#else
62 void ndebug_free(void* _pv)
63 {
64 #ifdef __DCL_DEBUG_FREE
65 #undef free
66 #endif
67 free(_pv);
68 #ifdef __DCL_DEBUG_FREE
69 #define free __DCL_DEBUG_FREE
70 #endif
71 }
72#endif // _WINDOWS
73#endif
74
75__DCL_BEGIN_NAMESPACE
76
77static const wchar_t* _serverTitle = __T("INFORMIX");
78
80{
81 return new IFXConnection(_serverTitle);
82}
83
85{
86 const char* envUTF8 = "en_US.UTF8";
87 char* lang = getenv("LANG");
88 if (!lang) {
89 lang = setlocale(LC_ALL, "");
90 }
91 if (lang) {
92 ByteString s = ByteString(lang).toLowerCase();
93 if (s.contains("ko") || s.contains("kr")) {
94 envUTF8 = "ko_KR.UTF8";
95 }
96 }
97
98 if (setenv("CLIENT_LOCALE", envUTF8, true)) {
99 return false;
100 }
101
102#if defined(__DCL_DEBUG) && defined(_DEBUG) && defined(_WINDOWS)
103 __hMSVCRT_DLL = ::LoadLibrary("MSVCRT.DLL");
104 if (!__hMSVCRT_DLL) {
105 return false;
106 }
107
108 __pfn_free = (__ndebug_free__)
109 ::GetProcAddress(__hMSVCRT_DLL, "free");
110 if (!__pfn_free) {
111 ::FreeLibrary(__hMSVCRT_DLL);
112 __hMSVCRT_DLL = NULL;
113 return false;
114 }
115#endif
116
117 return true;
118}
119
121{
122#if defined(__DCL_DEBUG) && defined(_DEBUG) && defined(_WINDOWS)
123 if (__hMSVCRT_DLL) {
124 ::FreeLibrary(__hMSVCRT_DLL);
125 __hMSVCRT_DLL = NULL;
126 }
127#endif
128 return true;
129}
130
131extern "C"
132{
135{
136 // DCL common members
137 sizeof(SQL::DRIVER_MODULE), // structure size
141 DCL_SQL_DRIVER_MODULE, // module type
142 __T("DCL SQL Driver for IBM Informix Database Server"),
143
144 // private members
146 _serverTitle,
147 __T("4.0.0.0"),
151};
152
153}
154
155__DCL_END_NAMESPACE
#define __THIS_FILE__
Definition _trace.h:14
#define __TIMESTAMP__
Definition Config.h:215
#define NULL
Definition Config.h:340
#define DCL_DSO_ENTRY_POINT
Definition Config.h:393
#define DCL_BUILD_FLAG
Definition Config.h:399
#define DCL_SQL_DRIVER_MODULE
Definition Config.h:390
#define DCL_SQL_VERSION
Definition Config.h:381
#define DCL_VERSION
Definition Config.h:376
#define DCL_DSO_EXPORT
Definition Config.h:111
bool ModuleInitialize()
bool ModuleCleanup()
SQL::Connection * CreateConnectionInstance()
#define ndebug_free(_p)
Definition IFXUtils.h:23
#define __DCL_ASSERT(expr)
Definition Object.h:371
#define __T(str)
Definition Object.h:44