Annotation of coherent/d/usr/src/examples/fgets.c, revision 1.1.1.1

1.1       root        1: #include <stdio.h>
                      2: #define MAXLINE 128
                      3: 
                      4: void fatal();
                      5: char buf[MAXLINE];
                      6: 
                      7: main(argc, argv)
                      8: int argc; 
                      9: char *argv[];
                     10: {
                     11:        if (argc != 2 && argc != 3)
                     12:                fatal("Usage: fgets pattern [ file ]");
                     13: 
                     14:        if (argc==3 && freopen(argv[2], "r", stdin) == NULL)
                     15:                fatal("cannot open input file");
                     16: 
                     17:        while (fgets(buf, MAXLINE, stdin) != NULL) {
                     18:                if (pnmatch(buf, argv[1], 1))
                     19:                        printf("%s", buf);
                     20:        }
                     21:        exit(0);
                     22: }
                     23: 
                     24: void fatal(s) char *s;
                     25: {
                     26:        fprintf(stderr, "fgets: %s\n", s);
                     27:        exit(1);
                     28: }
                     29: 

unix.superglobalmegacorp.com

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