Skip to content

Commit

Permalink
Add partial wininet bindings.
Browse files Browse the repository at this point in the history
Includes what *should* be all the types and constants from wininet.h,
and some of the functions.

Note that, unlike other header bindings, the `wininet` module is *not*
re-exported in the root `winapi` module.  This is because `wininet.h`
and `winhttp.h` define the same constants/enums with *different values.*

Also, due to wininet.dll exporting stdcall functions using cdecl mangling,
this commit uses the MinGW import libraries, and as such has to exclude
some functions when built using a GNU toolchain.  This is because creating
a more complete import library for the GNU toolchain would require
*actually writing* a dummy shared library in C, and I can't be bothered.
  • Loading branch information
DanielKeep committed Jul 16, 2016
1 parent 1026160 commit e79d8ea
Show file tree
Hide file tree
Showing 8 changed files with 1,702 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ uuid-sys = { version = "0", path = "lib/uuid" }
vssapi-sys = { version = "0", path = "lib/vssapi" }
wevtapi-sys = { version = "0", path = "lib/wevtapi" }
winhttp-sys = { version = "0", path = "lib/winhttp" }
wininet-sys = { version = "0", path = "lib/wininet" }
winmm-sys = { version = "0", path = "lib/winmm" }
winscard-sys = { version = "0", path = "lib/winscard" }
winspool-sys = { version = "0", path = "lib/winspool" }
Expand Down
2 changes: 1 addition & 1 deletion lib/wininet/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wininet-sys"
version = "0.0.1"
version = "0.1.0"
authors = ["Peter Atashian <[email protected]>"]
description = "Contains function definitions for the Windows API library wininet. See winapi for types and constants."
documentation = "https://retep998.github.io/doc/wininet/"
Expand Down
Binary file added lib/wininet/i686/libwininet.a
Binary file not shown.
329 changes: 325 additions & 4 deletions lib/wininet/src/lib.rs

Large diffs are not rendered by default.

Binary file added lib/wininet/x86_64/libwininet.a
Binary file not shown.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ pub use winerror::*;
pub use winevt::*;
pub use wingdi::*;
pub use winhttp::*;
// pub use wininet::*; // deliberately excluded; see `src/wininet.rs`
pub use winioctl::*;
pub use winnetwk::*;
pub use winnls::*;
Expand Down Expand Up @@ -329,6 +330,7 @@ pub mod winerror;
pub mod winevt;
pub mod wingdi;
pub mod winhttp;
pub mod wininet;
pub mod winioctl;
pub mod winnetwk;
pub mod winnls;
Expand Down
1,204 changes: 1,204 additions & 0 deletions src/wininet.rs

Large diffs are not rendered by default.

