wexec.h (1629B)
1 /* see LICENSE file for copyright and license details */ 2 #ifndef ARUU_WEXEC_H 3 #define ARUU_WEXEC_H 4 5 #include <stdio.h> 6 #include <sys/types.h> 7 8 typedef int (*wexec_fn)(int argc, char **argv); 9 10 int wexec_register(const char *name, wexec_fn fn); 11 int wexec_is_builtin(const char *name); 12 void wexec_register_env_lookup(char *(*fn)(const char *name)); 13 #if FEATURE_NOEXEC || FEATURE_NOFORK 14 int wexec_call_builtin(const char *name, char *const *argv); 15 void wexec_exit(int code) __attribute__((noreturn)); 16 #endif 17 18 /* search path for name, returns emallocd absolute path or null if not found 19 * when feature_noexec is compiled in and builtin dispatch is enabled, 20 * returns null for registered builtins (they have no filesystem path) */ 21 char *wwhich(const char *name); 22 23 int wexec_is_nofork(const char *name); 24 25 #if FEATURE_NOEXEC 26 void wexec_set_noexec(int enabled); 27 int wexec_get_noexec(void); 28 #else 29 #define wexec_get_noexec() 0 30 #endif 31 32 #if FEATURE_NOFORK 33 void wexec_set_nofork(int enabled); 34 int wexec_get_nofork(void); 35 #else 36 #define wexec_get_nofork() 0 37 #endif 38 39 int wexecvp(const char *name, char *const *argv); 40 int wexecv(const char *path, char *const *argv); 41 42 FILE *wpopen(const char *name, char *const *argv, const char *mode); 43 int wpclose(FILE *fp); 44 45 int wsystem(const char *cmd); 46 47 void wexecvp_self(const char *name, char *const *argv) __attribute__((noreturn)); 48 void wexecv_self(const char *path, char *const *argv) __attribute__((noreturn)); 49 void wexecve_self(const char *path, char *const *argv, char *const *envp) __attribute__((noreturn)); 50 51 int wpopen_track(FILE *fp, pid_t pid); 52 pid_t wpopen_untrack(FILE *fp); 53 54 #endif