From f724da712458f6cec8d16e1a1c5efdc62c6ed327 Mon Sep 17 00:00:00 2001 From: Daniel Keep Date: Mon, 31 Oct 2016 01:11:04 +1100 Subject: [PATCH] Fixes for wininet bindings. --- src/um/wininet.rs | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/src/um/wininet.rs b/src/um/wininet.rs index 3fa14aad5..439b6d84a 100644 --- a/src/um/wininet.rs +++ b/src/um/wininet.rs @@ -8,7 +8,7 @@ use ctypes::c_int; use shared::basetsd::DWORD_PTR; use shared::minwindef::{ - BOOL, BYTE, DWORD, FALSE, FILETIME, INT, LPBYTE, + BOOL, DWORD, FALSE, FILETIME, INT, LPBYTE, LPCVOID, LPDWORD, LPVOID, PBYTE, PDWORD, TRUE, WORD, }; use shared::ntdef::{ LONG, LONGLONG, PLONG }; @@ -39,7 +39,7 @@ pub const INTERNET_MAX_PATH_LENGTH: DWORD = 2048; pub const INTERNET_MAX_SCHEME_LENGTH: DWORD = 32; pub const INTERNET_MAX_URL_LENGTH: DWORD = INTERNET_MAX_SCHEME_LENGTH + 3 + INTERNET_MAX_PATH_LENGTH; -pub const INTERNET_KEEP_ALIVE_UNKNOWN: DWORD = !0; +pub const INTERNET_KEEP_ALIVE_UNKNOWN: DWORD = -1i32 as u32; pub const INTERNET_KEEP_ALIVE_ENABLED: DWORD = 1; pub const INTERNET_KEEP_ALIVE_DISABLED: DWORD = 0; pub const INTERNET_REQFLAG_FROM_CACHE: DWORD = 0x00000001; @@ -110,8 +110,8 @@ pub const WININET_API_FLAG_SYNC: DWORD = 0x00000004; pub const WININET_API_FLAG_USE_CONTEXT: DWORD = 0x00000008; pub const INTERNET_NO_CALLBACK: DWORD = 0; ENUM!{enum INTERNET_SCHEME { - INTERNET_SCHEME_PARTIAL = !0 - 1, - INTERNET_SCHEME_UNKNOWN = !0, + INTERNET_SCHEME_PARTIAL = -2i32 as u32, + INTERNET_SCHEME_UNKNOWN = -1i32 as u32, INTERNET_SCHEME_DEFAULT = 0, INTERNET_SCHEME_FTP, INTERNET_SCHEME_GOPHER, @@ -543,7 +543,7 @@ STRUCT!{struct CookieDecision { dwCookieState: DWORD, fAllowSession: BOOL, }} -pub const INTERNET_INVALID_STATUS_CALLBACK: usize = !0; +pub const INTERNET_INVALID_STATUS_CALLBACK: usize = -1isize as usize; pub const FTP_TRANSFER_TYPE_UNKNOWN: DWORD = 0x00000000; pub const FTP_TRANSFER_TYPE_ASCII: DWORD = 0x00000001; pub const FTP_TRANSFER_TYPE_BINARY: DWORD = 0x00000002; @@ -596,47 +596,47 @@ pub const GOPHER_TYPE_INLINE: DWORD = 0x00100000; pub const GOPHER_TYPE_UNKNOWN: DWORD = 0x20000000; pub const GOPHER_TYPE_ASK: DWORD = 0x40000000; pub const GOPHER_TYPE_GOPHER_PLUS: DWORD = 0x80000000; -#[inline] #[allow(dead_code)] +#[inline] pub fn IS_GOPHER_FILE(type_: DWORD) -> BOOL { if (type_ & GOPHER_TYPE_FILE_MASK) != 0 { TRUE } else { FALSE } } -#[inline] #[allow(dead_code)] +#[inline] pub fn IS_GOPHER_DIRECTORY(type_: DWORD) -> BOOL { if (type_ & GOPHER_TYPE_DIRECTORY) != 0 { TRUE } else { FALSE } } -#[inline] #[allow(dead_code)] +#[inline] pub fn IS_GOPHER_PHONE_SERVER(type_: DWORD) -> BOOL { if (type_ & GOPHER_TYPE_CSO) != 0 { TRUE } else { FALSE } } -#[inline] #[allow(dead_code)] +#[inline] pub fn IS_GOPHER_ERROR(type_: DWORD) -> BOOL { if (type_ & GOPHER_TYPE_ERROR) != 0 { TRUE } else { FALSE } } -#[inline] #[allow(dead_code)] +#[inline] pub fn IS_GOPHER_INDEX_SERVER(type_: DWORD) -> BOOL { if (type_ & GOPHER_TYPE_INDEX_SERVER) != 0 { TRUE } else { FALSE } } -#[inline] #[allow(dead_code)] +#[inline] pub fn IS_GOPHER_TELNET_SESSION(type_: DWORD) -> BOOL { if (type_ & GOPHER_TYPE_TELNET) != 0 { TRUE } else { FALSE } } -#[inline] #[allow(dead_code)] +#[inline] pub fn IS_GOPHER_BACKUP_SERVER(type_: DWORD) -> BOOL { if (type_ & GOPHER_TYPE_REDUNDANT) != 0 { TRUE } else { FALSE } } -#[inline] #[allow(dead_code)] +#[inline] pub fn IS_GOPHER_TN3270_SESSION(type_: DWORD) -> BOOL { if (type_ & GOPHER_TYPE_TN3270) != 0 { TRUE } else { FALSE } } -#[inline] #[allow(dead_code)] +#[inline] pub fn IS_GOPHER_ASK(type_: DWORD) -> BOOL { if (type_ & GOPHER_TYPE_ASK) != 0 { TRUE } else { FALSE } } -#[inline] #[allow(dead_code)] +#[inline] pub fn IS_GOPHER_PLUS(type_: DWORD) -> BOOL { if (type_ & GOPHER_TYPE_GOPHER_PLUS) != 0 { TRUE } else { FALSE } } -#[inline] #[allow(dead_code)] +#[inline] pub fn IS_GOPHER_TYPE_KNOWN(type_: DWORD) -> BOOL { if (type_ & GOPHER_TYPE_UNKNOWN) != 0 { FALSE } else { TRUE } } @@ -724,12 +724,17 @@ STRUCT!{struct GOPHER_UNKNOWN_ATTRIBUTE_TYPE { Text: LPCWSTR, }} pub type LPGOPHER_UNKNOWN_ATTRIBUTE_TYPE = *mut GOPHER_UNKNOWN_ATTRIBUTE_TYPE; +#[cfg(target_arch = "x86")] +STRUCT!{struct GOPHER_ATTRIBUTE_TYPE { + CategoryId: DWORD, + AttributeId: DWORD, + AttributeType: [u32; 6], +}} +#[cfg(target_arch = "x86_64")] STRUCT!{struct GOPHER_ATTRIBUTE_TYPE { - // ALIGN: 4/8 alignment on x86/x64. - Align: [usize; 0], CategoryId: DWORD, AttributeId: DWORD, - AttributeType: [BYTE; 24], + AttributeType: [u64; 3], }} UNION!(GOPHER_ATTRIBUTE_TYPE, AttributeType, Admin, Admin_mut, GOPHER_ADMIN_ATTRIBUTE_TYPE); UNION!(GOPHER_ATTRIBUTE_TYPE, AttributeType, ModDate, ModDate_mut, GOPHER_MOD_DATE_ATTRIBUTE_TYPE);