[BACK]Return to if_not_there.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / gc

Annotation of OpenXM_contrib2/asir2000/gc/if_not_there.c, Revision 1.2

1.1       noro        1: /* Conditionally execute a command based if the file argv[1] doesn't exist */
                      2: /* Except for execvp, we stick to ANSI C.                                 */
1.2     ! noro        3: # include "private/gcconfig.h"
1.1       noro        4: # include <stdio.h>
1.2     ! noro        5: # include <stdlib.h>
        !             6: # include <unistd.h>
1.1       noro        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");
1.2     ! noro       21:     fflush(stdout);
1.1       noro       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:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>