1 // Licensed under the Apache License, Version 2.0
2 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4 // All files in the project carrying such notice may not be copied, modified, or distributed
5 // except according to those terms.
6 //! This module defines the types used in ODBC
7 use ctypes::*;
8 #[cfg(target_pointer_width = "64")]
9 use shared::basetsd::{INT64, UINT64};
10 use shared::guiddef::GUID;
11 use shared::windef::HWND;
12 pub type SQLCHAR = c_uchar;
13 pub type SQLSCHAR = c_schar;
14 pub type SQLDATE = c_uchar;
15 pub type SQLDECIMAL = c_uchar;
16 pub type SQLDOUBLE = c_double;
17 pub type SQLFLOAT = c_double;
18 pub type SQLINTEGER = c_long;
19 pub type SQLUINTEGER = c_ulong;
20 #[cfg(target_pointer_width = "64")]
21 pub type SQLLEN = INT64;
22 #[cfg(target_pointer_width = "64")]
23 pub type SQLULEN = UINT64;
24 #[cfg(target_pointer_width = "64")]
25 pub type SQLSETPOSIROW = UINT64;
26 #[cfg(target_pointer_width = "32")]
27 pub type SQLLEN = SQLINTEGER;
28 #[cfg(target_pointer_width = "32")]
29 pub type SQLULEN = SQLUINTEGER;
30 #[cfg(target_pointer_width = "32")]
31 pub type SQLSETPOSIROW = SQLUSMALLINT;
32 pub type SQLROWCOUNT = SQLULEN;
33 pub type SQLROWSETSIZE = SQLULEN;
34 pub type SQLTRANSID = SQLULEN;
35 pub type SQLROWOFFSET = SQLLEN;
36 pub type SQLNUMERIC = c_uchar;
37 pub type SQLPOINTER = *mut c_void;
38 pub type SQLREAL = c_float;
39 pub type SQLSMALLINT = c_short;
40 pub type SQLUSMALLINT = c_ushort;
41 pub type SQLTIME = c_uchar;
42 pub type SQLTIMESTAMP = c_uchar;
43 pub type SQLVARCHAR = c_uchar;
44 pub type SQLRETURN = SQLSMALLINT;
45 pub type SQLHANDLE = *mut c_void;
46 pub type SQLHENV = SQLHANDLE;
47 pub type SQLHDBC = SQLHANDLE;
48 pub type SQLHSTMT = SQLHANDLE;
49 pub type SQLHDESC = SQLHANDLE;
50 //pub type UCHAR = c_uchar;
51 pub type SCHAR = c_schar;
52 //pub type SQLSCHAR = SCHAR;
53 pub type SDWORD = c_long;
54 pub type SWORD = c_short;
55 pub type UDWORD = c_ulong;
56 //pub type UWORD = c_ushort;
57 //#[cfg(target_pointer_width = "32")]
58 //pub type SQLUINTEGER = UDWORD;
59 pub type SLONG = c_long;
60 pub type SSHORT = c_short;
61 //pub type ULONG = c_ulong;
62 //pub type USHORT = c_ushort;
63 pub type SDOUBLE = c_double;
64 pub type LDOUBLE = c_double;
65 pub type SFLOAT = c_float;
66 pub type PTR = *mut c_void;
67 pub type HENV = *mut c_void;
68 pub type HDBC = *mut c_void;
69 pub type HSTMT = *mut c_void;
70 pub type RETCODE = c_short;
71 pub type SQLHWND = HWND;
72 STRUCT!{struct DATE_STRUCT {
73     year: SQLSMALLINT,
74     month: SQLUSMALLINT,
75     day: SQLUSMALLINT,
76 }}
77 pub type SQL_DATE_STRUCT = DATE_STRUCT;
78 STRUCT!{struct TIME_STRUCT {
79     hour: SQLUSMALLINT,
80     minute: SQLUSMALLINT,
81     second: SQLUSMALLINT,
82 }}
83 pub type SQL_TIME_STRUCT = TIME_STRUCT;
84 STRUCT!{struct TIMESTAMP_STRUCT {
85     year: SQLSMALLINT,
86     month: SQLUSMALLINT,
87     day: SQLUSMALLINT,
88     hour: SQLUSMALLINT,
89     minute: SQLUSMALLINT,
90     second: SQLUSMALLINT,
91     fraction: SQLUINTEGER,
92 }}
93 pub type SQL_TIMESTAMP_STRUCT = TIMESTAMP_STRUCT;
94 ENUM!{enum SQLINTERVAL {
95     SQL_IS_YEAR = 1,
96     SQL_IS_MONTH = 2,
97     SQL_IS_DAY = 3,
98     SQL_IS_HOUR = 4,
99     SQL_IS_MINUTE = 5,
100     SQL_IS_SECOND = 6,
101     SQL_IS_YEAR_TO_MONTH = 7,
102     SQL_IS_DAY_TO_HOUR = 8,
103     SQL_IS_DAY_TO_MINUTE = 9,
104     SQL_IS_DAY_TO_SECOND = 10,
105     SQL_IS_HOUR_TO_MINUTE = 11,
106     SQL_IS_HOUR_TO_SECOND = 12,
107     SQL_IS_MINUTE_TO_SECOND = 13,
108 }}
109 STRUCT!{struct SQL_YEAR_MONTH_STRUCT {
110     year: SQLUINTEGER,
111     month: SQLUINTEGER,
112 }}
113 STRUCT!{struct SQL_DAY_SECOND_STRUCT {
114     day: SQLUINTEGER,
115     hour: SQLUINTEGER,
116     minute: SQLUINTEGER,
117     second: SQLUINTEGER,
118     fraction: SQLUINTEGER,
119 }}
120 UNION!{union SQL_INTERVAL_STRUCT_intval {
121     [u32; 5],
122     year_month year_month_mut: SQL_YEAR_MONTH_STRUCT,
123     day_second day_second_mut: SQL_DAY_SECOND_STRUCT,
124 }}
125 STRUCT!{struct SQL_INTERVAL_STRUCT {
126     interval_type: SQLINTERVAL,
127     interval_sign: SQLSMALLINT,
128     intval: SQL_INTERVAL_STRUCT_intval,
129 }}
130 pub type ODBCINT64 = __int64;
131 pub type SQLBIGINT = ODBCINT64;
132 pub type SQLUBIGINT = __uint64;
133 pub const SQL_MAX_NUMERIC_LEN: usize = 16;
134 STRUCT!{struct SQL_NUMERIC_STRUCT {
135     precision: SQLCHAR,
136     scale: SQLSCHAR,
137     sign: SQLCHAR,
138     val: [SQLCHAR; SQL_MAX_NUMERIC_LEN],
139 }}
140 pub type SQLGUID = GUID;
141 pub type BOOKMARK = SQLULEN;
142 pub type SQLWCHAR = wchar_t;
143