From 035f7e860957e8c5637bdd1c033c1953dce980b3 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Fri, 5 Feb 2021 10:24:20 +0100 Subject: pkgs/profpatsch: adjust exec stuff to new skalibs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit skarnet thought it would be wise to completely change the skalibs exec function interface without any backwards compat, so here we are. Have to reverse the code a bit, because `xmexec0` is a recursive `#define` pointing to `xmexec0_af`. `record-get` gets a rust treatment, it doesn’t really need the C interface just to exec into prog. --- pkgs/profpatsch/execline/el_exec.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'pkgs/profpatsch/execline') diff --git a/pkgs/profpatsch/execline/el_exec.rs b/pkgs/profpatsch/execline/el_exec.rs index 25fad36f..0e4e11b7 100644 --- a/pkgs/profpatsch/execline/el_exec.rs +++ b/pkgs/profpatsch/execline/el_exec.rs @@ -12,12 +12,16 @@ fn to_c_argv>(s: &[S]) -> (&[S], Vec<*const libc::c_char>) { /// Exec into argv, or exit 0 if it’s empty. /// Will throw 127 if the executable is not found (ENOENT) /// and 126 for any other exec error. -pub fn xpathexec0<'a, S: AsRef>(argv: &'a [S]) { +pub fn xmexec0<'a, S: AsRef>(argv: &'a [S]) { let (c_strings, c_argv) = to_c_argv(argv); unsafe { - C::xpathexec0( - c_argv.as_ptr() as *const *const libc::c_char + let env = C::environ; + C::xmexec0_af( + c_argv[0] as *const libc::c_char, + c_argv.as_ptr() as *const *const libc::c_char, + env, + C::env_len(env) ) } } @@ -25,8 +29,15 @@ pub fn xpathexec0<'a, S: AsRef>(argv: &'a [S]) { mod C { #[link(name = "skarnet")] extern "C" { - pub fn xpathexec0( - argv: *const *const libc::c_char + pub fn xmexec0_af( + file: *const libc::c_char, + argv: *const *const libc::c_char, + envp: *const *const libc::c_char, + envlen: libc::size_t ); + pub static environ: *const *const libc::c_char; + pub fn env_len( + e: *const *const libc::c_char + ) -> libc::size_t; } } -- cgit 1.4.1