DCL 3.7.4
Loading...
Searching...
No Matches
PeModuleMain.cpp
Go to the documentation of this file.
1#include <dcl/Config.h>
2
3#ifdef _MSC_VER
4 #pragma comment(lib, "libecpg.lib")
5 #pragma comment(lib, "libpq.lib")
6 #pragma comment(lib, "libpgtypes.lib")
7#endif
8
9#include <string.h> // strchr
10#include <locale.h> // setlocale
11#include <dcl/_stdlib.h> // setenv
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 "PeConnection.h"
21
22#define __TRACE_THIS 0
23#if __TRACE_THIS
24#define __DCL_TRACE0_N __DCL_TRACE0
25#define __DCL_TRACE1_N __DCL_TRACE1
26#define __DCL_TRACE2_N __DCL_TRACE2
27#define __DCL_TRACE3_N __DCL_TRACE3
28#define __DCL_TRACE4_N __DCL_TRACE4
29#else
30#define __DCL_TRACE0_N(fmt)
31#define __DCL_TRACE1_N(fmt, arg)
32#define __DCL_TRACE2_N(fmt, arg1, arg2)
33#define __DCL_TRACE3_N(fmt, arg1, arg2, arg3)
34#define __DCL_TRACE4_N(fmt, arg1, arg2, arg3, arg4)
35#endif
36
37#if __DCL_HAVE_THIS_FILE__
38#undef __THIS_FILE__
39static const char_t __THIS_FILE__[] = __T("dcl/sql/PeModuleMain.cpp");
40#endif
41
42/*
43#ifdef _WINDOWS
44BOOL APIENTRY DllMain( HANDLE hModule,
45 DWORD ul_reason_for_call,
46 LPVOID lpReserved
47)
48{
49 switch (ul_reason_for_call) {
50 case DLL_PROCESS_ATTACH:
51 case DLL_PROCESS_DETACH:
52 return TRUE;
53 case DLL_THREAD_ATTACH:
54 case DLL_THREAD_DETACH:
55 break;
56 }
57 return FALSE;
58}
59#endif
60*/
61
62__DCL_BEGIN_NAMESPACE
63
64static const wchar_t* _serverTitle = __T("PostgreSQL/ecpg");
65
67{
68 return new PeConnection(_serverTitle);
69}
70
72{
73 /*
74 * LANG에 UTF-8이 없는 경우 LANG을 변경한다.
75 */
76 ByteStringBuilder sb;
77 char* lang = getenv("LANG");
78 if (!lang) {
79 // current locale
80 lang = setlocale(LC_CTYPE, NULL);
81 if (!(lang && strchr(lang, '.'))) {
82 // set default locale
83 lang = setlocale(LC_ALL, "");
84 }
85 }
86 if (lang) {
87 ByteString lang_ = ByteString(lang);
88 ByteString lower = lang_.toLowerCase();
89 if (!lower.contains("utf8")) {
90 if (lower.contains("ko") || lower.contains("kr")) {
91 sb.append("ko_KR");
92 }
93 else {
94 size_t index = lang_.indexOf(L'.');
95 sb.append(index == (size_t)-1 ?
96 lang_ : lang_.substring(0, index));
97 }
98 sb.append(".UTF-8");
99 }
100 }
101 else {
102 sb = "C.UTF-8";
103 }
104
105 if (sb.length() > 0) {
106 ByteString langUTF8 = sb.toByteString();
107 __DCL_TRACE1_N(L"setenv LANG=[%hs]\n", langUTF8.data());
108 return setenv("LANG", langUTF8, 1) == 0;;
109 }
110 return true;
111}
112
114{
115 return true;
116}
117
118extern "C"
119{
122{
123 // DCL common members
124 sizeof(SQL::DRIVER_MODULE), // structure size
128 DCL_SQL_DRIVER_MODULE, // module type
129 __T("DCL SQL Adapter for PostgreSQL Database Server"),
130
131 // private members
133 _serverTitle,
138};
139
140}
141
142__DCL_END_NAMESPACE
143
144#ifdef __WINNT_NEW_DELETE_OVERRIDE
145#undef new
146__WINNT_NEW_DELETE_OVERRIDE
147#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()
bool ModuleCleanup()
SQL::Connection * CreateConnectionInstance()
#define __T(str)
Definition Object.h:60
bool ModuleInitialize()
#define __DCL_TRACE1_N(fmt, arg)
bool ModuleCleanup()
SQL::Connection * CreateConnectionInstance()
#define DCL_SQL_VERSION
#define __BUILD_TIMESTAMP__
#define DCL_VERSION
#define DCL_SQL_VERSION_STRING