diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3d69c04 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/target +**/*.rs.bk +Cargo.lock +tags diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b374a47 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +dist: trusty +language: rust +rust: + - 1.28.0 +script: ci/script.sh +branches: + only: + - master diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..bb9c20a --- /dev/null +++ b/COPYING @@ -0,0 +1,3 @@ +This project is dual-licensed under the Unlicense and MIT licenses. + +You may use this code under the terms of either license. diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..8d16b92 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "winapi-util" +version = "0.1.0" #:version +authors = ["Andrew Gallant "] +description = "A dumping ground for high level safe wrappers over winapi." +documentation = "https://docs.rs/winapi-util" +homepage = "https://github.com/BurntSushi/winapi-util" +repository = "https://github.com/BurntSushi/winapi-util" +readme = "README.md" +keywords = ["windows", "winapi", "util", "win"] +license = "Unlicense/MIT" +categories = ["os::windows-apis", "external-ffi-bindings"] + +[target.'cfg(windows)'.dependencies.winapi] +version = "0.3" +features = [ + "std", + "fileapi", + "minwindef", + "processenv", + "winbase", +] diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..3303149 --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2017 Andrew Gallant + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ba4b078 --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +winapi-util +=========== +This crate provides a smattering of safe wrappers around various parts of the +[winapi](https://crates.io/crates/winapi) crate. + +[![Linux build status](https://api.travis-ci.org/BurntSushi/winapi-util.png)](https://travis-ci.org/BurntSushi/winapi-util) +[![Windows build status](https://ci.appveyor.com/api/projects/status/github/BurntSushi/winapi-util?svg=true)](https://ci.appveyor.com/project/BurntSushi/winapi-util) +[![](http://meritbadge.herokuapp.com/winapi-util)](https://crates.io/crates/winapi-util) + +Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org). + + +### Documentation + +https://docs.rs/winapi-util + + +### Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +winapi-util = "0.1" +``` + +and this to your crate root: + +```rust +extern crate winapi_util; +``` + + +### Notes + +This crate was born out of frustration with having to write lots of little +ffi utility bindings in a variety of crates in order to get Windows support. +Eventually, I started needing to copy & paste a lot of those utility routines. +Since they are utility routines, they often don't make sense to expose directly +in the crate in which they are defined. Instead of continuing this process, +I decide to make a crate instead. + +Normally, I'm not a huge fan of "utility" crates like this that don't have a +well defined scope, but this is primarily a practical endeavor to make it +easier to isolate Windows specific ffi code. + +While I don't have a long term vision for this crate, I will welcome additional +PRs that add more high level routines/types on an as-needed basis. + +**WARNING:** I am not a Windows developer, so extra review to make sure I've +got things right is most appreciated. diff --git a/UNLICENSE b/UNLICENSE new file mode 100644 index 0000000..68a49da --- /dev/null +++ b/UNLICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..9fdcaa8 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,26 @@ +environment: + matrix: + - TARGET: x86_64-pc-windows-gnu + BITS: 64 + MSYS2: 1 + - TARGET: x86_64-pc-windows-msvc + BITS: 64 + - TARGET: i686-pc-windows-gnu + BITS: 32 + MSYS2: 1 + - TARGET: i686-pc-windows-msvc + BITS: 32 +install: + - curl -sSf -o rustup-init.exe https://win.rustup.rs/ + - rustup-init.exe -y --default-host %TARGET% + - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin + - if defined MSYS2 set PATH=C:\msys64\mingw%BITS%\bin;%PATH% + - rustc -V + - cargo -V +build: false +test_script: + - cargo build --verbose --all + - cargo test --verbose --all +branches: + only: + - master diff --git a/ci/script.sh b/ci/script.sh new file mode 100755 index 0000000..90243df --- /dev/null +++ b/ci/script.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +set -ex + +cargo build --verbose --all +cargo doc --verbose --all +cargo test --verbose --all diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..21c68ba --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,14 @@ +/*! +TODO. + +Note that this crate is completely empty on non-Windows platforms. +*/ + +#[cfg(windows)] +extern crate winapi; + +#[cfg(windows)] +pub use win::*; + +#[cfg(windows)] +mod win; diff --git a/src/win.rs b/src/win.rs new file mode 100644 index 0000000..e69de29