OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uC-libc/] [misc/] [execvep.c] - Blame information for rev 1775

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
 
2
#include <unistd.h>
3
#include <stdlib.h>
4
#include <string.h>
5
#include <errno.h>
6
 
7
int execvep(path, argv, envp)
8
const char * path;
9
const char * argv[];
10
const char * envp[];
11
{
12
        if (!strchr(path, '/')) {
13
                char partial[128];
14
                char * p = getenv("PATH");
15
                char * p2;
16
 
17
                if (!p)
18
                        p = "/bin:/usr/bin";
19
 
20
                for (;p && *p;) {
21
 
22
                        strcpy(partial, p);
23
 
24
                        p2 = strchr(partial, ':');
25
                        if (p2)
26
                                *p2 = '\0';
27
 
28
                        if (strlen(partial))
29
                                strcat(partial, "/");
30
                        strcat(partial, path);
31
 
32
                        execve(partial, argv, envp);
33
 
34
                        if (errno != ENOENT)
35
                                return -1;
36
 
37
                        p2 = strchr(p, ':');
38
                        if (p2)
39
                                p = p2 + 1;
40
                        else
41
                                p = 0;
42
                }
43
                return -1;
44
        } else
45
                return execve(path, argv, envp);
46
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.