|
|
1.1 ! root 1: #include "stream.h" ! 2: ! 3: /* ! 4: Allocate some space for the buffer. ! 5: Returns: EOF on error ! 6: 0 on success ! 7: */ ! 8: int streambuf.allocate() ! 9: { ! 10: if (base == NULL) { ! 11: if ((base = new char[BUFSIZE]) != NULL) { ! 12: pptr = gptr = base; ! 13: eptr = base + BUFSIZE; ! 14: alloc = 1; ! 15: return 0; ! 16: } else ! 17: return EOF; ! 18: } ! 19: return 0; ! 20: } ! 21: ! 22: /* ! 23: Come here on a put to a full buffer. Allocate the buffer if ! 24: it is uninitialized. ! 25: Returns: EOF on error ! 26: the argument on success ! 27: */ ! 28: virtual int streambuf.overflow(int c) ! 29: { ! 30: if (allocate() == EOF) return EOF; ! 31: if (c != EOF) *pptr++ = c; ! 32: return c&0377; ! 33: } ! 34: ! 35: /* ! 36: Fill a buffer. ! 37: Returns: EOF on error or end of input ! 38: next character on success ! 39: */ ! 40: virtual int streambuf.underflow() ! 41: { ! 42: return EOF; ! 43: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.