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

Annotation of OpenXM_contrib/gc/if_not_there.c, Revision 1.1

1.1     ! maekawa     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 "gcconfig.h"
        !             4: # include <stdio.h>
        !             5:
        !             6: int main(argc, argv, envp)
        !             7: int argc;
        !             8: char ** argv;
        !             9: char ** envp;
        !            10: {
        !            11:     FILE * f;
        !            12:     if (argc < 3) goto Usage;
        !            13:     if ((f = fopen(argv[1], "rb")) != 0
        !            14:         || (f = fopen(argv[1], "r")) != 0) {
        !            15:         fclose(f);
        !            16:         return(0);
        !            17:     }
        !            18:     printf("^^^^Starting command^^^^\n");
        !            19:     execvp(argv[2], argv+2);
        !            20:     exit(1);
        !            21:
        !            22: Usage:
        !            23:     fprintf(stderr, "Usage: %s file_name command\n", argv[0]);
        !            24:     return(1);
        !            25: }
        !            26:

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