.TH MPU_SETVBUF 3 "August 2026" "libmpuio" "LIBMPUIO Programmer's Manual" .SH NAME mpu_setvbuf, mpu_setbuf, mpu_setlinebuf, mpu_feof, mpu_ferror, mpu_clearerr \- buffering and stream status .SH SYNOPSIS .nf #include int mpu_setvbuf( mpu_FILE *stream, unsigned char *buf, int mode, size_t size ); void mpu_setbuf( mpu_FILE *stream, unsigned char *buf ); void mpu_setlinebuf( mpu_FILE *stream ); int mpu_feof( mpu_FILE *stream ); int mpu_ferror( mpu_FILE *stream ); void mpu_clearerr( mpu_FILE *stream ); .fi .SH DESCRIPTION .B mpu_setvbuf selects full buffering (MPU_IOFBF), line buffering (MPU_IOLBF), or no buffering (MPU_IONBF). A caller-supplied buffer is used directly until the stream is closed or reconfigured. .PP .B mpu_setbuf selects full buffering with MPU_BUFSIZ when buf is non-NULL and unbuffered mode when buf is NULL. .PP .BR mpu_feof , .BR mpu_ferror , and .B mpu_clearerr inspect or clear stream status indicators. .SH STATUS AND ERROR INDICATORS .BR mpu_feof () reports the EOF indicator; it does not predict whether the next read will hit EOF. The indicator is set only after an input operation observes end of file. .BR mpu_ferror () reports the stream error indicator. .BR mpu_clearerr () clears both indicators. .PP EAGAIN/EWOULDBLOCK on a nonblocking descriptor sets error, not EOF. After the condition changes, clearerr followed by another input operation can continue. .SH LOCKED AND UNLOCKED STATUS OPERATIONS mpu_feof_unlocked, mpu_ferror_unlocked, and mpu_clearerr_unlocked have the same indicator semantics but do not acquire the stream mutex. Use them only with exclusive stream access or while holding mpu_flockfile(). .PP Buffer configuration functions have no unlocked variants. Buffering should be configured as a stream-state operation, not raced with active I/O. .SH TRANSACTIONAL RECONFIGURATION For descriptor and cookie streams, replacement storage is prepared before the current buffer is synchronized or released. If an internal buffer allocation fails, mpu_setvbuf() returns an error while leaving the previous buffer, active direction, and pending buffered data usable. A later synchronization failure may still change backend state as part of the attempted synchronization. .SH SEE ALSO .BR mpu_fopen (3), .BR mpu_fflush (3), .BR mpu_flushlbf (3), .BR libmpuio (3) .SH SETLINEBUF .BR mpu_setlinebuf () is a glibc-style convenience interface equivalent to selecting .B MPU_IOLBF with an internally allocated buffer of .B MPU_BUFSIZ characters/bytes appropriate to the byte-buffer backend. As with setbuf(3), it has no return value; use mpu_setvbuf() when the caller needs explicit error reporting. .SH FLUSHING LINE-BUFFERED STREAMS .BR mpu_flushlbf (3) flushes all currently writing streams configured with MPU_IOLBF while leaving fully buffered streams untouched.