From 44a3841d6bf3e2743a86f7257689f45b2f1e343b Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 13 Apr 2015 16:55:04 +0200 Subject: basic wrapper --- testModule/wrap.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 testModule/wrap.c (limited to 'testModule') diff --git a/testModule/wrap.c b/testModule/wrap.c new file mode 100644 index 00000000..0f118235 --- /dev/null +++ b/testModule/wrap.c @@ -0,0 +1,41 @@ +#include +#include +#include +#include + +void arg_print(int argc, char *argv[]) { + int i = 0; + int j = 0; + for (i = 0; i < argc; i ++) { + j = 0; + while(argv[i][j] != '\0') + printf("%c", argv[i][j++]); + + printf(" "); + } + printf("\n"); +} + + +int main(int argc, char *argv[]) { + + arg_print(argc, argv); + + int count; + char **copy = malloc(sizeof(char *) * (argc-1)); + for ( count = 0; count < argc - 1; count++ ) { + copy[count] = strdup(argv[count + 1]); + } + + arg_print(argc - 1, copy); + + copy[0][0] = '@'; + argv[0][0] = '@'; + + arg_print(argc - 1, copy); + + if (-1 == execvp(argv[1], copy)) { + perror("child process execve failed [%m]"); + return -1; + } +} -- cgit v1.2.3-55-g7522