clamav-sys: Reformat

pull/1152/head^2
Scott Hutton 3 years ago
parent 00065662dc
commit 48c1479432
  1. 10
      Cargo.toml
  2. 41
      build.rs
  3. 41
      src/lib.rs

@ -1,13 +1,13 @@
[package]
name = "clamav-sys"
description = "ClamAV low level bindings for Rust"
version = "0.0.5"
authors = ["Jonas Zaddach <jonas.zaddach@gmail.com>"]
edition = "2018"
license = "GPL-2.0"
categories = ["external-ffi-bindings"]
description = "ClamAV low level bindings for Rust"
edition = "2018"
homepage = "https://github.com/zaddach/clamav-sys/"
license = "GPL-2.0"
name = "clamav-sys"
repository = "https://github.com/zaddach/clamav-sys/"
version = "0.0.5"
[build-dependencies]
bindgen = "0.56.0"

@ -15,9 +15,8 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA.
use std::path::PathBuf;
use std::env;
use std::path::PathBuf;
fn generate_bindings(customize_bindings: &dyn Fn(bindgen::Builder) -> bindgen::Builder) {
let mut bindings = bindgen::Builder::default()
@ -53,10 +52,7 @@ fn generate_bindings(customize_bindings: &dyn Fn(bindgen::Builder) -> bindgen::B
.whitelist_var("CL_SCAN_.*")
.whitelist_var("CL_INIT_DEFAULT")
.whitelist_var("CL_DB_.*")
.header("wrapper.h")
// Tell cargo to invalidate the built crate whenever any of the
// included header files changed.
.parse_callbacks(Box::new(bindgen::CargoCallbacks));
@ -82,14 +78,15 @@ fn cargo_common() {
println!("cargo:rerun-if-changed=wrapper.h");
}
#[cfg(windows)]
fn main() {
let include_paths = match vcpkg::find_package("clamav") {
Ok(pkg) => pkg.include_paths,
Err(err) => {
println!("cargo:warning=Either vcpkg is not installed, or an error occurred in vcpkg: {}", err);
println!(
"cargo:warning=Either vcpkg is not installed, or an error occurred in vcpkg: {}",
err
);
let clamav_source = PathBuf::from(env::var("CLAMAV_SOURCE").expect("CLAMAV_SOURCE environment variable must be set and point to ClamAV's source directory"));
let clamav_build = PathBuf::from(env::var("CLAMAV_BUILD").expect("CLAMAV_BUILD environment variable must be set and point to ClamAV's build directory"));
let openssl_include = PathBuf::from(env::var("OPENSSL_INCLUDE").expect("OPENSSL_INCLUDE environment variable must be set and point to openssl's include directory"));
@ -101,14 +98,27 @@ fn main() {
_ => panic!("Unexpected build profile"),
};
println!("cargo:rustc-link-search=native={}", library_path.to_str().unwrap());
println!(
"cargo:rustc-link-search=native={}",
library_path.to_str().unwrap()
);
vec![clamav_source.join("libclamav"), clamav_build, openssl_include]
vec![
clamav_source.join("libclamav"),
clamav_build,
openssl_include,
]
}
};
cargo_common();
generate_bindings(&|x: bindgen::Builder| -> bindgen::Builder {let mut x = x; for include_path in &include_paths {x = x.clang_arg("-I").clang_arg(include_path.to_str().unwrap());}; x});
generate_bindings(&|x: bindgen::Builder| -> bindgen::Builder {
let mut x = x;
for include_path in &include_paths {
x = x.clang_arg("-I").clang_arg(include_path.to_str().unwrap());
}
x
});
}
#[cfg(unix)]
@ -127,6 +137,11 @@ fn main() {
}
cargo_common();
generate_bindings(&|x: bindgen::Builder| -> bindgen::Builder {let mut x = x; for include_path in &include_paths {x = x.clang_arg("-I").clang_arg(include_path.to_str().unwrap());}; x});
generate_bindings(&|x: bindgen::Builder| -> bindgen::Builder {
let mut x = x;
for include_path in &include_paths {
x = x.clang_arg("-I").clang_arg(include_path.to_str().unwrap());
}
x
});
}

@ -19,34 +19,33 @@
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
impl Default for cl_scan_options {
fn default() -> Self {
cl_scan_options {
general: 0,
parse: CL_SCAN_PARSE_ARCHIVE
| CL_SCAN_PARSE_MAIL
| CL_SCAN_PARSE_OLE2
| CL_SCAN_PARSE_PDF
| CL_SCAN_PARSE_HTML
| CL_SCAN_PARSE_SWF
| CL_SCAN_PARSE_PE
| CL_SCAN_PARSE_ELF
| CL_SCAN_PARSE_SWF
| CL_SCAN_PARSE_XMLDOCS,
heuristic: 0,
mail: 0,
dev: 0,
}
parse: CL_SCAN_PARSE_ARCHIVE
| CL_SCAN_PARSE_MAIL
| CL_SCAN_PARSE_OLE2
| CL_SCAN_PARSE_PDF
| CL_SCAN_PARSE_HTML
| CL_SCAN_PARSE_SWF
| CL_SCAN_PARSE_PE
| CL_SCAN_PARSE_ELF
| CL_SCAN_PARSE_SWF
| CL_SCAN_PARSE_XMLDOCS,
heuristic: 0,
mail: 0,
dev: 0,
}
}
}
impl PartialEq for cl_scan_options {
fn eq(& self, other: &Self) -> bool {
self.general == other.general &&
self.parse == other.parse &&
self.heuristic == other.heuristic &&
self.mail == other.mail &&
self.dev == other.dev
fn eq(&self, other: &Self) -> bool {
self.general == other.general
&& self.parse == other.parse
&& self.heuristic == other.heuristic
&& self.mail == other.mail
&& self.dev == other.dev
}
}

Loading…
Cancel
Save