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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
// All files in the project carrying such notice may not be copied, modified, or distributed
// except according to those terms.
//! This module defines the types used in ODBC
use ctypes::*;
#[cfg(target_pointer_width = "64")]
use shared::basetsd::{INT64, UINT64};
use shared::guiddef::GUID;
use shared::windef::HWND;
pub type SQLCHAR = c_uchar;
pub type SQLSCHAR = c_schar;
pub type SQLDATE = c_uchar;
pub type SQLDECIMAL = c_uchar;
pub type SQLDOUBLE = c_double;
pub type SQLFLOAT = c_double;
pub type SQLINTEGER = c_long;
pub type SQLUINTEGER = c_ulong;
#[cfg(target_pointer_width = "64")]
pub type SQLLEN = INT64;
#[cfg(target_pointer_width = "64")]
pub type SQLULEN = UINT64;
#[cfg(target_pointer_width = "64")]
pub type SQLSETPOSIROW = UINT64;
#[cfg(target_pointer_width = "32")]
pub type SQLLEN = SQLINTEGER;
#[cfg(target_pointer_width = "32")]
pub type SQLULEN = SQLUINTEGER;
#[cfg(target_pointer_width = "32")]
pub type SQLSETPOSIROW = SQLUSMALLINT;
pub type SQLROWCOUNT = SQLULEN;
pub type SQLROWSETSIZE = SQLULEN;
pub type SQLTRANSID = SQLULEN;
pub type SQLROWOFFSET = SQLLEN;
pub type SQLNUMERIC = c_uchar;
pub type SQLPOINTER = *mut c_void;
pub type SQLREAL = c_float;
pub type SQLSMALLINT = c_short;
pub type SQLUSMALLINT = c_ushort;
pub type SQLTIME = c_uchar;
pub type SQLTIMESTAMP = c_uchar;
pub type SQLVARCHAR = c_uchar;
pub type SQLRETURN = SQLSMALLINT;
pub type SQLHANDLE = *mut c_void;
pub type SQLHENV = SQLHANDLE;
pub type SQLHDBC = SQLHANDLE;
pub type SQLHSTMT = SQLHANDLE;
pub type SQLHDESC = SQLHANDLE;
//pub type UCHAR = c_uchar;
pub type SCHAR = c_schar;
//pub type SQLSCHAR = SCHAR;
pub type SDWORD = c_long;
pub type SWORD = c_short;
pub type UDWORD = c_ulong;
//pub type UWORD = c_ushort;
//#[cfg(target_pointer_width = "32")]
//pub type SQLUINTEGER = UDWORD;
pub type SLONG = c_long;
pub type SSHORT = c_short;
//pub type ULONG = c_ulong;
//pub type USHORT = c_ushort;
pub type SDOUBLE = c_double;
pub type LDOUBLE = c_double;
pub type SFLOAT = c_float;
pub type PTR = *mut c_void;
pub type HENV = *mut c_void;
pub type HDBC = *mut c_void;
pub type HSTMT = *mut c_void;
pub type RETCODE = c_short;
pub type SQLHWND = HWND;
STRUCT!{struct DATE_STRUCT {
    year: SQLSMALLINT,
    month: SQLUSMALLINT,
    day: SQLUSMALLINT,
}}
pub type SQL_DATE_STRUCT = DATE_STRUCT;
STRUCT!{struct TIME_STRUCT {
    hour: SQLUSMALLINT,
    minute: SQLUSMALLINT,
    second: SQLUSMALLINT,
}}
pub type SQL_TIME_STRUCT = TIME_STRUCT;
STRUCT!{struct TIMESTAMP_STRUCT {
    year: SQLSMALLINT,
    month: SQLUSMALLINT,
    day: SQLUSMALLINT,
    hour: SQLUSMALLINT,
    minute: SQLUSMALLINT,
    second: SQLUSMALLINT,
    fraction: SQLUINTEGER,
}}
pub type SQL_TIMESTAMP_STRUCT = TIMESTAMP_STRUCT;
ENUM!{enum SQLINTERVAL {
    SQL_IS_YEAR = 1,
    SQL_IS_MONTH = 2,
    SQL_IS_DAY = 3,
    SQL_IS_HOUR = 4,
    SQL_IS_MINUTE = 5,
    SQL_IS_SECOND = 6,
    SQL_IS_YEAR_TO_MONTH = 7,
    SQL_IS_DAY_TO_HOUR = 8,
    SQL_IS_DAY_TO_MINUTE = 9,
    SQL_IS_DAY_TO_SECOND = 10,
    SQL_IS_HOUR_TO_MINUTE = 11,
    SQL_IS_HOUR_TO_SECOND = 12,
    SQL_IS_MINUTE_TO_SECOND = 13,
}}
STRUCT!{struct SQL_YEAR_MONTH_STRUCT {
    year: SQLUINTEGER,
    month: SQLUINTEGER,
}}
STRUCT!{struct SQL_DAY_SECOND_STRUCT {
    day: SQLUINTEGER,
    hour: SQLUINTEGER,
    minute: SQLUINTEGER,
    second: SQLUINTEGER,
    fraction: SQLUINTEGER,
}}
UNION!{union SQL_INTERVAL_STRUCT_intval {
    [u32; 5],
    year_month year_month_mut: SQL_YEAR_MONTH_STRUCT,
    day_second day_second_mut: SQL_DAY_SECOND_STRUCT,
}}
STRUCT!{struct SQL_INTERVAL_STRUCT {
    interval_type: SQLINTERVAL,
    interval_sign: SQLSMALLINT,
    intval: SQL_INTERVAL_STRUCT_intval,
}}
pub type ODBCINT64 = __int64;
pub type SQLBIGINT = ODBCINT64;
pub type SQLUBIGINT = __uint64;
pub const SQL_MAX_NUMERIC_LEN: usize = 16;
STRUCT!{struct SQL_NUMERIC_STRUCT {
    precision: SQLCHAR,
    scale: SQLSCHAR,
    sign: SQLCHAR,
    val: [SQLCHAR; SQL_MAX_NUMERIC_LEN],
}}
pub type SQLGUID = GUID;
pub type BOOKMARK = SQLULEN;
pub type SQLWCHAR = wchar_t;