fixed Windows build for DB drivers
[public/netxms.git] / src / db / dbdrv / db2 / db2drv.h
1 /*
2 ** DB2 Database Driver
3 ** Copyright (C) 2010-2016 Raden Solutions
4 **
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
14 **
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 **
19 ** File: db2drv.h
20 **
21 **/
22
23 #ifndef _db2drv_h_
24 #define _db2drv_h_
25
26 #ifdef _WIN32
27 #include <winsock2.h>
28 #include <windows.h>
29 #define EXPORT __declspec(dllexport)
30 #else
31 #define EXPORT
32 #endif /* _WIN32 */
33
34 #include <stdio.h>
35 #include <string.h>
36 #include <dbdrv.h>
37 #include <nms_util.h>
38
39 #ifndef _WIN32
40
41 #if HAVE_WCHAR_H
42 #define NETXMS_WCHAR wchar_t
43 #else /* HAVE_WCHAR_T */
44 #define NETXMS_WCHAR WCHAR
45 #endif /* HAVE_WCHAR_T */
46 #undef WCHAR
47
48 #else /* _WIN32 */
49 #define NETXMS_WCHAR WCHAR
50 #endif
51
52 #define __BOOL // disable BOOL typedef
53 #include <db2ApiDf.h>
54 #include <sqlcli1.h>
55
56 /**
57 * Fixes build failure
58 * Allows to use SQLConnect and SQLSetEnvAttr in unicode builds
59 */
60 #undef SQLConnect
61 #undef SQLSetEnvAttr
62
63 /**
64 * Driver connection handle structure
65 */
66 typedef struct
67 {
68 MUTEX mutexQuery;
69 SQLHENV sqlEnv;
70 SQLHDBC sqlConn;
71 } DB2DRV_CONN;
72
73 /**
74 * Prepared statement structure
75 */
76 typedef struct
77 {
78 SQLHSTMT handle;
79 Array *buffers;
80 DB2DRV_CONN *connection;
81 } DB2DRV_STATEMENT;
82
83 /**
84 * Result buffer structure
85 */
86 typedef struct
87 {
88 long numRows;
89 long numColumns;
90 NETXMS_WCHAR **values;
91 char **columnNames;
92 } DB2DRV_QUERY_RESULT;
93
94 /**
95 * Async result buffer structure
96 */
97 typedef struct
98 {
99 SQLHSTMT sqlStatement;
100 bool isPrepared;
101 long numColumns;
102 DB2DRV_CONN *pConn;
103 bool noMoreRows;
104 char **columnNames;
105 } DB2DRV_UNBUFFERED_QUERY_RESULT;
106
107 #endif /* _db2drv_h_ */