source: trunk/gc6.8/if_not_there.c

Last change on this file was 132, checked in by cinc, 19 years ago

Boehm-Demers-Weiser garbage collector. Single-threaded for OS/2.

File size: 876 bytes
Line 
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#ifdef __DJGPP__
8#include <dirent.h>
9#endif /* __DJGPP__ */
10
11int main(argc, argv, envp)
12int argc;
13char ** argv;
14char ** 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
37Usage:
38 fprintf(stderr, "Usage: %s file_name command\n", argv[0]);
39 return(1);
40}
41
Note: See TracBrowser for help on using the repository browser.