1
2 /*
3 /* execv: function to chain to another C-generated com file, with text argument passing.
4 /*
5 /* Calling sequence:
6 /* execv(prog, args);
7 /* char *prog, char *args[];
8 /*
9 /* where
10 /* prog is the name of the program being executed next
11 /* args is a NULL terminated string array, with the 'prog' command on top
12 /*
13 /* This function is based on the simplified implementation of execl()
14 */
15
16 #include <unistd.h>
17 #include <stdlib.h>
18 #include <string.h>
19
execv(const char * cpm_prog,const char * cpm_args[])20 int execv(const char *cpm_prog, const char *cpm_args[])
21 {
22 int cpm_argc;
23 char cpm_arglist[110];
24
25 if (!cpm_args[0])
26 return (-1);
27
28 if ((!cpm_args[1]) || (!cpm_args[2]))
29 return (execl(cpm_prog,""));
30
31 strcpy(cpm_arglist, cpm_args[1]);
32 cpm_argc=2;
33
34 while (cpm_args[cpm_argc]) {
35 strcat(cpm_arglist, " ");
36 strcat(cpm_arglist, cpm_args[cpm_argc++]);
37 }
38 return (execl(cpm_prog,cpm_arglist));
39 }
40
41