~ubuntu-branches/ubuntu/intrepid/ecl/intrepid

« back to all changes in this revision

Viewing changes to src/gc/if_not_there.c

  • Committer: Bazaar Package Importer
  • Author(s): Peter Van Eynde
  • Date: 2006-05-17 02:46:26 UTC
  • Revision ID: james.westby@ubuntu.com-20060517024626-lljr08ftv9g9vefl
Tags: upstream-0.9h-20060510
ImportĀ upstreamĀ versionĀ 0.9h-20060510

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
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