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

1.1     ! root        1: #include <ctype.h>
        !             2: #include <stdio.h>
        !             3: 
        !             4: void adios();
        !             5: 
        !             6: main(argc, argv)
        !             7: int argc; char *argv[];
        !             8: {
        !             9:        extern FILE *fdopen();
        !            10:        FILE *fd;
        !            11:        int fo;
        !            12:        int holder;
        !            13: 
        !            14:        if (--argc != 1)
        !            15:                adios("Usage: fdopen example_filename");
        !            16:        if ((fo = open(argv[1], 0)) == -1)
        !            17:                adios("open failed.");
        !            18:        if ((fd = fdopen(fo, "r")) == NULL)
        !            19:                adios("fdopen failed.");
        !            20: 
        !            21:        while ((holder = fgetc(fd)) != EOF) {
        !            22:                if ((holder > '\177') && (holder < ' '))
        !            23:                        switch(holder) {
        !            24:                                case '\t':
        !            25:                                case '\n':
        !            26:                                        break;
        !            27:                                default:
        !            28:                                        fprintf(stderr, 
        !            29:                                        "Seeing char %d\n", holder);
        !            30:                                        exit(1);
        !            31:                        }
        !            32:                fputc(holder, stdout);
        !            33:        }
        !            34:        exit(0);
        !            35: }
        !            36: 
        !            37: void adios(message)
        !            38: char *message;
        !            39: {
        !            40:        fprintf(stderr, "%s\n", message);
        !            41:        exit(1);
        !            42: }

unix.superglobalmegacorp.com

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