4e8fb719c1745de96a64e7fd4cb49fd2538811aa
   1line_buffer API
   2===============
   3
   4The line_buffer library provides a convenient interface for
   5mostly-line-oriented input.
   6
   7Each line is not permitted to exceed 10000 bytes.  The provided
   8functions are not thread-safe or async-signal-safe, and like
   9`fgets()`, they generally do not function correctly if interrupted
  10by a signal without SA_RESTART set.
  11
  12Calling sequence
  13----------------
  14
  15The calling program:
  16
  17 - initializes a `struct line_buffer` to LINE_BUFFER_INIT
  18 - specifies a file to read with `buffer_init`
  19 - processes input with `buffer_read_line`, `buffer_read_string`,
  20   `buffer_skip_bytes`, and `buffer_copy_bytes`
  21 - closes the file with `buffer_deinit`, perhaps to start over and
  22   read another file.
  23
  24When finished, the caller can use `buffer_reset` to deallocate
  25resources.
  26
  27Functions
  28---------
  29
  30`buffer_init`, `buffer_fdinit`::
  31        Open the named file or file descriptor for input.
  32        buffer_init(buf, NULL) prepares to read from stdin.
  33        On failure, returns -1 (with errno indicating the nature
  34        of the failure).
  35
  36`buffer_deinit`::
  37        Stop reading from the current file (closing it unless
  38        it was stdin).  Returns nonzero if `fclose` fails or
  39        the error indicator was set.
  40
  41`buffer_read_line`::
  42        Read a line and strip off the trailing newline.
  43        On failure or end of file, returns NULL.
  44
  45`buffer_read_string`::
  46        Read `len` characters of input or up to the end of the
  47        file, whichever comes first.  Returns NULL on error.
  48        Returns whatever characters were read (possibly "")
  49        for end of file.
  50
  51`buffer_copy_bytes`::
  52        Read `len` bytes of input and dump them to the standard output
  53        stream.  Returns early for error or end of file.
  54
  55`buffer_skip_bytes`::
  56        Discards `len` bytes from the input stream (stopping early
  57        if necessary because of an error or eof).
  58
  59`buffer_reset`::
  60        Deallocates non-static buffers.