Annotation of coherent/a/tmp/smail/utils/lcasep.c, revision 1.1

1.1     ! root        1: /*
        !             2: ** convert the host name on a pathalias line to lower case
        !             3: */
        !             4: 
        !             5: #ifndef lint
        !             6: static char    *sccsid="@(#)lcasep.c   2.5 (smail) 9/15/87";
        !             7: #endif
        !             8: 
        !             9: #include <stdio.h>
        !            10: #include <ctype.h>
        !            11: 
        !            12: # define lower(c)              ( isupper(c) ? c-'A'+'a' : c )
        !            13: 
        !            14: void exit(), perror();
        !            15: 
        !            16: main(argc, argv)
        !            17: int argc;
        !            18: char *argv[];
        !            19: {
        !            20:        FILE *ifp, *ofp;
        !            21:        char buf[BUFSIZ];
        !            22:        register char *p;
        !            23:        int c;
        !            24: 
        !            25:        extern int optind;
        !            26:        extern char *optarg;
        !            27: 
        !            28:        ifp = stdin;
        !            29:        ofp = stdout;
        !            30: 
        !            31:        while((c = getopt(argc, argv, "f:o:")) != EOF) {
        !            32:                switch(c) {
        !            33:                case 'f':
        !            34:                        if((ifp = fopen(optarg, "r")) == NULL) {
        !            35:                                (void) fprintf(stderr, "%s: can't open %s: ",
        !            36:                                        argv[0], optarg);
        !            37:                                perror("");
        !            38:                                exit(1);
        !            39:                        }
        !            40:                        break;
        !            41:                case 'o':
        !            42:                        if((ofp = fopen(optarg, "w")) == NULL) {
        !            43:                                (void) fprintf(stderr, "%s: can't open %s: ",
        !            44:                                        argv[0], optarg);
        !            45:                                perror("");
        !            46:                                exit(1);
        !            47:                        }
        !            48:                        break;
        !            49:                default:
        !            50:                        (void) fprintf(stderr,
        !            51:                                "usage: %s [-f file] [-o outfile]\n", argv[0]);
        !            52:                        exit(1);
        !            53:                        /* NOTREACHED */
        !            54:                        break;
        !            55:                }
        !            56:        }
        !            57: 
        !            58:        while(fgets(buf, sizeof(buf), ifp) != NULL) {
        !            59:                for(p = buf; *p != '\t' && *p != '\0' ; p++) {
        !            60:                        (void) fputc(lower(*p), ofp);
        !            61:                }
        !            62:                (void) fputs(p, ofp);
        !            63:        }
        !            64:        return(0);
        !            65: }

unix.superglobalmegacorp.com

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