diff --git a/Cargo.lock b/Cargo.lock index a140817596012477e19351d56062e6a1314d2cdd..557319c6df231f95c8c888aeafe9a7ad72026976 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -262,6 +262,7 @@ dependencies = [ "stdlib 0.1.0", "string 0.1.0", "unistd 0.1.0", + "wctype 0.1.0", ] [[package]] @@ -582,6 +583,14 @@ name = "vec_map" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "wctype" +version = "0.1.0" +dependencies = [ + "cbindgen 0.5.0", + "platform 0.1.0", +] + [[package]] name = "winapi" version = "0.2.8" diff --git a/Cargo.toml b/Cargo.toml index 5c7f356e871b6e904f7e0753e0c75e713ee61f12..4bb5d97b8abd64fbed9189f57220bf525c32f17c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ stdio = { path = "src/stdio" } stdlib = { path = "src/stdlib" } string = { path = "src/string" } unistd = { path = "src/unistd" } +wctype = { path = "src/wctype" } [profile.dev] panic = "abort" diff --git a/src/lib.rs b/src/lib.rs index b3b38a57b8c4c8b2e3d8ec4ec6313c4aca166b25..52053e45801c335ca0518b57d5c4c0a1d6e3c7ce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,6 +14,7 @@ extern crate stdio; extern crate stdlib; extern crate string; extern crate unistd; +extern crate wctype; #[lang = "eh_personality"] #[no_mangle] diff --git a/src/platform/src/types.rs b/src/platform/src/types.rs index dbbc2be301c3e905c71be50f62de89ff4465bcb9..0057825f297576d2cfc74c6d42f7683b22a64314 100644 --- a/src/platform/src/types.rs +++ b/src/platform/src/types.rs @@ -44,6 +44,7 @@ pub type c_ulong = u64; pub type wchar_t = i16; pub type wint_t = i32; +pub type wctype_t = i64; pub type off_t = c_long; pub type mode_t = u16; diff --git a/src/wctype/Cargo.toml b/src/wctype/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..abb1ba562f7fca5ffa268b8361befb612aea66f0 --- /dev/null +++ b/src/wctype/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "wctype" +version = "0.1.0" +authors = ["Dan Robertson <danlrobertson89@gmail.com>"] +build = "build.rs" + +[build-dependencies] +cbindgen = { path = "../../cbindgen" } + +[dependencies] +platform = { path = "../platform" } diff --git a/src/wctype/build.rs b/src/wctype/build.rs new file mode 100644 index 0000000000000000000000000000000000000000..d0b0702ceaf7025f58b141e3c71e3bb695727ab4 --- /dev/null +++ b/src/wctype/build.rs @@ -0,0 +1,11 @@ +extern crate cbindgen; + +use std::{env, fs}; + +fn main() { + let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set"); + fs::create_dir_all("../../target/include").expect("failed to create include directory"); + cbindgen::generate(crate_dir) + .expect("failed to generate bindings") + .write_to_file("../../target/include/wctype.h"); +} diff --git a/src/wctype/cbindgen.toml b/src/wctype/cbindgen.toml new file mode 100644 index 0000000000000000000000000000000000000000..f31ad97cf12ba0bb92a4571452aa171b06b99ac0 --- /dev/null +++ b/src/wctype/cbindgen.toml @@ -0,0 +1,6 @@ +sys_includes = [] +include_guard = "_WCTYPE_H" +language = "C" + +[enum] +prefix_with_name = true diff --git a/src/wctype/src/lib.rs b/src/wctype/src/lib.rs new file mode 100644 index 0000000000000000000000000000000000000000..2c9b6d07845b15f710cbfbfb28af321e275b5b9e --- /dev/null +++ b/src/wctype/src/lib.rs @@ -0,0 +1,82 @@ +//! wctype implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/wctype.h.html + +#![no_std] + +extern crate platform; + +use platform::types::*; + +#[no_mangle] +pub extern "C" fn iswalnum(wc: wint_t) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn iswalpha(wc: wint_t) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn iswcntrl(wc: wint_t) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn iswdigit(wc: wint_t) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn iswgraph(wc: wint_t) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn iswlower(wc: wint_t) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn iswprint(wc: wint_t) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn iswpunct(wc: wint_t) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn iswspace(wc: wint_t) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn iswupper(wc: wint_t) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn iswxdigit(wc: wint_t) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn iswctype(wc: wint_t, charclass: wctype_t) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn towlower(wc: wint_t) -> wint_t { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn towupper(wc: wint_t) -> wint_t { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn wctype(property: *const c_char) -> c_int { + unimplemented!(); +}