Annotation of coherent/d/usr/src/examples/access.c, revision 1.1

1.1     ! root        1: #include <access.h>
        !             2: #include <stdio.h>
        !             3: 
        !             4: main(argc, argv)
        !             5: int argc; char *argv[];
        !             6: {
        !             7:        int mode;
        !             8:        extern int access();
        !             9: 
        !            10:        if (argc != 3) {
        !            11:                fprintf(stderr, "Usage: access filename mode\n");
        !            12:                exit(1);
        !            13:        }
        !            14:        switch (*argv[2]) {
        !            15:        case 'x':
        !            16:                mode = AEXEC;
        !            17:                break;
        !            18:        case 'w':
        !            19:                mode = AWRITE;
        !            20:                break;
        !            21:        case 'r':
        !            22:                mode = AREAD;
        !            23:                break;
        !            24:        default:
        !            25:                fprintf(stderr, 
        !            26:                        "modes: x = execute, w = write, r = read\n");
        !            27:                exit(1);
        !            28:                break;
        !            29:        }
        !            30:        if (access(argv[1], mode)) {
        !            31:                printf("file %s not found in mode %d\n", argv[1], mode);
        !            32:                exit(0);
        !            33:        } else
        !            34:                printf("file %s accessible in mode %d\n",
        !            35:                                argv[1], mode);
        !            36:        exit(0);
        !            37: }
        !            38:                        

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.