Annotation of researchv10dc/cmd/zero.c, revision 1.1.1.1

1.1       root        1: #include       <stdlib.h>
                      2: #include       <limits.h>
                      3: #include       <stdio.h>
                      4: 
                      5: #define                BLOCK           (32*1024)
                      6: 
                      7: main(int argc, char **argv)
                      8: {
                      9:        int byte = 0;
                     10:        long nbytes = LONG_MAX;
                     11:        char buf[BLOCK];
                     12: 
                     13:        if(argc > 3){
                     14:                fprintf(stderr, "Usage: zero [byte [nbytes]]\n");
                     15:                exit(1);
                     16:        }
                     17:        if(argc > 1)
                     18:                byte = strtol(argv[1], (char **)0, 0);
                     19:        if(argc > 2)
                     20:                nbytes = strtol(argv[2], (char **)0, 0);
                     21:        memset(buf, byte, BLOCK);
                     22:        while(nbytes > BLOCK){
                     23:                if(write(1, buf, BLOCK) != BLOCK){
                     24:                        perror("zero: write error");
                     25:                        exit(2);
                     26:                }
                     27:                nbytes -= BLOCK;
                     28:        }
                     29:        if(nbytes){
                     30:                if(write(1, buf, (int)nbytes) != (int)nbytes){
                     31:                        perror("zero: write error");
                     32:                        exit(2);
                     33:                }
                     34:        }
                     35:        exit(0);
                     36: }

unix.superglobalmegacorp.com

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