diff options
Diffstat (limited to 'guts')
-rw-r--r-- | guts/execl.c | 30 | ||||
-rw-r--r-- | guts/execle.c | 32 | ||||
-rw-r--r-- | guts/execlp.c | 30 | ||||
-rw-r--r-- | guts/execv.c | 15 | ||||
-rw-r--r-- | guts/execvp.c | 15 |
5 files changed, 122 insertions, 0 deletions
diff --git a/guts/execl.c b/guts/execl.c new file mode 100644 index 0000000..92a4cdc --- /dev/null +++ b/guts/execl.c @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2010 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * static int + * wrap_execl(const char *path, const char *arg, va_list ap) { + * int rc = -1; + */ + + size_t i = 0; + size_t alloc_size = 256; + const char **argv = malloc(sizeof (const char *) * alloc_size); + + argv[i++] = arg; + + while (argv[i-1]) { + argv[i++] = va_arg (ap, const char *); + if ( i > alloc_size - 1 ) { + alloc_size = alloc_size + 256; + argv = realloc(argv, sizeof (const char *) * alloc_size); + } + } + + rc = wrap_execv (path, (char *const *) argv); + + free (argv); + +/* return rc; + * } + */ diff --git a/guts/execle.c b/guts/execle.c new file mode 100644 index 0000000..f4c2ea7 --- /dev/null +++ b/guts/execle.c @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2010 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * static int + * wrap_execle(const char *path, const char *arg, va_list ap) { + * int rc = -1; + */ + + size_t i = 0; + size_t alloc_size = 256; + const char **argv = malloc(sizeof (const char *) * alloc_size); + char *const *envp; + + argv[i++] = arg; + + while (argv[i-1]) { + argv[i++] = va_arg (ap, const char *); + if ( i > alloc_size - 1 ) { + alloc_size = alloc_size + 256; + argv = realloc(argv, sizeof (const char *) * alloc_size); + } + } + envp = va_arg (ap, char *const *); + + rc = wrap_execve (path, (char *const *) argv, envp); + + free (argv); + +/* return rc; + * } + */ diff --git a/guts/execlp.c b/guts/execlp.c new file mode 100644 index 0000000..8fd2cdf --- /dev/null +++ b/guts/execlp.c @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2010 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * static int + * wrap_execlp(const char *file, const char *arg, va_list ap) { + * int rc = -1; + */ + + size_t i = 0; + size_t alloc_size = 256; + const char **argv = malloc(sizeof (const char *) * alloc_size); + + argv[i++] = arg; + + while (argv[i-1]) { + argv[i++] = va_arg (ap, const char *); + if ( i > alloc_size - 1 ) { + alloc_size = alloc_size + 256; + argv = realloc(argv, sizeof (const char *) * alloc_size); + } + } + + rc = wrap_execvp (file, (char *const *) argv); + + free (argv); + +/* return rc; + * } + */ diff --git a/guts/execv.c b/guts/execv.c new file mode 100644 index 0000000..3fec52a --- /dev/null +++ b/guts/execv.c @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2010 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * static int + * wrap_execv(const char *path, char *const *argv) { + * int rc = -1; + */ + environ = pseudo_setupenv(environ, getenv("PSEUDO_OPTS")); + + rc = real_execv(path, argv); + +/* return rc; + * } + */ diff --git a/guts/execvp.c b/guts/execvp.c new file mode 100644 index 0000000..64e4b4b --- /dev/null +++ b/guts/execvp.c @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2008-2010 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * static int + * wrap_execvp(const char *file, char *const *argv) { + * int rc = -1; + */ + environ = pseudo_setupenv(environ, getenv("PSEUDO_OPTS")); + + rc = real_execvp(file, argv); + +/* return rc; + * } + */ |