Annotation of coherent/d/bin/sleep.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Sleep command
        !             3:  */
        !             4: 
        !             5: #include <stdio.h>
        !             6: #include <sys/mdata.h>
        !             7: 
        !             8: long   numeric();
        !             9: long   atol();
        !            10: 
        !            11: main(argc, argv)
        !            12: char *argv[];
        !            13: {
        !            14:        if (argc > 2)
        !            15:                usage();
        !            16:        if (argc > 1)
        !            17:                lsleep(numeric(argv[1]));
        !            18:        return (0);
        !            19: }
        !            20: 
        !            21: /*
        !            22:  * Check if argument is numeric and
        !            23:  * return it.
        !            24:  */
        !            25: long
        !            26: numeric(s)
        !            27: register char *s;
        !            28: {
        !            29:        long n;
        !            30: 
        !            31:        n = atol(s);
        !            32:        for (; *s!='\0'; s++)
        !            33:                if (*s<'0' || *s>'9')
        !            34:                        usage();
        !            35:        return (n);
        !            36: }
        !            37: 
        !            38: /*
        !            39:  * Sleep that takes a long argument.
        !            40:  */
        !            41: lsleep(n)
        !            42: long n;
        !            43: {
        !            44:        register unsigned i;
        !            45: 
        !            46:        while (n > 0) {
        !            47:                i = n>MAXUINT ? MAXUINT : n;
        !            48:                sleep(i);
        !            49:                n -= i;
        !            50:        }
        !            51: }
        !            52: 
        !            53: usage()
        !            54: {
        !            55:        fprintf(stderr, "Usage: sleep seconds\n");
        !            56:        exit(1);
        !            57: }

unix.superglobalmegacorp.com

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