Start of the project
This commit is contained in:
commit
14365ec9be
|
@ -0,0 +1,2 @@
|
|||
/target
|
||||
Cargo.lock
|
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
name = "skanny"
|
||||
version = "0.1.0"
|
||||
authors = ["Magnus Ulimoen <magnus@ulimoen.dev>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"sane-sys"
|
||||
]
|
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "sane-sys"
|
||||
version = "0.1.0"
|
||||
authors = ["Magnus Ulimoen <magnus@ulimoen.dev>"]
|
||||
edition = "2018"
|
||||
links = "sane"
|
||||
build = "build.rs"
|
||||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
|
||||
[build-dependencies]
|
||||
bindgen = "0.54.1"
|
|
@ -0,0 +1,7 @@
|
|||
# sane-sys
|
||||
|
||||
FFI wrapper for the [SANE API](http://www.sane-project.org) for consumption by rustaceans.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Requires the SANE library to be installed, including the headers when building this library.
|
|
@ -0,0 +1,20 @@
|
|||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=src/wrapper.h");
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
|
||||
println!("cargo:rustc-link-lib=sane");
|
||||
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header("src/wrapper.h")
|
||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
|
||||
.generate()
|
||||
.expect("Unable to generate bindings to SANE");
|
||||
|
||||
let out_path = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||
bindings
|
||||
.write_to_file(out_path.join("bindings.rs"))
|
||||
.expect("Couldn't write SANE bindings");
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
#![allow(non_upper_case_globals)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||
|
||||
pub const fn SANE_VERSION_MAJOR(code: SANE_Int) -> SANE_Word {
|
||||
(code >> 24) as SANE_Word & 0xff
|
||||
}
|
||||
|
||||
pub const fn SANE_VERSION_MINOR(code: SANE_Int) -> SANE_Word {
|
||||
(code >> 16) as SANE_Word & 0xff
|
||||
}
|
||||
|
||||
pub const fn SANE_VERSION_BUILD(code: SANE_Int) -> SANE_Word {
|
||||
(code >> 0) as SANE_Word & 0xffff
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn smokescreen() {
|
||||
use std::ptr::null_mut;
|
||||
let status = unsafe { sane_init(null_mut(), None) };
|
||||
assert_eq!(status, SANE_Status_SANE_STATUS_GOOD);
|
||||
|
||||
unsafe { sane_exit() }
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
#include <sane/sane.h>
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
Loading…
Reference in New Issue