|
|
1.1 root 1: #include <stdio.h>
2: char *malloc();
3:
4: _filbuf(iop)
5: register FILE *iop;
6: {
7: static char smallbuf[_NFILE];
8:
9: if ((iop->_flag&_IOREAD) == 0)
10: return(EOF);
11: if (iop->_flag&_IOSTRG)
12: return(EOF);
13: tryagain:
14: if (iop->_base==NULL) {
15: if (iop->_flag&_IONBF) {
16: iop->_base = &smallbuf[fileno(iop)];
17: goto tryagain;
18: }
19: if ((iop->_base = malloc(BUFSIZ)) == NULL) {
20: iop->_flag |= _IONBF;
21: goto tryagain;
22: }
23: iop->_flag |= _IOMYBUF;
24: }
25: iop->_ptr = iop->_base;
26: if (iop == stdin && (stdout->_flag&_IOLBF))
27: fflush(stdout);
28: iop->_cnt = read(fileno(iop), iop->_ptr, iop->_flag&_IONBF?1:BUFSIZ);
29: if (--iop->_cnt < 0) {
30: if (iop->_cnt == -1)
31: iop->_flag |= _IOEOF;
32: else
33: iop->_flag |= _IOERR;
34: iop->_cnt = 0;
35: return(-1);
36: }
37: return(*iop->_ptr++&0377);
38: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.