diff --git a/src/um/wininet.rs b/src/um/wininet.rs index 3fa14aad5..4f7ed7651 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, @@ -475,9 +475,9 @@ pub const SECURITY_SET_MASK: DWORD = SECURITY_FLAG_IGNORE_REVOCATION pub const AUTODIAL_MODE_NEVER: DWORD = 1; pub const AUTODIAL_MODE_ALWAYS: DWORD = 2; pub const AUTODIAL_MODE_NO_NETWORK_PRESENT: DWORD = 4; -pub type INTERNET_STATUS_CALLBACK = Option; +FN!{stdcall INTERNET_STATUS_CALLBACK( + HINTERNET, DWORD_PTR, DWORD, LPVOID, DWORD +) -> ()} pub type LPINTERNET_STATUS_CALLBACK = *mut INTERNET_STATUS_CALLBACK; pub const INTERNET_STATUS_RESOLVING_NAME: DWORD = 10; pub const INTERNET_STATUS_NAME_RESOLVED: DWORD = 11; @@ -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); @@ -806,9 +811,9 @@ pub const GOPHER_ATTRIBUTE_ID_ABSTRACT: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 22; pub const GOPHER_ATTRIBUTE_ID_VIEW: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 23; pub const GOPHER_ATTRIBUTE_ID_TREEWALK: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 24; pub const GOPHER_ATTRIBUTE_ID_UNKNOWN: DWORD = GOPHER_ATTRIBUTE_ID_BASE + 25; -pub type GOPHER_ATTRIBUTE_ENUMERATOR = Option BOOL>; +FN!{stdcall GOPHER_ATTRIBUTE_ENUMERATOR( + LPGOPHER_ATTRIBUTE_TYPE, DWORD +) -> BOOL} pub const HTTP_MAJOR_VERSION: DWORD = 1; pub const HTTP_MINOR_VERSION: DWORD = 0; pub const HTTP_VERSION: &'static str = "HTTP/1.0"; @@ -995,7 +1000,7 @@ pub const FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS: DWORD = 0x02; pub const FLAGS_ERROR_UI_FLAGS_GENERATE_DATA: DWORD = 0x04; pub const FLAGS_ERROR_UI_FLAGS_NO_UI: DWORD = 0x08; pub const FLAGS_ERROR_UI_SERIALIZE_DIALOGS: DWORD = 0x10; -pub type PFN_AUTH_NOTIFY = Option DWORD>; +FN!{stdcall PFN_AUTH_NOTIFY(DWORD_PTR, DWORD, LPVOID) -> DWORD} STRUCT!{struct INTERNET_AUTH_NOTIFY_DATA { cbStruct: DWORD, dwOptions: DWORD, @@ -1238,15 +1243,15 @@ pub type LPAUTO_PROXY_SCRIPT_BUFFER = *mut AUTO_PROXY_SCRIPT_BUFFER; STRUCT!{struct AutoProxyHelperFunctions { lpVtbl: *const AutoProxyHelperVtbl, }} -pub type pfnInternetInitializeAutoProxyDll = Option BOOL>; -pub type pfnInternetDeInitializeAutoProxyDll = Option BOOL>; -pub type pfnInternetGetProxyInfo = Option BOOL>; +FN!{stdcall pfnInternetInitializeAutoProxyDll( + DWORD, LPSTR, LPSTR, *mut AutoProxyHelperFunctions, LPAUTO_PROXY_SCRIPT_BUFFER +) -> BOOL} +FN!{stdcall pfnInternetDeInitializeAutoProxyDll( + LPSTR, DWORD +) -> BOOL} +FN!{stdcall pfnInternetGetProxyInfo( + LPCSTR, DWORD, LPSTR, DWORD, *mut LPSTR, LPDWORD +) -> BOOL} ENUM!{enum WPAD_CACHE_DELETE { WPAD_CACHE_DELETE_CURRENT = 0x0, WPAD_CACHE_DELETE_ALL = 0x1, @@ -1258,9 +1263,9 @@ pub const INTERNET_CONNECTION_MODEM_BUSY: DWORD = 0x08; pub const INTERNET_RAS_INSTALLED: DWORD = 0x10; pub const INTERNET_CONNECTION_OFFLINE: DWORD = 0x20; pub const INTERNET_CONNECTION_CONFIGURED: DWORD = 0x40; -pub type PFN_DIAL_HANDLER = Option DWORD>; +FN!{stdcall PFN_DIAL_HANDLER( + HWND, LPCSTR, DWORD, LPDWORD +) -> DWORD} pub const INTERNET_CUSTOMDIAL_CONNECT: DWORD = 0; pub const INTERNET_CUSTOMDIAL_UNATTENDED: DWORD = 1; pub const INTERNET_CUSTOMDIAL_DISCONNECT: DWORD = 2; diff --git a/tests/structs.rs b/tests/structs.rs index d4110d9f8..bbaa4eaa3 100644 --- a/tests/structs.rs +++ b/tests/structs.rs @@ -390,7 +390,7 @@ fn shared_windef() { assert_eq!(align_of::(), 2); } #[cfg(all(target_arch = "x86", feature = "um-wininet"))] #[test] -fn wininet() { +fn um_wininet() { use winapi::um::wininet::*; assert_eq!(size_of::(), 8); assert_eq!(align_of::(), 4); @@ -496,7 +496,7 @@ fn wininet() { assert_eq!(align_of::(), 4); } #[cfg(all(target_arch = "x86_64", feature = "um-wininet"))] #[test] -fn wininet() { +fn um_wininet() { use winapi::um::wininet::*; assert_eq!(size_of::(), 16); assert_eq!(align_of::(), 8);