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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [sys/] [sysvi386/] [exec.c] - Blame information for rev 207

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
#include <sys/unistd.h>
2
#include <errno.h>
3
 
4
extern char **environ;
5
 
6
int
7
execv (const char *path, char * const *args) {
8
        extern int execve (const char *, char * const *, char * const*);
9
        return execve (path, args, environ);
10
}
11
 
12
int
13
execl(const char *path, const char *arg1, ...) {
14
        return execv (path, &arg1);
15
}
16
 
17
/*
18
 * Copy string, until c or <nul> is encountered.
19
 * NUL-terminate the destination string (s1).
20
 */
21
 
22
static char *
23
strccpy (char *s1, char *s2, char c) {
24
        char *dest = s1;
25
        while (*s2 && *s2 != c) {
26
                *s1++ = *s2++;
27
        }
28
        *s1 = 0;
29
        return dest;
30
}
31
 
32
int
33
execvp(const char *file, char * const *args) {
34
        extern char *getenv (const char *);
35
        char *path = getenv ("PATH");
36
        char buf[MAXNAMLEN];
37
 
38
        if (file[0] == '/') {    /* absolute pathname -- easy out */
39
                return execv (file, args);
40
        }
41
 
42
        buf[0] = 0;       /* lots of initialization here 8-) */
43
        while (*path) {
44
                strccpy (buf, path, ':');
45
                strcat (buf, "/");
46
                strcat (buf, file);
47
                execv (buf, args);
48
                if (errno != ENOENT)
49
                        return -1;
50
                while (*path && *path != ':')
51
                        path++;
52
        }
53
        return -1;
54
}

powered by: WebSVN 2.1.0

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