dkof.h File Reference

Output filtering. More...

#include <dk.h>
#include <dktypes.h>

Go to the source code of this file.

Defines

#define DK_OF_TYPE_NONE   0
 Output filter cell type: No filtering at all.
#define DK_OF_TYPE_BUFFERED   1
 Output filter cell type: Buffering to chunks of 512 bytes.
#define DK_OF_TYPE_ASCII85   2
 Output filter cell type: ASCII85 encoding.
#define DK_OF_TYPE_FLATE   3
 Output filter cell type: Flate compression.
#define DK_OF_TYPE_ASCIIHEX   4
 Output filter cell type: ASCII-Hex encoding.
#define DK_OF_TYPE_PSRL   5
 Output filter cell type: Run-length compression for PostScript.
#define DK_OF_TYPE_LZW   6
 Output filter cell type: LZW compression (not supported).

Functions

dk_stream_tdkof_open (dk_stream_t *s, size_t n)
 Create new output filtering dk_stream_t on top of an existing stream.
void dkof_close (dk_stream_t *s)
 Close/release dk_stream_t obtained from dkof_open().
int dkof_set (dk_stream_t *s, size_t i, int t)
 Set output filtering cell type.
void dkof_set_max_line_length (dk_stream_t *s, size_t l)
 Set maximum line length for ASCII-Hex or ASCII85 encoded output.
void dkof_set_crnl (dk_stream_t *s, int f)
 Configure the use of CR-NL combination or simple NL.
void dkof_set_finalizing (dk_stream_t *s, int f)
 Configure finalizers for ASCII-Hex or ASCII85 encoded chunks.
int dkof_start_chunk (dk_stream_t *s)
 Start filtered chunk.
int dkof_end_chunk (dk_stream_t *s)
 End filtered chunk.
dk_bitshift_tdkof_bs_open (dk_stream_t *s)
 Open bit shifter on top of a stream.
void dkof_bs_close (dk_bitshift_t *b)
 Release/close a bitshifter obtained from dkof_bs_open().
int dkof_bs_put (dk_bitshift_t *b, unsigned short c, unsigned short n)
 Write bits.
int dkof_bs_flush (dk_bitshift_t *b)
 Flush bits.


Detailed Description

Output filtering.

This module provides functions to use output filters (i.e. compression and encoding) and bit writing filters on top of a dk_stream_t.

After opening an output filtering stream you can configure the filter cells for compression and encoding methods. Data written to the stream is passed to the highest filtering cell first. The output of each filtering cell is passed to the filtering cell one level below, output from the lowest filtering cell (level 0) is passed to the target stream.

Unless otherwise stated, int functions in this module return a positive number to indicate success or a true condition, 0 to indicate an error or an unfullfilled condition. Pointer functions return valid pointers on success, NULL on error.


Function Documentation

void dkof_bs_close ( dk_bitshift_t b  ) 

Release/close a bitshifter obtained from dkof_bs_open().

Parameters:
b The bit shifter.

int dkof_bs_flush ( dk_bitshift_t b  ) 

Flush bits.

The bit shifters internal buffers are written to the underlaying stream. Unused bits in the last byte are zero-padded.

Parameters:
b The bit shifter.
Returns:
Flag to indicate success.

dk_bitshift_t* dkof_bs_open ( dk_stream_t s  ) 

Open bit shifter on top of a stream.

A new bit shifter (dk_bitshift_t) is created in dynamically allocated memory. You must release the memory by calling dkof_bs_close() after usage.

Parameters:
s The stream to write the bits to.
Returns:
Pointer to new dk_bitshift_t.

int dkof_bs_put ( dk_bitshift_t b,
unsigned short  c,
unsigned short  n 
)

Write bits.

The least significant n bits from c are written to the bit shifter.

Parameters:
b The bit shifter.
c Integer value containing the bits.
n Number of bits
Returns:
Flag to indicate success.

void dkof_close ( dk_stream_t s  ) 

Close/release dk_stream_t obtained from dkof_open().

This function does not close the underlaying dk_stream_t (provided as parameter s to dkof_open()).

Parameters:
s Output filtering stream to close.

int dkof_end_chunk ( dk_stream_t s  ) 

End filtered chunk.

Parameters:
s Output filtering stream.
Returns:
Flag to indicate success.

dk_stream_t* dkof_open ( dk_stream_t s,
size_t  n 
)

Create new output filtering dk_stream_t on top of an existing stream.

The resulting dk_stream_t must be released by calling dkof_close() after usage.

Parameters:
s Existing dk_stream_t.
n Number of filter cells (Filter cells have indices 0 ... n-1).
Returns:
New dk_stream_t on success, NULL on error.

int dkof_set ( dk_stream_t s,
size_t  i,
int  t 
)

Set output filtering cell type.

Parameters:
s The output filtering stream.
i Index of cell to configure (0...n-1).
t Output filtering cell type (DK_OF_TYPE_...)
Returns:
Flag to indicate success.

void dkof_set_crnl ( dk_stream_t s,
int  f 
)

Configure the use of CR-NL combination or simple NL.

Some file types want carriage-newline combinations at line breaks, others want simple newlines.

Parameters:
s Output filtering stream to configure.
f Flag to use CF-NL combination.

void dkof_set_finalizing ( dk_stream_t s,
int  f 
)

Configure finalizers for ASCII-Hex or ASCII85 encoded chunks.

Some systems want ">" or "~>" finalizers for ASCII-Hex or ASCII85 encoded chunks, others don't.

Parameters:
s Output filtering stream to configure.
f Flag to create finalizers.

void dkof_set_max_line_length ( dk_stream_t s,
size_t  l 
)

Set maximum line length for ASCII-Hex or ASCII85 encoded output.

Parameters:
s Output filtering stream.
l Maximum line length.

int dkof_start_chunk ( dk_stream_t s  ) 

Start filtered chunk.

Parameters:
s Output filtering stream.
Returns:
Flag to indicate success.


Generated on Mon Feb 16 17:12:04 2009 for dklibs by  doxygen 1.5.6