OSDN Git Service

* Makefile.direct, alloc.c: Resync to upstream 6.3 alpha 1.
[pf3gnuchains/gcc-fork.git] / boehm-gc / if_not_there.c
1 /* 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
8 int main(argc, argv, envp)
9 int argc;
10 char ** argv;
11 char ** envp;
12 {
13     FILE * f;
14     if (argc < 3) goto Usage;
15     if ((f = fopen(argv[1], "rb")) != 0
16         || (f = fopen(argv[1], "r")) != 0) {
17         fclose(f);
18         return(0);
19     }
20     printf("^^^^Starting command^^^^\n");
21     fflush(stdout);
22     execvp(argv[2], argv+2);
23     exit(1);
24     
25 Usage:
26     fprintf(stderr, "Usage: %s file_name command\n", argv[0]);
27     return(1);
28 }
29