summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/skalibs/djbunix.h22
-rw-r--r--src/include/skalibs/env.h8
-rw-r--r--src/include/skalibs/exec.h160
-rw-r--r--src/include/skalibs/stddjb.h1
-rw-r--r--src/libenvexec/env_addmodif.c (renamed from src/libstddjb/env_addmodif.c)0
-rw-r--r--src/libenvexec/env_dump.c (renamed from src/libstddjb/env_dump.c)0
-rw-r--r--src/libenvexec/env_get.c (renamed from src/libstddjb/env_get.c)0
-rw-r--r--src/libenvexec/env_get2.c (renamed from src/libstddjb/env_get2.c)0
-rw-r--r--src/libenvexec/env_len.c (renamed from src/libstddjb/env_len.c)0
-rw-r--r--src/libenvexec/env_make.c (renamed from src/libstddjb/env_make.c)0
-rw-r--r--src/libenvexec/env_merg.c8
-rw-r--r--src/libenvexec/env_merge.c9
-rw-r--r--src/libenvexec/env_mergen.c (renamed from src/libstddjb/env_merge.c)4
-rw-r--r--src/libenvexec/env_mergn.c8
-rw-r--r--src/libenvexec/env_string.c (renamed from src/libstddjb/env_string.c)0
-rw-r--r--src/libenvexec/envalloc_0.c (renamed from src/libstddjb/envalloc_0.c)0
-rw-r--r--src/libenvexec/envalloc_make.c (renamed from src/libstddjb/envalloc_make.c)0
-rw-r--r--src/libenvexec/envalloc_merge.c (renamed from src/libstddjb/envalloc_merge.c)2
-rw-r--r--src/libenvexec/envalloc_uniq.c (renamed from src/libstddjb/envalloc_uniq.c)0
-rw-r--r--src/libenvexec/envdir.c (renamed from src/libstddjb/envdir.c)0
-rw-r--r--src/libenvexec/exec0_ae.c11
-rw-r--r--src/libenvexec/exec_ae.c (renamed from src/libstddjb/pathexec_run.c)5
-rw-r--r--src/libenvexec/mexec0_af.c11
-rw-r--r--src/libenvexec/mexec0_afm.c11
-rw-r--r--src/libenvexec/mexec0_afn.c11
-rw-r--r--src/libenvexec/mexec_af.c17
-rw-r--r--src/libenvexec/mexec_afm.c9
-rw-r--r--src/libenvexec/mexec_afn.c11
-rw-r--r--src/libenvexec/xexec0_ae.c11
-rw-r--r--src/libenvexec/xexec_ae.c12
-rw-r--r--src/libenvexec/xexecvep.c (renamed from src/libstddjb/xexecvep.c)3
-rw-r--r--src/libenvexec/xexecvep_loose.c13
-rw-r--r--src/libenvexec/xmexec0_af.c12
-rw-r--r--src/libenvexec/xmexec0_afm.c12
-rw-r--r--src/libenvexec/xmexec0_afn.c12
-rw-r--r--src/libenvexec/xmexec_af.c12
-rw-r--r--src/libenvexec/xmexec_afm.c12
-rw-r--r--src/libenvexec/xmexec_afn.c12
-rw-r--r--src/libstddjb/pathexec.c12
-rw-r--r--src/libstddjb/pathexec0.c10
-rw-r--r--src/libstddjb/pathexec0_run.c10
-rw-r--r--src/libstddjb/pathexec_fromenv.c17
-rw-r--r--src/libstddjb/pathexec_r.c8
-rw-r--r--src/libstddjb/pathexec_r_name.c13
-rw-r--r--src/libstddjb/xpathexec.c12
-rw-r--r--src/libstddjb/xpathexec0.c12
-rw-r--r--src/libstddjb/xpathexec0_run.c12
-rw-r--r--src/libstddjb/xpathexec_fromenv.c12
-rw-r--r--src/libstddjb/xpathexec_r.c12
-rw-r--r--src/libstddjb/xpathexec_r_name.c12
-rw-r--r--src/libstddjb/xpathexec_run.c12
51 files changed, 392 insertions, 181 deletions
diff --git a/src/include/skalibs/djbunix.h b/src/include/skalibs/djbunix.h
index 03cc1af..885a623 100644
--- a/src/include/skalibs/djbunix.h
+++ b/src/include/skalibs/djbunix.h
@@ -6,10 +6,10 @@
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/wait.h>
+
#include <skalibs/gccattributes.h>
#include <skalibs/stralloc.h>
-#include <skalibs/envalloc.h>
-#include <skalibs/posixplz.h>
+#include <skalibs/exec.h> /* compat */
#define DJBUNIX_FLAG_NB 0x01U
#define DJBUNIX_FLAG_COE 0x02U
@@ -64,24 +64,6 @@ extern int socketpair_internal (int, int, int, unsigned int, int *) ;
extern size_t path_canonicalize (char *, char const *, int) ;
-extern int pathexec_env (char const *, char const *) ;
-extern void pathexec_r (char const *const *, char const *const *, size_t, char const *, size_t) ;
-extern void pathexec_r_name (char const *, char const *const *, char const *const *, size_t, char const *, size_t) ;
-extern void pathexec_fromenv (char const *const *, char const *const *, size_t) ;
-extern void pathexec_run (char const *, char const *const *, char const *const *) ;
-extern void pathexec0_run (char const *const *, char const *const *) ;
-extern void pathexec (char const *const *) ;
-extern void pathexec0 (char const *const *) ;
-
-extern void xpathexec_r (char const *const *, char const *const *, size_t, char const *, size_t) gccattr_noreturn ;
-extern void xpathexec_r_name (char const *, char const *const *, char const *const *, size_t, char const *, size_t) gccattr_noreturn ;
-extern void xpathexec_fromenv (char const *const *, char const *const *, size_t) gccattr_noreturn ;
-extern void xexecvep (char const *, char const *const *, char const *const *, char const *) gccattr_noreturn ;
-extern void xpathexec_run (char const *, char const *const *, char const *const *) gccattr_noreturn ;
-extern void xpathexec0_run (char const *const *, char const *const *) gccattr_noreturn ;
-extern void xpathexec (char const *const *) gccattr_noreturn ;
-extern void xpathexec0 (char const *const *) gccattr_noreturn ;
-
extern pid_t wait_nointr (int *) ;
extern pid_t waitpid_nointr (pid_t, int *, int) ;
#define wait_pid(pid, wstat) waitpid_nointr(pid, (wstat), 0)
diff --git a/src/include/skalibs/env.h b/src/include/skalibs/env.h
index bc8177b..73398c2 100644
--- a/src/include/skalibs/env.h
+++ b/src/include/skalibs/env.h
@@ -4,6 +4,7 @@
#define SKALIBS_ENV_H
#include <sys/types.h>
+
#include <skalibs/gccattributes.h>
#include <skalibs/stralloc.h>
@@ -11,11 +12,16 @@ extern size_t env_len (char const *const *) gccattr_pure ;
extern char const *env_get (char const *) gccattr_deprecated ;
extern char const *env_get2 (char const *const *, char const *) gccattr_pure ;
extern char const *ucspi_get (char const *) gccattr_pure ;
+
extern int env_addmodif (stralloc *, char const *, char const *) ;
extern int env_make (char const **, size_t, char const *, size_t) ;
-extern size_t env_merge (char const **, size_t, char const *const *, size_t, char const *, size_t) ;
extern int env_string (stralloc *, char const *const *, size_t) ;
+extern size_t env_mergen (char const **, size_t, char const *const *, size_t, char const *, size_t, size_t) ;
+extern size_t env_merge (char const **, size_t, char const *const *, size_t, char const *, size_t) ;
+extern size_t env_mergn (char const **, size_t, char const *const *, char const *, size_t, size_t) ;
+extern size_t env_merg (char const **, size_t, char const *const *, char const *, size_t) ;
+
#define SKALIBS_ENVDIR_VERBATIM 0x01
#define SKALIBS_ENVDIR_NOCHOMP 0x02
extern int envdir_internal (char const *, stralloc *, unsigned int, char) ;
diff --git a/src/include/skalibs/exec.h b/src/include/skalibs/exec.h
new file mode 100644
index 0000000..46b4c8a
--- /dev/null
+++ b/src/include/skalibs/exec.h
@@ -0,0 +1,160 @@
+/* ISC license. */
+
+#ifndef SKALIBS_EXEC_H
+#define SKALIBS_EXEC_H
+
+#include <stddef.h>
+
+#include <skalibs/environ.h>
+#include <skalibs/env.h>
+#include <skalibs/gccattributes.h>
+
+
+ /* Without environment modifications */
+
+extern void xexecvep (char const *, char const *const *, char const *const *, char const *) gccattr_noreturn ;
+extern void xexecvep_loose (char const *, char const *const *, char const *const *, char const *) gccattr_noreturn ;
+
+extern void exec_ae (char const *, char const *const *, char const *const *) ;
+#define exec_a(file, argv) exec_ae(file, (argv), (char const *const *)environ)
+#define exec_e(argv, envp) exec_ae((argv)[0], (argv), envp)
+#define exec(argv) exec_a((argv)[0], (argv))
+
+extern void xexec_ae (char const *, char const *const *, char const *const *) gccattr_noreturn ;
+#define xexec_a(file, argv) xexec_ae(file, (argv), (char const *const *)environ)
+#define xexec_e(argv, envp) xexec_ae((argv)[0], (argv), envp)
+#define xexec(argv) xexec_a((argv)[0], (argv))
+
+extern void exec0_ae (char const *, char const *const *, char const *const *) ;
+#define exec0_a(file, argv) exec0_ae(file, (argv), (char const *const *)environ)
+#define exec0_e(argv, envp) exec0_ae((argv)[0], (argv), envp)
+#define exec0(argv) exec0_a((argv)[0], (argv))
+
+extern void xexec0_ae (char const *, char const *const *, char const *const *) gccattr_noreturn ;
+#define xexec0_a(file, argv) xexec0_ae(file, (argv), (char const *const *)environ)
+#define xexec0_e(argv, envp) xexec0_ae((argv)[0], (argv), envp)
+#define xexec0(argv) xexec0_a((argv)[0], (argv))
+
+
+ /* With environment modifications : env_merge and exec */
+
+extern int env_mexec (char const *, char const *) ;
+
+extern void mexec_afn (char const *, char const *const *, char const *const *, size_t, char const *, size_t, size_t) ;
+extern void mexec_afm (char const *, char const *const *, char const *const *, size_t, char const *, size_t) ;
+extern void mexec_af (char const *, char const *const *, char const *const *, size_t) ;
+
+#define mexec_aen(file, argv, envp, modif, modiflen, modifn) mexec_afn(file, argv, envp, env_len(envp), modif, modiflen, modifn)
+#define mexec_aem(file, argv, envp, modif, modiflen) mexec_afm(file, argv, envp, env_len(envp), modif, modiflen)
+#define mexec_ae(file, argv, envp) mexec_af(file, argv, envp, env_len(envp))
+
+#define mexec_an(file, argv, modif, modiflen, modifn) mexec_aen(file, argv, (char const *const *)environ, modif, modiflen, modifn)
+#define mexec_am(file, argv, modif, modiflen) mexec_aem(file, argv, (char const *const *)environ, modif, modiflen)
+#define mexec_a(file, argv) mexec_ae(file, argv, (char const *const *)environ)
+
+#define mexec_fn(argv, envp, envlen, modif, modiflen, modifn) mexec_afn((argv)[0], (argv), envp, envlen, modif, modiflen, modifn)
+#define mexec_fm(argv, envp, envlen, modif, modiflen) mexec_afm((argv)[0], (argv), envp, envlen, modif, modiflen)
+#define mexec_f(argv, envp, envlen) mexec_af((argv)[0], (argv), envp, envlen)
+
+#define mexec_en(argv, envp, modif, modiflen, modifn) mexec_aen((argv)[0], (argv), envp, modif, modiflen, modifn)
+#define mexec_em(argv, envp, modif, modiflen) mexec_aem((argv)[0], (argv), envp, modif, modiflen)
+#define mexec_e(argv, envp) mexec_a((argv)[0], (argv), envp)
+
+#define mexec_n(argv, modif, modiflen, modifn) mexec_an((argv)[0], (argv), modif, modiflen, modifn)
+#define mexec_m(argv, modif, modiflen) mexec_am((argv)[0], (argv), modif, modiflen)
+#define mexec(argv) mexec_a((argv)[0], (argv))
+
+extern void mexec0_afn (char const *, char const *const *, char const *const *, size_t, char const *, size_t, size_t) ;
+extern void mexec0_afm (char const *, char const *const *, char const *const *, size_t, char const *, size_t) ;
+extern void mexec0_af (char const *, char const *const *, char const *const *, size_t) ;
+
+#define mexec0_aen(file, argv, envp, modif, modiflen, modifn) mexec0_afn(file, argv, envp, env_len(envp), modif, modiflen, modifn)
+#define mexec0_aem(file, argv, envp, modif, modiflen) mexec0_afm(file, argv, envp, env_len(envp), modif, modiflen)
+#define mexec0_ae(file, argv, envp) mexec0_af(file, argv, envp, env_len(envp))
+
+#define mexec0_an(file, argv, modif, modiflen, modifn) mexec0_aen(file, argv, (char const *const *)environ, modif, modiflen, modifn)
+#define mexec0_am(file, argv, modif, modiflen) mexec0_aem(file, argv, (char const *const *)environ, modif, modiflen)
+#define mexec0_a(file, argv) mexec0_ae(file, argv, (char const *const *)environ)
+
+#define mexec0_fn(argv, envp, envlen, modif, modiflen, modifn) mexec0_afn((argv)[0], (argv), envp, envlen, modif, modiflen, modifn)
+#define mexec0_fm(argv, envp, envlen, modif, modiflen) mexec0_afm((argv)[0], (argv), envp, envlen, modif, modiflen)
+#define mexec0_f(argv, envp, envlen) mexec0_af((argv)[0], (argv), envp, envlen)
+
+#define mexec0_en(argv, envp, modif, modiflen, modifn) mexec0_aen((argv)[0], (argv), envp, modif, modiflen, modifn)
+#define mexec0_em(argv, envp, modif, modiflen) mexec0_aem((argv)[0], (argv), envp, modif, modiflen)
+#define mexec0_e(argv, envp) mexec0_a((argv)[0], (argv), envp)
+
+#define mexec0_n(argv, modif, modiflen, modifn) mexec0_an((argv)[0], (argv), modif, modiflen, modifn)
+#define mexec0_m(argv, modif, modiflen) mexec0_am((argv)[0], (argv), modif, modiflen)
+#define mexec0(argv) mexec0_a((argv)[0], (argv))
+
+extern void xmexec_afn (char const *, char const *const *, char const *const *, size_t, char const *, size_t, size_t) gccattr_noreturn ;
+extern void xmexec_afm (char const *, char const *const *, char const *const *, size_t, char const *, size_t) gccattr_noreturn ;
+extern void xmexec_af (char const *, char const *const *, char const *const *, size_t) gccattr_noreturn ;
+
+#define xmexec_aen(file, argv, envp, modif, modiflen, modifn) xmexec_afn(file, argv, envp, env_len(envp), modif, modiflen, modifn)
+#define xmexec_aem(file, argv, envp, modif, modiflen) xmexec_afm(file, argv, envp, env_len(envp), modif, modiflen)
+#define xmexec_ae(file, argv, envp) xmexec_af(file, argv, envp, env_len(envp))
+
+#define xmexec_an(file, argv, modif, modiflen, modifn) xmexec_aen(file, argv, (char const *const *)environ, modif, modiflen, modifn)
+#define xmexec_am(file, argv, modif, modiflen) xmexec_aem(file, argv, (char const *const *)environ, modif, modiflen)
+#define xmexec_a(file, argv) xmexec_ae(file, argv, (char const *const *)environ)
+
+#define xmexec_fn(argv, envp, envlen, modif, modiflen, modifn) xmexec_afn((argv)[0], (argv), envp, envlen, modif, modiflen, modifn)
+#define xmexec_fm(argv, envp, envlen, modif, modiflen) xmexec_afm((argv)[0], (argv), envp, envlen, modif, modiflen)
+#define xmexec_f(argv, envp, envlen) xmexec_af((argv)[0], (argv), envp, envlen)
+
+#define xmexec_en(argv, envp, modif, modiflen, modifn) xmexec_aen((argv)[0], (argv), envp, modif, modiflen, modifn)
+#define xmexec_em(argv, envp, modif, modiflen) xmexec_aem((argv)[0], (argv), envp, modif, modiflen)
+#define xmexec_e(argv, envp) xmexec_a((argv)[0], (argv), envp)
+
+#define xmexec_n(argv, modif, modiflen, modifn) xmexec_an((argv)[0], (argv), modif, modiflen, modifn)
+#define xmexec_m(argv, modif, modiflen) xmexec_am((argv)[0], (argv), modif, modiflen)
+#define xmexec(argv) xmexec_a((argv)[0], (argv))
+
+extern void xmexec0_afn (char const *, char const *const *, char const *const *, size_t, char const *, size_t, size_t) ;
+extern void xmexec0_afm (char const *, char const *const *, char const *const *, size_t, char const *, size_t) ;
+extern void xmexec0_af (char const *, char const *const *, char const *const *, size_t) ;
+
+#define xmexec0_aen(file, argv, envp, modif, modiflen, modifn) xmexec0_afn(file, argv, envp, env_len(envp), modif, modiflen, modifn)
+#define xmexec0_aem(file, argv, envp, modif, modiflen) xmexec0_afm(file, argv, envp, env_len(envp), modif, modiflen)
+#define xmexec0_ae(file, argv, envp) xmexec0_af(file, argv, envp, env_len(envp))
+
+#define xmexec0_an(file, argv, modif, modiflen, modifn) xmexec0_aen(file, argv, (char const *const *)environ, modif, modiflen, modifn)
+#define xmexec0_am(file, argv, modif, modiflen) xmexec0_aem(file, argv, (char const *const *)environ, modif, modiflen)
+#define xmexec0_a(file, argv) xmexec0_ae(file, argv, (char const *const *)environ)
+
+#define xmexec0_fn(argv, envp, envlen, modif, modiflen, modifn) xmexec0_afn((argv)[0], (argv), envp, envlen, modif, modiflen, modifn)
+#define xmexec0_fm(argv, envp, envlen, modif, modiflen) xmexec0_afm((argv)[0], (argv), envp, envlen, modif, modiflen)
+#define xmexec0_f(argv, envp, envlen) xmexec0_af((argv)[0], (argv), envp, envlen)
+
+#define xmexec0_en(argv, envp, modif, modiflen, modifn) xmexec0_aen((argv)[0], (argv), envp, modif, modiflen, modifn)
+#define xmexec0_em(argv, envp, modif, modiflen) xmexec0_aem((argv)[0], (argv), envp, modif, modiflen)
+#define xmexec0_e(argv, envp) xmexec0_a((argv)[0], (argv), envp)
+
+#define xmexec0_n(argv, modif, modiflen, modifn) xmexec0_an((argv)[0], (argv), modif, modiflen, modifn)
+#define xmexec0_m(argv, modif, modiflen) xmexec0_am((argv)[0], (argv), modif, modiflen)
+#define xmexec0(argv) xmexec0_a((argv)[0], (argv))
+
+
+ /* Compatibility */
+
+#define pathexec_run(file, argv, envp) exec_ae(file, argv, envp)
+#define pathexec0_run(file, argv, envp) exec0_ae(file, argv, envp)
+#define xpathexec_run(file, argv, envp) xexec_ae(file, argv, envp)
+#define xpathexec0_run(file, argv, envp) xexec0_ae(file, argv, envp)
+
+#define pathexec_env(key, value) env_mexec(key, value)
+#define pathexec_fromenv(argv, envp, envlen) mexec_f(argv, envp, envlen)
+#define pathexec(argv) mexec(argv)
+#define pathexec0(argv) mexec0(argv)
+#define xpathexec_fromenv(argv, envp, envlen) xmexec_f(argv, envp, envlen)
+#define xpathexec(argv) xmexec(argv)
+#define xpathexec0(argv) xmexec0(argv)
+
+#define pathexec_r_name(file, argv, envp, envlen, modif, modiflen) mexec_afm(file, argv, envp, envlen, modif, modiflen)
+#define pathexec_r(argv, envp, envlen, modif, modiflen) mexec_fm(argv, envp, envlen, modif, modiflen)
+#define xpathexec_r_name(file, argv, envp, envlen, modif, modiflen) xmexec_afm(file, argv, envp, envlen, modif, modiflen)
+#define xpathexec_r(argv, envp, envlen, modif, modiflen) xmexec_fm(argv, envp, envlen, modif, modiflen)
+
+#endif
diff --git a/src/include/skalibs/stddjb.h b/src/include/skalibs/stddjb.h
index 232b5f3..071c913 100644
--- a/src/include/skalibs/stddjb.h
+++ b/src/include/skalibs/stddjb.h
@@ -28,6 +28,7 @@
#include <skalibs/djbunix.h>
#include <skalibs/envalloc.h>
#include <skalibs/env.h>
+#include <skalibs/exec.h>
#include <skalibs/fmtscan.h>
#include <skalibs/functypes.h>
#include <skalibs/gccattributes.h>
diff --git a/src/libstddjb/env_addmodif.c b/src/libenvexec/env_addmodif.c
index ddd1be3..ddd1be3 100644
--- a/src/libstddjb/env_addmodif.c
+++ b/src/libenvexec/env_addmodif.c
diff --git a/src/libstddjb/env_dump.c b/src/libenvexec/env_dump.c
index 10f5913..10f5913 100644
--- a/src/libstddjb/env_dump.c
+++ b/src/libenvexec/env_dump.c
diff --git a/src/libstddjb/env_get.c b/src/libenvexec/env_get.c
index d809461..d809461 100644
--- a/src/libstddjb/env_get.c
+++ b/src/libenvexec/env_get.c
diff --git a/src/libstddjb/env_get2.c b/src/libenvexec/env_get2.c
index 5909ea6..5909ea6 100644
--- a/src/libstddjb/env_get2.c
+++ b/src/libenvexec/env_get2.c
diff --git a/src/libstddjb/env_len.c b/src/libenvexec/env_len.c
index eef30c4..eef30c4 100644
--- a/src/libstddjb/env_len.c
+++ b/src/libenvexec/env_len.c
diff --git a/src/libstddjb/env_make.c b/src/libenvexec/env_make.c
index 60148f8..60148f8 100644
--- a/src/libstddjb/env_make.c
+++ b/src/libenvexec/env_make.c
diff --git a/src/libenvexec/env_merg.c b/src/libenvexec/env_merg.c
new file mode 100644
index 0000000..3c403ae
--- /dev/null
+++ b/src/libenvexec/env_merg.c
@@ -0,0 +1,8 @@
+/* ISC license. */
+
+#include <skalibs/env.h>
+
+size_t env_merg (char const **v, size_t vmax, char const *const *envp, char const *modifs, size_t modiflen)
+{
+ return env_merge(v, vmax, envp, env_len(envp), modifs, modiflen) ;
+}
diff --git a/src/libenvexec/env_merge.c b/src/libenvexec/env_merge.c
new file mode 100644
index 0000000..ac3e17c
--- /dev/null
+++ b/src/libenvexec/env_merge.c
@@ -0,0 +1,9 @@
+/* ISC license. */
+
+#include <skalibs/bytestr.h>
+#include <skalibs/env.h>
+
+size_t env_merge (char const **v, size_t vmax, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen)
+{
+ return env_mergen(v, vmax, envp, envlen, modifs, modiflen, byte_count(modifs, modiflen, '\0')) ;
+}
diff --git a/src/libstddjb/env_merge.c b/src/libenvexec/env_mergen.c
index 5543e08..acc7c39 100644
--- a/src/libstddjb/env_merge.c
+++ b/src/libenvexec/env_mergen.c
@@ -2,12 +2,12 @@
#include <string.h>
#include <errno.h>
+
#include <skalibs/bytestr.h>
#include <skalibs/env.h>
-size_t env_merge (char const **v, size_t vmax, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen)
+size_t env_mergen (char const **v, size_t vmax, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen, size_t n)
{
- size_t n = byte_count(modifs, modiflen, '\0') ;
size_t vlen = envlen ;
size_t i = 0 ;
if (envlen + n + 1 > vmax) return (errno = ENAMETOOLONG, 0) ;
diff --git a/src/libenvexec/env_mergn.c b/src/libenvexec/env_mergn.c
new file mode 100644
index 0000000..a8a93c1
--- /dev/null
+++ b/src/libenvexec/env_mergn.c
@@ -0,0 +1,8 @@
+/* ISC license. */
+
+#include <skalibs/env.h>
+
+size_t env_mergn (char const **v, size_t vmax, char const *const *envp, char const *modifs, size_t modiflen, size_t modifn)
+{
+ return env_mergen(v, vmax, envp, env_len(envp), modifs, modiflen, modifn) ;
+}
diff --git a/src/libstddjb/env_string.c b/src/libenvexec/env_string.c
index e30f095..e30f095 100644
--- a/src/libstddjb/env_string.c
+++ b/src/libenvexec/env_string.c
diff --git a/src/libstddjb/envalloc_0.c b/src/libenvexec/envalloc_0.c
index 114f69e..114f69e 100644
--- a/src/libstddjb/envalloc_0.c
+++ b/src/libenvexec/envalloc_0.c
diff --git a/src/libstddjb/envalloc_make.c b/src/libenvexec/envalloc_make.c
index f8c459a..f8c459a 100644
--- a/src/libstddjb/envalloc_make.c
+++ b/src/libenvexec/envalloc_make.c
diff --git a/src/libstddjb/envalloc_merge.c b/src/libenvexec/envalloc_merge.c
index 2747f50..84716e4 100644
--- a/src/libstddjb/envalloc_merge.c
+++ b/src/libenvexec/envalloc_merge.c
@@ -9,7 +9,7 @@ int envalloc_merge (genalloc *v, char const *const *envp, size_t envlen, char co
{
size_t n = envlen + 1 + byte_count(modifs, modiflen, '\0') ;
if (!genalloc_readyplus(char const *, v, n)) return 0 ;
- n = env_merge(genalloc_s(char const *, v) + genalloc_len(char const *, v), n, envp, envlen, modifs, modiflen) ;
+ n = env_mergen(genalloc_s(char const *, v) + genalloc_len(char const *, v), n, envp, envlen, modifs, modiflen, n) ;
genalloc_setlen(char const *, v, genalloc_len(char const *, v) + n) ;
return 1 ;
}
diff --git a/src/libstddjb/envalloc_uniq.c b/src/libenvexec/envalloc_uniq.c
index cf60b44..cf60b44 100644
--- a/src/libstddjb/envalloc_uniq.c
+++ b/src/libenvexec/envalloc_uniq.c
diff --git a/src/libstddjb/envdir.c b/src/libenvexec/envdir.c
index 6992654..6992654 100644
--- a/src/libstddjb/envdir.c
+++ b/src/libenvexec/envdir.c
diff --git a/src/libenvexec/exec0_ae.c b/src/libenvexec/exec0_ae.c
new file mode 100644
index 0000000..14aac8b
--- /dev/null
+++ b/src/libenvexec/exec0_ae.c
@@ -0,0 +1,11 @@
+/* ISC license. */
+
+#include <unistd.h>
+
+#include <skalibs/exec.h>
+
+void exec0_ae (char const *file, char const *const *argv, char const *const *envp)
+{
+ if (!argv[0]) _exit(0) ;
+ exec_ae(file, argv, envp) ;
+}
diff --git a/src/libstddjb/pathexec_run.c b/src/libenvexec/exec_ae.c
index 5888ba2..3c28722 100644
--- a/src/libstddjb/pathexec_run.c
+++ b/src/libenvexec/exec_ae.c
@@ -1,11 +1,12 @@
/* ISC license. */
#include <stdlib.h>
+
#include <skalibs/config.h>
#include <skalibs/posixplz.h>
-#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
-void pathexec_run (char const *file, char const *const *argv, char const *const *envp)
+void exec_ae (char const *file, char const *const *argv, char const *const *envp)
{
char const *path = getenv("PATH") ;
if (!path) path = SKALIBS_DEFAULTPATH ;
diff --git a/src/libenvexec/mexec0_af.c b/src/libenvexec/mexec0_af.c
new file mode 100644
index 0000000..97e228d
--- /dev/null
+++ b/src/libenvexec/mexec0_af.c
@@ -0,0 +1,11 @@
+/* ISC license. */
+
+#include <unistd.h>
+
+#include <skalibs/exec.h>
+
+void mexec0_af (char const *file, char const *const *argv, char const *const *envp, size_t envlen)
+{
+ if (!argv[0]) _exit(0) ;
+ mexec_af(file, argv, envp, envlen) ;
+}
diff --git a/src/libenvexec/mexec0_afm.c b/src/libenvexec/mexec0_afm.c
new file mode 100644
index 0000000..1ece07e
--- /dev/null
+++ b/src/libenvexec/mexec0_afm.c
@@ -0,0 +1,11 @@
+/* ISC license. */
+
+#include <unistd.h>
+
+#include <skalibs/exec.h>
+
+void mexec0_afm (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen)
+{
+ if (!argv[0]) _exit(0) ;
+ mexec_afm(file, argv, envp, envlen, modif, modiflen) ;
+}
diff --git a/src/libenvexec/mexec0_afn.c b/src/libenvexec/mexec0_afn.c
new file mode 100644
index 0000000..160a509
--- /dev/null
+++ b/src/libenvexec/mexec0_afn.c
@@ -0,0 +1,11 @@
+/* ISC license. */
+
+#include <unistd.h>
+
+#include <skalibs/exec.h>
+
+void mexec0_afn (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen, size_t modifn)
+{
+ if (!argv[0]) _exit(0) ;
+ mexec_afn(file, argv, envp, envlen, modif, modiflen, modifn) ;
+}
diff --git a/src/libenvexec/mexec_af.c b/src/libenvexec/mexec_af.c
new file mode 100644
index 0000000..34c266a
--- /dev/null
+++ b/src/libenvexec/mexec_af.c
@@ -0,0 +1,17 @@
+/* ISC license. */
+
+#include <skalibs/stralloc.h>
+#include <skalibs/env.h>
+#include <skalibs/exec.h>
+
+static stralloc modifsa = STRALLOC_ZERO ;
+
+int env_mexec (char const *key, char const *value)
+{
+ return env_addmodif(&modifsa, key, value) ;
+}
+
+void mexec_af (char const *file, char const *const *argv, char const *const *envp, size_t envlen)
+{
+ mexec_afm(file, argv, envp, envlen, modifsa.s, modifsa.len) ;
+}
diff --git a/src/libenvexec/mexec_afm.c b/src/libenvexec/mexec_afm.c
new file mode 100644
index 0000000..01571a1
--- /dev/null
+++ b/src/libenvexec/mexec_afm.c
@@ -0,0 +1,9 @@
+/* ISC license. */
+
+#include <skalibs/bytestr.h>
+#include <skalibs/exec.h>
+
+void mexec_afm (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen)
+{
+ mexec_afn(file, argv, envp, envlen, modif, modiflen, byte_count(modif, modiflen, '\0')) ;
+}
diff --git a/src/libenvexec/mexec_afn.c b/src/libenvexec/mexec_afn.c
new file mode 100644
index 0000000..278be11
--- /dev/null
+++ b/src/libenvexec/mexec_afn.c
@@ -0,0 +1,11 @@
+/* ISC license. */
+
+#include <skalibs/env.h>
+#include <skalibs/exec.h>
+
+void mexec_afn (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen, size_t modifn)
+{
+ char const *newenvp[envlen + modifn + 1] ;
+ env_mergen(newenvp, envlen + modifn + 1, envp, envlen, modif, modiflen, modifn) ;
+ exec_ae(file, argv, newenvp) ;
+}
diff --git a/src/libenvexec/xexec0_ae.c b/src/libenvexec/xexec0_ae.c
new file mode 100644
index 0000000..f0bd39c
--- /dev/null
+++ b/src/libenvexec/xexec0_ae.c
@@ -0,0 +1,11 @@
+/* ISC license. */
+
+#include <unistd.h>
+
+#include <skalibs/exec.h>
+
+void xexec0_ae (char const *file, char const *const *argv, char const *const *envp)
+{
+ if (!argv[0]) _exit(0) ;
+ xexec_ae(file, argv, envp) ;
+}
diff --git a/src/libenvexec/xexec_ae.c b/src/libenvexec/xexec_ae.c
new file mode 100644
index 0000000..55b7c70
--- /dev/null
+++ b/src/libenvexec/xexec_ae.c
@@ -0,0 +1,12 @@
+/* ISC license. */
+
+#include <errno.h>
+
+#include <skalibs/exec.h>
+#include <skalibs/strerr2.h>
+
+void xexec_ae (char const *file, char const *const *argv, char const *const *envp)
+{
+ exec_ae(file, argv, envp) ;
+ strerr_dieexec(errno == ENOENT ? 127 : 126, file) ;
+}
diff --git a/src/libstddjb/xexecvep.c b/src/libenvexec/xexecvep.c
index 17a3abf..c272401 100644
--- a/src/libstddjb/xexecvep.c
+++ b/src/libenvexec/xexecvep.c
@@ -1,9 +1,10 @@
/* ISC license. */
#include <errno.h>
+
#include <skalibs/posixplz.h>
-#include <skalibs/djbunix.h>
#include <skalibs/strerr2.h>
+#include <skalibs/exec.h>
void xexecvep (char const *file, char const *const *argv, char const *const *envp, char const *path)
{
diff --git a/src/libenvexec/xexecvep_loose.c b/src/libenvexec/xexecvep_loose.c
new file mode 100644
index 0000000..a9935a6
--- /dev/null
+++ b/src/libenvexec/xexecvep_loose.c
@@ -0,0 +1,13 @@
+/* ISC license. */
+
+#include <errno.h>
+
+#include <skalibs/posixplz.h>
+#include <skalibs/strerr2.h>
+#include <skalibs/exec.h>
+
+void xexecvep_loose (char const *file, char const *const *argv, char const *const *envp, char const *path)
+{
+ xexecvep_loose(file, argv, envp, path) ;
+ strerr_dieexec(errno == ENOENT ? 127 : 126, file) ;
+}
diff --git a/src/libenvexec/xmexec0_af.c b/src/libenvexec/xmexec0_af.c
new file mode 100644
index 0000000..a0bf84d
--- /dev/null
+++ b/src/libenvexec/xmexec0_af.c
@@ -0,0 +1,12 @@
+/* ISC license. */
+
+#include <errno.h>
+
+#include <skalibs/exec.h>
+#include <skalibs/strerr2.h>
+
+void xmexec0_af (char const *file, char const *const *argv, char const *const *envp, size_t envlen)
+{
+ xmexec0_af(file, argv, envp, envlen) ;
+ strerr_dieexec(errno == ENOENT ? 127 : 126, file) ;
+}
diff --git a/src/libenvexec/xmexec0_afm.c b/src/libenvexec/xmexec0_afm.c
new file mode 100644
index 0000000..a43cb49
--- /dev/null
+++ b/src/libenvexec/xmexec0_afm.c
@@ -0,0 +1,12 @@
+/* ISC license. */
+
+#include <errno.h>
+
+#include <skalibs/exec.h>
+#include <skalibs/strerr2.h>
+
+void xmexec0_afm (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen)
+{
+ mexec0_afm(file, argv, envp, envlen, modif, modiflen) ;
+ strerr_dieexec(errno == ENOENT ? 127 : 126, file) ;
+}
diff --git a/src/libenvexec/xmexec0_afn.c b/src/libenvexec/xmexec0_afn.c
new file mode 100644
index 0000000..73eeb04
--- /dev/null
+++ b/src/libenvexec/xmexec0_afn.c
@@ -0,0 +1,12 @@
+/* ISC license. */
+
+#include <errno.h>
+
+#include <skalibs/exec.h>
+#include <skalibs/strerr2.h>
+
+void xmexec0_afn (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen, size_t modifn)
+{
+ mexec0_afn(file, argv, envp, envlen, modif, modiflen, modifn) ;
+ strerr_dieexec(errno == ENOENT ? 127 : 126, file) ;
+}
diff --git a/src/libenvexec/xmexec_af.c b/src/libenvexec/xmexec_af.c
new file mode 100644
index 0000000..240220b
--- /dev/null
+++ b/src/libenvexec/xmexec_af.c
@@ -0,0 +1,12 @@
+/* ISC license. */
+
+#include <errno.h>
+
+#include <skalibs/exec.h>
+#include <skalibs/strerr2.h>
+
+void xmexec_af (char const *file, char const *const *argv, char const *const *envp, size_t envlen)
+{
+ xmexec_af(file, argv, envp, envlen) ;
+ strerr_dieexec(errno == ENOENT ? 127 : 126, file) ;
+}
diff --git a/src/libenvexec/xmexec_afm.c b/src/libenvexec/xmexec_afm.c
new file mode 100644
index 0000000..ac86c3a
--- /dev/null
+++ b/src/libenvexec/xmexec_afm.c
@@ -0,0 +1,12 @@
+/* ISC license. */
+
+#include <errno.h>
+
+#include <skalibs/exec.h>
+#include <skalibs/strerr2.h>
+
+void xmexec_afm (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen)
+{
+ mexec_afm(file, argv, envp, envlen, modif, modiflen) ;
+ strerr_dieexec(errno == ENOENT ? 127 : 126, file) ;
+}
diff --git a/src/libenvexec/xmexec_afn.c b/src/libenvexec/xmexec_afn.c
new file mode 100644
index 0000000..93f0c33
--- /dev/null
+++ b/src/libenvexec/xmexec_afn.c
@@ -0,0 +1,12 @@
+/* ISC license. */
+
+#include <errno.h>
+
+#include <skalibs/exec.h>
+#include <skalibs/strerr2.h>
+
+void xmexec_afn (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen, size_t modifn)
+{
+ mexec_afn(file, argv, envp, envlen, modif, modiflen, modifn) ;
+ strerr_dieexec(errno == ENOENT ? 127 : 126, file) ;
+}
diff --git a/src/libstddjb/pathexec.c b/src/libstddjb/pathexec.c
deleted file mode 100644
index da8788c..0000000
--- a/src/libstddjb/pathexec.c
+++ /dev/null
@@ -1,12 +0,0 @@
-/* ISC license. */
-
-/* MT-unsafe */
-
-#include <skalibs/env.h>
-#include <skalibs/djbunix.h>
-#include <skalibs/posixplz.h>
-
-void pathexec (char const *const *argv)
-{
- pathexec_fromenv(argv, (char const **)environ, env_len((char const **)environ)) ;
-}
diff --git a/src/libstddjb/pathexec0.c b/src/libstddjb/pathexec0.c
deleted file mode 100644
index bfddfdf..0000000
--- a/src/libstddjb/pathexec0.c
+++ /dev/null
@@ -1,10 +0,0 @@
-/* ISC license. */
-
-#include <unistd.h>
-#include <skalibs/djbunix.h>
-
-void pathexec0 (char const *const *argv)
-{
- if (!argv[0]) _exit(0) ;
- pathexec(argv) ;
-}
diff --git a/src/libstddjb/pathexec0_run.c b/src/libstddjb/pathexec0_run.c
deleted file mode 100644
index 818877e..0000000
--- a/src/libstddjb/pathexec0_run.c
+++ /dev/null
@@ -1,10 +0,0 @@
-/* ISC license. */
-
-#include <unistd.h>
-#include <skalibs/djbunix.h>
-
-void pathexec0_run (char const *const *argv, char const *const *envp)
-{
- if (!argv[0]) _exit(0) ;
- pathexec_run(argv[0], argv, envp) ;
-}
diff --git a/src/libstddjb/pathexec_fromenv.c b/src/libstddjb/pathexec_fromenv.c
deleted file mode 100644
index f9c973b..0000000
--- a/src/libstddjb/pathexec_fromenv.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/stralloc.h>
-#include <skalibs/env.h>
-#include <skalibs/djbunix.h>
-
-static stralloc plus = STRALLOC_ZERO ;
-
-int pathexec_env (char const *s, char const *t) /* historic, bad name */
-{
- return env_addmodif(&plus, s, t) ;
-}
-
-void pathexec_fromenv (char const *const *argv, char const *const *envp, size_t envlen)
-{
- pathexec_r(argv, envp, envlen, plus.s, plus.len) ;
-}
diff --git a/src/libstddjb/pathexec_r.c b/src/libstddjb/pathexec_r.c
deleted file mode 100644
index fe05434..0000000
--- a/src/libstddjb/pathexec_r.c
+++ /dev/null
@@ -1,8 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/djbunix.h>
-
-void pathexec_r (char const *const *argv, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen)
-{
- pathexec_r_name(argv[0], argv, envp, envlen, modifs, modiflen) ;
-}
diff --git a/src/libstddjb/pathexec_r_name.c b/src/libstddjb/pathexec_r_name.c
deleted file mode 100644
index 29c0863..0000000
--- a/src/libstddjb/pathexec_r_name.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/bytestr.h>
-#include <skalibs/env.h>
-#include <skalibs/djbunix.h>
-
-void pathexec_r_name (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen)
-{
- size_t n = envlen + 1 + byte_count(modifs, modiflen, '\0') ;
- char const *v[n] ;
- if (env_merge(v, n, envp, envlen, modifs, modiflen))
- pathexec_run(file, argv, v) ;
-}
diff --git a/src/libstddjb/xpathexec.c b/src/libstddjb/xpathexec.c
deleted file mode 100644
index 473f682..0000000
--- a/src/libstddjb/xpathexec.c
+++ /dev/null
@@ -1,12 +0,0 @@
-/* ISC license. */
-
-#include <errno.h>
-
-#include <skalibs/djbunix.h>
-#include <skalibs/strerr2.h>
-
-void xpathexec (char const *const *argv)
-{
- pathexec(argv) ;
- strerr_dieexec(errno == ENOENT ? 127 : 126, argv[0]) ;
-}
diff --git a/src/libstddjb/xpathexec0.c b/src/libstddjb/xpathexec0.c
deleted file mode 100644
index ed0848c..0000000
--- a/src/libstddjb/xpathexec0.c
+++ /dev/null
@@ -1,12 +0,0 @@
-/* ISC license. */
-
-#include <errno.h>
-
-#include <skalibs/djbunix.h>
-#include <skalibs/strerr2.h>
-
-void xpathexec0 (char const *const *argv)
-{
- pathexec0(argv) ;
- strerr_dieexec(errno == ENOENT ? 127 : 126, argv[0]) ;
-}
diff --git a/src/libstddjb/xpathexec0_run.c b/src/libstddjb/xpathexec0_run.c
deleted file mode 100644
index ab3e645..0000000
--- a/src/libstddjb/xpathexec0_run.c
+++ /dev/null
@@ -1,12 +0,0 @@
-/* ISC license. */
-
-#include <errno.h>
-
-#include <skalibs/djbunix.h>
-#include <skalibs/strerr2.h>
-
-void xpathexec0_run (char const *const *argv, char const *const *envp)
-{
- pathexec0_run(argv, envp) ;
- strerr_dieexec(errno == ENOENT ? 127 : 126, argv[0]) ;
-}
diff --git a/src/libstddjb/xpathexec_fromenv.c b/src/libstddjb/xpathexec_fromenv.c
deleted file mode 100644
index c434331..0000000
--- a/src/libstddjb/xpathexec_fromenv.c
+++ /dev/null
@@ -1,12 +0,0 @@
-/* ISC license. */
-
-#include <errno.h>
-
-#include <skalibs/djbunix.h>
-#include <skalibs/strerr2.h>
-
-void xpathexec_fromenv (char const *const *argv, char const *const *envp, size_t envlen)
-{
- pathexec_fromenv(argv, envp, envlen) ;
- strerr_dieexec(errno == ENOENT ? 127 : 126, argv[0]) ;
-}
diff --git a/src/libstddjb/xpathexec_r.c b/src/libstddjb/xpathexec_r.c
deleted file mode 100644
index a44fc0f..0000000
--- a/src/libstddjb/xpathexec_r.c
+++ /dev/null
@@ -1,12 +0,0 @@
-/* ISC license. */
-
-#include <errno.h>
-
-#include <skalibs/djbunix.h>
-#include <skalibs/strerr2.h>
-
-void xpathexec_r (char const *const *argv, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen)
-{
- pathexec_r(argv, envp, envlen, modifs, modiflen) ;
- strerr_dieexec(errno == ENOENT ? 127 : 126, argv[0]) ;
-}
diff --git a/src/libstddjb/xpathexec_r_name.c b/src/libstddjb/xpathexec_r_name.c
deleted file mode 100644
index cd118f5..0000000
--- a/src/libstddjb/xpathexec_r_name.c
+++ /dev/null
@@ -1,12 +0,0 @@
-/* ISC license. */
-
-#include <errno.h>
-
-#include <skalibs/djbunix.h>
-#include <skalibs/strerr2.h>
-
-void xpathexec_r_name (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen)
-{
- pathexec_r_name(file, argv, envp, envlen, modifs, modiflen) ;
- strerr_dieexec(errno == ENOENT ? 127 : 126, file) ;
-}
diff --git a/src/libstddjb/xpathexec_run.c b/src/libstddjb/xpathexec_run.c
deleted file mode 100644
index 7c054ee..0000000
--- a/src/libstddjb/xpathexec_run.c
+++ /dev/null
@@ -1,12 +0,0 @@
-/* ISC license. */
-
-#include <errno.h>
-
-#include <skalibs/djbunix.h>
-#include <skalibs/strerr2.h>
-
-void xpathexec_run (char const *file, char const *const *argv, char const *const *envp)
-{
- pathexec_run(file, argv, envp) ;
- strerr_dieexec(errno == ENOENT ? 127 : 126, file) ;
-}