1: #include <stdio.h> 2: 3: setbuf(iop, buf) 4: register struct _iobuf *iop; 5: char *buf; 6: { 7: if (iop->_base != NULL && iop->_flag&_IOMYBUF) 8: free(iop->_base); 9: iop->_flag &= ~(_IOMYBUF|_IONBF); 10: if ((iop->_base = buf) == NULL) 11: iop->_flag |= _IONBF; 12: else 13: iop->_ptr = iop->_base; 14: iop->_cnt = 0; 15: }