about summary refs log tree commit diff
path: root/pkgs/profpatsch/execline
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2021-02-05 10:24:20 +0100
committerProfpatsch <mail@profpatsch.de>2021-02-05 10:24:20 +0100
commit035f7e860957e8c5637bdd1c033c1953dce980b3 (patch)
tree71b076b536d6a6a8839a54c57debd6c3401cdb14 /pkgs/profpatsch/execline
parent8faf9338c363df8cebae4089b8c4b1832b6cb251 (diff)
pkgs/profpatsch: adjust exec stuff to new skalibs
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.
Diffstat (limited to 'pkgs/profpatsch/execline')
-rw-r--r--pkgs/profpatsch/execline/el_exec.rs21
1 files changed, 16 insertions, 5 deletions
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: AsRef<CStr>>(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<CStr>>(argv: &'a [S]) {
+pub fn xmexec0<'a, S: AsRef<CStr>>(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<CStr>>(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;
     }
 }