From bc5f2456627164013aab3650a4add4d1ae65be59 Mon Sep 17 00:00:00 2001 From: zhanghuanhuan Date: Mon, 9 Oct 2023 17:27:18 +0800 Subject: [PATCH] init bind_variable func for variables file --- bash-5.1/r_variables/src/lib.rs | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/bash-5.1/r_variables/src/lib.rs b/bash-5.1/r_variables/src/lib.rs index e69de29b..667d637b 100644 --- a/bash-5.1/r_variables/src/lib.rs +++ b/bash-5.1/r_variables/src/lib.rs @@ -0,0 +1,46 @@ +use libc::*; +use r_bash::*; +use std::ffi::CStr; + +extern "C" { + fn xmalloc(_: size_t) -> *mut libc::c_void; + fn parse_and_execute( + _: *mut libc::c_char, + _: *const libc::c_char, + _: libc::c_int, + ) -> libc::c_int; +} + +#[no_mangle] +pub unsafe extern "C" fn bind_variable( + mut name: *const libc::c_char, + mut value: *mut libc::c_char, + mut flags: libc::c_int, +) -> *mut SHELL_VAR { + let mut v: *mut SHELL_VAR = 0 as *mut SHELL_VAR; + let mut nv: *mut SHELL_VAR = 0 as *mut SHELL_VAR; + let mut vc: *mut VAR_CONTEXT = 0 as *mut VAR_CONTEXT; + let mut nvc: *mut VAR_CONTEXT = 0 as *mut VAR_CONTEXT; + + + if shell_variables.is_null() { + create_variable_tables(); + } + if !temporary_env.is_null() && !value.is_null() { + bind_tempenv_variable(name, value); + } + vc = shell_variables; + while !vc.is_null() { + if vc_isfuncenv!(vc) || vc_isbltnenv!(vc) + { + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct saved_dollar_vars { + pub first_ten: *mut *mut libc::c_char, + pub rest: *mut WORD_LIST, + pub count: libc::c_int, +} + -- Gitee