DCL 3.7.4
Loading...
Searching...
No Matches
ODBCModuleMain.cpp File Reference
#include <dcl/Config.h>
#include <string.h>
#include <locale.h>
#include <dcl/_stdlib.h>
#include <sql.h>
#include <dcl/Object.h>
#include <dcl/SQLCore.h>
#include "ODBCConnection.h"

Go to the source code of this file.

Macros

#define __TRACE_THIS   0
#define __DCL_TRACE0_N(fmt)
#define __DCL_TRACE1_N(fmt, arg)
#define __DCL_TRACE2_N(fmt, arg1, arg2)
#define __DCL_TRACE3_N(fmt, arg1, arg2, arg3)
#define __DCL_TRACE4_N(fmt, arg1, arg2, arg3, arg4)

Functions

SQL::ConnectionCreateConnectionInstance ()
bool ModuleInitialize ()
bool ModuleCleanup ()

Variables

DCL_DSO_EXPORT SQL::DRIVER_MODULE DCL_DSO_ENTRY_POINT

Macro Definition Documentation

◆ __DCL_TRACE0_N

#define __DCL_TRACE0_N ( fmt)

Definition at line 34 of file ODBCModuleMain.cpp.

◆ __DCL_TRACE1_N

#define __DCL_TRACE1_N ( fmt,
arg )

Definition at line 35 of file ODBCModuleMain.cpp.

◆ __DCL_TRACE2_N

#define __DCL_TRACE2_N ( fmt,
arg1,
arg2 )

Definition at line 36 of file ODBCModuleMain.cpp.

◆ __DCL_TRACE3_N

#define __DCL_TRACE3_N ( fmt,
arg1,
arg2,
arg3 )

Definition at line 37 of file ODBCModuleMain.cpp.

◆ __DCL_TRACE4_N

#define __DCL_TRACE4_N ( fmt,
arg1,
arg2,
arg3,
arg4 )

Definition at line 38 of file ODBCModuleMain.cpp.

◆ __TRACE_THIS

#define __TRACE_THIS   0

Definition at line 26 of file ODBCModuleMain.cpp.

Function Documentation

◆ CreateConnectionInstance()

SQL::Connection * CreateConnectionInstance ( )

Definition at line 70 of file ODBCModuleMain.cpp.

71{
72 return new ODBCConnection(_serverTitle);
73}

◆ ModuleCleanup()

bool ModuleCleanup ( )

Definition at line 129 of file ODBCModuleMain.cpp.

130{
131 return true;
132}

◆ ModuleInitialize()

bool ModuleInitialize ( )

Definition at line 75 of file ODBCModuleMain.cpp.

76{
77 /*
78 * Windows mingw-w64-*-x86_64-unixodbc
79 * LDFLAGS += -lodbc unixODBC
80 * - odbcinst: SQLGetPrivateProfileString failed with Unable to find component name.
81 * - mingw에서 동작하지 않는다.
82 * LDFLAGS += -lodbc32 Windows Native
83 * - Windows/System32/odbcad32.exe
84 * - mingw에서도 이것을 사용해야 한다.
85 * Windows에서 다음의 환경변수 설정이 적용되지 않는다.
86 *
87 * LANG에 UTF-8이 없는 경우 LANG을 변경한다.
88 */
89 ByteStringBuilder sb;
90 char* lang = getenv("LANG");
91 if (!lang) {
92 // current locale
93 lang = setlocale(LC_CTYPE, NULL);
94 if (!(lang && strchr(lang, '.'))) {
95 // set default locale
96 lang = setlocale(LC_ALL, "");
97 }
98 }
99 if (lang) {
100 ByteString lang_ = ByteString(lang);
101 ByteString lower = lang_.toLowerCase();
102 if (!lower.contains("utf8")) {
103 if (lower.contains("ko") || lower.contains("kr")) {
104 sb.append("ko_KR");
105 }
106 else {
107 size_t index = lang_.indexOf(L'.');
108 sb.append(index == (size_t) -1 ?
109 lang_ : lang_.substring(0, index));
110 }
111 sb.append(".UTF-8");
112 }
113 }
114 else {
115 sb = "C.UTF-8";
116 }
117
118 setenv("CLIENT_LOCALE", "en_US.UTF8", 0); // Informix
119 setenv("NLS_LANG", "AMERICAN_AMERICA.UTF8", 0); // Oracle
120
121 if (sb.length() > 0) {
122 ByteString langUTF8 = sb.toByteString();
123 __DCL_TRACE1_N(L"setenv LANG=[%hs]\n", langUTF8.data());
124 return setenv("LANG", langUTF8, 1) == 0;;
125 }
126 return true;
127}
#define NULL
Definition Config.h:312
#define __DCL_TRACE1_N(fmt, arg)

Variable Documentation

◆ DCL_DSO_ENTRY_POINT

DCL_DSO_EXPORT SQL::DRIVER_MODULE DCL_DSO_ENTRY_POINT
Initial value:
=
{
__T("DCL SQL Adapter for ODBC"),
_serverTitle,
}
#define DCL_BUILD_FLAG
Definition Config.h:362
#define DCL_SQL_DRIVER_MODULE
Definition Config.h:353
bool ModuleInitialize()
bool ModuleCleanup()
SQL::Connection * CreateConnectionInstance()
#define __T(str)
Definition Object.h:60
#define DCL_SQL_VERSION
#define __BUILD_TIMESTAMP__
#define DCL_VERSION
#define DCL_SQL_VERSION_STRING

Definition at line 137 of file ODBCModuleMain.cpp.

138{
139 // DCL common members
140 sizeof(SQL::DRIVER_MODULE), // structure size
144 DCL_SQL_DRIVER_MODULE, // module type
145 __T("DCL SQL Adapter for ODBC"),
146
147 // private members
149 _serverTitle,
154};