169 changes: 169 additions & 0 deletions tests/wininet.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
// Copyright © 2016, Daniel Keep
// Licensed under the MIT License <LICENSE.md>
#![cfg(windows)]
extern crate wininet;
use wininet::*;
macro_rules! bb { ($e:expr) => { bb($e as usize) } }
#[inline(never)] fn bb<T>(_: T) {}
#[test]
fn functions() {
bb!(CommitUrlCacheEntryA);
bb!(CommitUrlCacheEntryW);
bb!(CreateMD5SSOHash);
bb!(CreateUrlCacheEntryA);
bb!(CreateUrlCacheEntryW);
bb!(CreateUrlCacheGroup);
bb!(DeleteUrlCacheEntryA);
bb!(DeleteUrlCacheEntryW);
bb!(DeleteUrlCacheGroup);
bb!(DetectAutoProxyUrl);
bb!(FindCloseUrlCache);
bb!(FindFirstUrlCacheEntryA);
bb!(FindFirstUrlCacheEntryExA);
bb!(FindFirstUrlCacheEntryExW);
bb!(FindFirstUrlCacheEntryW);
bb!(FindFirstUrlCacheGroup);
bb!(FindNextUrlCacheEntryA);
bb!(FindNextUrlCacheEntryExA);
bb!(FindNextUrlCacheEntryExW);
bb!(FindNextUrlCacheEntryW);
bb!(FindNextUrlCacheGroup);
bb!(FtpCommandA);
bb!(FtpCommandW);
bb!(FtpCreateDirectoryA);
bb!(FtpCreateDirectoryW);
bb!(FtpDeleteFileA);
bb!(FtpDeleteFileW);
bb!(FtpFindFirstFileA);
bb!(FtpFindFirstFileW);
bb!(FtpGetCurrentDirectoryA);
bb!(FtpGetCurrentDirectoryW);
bb!(FtpGetFileA);
bb!(FtpGetFileEx);
bb!(FtpGetFileSize);
bb!(FtpGetFileW);
bb!(FtpOpenFileA);
bb!(FtpOpenFileW);
bb!(FtpPutFileA);
bb!(FtpPutFileEx);
bb!(FtpPutFileW);
bb!(FtpRemoveDirectoryA);
bb!(FtpRemoveDirectoryW);
bb!(FtpRenameFileA);
bb!(FtpRenameFileW);
bb!(FtpSetCurrentDirectoryA);
bb!(FtpSetCurrentDirectoryW);
bb!(GetUrlCacheEntryInfoA);
bb!(GetUrlCacheEntryInfoExA);
bb!(GetUrlCacheEntryInfoExW);
bb!(GetUrlCacheEntryInfoW);
bb!(GetUrlCacheGroupAttributeA);
bb!(GetUrlCacheGroupAttributeW);
bb!(HttpAddRequestHeadersA);
bb!(HttpAddRequestHeadersW);
bb!(HttpEndRequestA);
bb!(HttpEndRequestW);
bb!(HttpOpenRequestA);
bb!(HttpOpenRequestW);
bb!(HttpQueryInfoA);
bb!(HttpQueryInfoW);
bb!(HttpSendRequestA);
bb!(HttpSendRequestExA);
bb!(HttpSendRequestExW);
bb!(HttpSendRequestW);
bb!(InternetAttemptConnect);
bb!(InternetAutodial);
bb!(InternetAutodialHangup);
bb!(InternetCanonicalizeUrlA);
bb!(InternetCanonicalizeUrlW);
bb!(InternetCheckConnectionA);
bb!(InternetCheckConnectionW);
bb!(InternetClearAllPerSiteCookieDecisions);
bb!(InternetCloseHandle);
bb!(InternetCombineUrlA);
bb!(InternetCombineUrlW);
bb!(InternetConfirmZoneCrossingA);
bb!(InternetConfirmZoneCrossingW);
bb!(InternetConnectA);
bb!(InternetConnectW);
bb!(InternetDialA);
bb!(InternetDialW);
bb!(InternetEnumPerSiteCookieDecisionA);
bb!(InternetEnumPerSiteCookieDecisionW);
bb!(InternetErrorDlg);
bb!(InternetFindNextFileA);
bb!(InternetFindNextFileW);
bb!(InternetGetConnectedState);
bb!(InternetGetConnectedStateExA);
bb!(InternetGetConnectedStateExW);
bb!(InternetGetCookieA);
bb!(InternetGetCookieExA);
bb!(InternetGetCookieExW);
bb!(InternetGetCookieW);
bb!(InternetGetLastResponseInfoA);
bb!(InternetGetLastResponseInfoW);
bb!(InternetGetPerSiteCookieDecisionA);
bb!(InternetGetPerSiteCookieDecisionW);
bb!(InternetGoOnlineA);
bb!(InternetGoOnlineW);
bb!(InternetHangUp);
bb!(InternetInitializeAutoProxyDll);
bb!(InternetLockRequestFile);
bb!(InternetOpenA);
bb!(InternetOpenUrlA);
bb!(InternetOpenUrlW);
bb!(InternetOpenW);
bb!(InternetQueryDataAvailable);
bb!(InternetQueryOptionA);
bb!(InternetQueryOptionW);
bb!(InternetReadFile);
bb!(InternetReadFileExA);
bb!(InternetReadFileExW);
bb!(InternetSetCookieA);
bb!(InternetSetCookieExA);
bb!(InternetSetCookieExW);
bb!(InternetSetCookieW);
bb!(InternetSetDialStateA);
bb!(InternetSetDialStateW);
bb!(InternetSetFilePointer);
bb!(InternetSetOptionA);
bb!(InternetSetOptionExA);
bb!(InternetSetOptionExW);
bb!(InternetSetOptionW);
bb!(InternetSetPerSiteCookieDecisionA);
bb!(InternetSetPerSiteCookieDecisionW);
bb!(InternetSetStatusCallbackA);
bb!(InternetSetStatusCallbackW);
bb!(InternetTimeFromSystemTimeA);
bb!(InternetTimeFromSystemTimeW);
bb!(InternetTimeToSystemTimeA);
bb!(InternetTimeToSystemTimeW);
bb!(InternetUnlockRequestFile);
bb!(InternetWriteFile);
bb!(PrivacyGetZonePreferenceW);
bb!(PrivacySetZonePreferenceW);
bb!(ReadUrlCacheEntryStream);
bb!(ResumeSuspendedDownload);
bb!(RetrieveUrlCacheEntryFileA);
bb!(RetrieveUrlCacheEntryFileW);
bb!(RetrieveUrlCacheEntryStreamA);
bb!(RetrieveUrlCacheEntryStreamW);
bb!(SetUrlCacheEntryGroupA);
bb!(SetUrlCacheEntryGroupW);
bb!(SetUrlCacheEntryInfoA);
bb!(SetUrlCacheEntryInfoW);
bb!(SetUrlCacheGroupAttributeA);
bb!(SetUrlCacheGroupAttributeW);
bb!(UnlockUrlCacheEntryFileA);
bb!(UnlockUrlCacheEntryFileW);
bb!(UnlockUrlCacheEntryStream);
}
#[cfg(not(target_env="gnu"))]
#[test]
fn functions_missing_in_mingw() {
bb!(DeleteWpadCacheForNetworks);
bb!(InternetFreeCookies);
bb!(InternetGetCookieEx2);
bb!(InternetSetCookieEx2);
bb!(ReadUrlCacheEntryStreamEx);
}

0 comments on commit e79d8ea

Please sign in to comment.