]> diplodocus.org Git - nmh/blob - docs/historical/mh-jun-1982/Extras/libh/excsrh.c
Replaced use of snprintf() with memcpy()/memmove().
[nmh] / docs / historical / mh-jun-1982 / Extras / libh / excsrh.c
1 #ifdef COMMENT
2 Proprietary Rand Corporation, 1981.
3 Further distribution of this software
4 subject to the terms of the Rand
5 license agreement.
6 #endif
7
8 #
9 #include "../h/errors.h"
10
11 char *SRHLIST[] { /* upper case!! */
12 "",
13 "%",
14 "/bin/",
15 "/usr/bin/",
16 0
17 };
18
19 char **srhlist SRHLIST;
20
21 execvsrh(argv)
22 char **argv;
23 {
24 return(excvsrh(argv[0], argv));
25 }
26
27 excvsrh(prog, argv)
28 char *prog, **argv;
29 {
30 extern errno;
31 register char **r1, *r2, *r3;
32 static char command[50];
33
34 for (r1 = srhlist; r2 = *r1++; ) {
35 r3 = command;
36 if(*r2 == '%') {
37 r2 = getpath(getruid()&0377);
38 while(*r3++ = *r2++);
39 --r3;
40 r2 = "/bin/";
41 }
42 while (*r3++ = *r2++);
43 --r3;
44 r2 = prog;
45 while (*r3++ = *r2++);
46 if (execvsh(command, argv) != 0) break;
47 }
48 errtype(prog, errno==E2BIG?"arg list too long":"not found");
49 return(-1);
50 }
51 execlsrh(arg1,arg2,arg3)
52 char *arg1,*arg2,*arg3;
53 {
54 return(excvsrh(arg1, &arg1));
55 }
56
57 exclsrh(prog, arg1, arg2)
58 char *prog, *arg1, *arg2;
59 {
60 return(excvsrh(prog, &arg1));
61 }