Back to index

tetex-bin  3.0
Functions
setbuf.c File Reference
#include <curses.priv.h>

Go to the source code of this file.

Functions

 _nc_set_buffer (FILE *ofp, bool buffered)

Function Documentation

_nc_set_buffer ( FILE ofp,
bool  buffered 
)

Definition at line 101 of file setbuf.c.

{
    /* optional optimization hack -- do before any output to ofp */
#if HAVE_SETVBUF || HAVE_SETBUFFER
    if (SP->_buffered != (int)buffered) {
       unsigned buf_len;
       char *buf_ptr;

       if (getenv("NCURSES_NO_SETBUF") != 0)
           return;

       fflush(ofp);
#ifdef __DJGPP__
       setmode(ofp, O_BINARY);
#endif
       if (buffered != 0) {
           buf_len = min(LINES * (COLS + 6), 2800);
           if ((buf_ptr = SP->_setbuf) == 0) {
              if ((buf_ptr = typeMalloc(char, buf_len)) == NULL)
                    return;
              SP->_setbuf = buf_ptr;
              /* Don't try to free this! */
           }
#if !USE_SETBUF_0
           else
              return;
#endif
       } else {
#if !USE_SETBUF_0
           return;
#else
           buf_len = 0;
           buf_ptr = 0;
#endif
       }

#if HAVE_SETVBUF
#ifdef SETVBUF_REVERSED            /* pre-svr3? */
       (void) setvbuf(ofp, buf_ptr, buf_len, buf_len ? _IOFBF : _IOLBF);
#else
       (void) setvbuf(ofp, buf_ptr, buf_len ? _IOFBF : _IOLBF, buf_len);
#endif
#elif HAVE_SETBUFFER
       (void) setbuffer(ofp, buf_ptr, (int) buf_len);
#endif

       SP->_buffered = buffered;
    }
#endif /* HAVE_SETVBUF || HAVE_SETBUFFER */
}

Here is the call graph for this function:

Here is the caller graph for this function: