/* _vv_flush.c *********** Copyright 1987-1995 by Vermont Creative Software *********** _vv_flush() Flushes the Vermont Views output buffer Call #include void _vv_flush() Returns None Description Flushes as many characters as are in the Vermont Views output buffer to the operating system. Uses write() for UNIX and POSIX, sys$qiow for VMS. Cautions This function only flushes the Vermont Views output buffer. It will not work on output streams. */ #include #if VMS #include #endif #if POSIX #include #endif #if UNIX #ifdef LINT_ARGS PROTOTYPE int write(int, char *, int); #else extern int write(); #endif #endif #if OLD_STYLE void _vv_flush() #else void _vv_flush(void) #endif { #if VMS IOSB_WR iosb; #else int retval; int tty_out = 1; #endif int written = 0; if (_outbufcnt > 0) /*if characters to write */ { /*--------------------------------------------------------------------*/ /* Write what is in the output buffer. If the whole buffer is not */ /* flushed, try again if the write was interrupted. Keep trying */ /* until the whole buffer is flushed or the write fails completely. */ /*--------------------------------------------------------------------*/ #if VMS do { sys$qiow(0, _outchan, IO$_WRITELBLK | IO$M_BREAKTHRU | IO$M_NOFORMAT, &iosb, NULLFP, 0, _outbuf + written, _outbufcnt - written, 0, 0, 0, 0); written += iosb.byte_count; } while (written < _outbufcnt && iosb.byte_count > 0); #else do { retval = write(tty_out,(char *)(_outbuf + written), _outbufcnt - written); if (retval < 0) written = _outbufcnt; /* I/O error! break out of loop now! */ else written += retval; } while (written < _outbufcnt); /*--------------------------------------------------------------------*/ /* This really should only loop if errno is set to EINTR, but this */ /* doesn't seem to work as well, for reasons as yet unknown. */ /*--------------------------------------------------------------------*/ #endif } _outbufcnt = 0; return; }