dklibs(3)

NAME
dkof - output filtering

SYNOPSIS
  #include <dkof.h>

  dk_stream_t *
  dkof_open (dk_stream_t *target, size_t nof);

  void
  dkof_close (dk_stream_t *str);

  int
  dkof_set (dk_stream_t *str, size_t n, int what);

  int
  dkof_start_chunk (dk_stream_t *str);

  int
  dkof_end_chunk (dk_stream_t *str);

  void
  dkof_set_crnl (dk_stream_t *str, int v);

DESCRIPTION
Some file formats - i.e. Postscript and PDF - mix plain text and compressed chunks.

Output filters are intended to create the compressed chunks.

The dkof module creates a new dk_stream_t for compression and encoding which writes output to an existing dk_stream_t.

The dkof_open() function creates such a new stream. The nof parameter is the number of filters to apply. The function returns a valid pointer on success, NULL on error.

The dkof_set() function sets a filter cell n to a specified method what. Filter cell n-1 is applied first, 0 is the last cell before writing the output. The following filter cell types can be used:

* DK_OF_TYPE_FLATE
    Flate compression from the zlib library.

* ASCII85-encoding
    ASCII-85-Encoding.

* DK_OF_TYPE_BUFFERED
    Output data is collected to write 512-byte buffers instead of single bytes.

Each stream created by dkof_open() must be closed after usage by the dkof_close() function.

The dkof_set_crnl() function can be used to set up UNIX style line ends (v=0) or Windows style line ends (v=1).

Before writing a compressed chunk the stream must be initialized using dkof_start_chunk().

After writing all chunk data the dkof_end_chunk() function must be used to flush all buffers.

AUTHOR
Dirk Krause

COPYRIGHT AND LICENSE
Copyright (c) 2001-2008, Dirk Krause All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

 * Redistributions of source code must retain the above
   copyright notice, this list of conditions and the
   following disclaimer.

 * Redistributions in binary form must reproduce the above
   copyright notice, this list of conditions and the following
   disclaimer in the documentation and/or other materials
   provided with the distribution.

 * Neither the name of the Dirk Krause nor the names of
   contributors may be used to endorse or promote products
   derived from this software without specific prior written
   permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.