Annotation of coherent/d/lib/libc/stdio/fread.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Standard I/O Library
                      3:  * Read nitems of size from file fp
                      4:  */
                      5: 
                      6: #include <stdio.h>
                      7: 
                      8: int
                      9: fread(bp, size, nitems, fp)
                     10: register char  *bp;
                     11: unsigned int   size;
                     12: unsigned int   nitems;
                     13: register FILE  *fp;
                     14: {
                     15:        unsigned int    nb = size*nitems;
                     16:        register int    c;
                     17: 
                     18:        if (fp->_ff&_FUNGOT) {
                     19:                *bp++ = (*fp->_gt)(fp);
                     20:                nb--;
                     21:        }
                     22:        if (fp->_bp!=NULL || !(fp->_ff&_FSTBUF))
                     23:                for (; nb && (c=getc(fp))!=EOF; nb--)
                     24:                        *bp++ = c;
                     25:        else if ((c=read(fileno(fp), bp, nb)) > 0)
                     26:                nb -= c;
                     27:        else if (c == 0)
                     28:                fp->_ff |= _FEOF;
                     29:        else
                     30:                fp->_ff |= _FERR;
                     31:        return ((size*nitems-nb)/size);
                     32: }

unix.superglobalmegacorp.com

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