-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete revamp of the pathexec functions
- pathexec_run is now called exec_ae a for provided file name (default: argv[0]) e for provided envp (default: environ) - pathexec is now called mexec. m for merge environment. Option letters are: a for provided file name (default: argv[0]) e for provided envp (default: environ) f for provided envp *and* length of the envp m for provided modif string plus its length (the length is always needed because the modifs are null-terminated) n for provided modif string, length *and* number of modifs - functions have a foo0 version for _exit(0) when argv[0] is null - functions have a xfoo version to die if the exec fails - and a xfoo0 - Compatibility #defines and #includes are there until the next major bump
- Loading branch information
Showing
54 changed files
with
435 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) ; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')) ; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) ; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) ; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) ; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) ; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) ; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) ; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')) ; | ||
} |
Oops, something went wrong.