-
Notifications
You must be signed in to change notification settings - Fork 1
/
OdbcEnv.h
107 lines (93 loc) · 2.78 KB
/
OdbcEnv.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
*
* The contents of this file are subject to the Initial
* Developer's Public License Version 1.0 (the "License");
* you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* https://www.firebirdsql.org/en/initial-developer-s-public-license-version-1-0/
*
* Software distributed under the License is distributed on
* an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
*
* The Original Code was created by James A. Starkey for IBPhoenix.
*
* Copyright (c) 1999, 2000, 2001 James A. Starkey
* All Rights Reserved.
*/
// OdbcEnv.h: interface for the OdbcEnv class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(_ODBCENV_H_)
#define _ODBCENV_H_
#include "OdbcObject.h"
#include "IscDbc/Connection.h"
#include "IscDbc/Mutex.h"
namespace OdbcJdbcLibrary {
using namespace classMutex;
using namespace IscDbcLibrary;
class OdbcConnection;
class OdbcEnv : public OdbcObject
{
public:
SQLRETURN sqlGetEnvAttr(int attribute, SQLPOINTER ptr, int bufferLength, SQLINTEGER *lengthPtr);
SQLRETURN sqlSetEnvAttr (int attribute, SQLPOINTER value, int length);
void connectionClosed (OdbcConnection *connection);
SQLRETURN sqlEndTran(int operation);
SQLRETURN sqlDrivers( SQLUSMALLINT direction, SQLCHAR * serverName, SQLSMALLINT bufferLength1, SQLSMALLINT * nameLength1Ptr, SQLCHAR * description, SQLSMALLINT bufferLength2, SQLSMALLINT * nameLength2Ptr);
SQLRETURN sqlDataSources( SQLUSMALLINT direction, SQLCHAR * serverName, SQLSMALLINT bufferLength1, SQLSMALLINT * nameLength1Ptr, SQLCHAR * description, SQLSMALLINT bufferLength2, SQLSMALLINT * nameLength2Ptr);
#ifdef _WINDOWS
BOOL getDrivers();
bool getDataSources( SQLUSMALLINT wConfigMode );
#endif
virtual SQLRETURN allocHandle (int handleType, SQLHANDLE *outputHandle);
void LockEnv();
void UnLockEnv();
virtual OdbcConnection* getConnection();
virtual OdbcObjectType getType();
OdbcEnv();
~OdbcEnv();
#ifdef _WINDOWS
HINSTANCE libraryHandle;
#else
void *libraryHandle;
#endif
Mutex mutex;
EnvironmentShare *envShare;
OdbcConnection *connections;
const char *odbcIniFileName;
const char *odbcInctFileName;
int useAppOdbcVersion;
#ifdef _WINDOWS
char listDSN[1024];
char *activeDSN;
char *endDSN;
char listDrv[2048];
char *activeDrv;
char *endDrv;
#endif
};
class SafeEnvThread
{
OdbcEnv * env;
public:
SafeEnvThread(OdbcEnv * ptEnv)
{
if( ptEnv )
{
env = ptEnv;
env->LockEnv();
}
else
env = NULL;
}
~SafeEnvThread()
{
if(env)
env->UnLockEnv();
}
};
}; // end namespace OdbcJdbcLibrary
#endif // !defined(_ODBCENV_H_)