Annotation of researchv9/libc/stdio/rdwr.c, revision 1.1

1.1     ! root        1: /* @(#)rdwr.c  4.1 (Berkeley) 12/21/80 */
        !             2: #include       <stdio.h>
        !             3: 
        !             4: fread(ptr, size, count, iop)
        !             5: unsigned size, count;
        !             6: register char *ptr;
        !             7: register FILE *iop;
        !             8: {
        !             9:        register c;
        !            10:        unsigned ndone, s;
        !            11: 
        !            12:        ndone = 0;
        !            13:        if (size)
        !            14:        for (; ndone<count; ndone++) {
        !            15:                s = size;
        !            16:                do {
        !            17:                        if ((c = getc(iop)) >= 0)
        !            18:                                *ptr++ = c;
        !            19:                        else
        !            20:                                return(ndone);
        !            21:                } while (--s);
        !            22:        }
        !            23:        return(ndone);
        !            24: }
        !            25: 
        !            26: fwrite(ptr, size, count, iop)
        !            27: unsigned size, count;
        !            28: register char *ptr;
        !            29: register FILE *iop;
        !            30: {
        !            31:        register unsigned s;
        !            32:        unsigned ndone;
        !            33: 
        !            34:        ndone = 0;
        !            35:        if (size)
        !            36:        for (; ndone<count; ndone++) {
        !            37:                s = size;
        !            38:                do {
        !            39:                        putc(*ptr++, iop);
        !            40:                } while (--s);
        !            41:                if (ferror(iop))
        !            42:                        break;
        !            43:        }
        !            44:        return(ndone);
        !            45: }

unix.superglobalmegacorp.com

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