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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [boehm-gc/] [if_not_there.c] - Blame information for rev 841

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

Line No. Rev Author Line
1 721 jeremybenn
/* Conditionally execute a command based if the file argv[1] doesn't exist */
2
/* Except for execvp, we stick to ANSI C.                                  */
3
# include "private/gcconfig.h"
4
# include <stdio.h>
5
# include <stdlib.h>
6
# include <unistd.h>
7
#ifdef __DJGPP__
8
#include <dirent.h>
9
#endif /* __DJGPP__ */
10
 
11
int main(argc, argv, envp)
12
int argc;
13
char ** argv;
14
char ** envp;
15
{
16
    FILE * f;
17
#ifdef __DJGPP__
18
    DIR * d;
19
#endif /* __DJGPP__ */
20
    if (argc < 3) goto Usage;
21
    if ((f = fopen(argv[1], "rb")) != 0
22
        || (f = fopen(argv[1], "r")) != 0) {
23
        fclose(f);
24
        return(0);
25
    }
26
#ifdef __DJGPP__
27
    if ((d = opendir(argv[1])) != 0) {
28
            closedir(d);
29
            return(0);
30
    }
31
#endif
32
    printf("^^^^Starting command^^^^\n");
33
    fflush(stdout);
34
    execvp(argv[2], argv+2);
35
    exit(1);
36
 
37
Usage:
38
    fprintf(stderr, "Usage: %s file_name command\n", argv[0]);
39
    return(1);
40
}
41
 

powered by: WebSVN 2.1.0

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