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

Subversion Repositories or1k

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

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 <stdarg.h>
4
 
5
extern char ** environ;
6
 
7
int execl(path, arg)
8
const char * path;
9
const char * arg;
10
{
11
        const char *shortargv[16];
12
        const char **argv;
13
        const char * c;
14
        int i;
15
        va_list args;
16
 
17
        i = 1;
18
 
19
        va_start(args, arg);
20
 
21
        do {
22
          c = va_arg (args, const char *);
23
          i++;
24
        } while (c);
25
 
26
        va_end(args);
27
 
28
        if (i <= 16)
29
                argv = shortargv;
30
        else {
31
                argv = (const char**)malloc(sizeof(char*) * i);
32
        }
33
 
34
        argv[0] = arg;
35
        i = 1;
36
 
37
        va_start(args, arg);
38
 
39
        do {
40
          argv[i] = va_arg (args, const char *);
41
        } while (argv[i++]);
42
 
43
        va_end(args);
44
 
45
        i = execve(path, argv, environ);
46
 
47
        if (argv != shortargv)
48
                free(argv);
49
 
50
        return i;
51
}

powered by: WebSVN 2.1.0

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