#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_t * | dkof_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_t * | dkof_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. |
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.
void dkof_bs_close | ( | dk_bitshift_t * | b | ) |
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.
b | The bit shifter. |
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.
s | The stream to write the bits to. |
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.
b | The bit shifter. | |
c | Integer value containing the bits. | |
n | Number of bits |
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()).
s | Output filtering stream to close. |
int dkof_end_chunk | ( | dk_stream_t * | s | ) |
End filtered chunk.
s | Output filtering stream. |
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.
s | Existing dk_stream_t. | |
n | Number of filter cells (Filter cells have indices 0 ... n-1). |
int dkof_set | ( | dk_stream_t * | s, | |
size_t | i, | |||
int | t | |||
) |
Set output filtering cell type.
s | The output filtering stream. | |
i | Index of cell to configure (0...n-1). | |
t | Output filtering cell type (DK_OF_TYPE_...) |
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.
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.
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.
s | Output filtering stream. | |
l | Maximum line length. |
int dkof_start_chunk | ( | dk_stream_t * | s | ) |
Start filtered chunk.
s | Output filtering stream. |