log parser status kept as integer; minor refactoing
[public/netxms.git] / include / dbdrv.h
1 /*
2 ** NetXMS - Network Management System
3 ** Copyright (C) 2003-2012 Victor Kirhenshtein
4 **
5 ** This program is free software; you can redistribute it and/or modify
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
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 Lesser 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: dbdrv.h
20 **
21 **/
22
23 #ifndef _dbdrv_h_
24 #define _dbdrv_h_
25
26 #include <nms_common.h>
27
28 /**
29 * API version
30 */
31 #define DBDRV_API_VERSION 20
32
33
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
53 //
54 // Constants
55 //
56
57 #define DBDRV_MAX_ERROR_TEXT 1024
58
59
60 //
61 // Datatypes
62 //
63
64 typedef void * DBDRV_CONNECTION;
65 typedef void * DBDRV_STATEMENT;
66 typedef void * DBDRV_RESULT;
67 typedef void * DBDRV_UNBUFFERED_RESULT;
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
79
80 //
81 // DB binding buffer allocation types
82 //
83
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
87
88
89 //
90 // C and SQL types for parameter binding
91 //
92
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
106
107 /**
108 * DBIsTableExist return codes
109 */
110 enum
111 {
112 DBIsTableExist_Failure = -1,
113 DBIsTableExist_NotFound = 0,
114 DBIsTableExist_Found = 1
115 };
116
117 #endif /* _dbdrv_h_ */