Commit | Line | Data |
---|---|---|
5039dede AK |
1 | /* |
2 | ** NetXMS - Network Management System | |
de1d708f | 3 | ** Copyright (C) 2003-2012 Victor Kirhenshtein |
5039dede AK |
4 | ** |
5 | ** This program is free software; you can redistribute it and/or modify | |
0702ed69 VK |
6 | ** it under the terms of the GNU Lesser General Public License as published by |
7 | ** the Free Software Foundation; either version 3 of the License, or | |
5039dede AK |
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 | ** | |
0702ed69 | 15 | ** You should have received a copy of the GNU Lesser General Public License |
5039dede AK |
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: dbdrv.h | |
20 | ** | |
21 | **/ | |
22 | ||
23 | #ifndef _dbdrv_h_ | |
24 | #define _dbdrv_h_ | |
25 | ||
26 | #include <nms_common.h> | |
27 | ||
daf3c104 VK |
28 | /** |
29 | * API version | |
30 | */ | |
7f8e3ccf | 31 | #define DBDRV_API_VERSION 20 |
5039dede AK |
32 | |
33 | ||
17b35ccc VK |
34 | // |
35 | // Driver header | |
36 | // | |
37 | ||
38 | #ifdef _WIN32 | |
39 | #define __EXPORT __declspec(dllexport) | |
40 | #else | |
41 | #define __EXPORT | |
42 | #endif | |
43 | ||
44 | #define DECLARE_DRIVER_HEADER(name) \ | |
45 | extern "C" int EXPORT drvAPIVersion; \ | |
46 | extern "C" const char EXPORT *drvName; \ | |
47 | int EXPORT drvAPIVersion = DBDRV_API_VERSION; \ | |
48 | const char EXPORT *drvName = name; | |
49 | ||
50 | #undef __EXPORT | |
51 | ||
52 | ||
5039dede AK |
53 | // |
54 | // Constants | |
55 | // | |
56 | ||
57 | #define DBDRV_MAX_ERROR_TEXT 1024 | |
58 | ||
59 | ||
60 | // | |
61 | // Datatypes | |
62 | // | |
63 | ||
b8c1ec69 | 64 | typedef void * DBDRV_CONNECTION; |
e970c99b | 65 | typedef void * DBDRV_STATEMENT; |
b8c1ec69 | 66 | typedef void * DBDRV_RESULT; |
f17cf019 | 67 | typedef void * DBDRV_UNBUFFERED_RESULT; |
5039dede AK |
68 | |
69 | ||
70 | // | |
71 | // Error codes | |
72 | // | |
73 | ||
74 | #define DBERR_SUCCESS 0 | |
75 | #define DBERR_CONNECTION_LOST 1 | |
76 | #define DBERR_INVALID_HANDLE 2 | |
77 | #define DBERR_OTHER_ERROR 255 | |
78 | ||
ec19ded8 | 79 | |
cd5bb14b VK |
80 | // |
81 | // DB binding buffer allocation types | |
82 | // | |
83 | ||
8e46c618 AK |
84 | #define DB_BIND_STATIC 0 // buffer is managed by caller and will be valid until after the query is executed |
85 | #define DB_BIND_TRANSIENT 1 // buffer will be duplicated by DB driver in DBBind() | |
86 | #define DB_BIND_DYNAMIC 2 // DB Driver will call free() on buffer | |
cd5bb14b VK |
87 | |
88 | ||
ec19ded8 VK |
89 | // |
90 | // C and SQL types for parameter binding | |
91 | // | |
92 | ||
b8849590 VK |
93 | #define DB_CTYPE_STRING 0 |
94 | #define DB_CTYPE_INT32 1 | |
95 | #define DB_CTYPE_UINT32 2 | |
96 | #define DB_CTYPE_INT64 3 | |
97 | #define DB_CTYPE_UINT64 4 | |
98 | #define DB_CTYPE_DOUBLE 5 | |
99 | #define DB_CTYPE_UTF8_STRING 6 | |
100 | ||
101 | #define DB_SQLTYPE_VARCHAR 0 | |
102 | #define DB_SQLTYPE_INTEGER 1 | |
103 | #define DB_SQLTYPE_BIGINT 2 | |
104 | #define DB_SQLTYPE_DOUBLE 3 | |
105 | #define DB_SQLTYPE_TEXT 4 | |
ec19ded8 | 106 | |
daf3c104 VK |
107 | /** |
108 | * DBIsTableExist return codes | |
109 | */ | |
110 | enum | |
111 | { | |
112 | DBIsTableExist_Failure = -1, | |
113 | DBIsTableExist_NotFound = 0, | |
114 | DBIsTableExist_Found = 1 | |
115 | }; | |
116 | ||
5039dede | 117 | #endif /* _dbdrv_h_ */ |