From 60cdf32f71d200edafb00056b287f07b0a14628a Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 16 Jun 2023 11:27:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=BB=BAbind=E5=B7=A5=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bash-5.1/builtins_rust/bind/Cargo.toml | 16 ++++++++++++++++ bash-5.1/builtins_rust/bind/src/lib.rs | 1 + 2 files changed, 17 insertions(+) create mode 100644 bash-5.1/builtins_rust/bind/Cargo.toml create mode 100644 bash-5.1/builtins_rust/bind/src/lib.rs diff --git a/bash-5.1/builtins_rust/bind/Cargo.toml b/bash-5.1/builtins_rust/bind/Cargo.toml new file mode 100644 index 00000000..22f987f4 --- /dev/null +++ b/bash-5.1/builtins_rust/bind/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "rbind" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +libc = "*" +nix = "*" +rcommon = {path = "../common"} +rhelp = {path ="../help"} + +[lib] +crate-type = ["staticlib","rlib"] +name = "rbind" diff --git a/bash-5.1/builtins_rust/bind/src/lib.rs b/bash-5.1/builtins_rust/bind/src/lib.rs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/bash-5.1/builtins_rust/bind/src/lib.rs @@ -0,0 +1 @@ + -- Gitee From f15571e8919c376f2e33368ecc9bf600676089ea Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 26 Jun 2023 10:09:07 +0800 Subject: [PATCH 2/2] add echo struct and use lib --- bash-5.1/builtins_rust/echo/src/lib.rs | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/bash-5.1/builtins_rust/echo/src/lib.rs b/bash-5.1/builtins_rust/echo/src/lib.rs index e69de29b..3bd00d19 100644 --- a/bash-5.1/builtins_rust/echo/src/lib.rs +++ b/bash-5.1/builtins_rust/echo/src/lib.rs @@ -0,0 +1,34 @@ +extern crate libc; + +use libc::{c_char,c_int, strchr, putchar,clearerr,free,FILE, fprintf, c_void}; +use std::ffi::{CString,CStr,}; +use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE}; +// use std::io::{stdout, Write}; +use std::ptr::read_volatile; +use rhelp::r_builtin_help; + +//结构体 + +//枚举 + +//宏 +#[macro_export] +macro_rules! VALID_ECHO_OPTIONS { + () => { + CString::new("neE").unwrap().as_ptr() + }; +} + + +#[macro_export] +macro_rules! QUIT { + () => { + if read_volatile(&terminating_signal as *const i32) != 0{ + termsig_handler(read_volatile(&terminating_signal as *const i32)); + } + if interrupt_state != 0{ + throw_to_top_level(); + } + }; +} + -- Gitee