Browse Source

Build grp header

Jeremy Soller 7 years ago
parent
commit
352f485649
7 changed files with 64 additions and 16 deletions
  1. 9 0
      Cargo.lock
  2. 1 0
      Cargo.toml
  3. 11 0
      src/grp/Cargo.toml
  4. 11 0
      src/grp/build.rs
  5. 6 0
      src/grp/cbindgen.toml
  6. 25 16
      src/grp/src/lib.rs
  7. 1 0
      src/lib.rs

+ 9 - 0
Cargo.lock

@@ -97,6 +97,14 @@ name = "fuchsia-zircon-sys"
 version = "0.3.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
+[[package]]
+name = "grp"
+version = "0.1.0"
+dependencies = [
+ "cbindgen 0.5.0",
+ "platform 0.1.0",
+]
+
 [[package]]
 name = "itoa"
 version = "0.3.4"
@@ -222,6 +230,7 @@ dependencies = [
  "compiler_builtins 0.1.0 (git+https://github.com/rust-lang-nursery/compiler-builtins.git)",
  "ctype 0.1.0",
  "fcntl 0.1.0",
+ "grp 0.1.0",
  "platform 0.1.0",
  "stdio 0.1.0",
  "stdlib 0.1.0",

+ 1 - 0
Cargo.toml

@@ -15,6 +15,7 @@ compiler_builtins = { git = "https://github.com/rust-lang-nursery/compiler-built
 platform = { path = "platform" }
 ctype = { path = "src/ctype" }
 fcntl = { path = "src/fcntl" }
+grp = { path = "src/grp" }
 stdio = { path = "src/stdio" }
 stdlib = { path = "src/stdlib" }
 string = { path = "src/string" }

+ 11 - 0
src/grp/Cargo.toml

@@ -0,0 +1,11 @@
+[package]
+name = "grp"
+version = "0.1.0"
+authors = ["Jeremy Soller <jackpot51@gmail.com>"]
+build = "build.rs"
+
+[build-dependencies]
+cbindgen = { path = "../../cbindgen" }
+
+[dependencies]
+platform = { path = "../../platform" }

+ 11 - 0
src/grp/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/grp.h");
+}

+ 6 - 0
src/grp/cbindgen.toml

@@ -0,0 +1,6 @@
+sys_includes = []
+include_guard = "_GRP_H"
+language = "C"
+
+[enum]
+prefix_with_name = true

+ 25 - 16
src/todo/grp/lib.rs → src/grp/src/lib.rs

@@ -1,24 +1,26 @@
-/* automatically generated by rust-bindgen */
+//! grp implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/grp.h.html
+
+#![no_std]
+
+extern crate platform;
+
+use platform::types::*;
+
 #[repr(C)]
-#[derive(Debug, Copy)]
 pub struct group {
-    pub gr_name: *mut libc::c_char,
-    pub gr_passwd: *mut libc::c_char,
+    pub gr_name: *mut c_char,
+    pub gr_passwd: *mut c_char,
     pub gr_gid: gid_t,
-    pub gr_mem: *mut *mut libc::c_char,
-}
-impl Clone for group {
-    fn clone(&self) -> Self {
-        *self
-    }
+    pub gr_mem: *mut *mut c_char,
 }
+
 #[no_mangle]
 pub extern "C" fn getgrgid(gid: gid_t) -> *mut group {
     unimplemented!();
 }
 
 #[no_mangle]
-pub extern "C" fn getgrnam(name: *const libc::c_char) -> *mut group {
+pub extern "C" fn getgrnam(name: *const c_char) -> *mut group {
     unimplemented!();
 }
 
@@ -26,21 +28,21 @@ pub extern "C" fn getgrnam(name: *const libc::c_char) -> *mut group {
 pub extern "C" fn getgrgid_r(
     gid: gid_t,
     grp: *mut group,
-    buffer: *mut libc::c_char,
+    buffer: *mut c_char,
     bufsize: usize,
     result: *mut *mut group,
-) -> libc::c_int {
+) -> c_int {
     unimplemented!();
 }
 
 #[no_mangle]
 pub extern "C" fn getgrnam_r(
-    name: *const libc::c_char,
+    name: *const c_char,
     grp: *mut group,
-    buffer: *mut libc::c_char,
+    buffer: *mut c_char,
     bufsize: usize,
     result: *mut *mut group,
-) -> libc::c_int {
+) -> c_int {
     unimplemented!();
 }
 
@@ -58,3 +60,10 @@ pub extern "C" fn endgrent() {
 pub extern "C" fn setgrent() {
     unimplemented!();
 }
+
+/*
+#[no_mangle]
+pub extern "C" fn func(args) -> c_int {
+    unimplemented!();
+}
+*/

+ 1 - 0
src/lib.rs

@@ -6,6 +6,7 @@ extern crate platform;
 
 extern crate ctype;
 extern crate fcntl;
+extern crate grp;
 extern crate stdio;
 extern crate stdlib;
 extern crate string;