Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ setbuffer(3S) — Dell System V Release 4 Issue 2.2

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

setbuf(3S)

setbuffer(3S)

fclose(3S)

fopen(3S)

fread(3S)

getc(3S)

malloc(3C)

printf(3S)

putc(3S)

puts(3S)

setbuf(3S)



setbuffer(3S)      UNIX System V(BSD Compatibility Package)       setbuffer(3S)


NAME
      setbuffer, setlinebuf - assign buffering to a stream

SYNOPSIS
      cc [ flag. . . ] file . . . -lucb

      #include <stdio.h>

      setbuffer(stream, buf, size)
      FILE *stream;
      char *buf;
      int size;

      setlinebuf(stream)
      FILE *stream;

DESCRIPTION
      The three types of buffering available are unbuffered, block buffered,
      and line buffered.  When an output stream is unbuffered, information
      appears on the destination file or terminal as soon as written; when it
      is block buffered many characters are saved up and written as a block;
      when it is line buffered characters are saved up until a NEWLINE is
      encountered or input is read from any line buffered input stream.  fflush
      (see fclose(3S)) may be used to force the block out early.  Normally all
      files are block buffered.  A buffer is obtained from malloc(3C) upon the
      first getc or putc(3S) on the file.

      By default, output to a terminal is line buffered, except for output to
      the standard stream stderr which is unbuffered, and all other
      input/output is fully buffered.

      setbuffer can be used after a stream has been opened but before it is
      read or written.  It uses the character array buf whose size is
      determined by the size argument instead of an automatically allocated
      buffer.  If buf is the NULL pointer, input/output will be completely
      unbuffered.  A manifest constant BUFSIZ, defined in the <stdio.h> header
      file, tells how big an array is needed:

            char buf[BUFSIZ];

      setlinebuf is used to change the buffering on a stream from block
      buffered or unbuffered to line buffered.  Unlike setbuffer, it can be
      used at any time that the file descriptor is active.

      A file can be changed from unbuffered or line buffered to block buffered
      by using freopen (see fopen(3S)).  A file can be changed from block
      buffered or line buffered to unbuffered by using freopen followed by
      setbuffer with a buffer argument of NULL.

SEE ALSO
      setbuf(3S)



10/89                                                                    Page 1







setbuffer(3S)      UNIX System V(BSD Compatibility Package)       setbuffer(3S)


      fclose(3S), fopen(3S), fread(3S), getc(3S), malloc(3C), printf(3S),
      putc(3S), puts(3S), setbuf(3S) in the Programmer's Reference Manual

NOTE
      A common source of error is allocating buffer space as an automatic
      variable in a code block, and then failing to close the stream in the
      same block.















































Page 2                                                                    10/89





Typewritten Software • bear@typewritten.org • Edmonds, WA 98026