Squash  0.7.0
Data Structures | Enumerations | Enumerator | Functions
SquashStream

Low-level compression and decompression streams. More...

Data Structures

struct  SquashStream
 Compression/decompression streams. More...
 
struct  _SquashStreamPrivate
 Private data for streams. More...
 

Enumerations

enum  SquashStreamType { SQUASH_STREAM_COMPRESS = 1, SQUASH_STREAM_DECOMPRESS = 2 }
 Stream type. More...
 
enum  SquashOperation { SQUASH_OPERATION_PROCESS = 1, SQUASH_OPERATION_FLUSH = 2, SQUASH_OPERATION_FINISH = 3, SQUASH_OPERATION_TERMINATE = 4 }
 Operations to perform on a stream. More...
 

Functions

SquashOperation squash_stream_yield (SquashStream *stream, SquashStatus status)
 Yield execution back to the main thread. More...
 
void squash_stream_init (void *stream, SquashCodec *codec, SquashStreamType stream_type, SquashOptions *options, SquashDestroyNotify destroy_notify)
 Initialize a stream. More...
 
void squash_stream_destroy (void *stream)
 Destroy a stream. More...
 
SquashStream * squash_stream_new (const char *codec, SquashStreamType stream_type,...)
 Create a new stream. More...
 
SquashStream * squash_stream_newv (const char *codec, SquashStreamType stream_type, va_list options)
 Create a new stream with a variadic list of options. More...
 
SquashStream * squash_stream_newa (const char *codec, SquashStreamType stream_type, const char *const *keys, const char *const *values)
 Create a new stream with key/value option arrays. More...
 
SquashStream * squash_stream_new_with_options (const char *codec, SquashStreamType stream_type, SquashOptions *options)
 Create a new stream with options. More...
 
SquashStream * squash_stream_new_codec (SquashCodec *codec, SquashStreamType stream_type,...)
 Create a new stream using a codec instance. More...
 
SquashStream * squash_stream_new_codec_with_options (SquashCodec *codec, SquashStreamType stream_type, SquashOptions *options)
 Create a new stream using codec and options intances. More...
 
SquashStatus squash_stream_process (SquashStream *stream)
 Process a stream. More...
 
SquashStatus squash_stream_flush (SquashStream *stream)
 Flush a stream. More...
 
SquashStatus squash_stream_finish (SquashStream *stream)
 Finish writing to a stream. More...
 

Detailed Description

Low-level compression and decompression streams.

Enumeration Type Documentation

Operations to perform on a stream.

Enumerator
SQUASH_OPERATION_PROCESS 

Continue processing the stream normally.

See also
squash_stream_process
SQUASH_OPERATION_FLUSH 

Flush the stream.

See also
squash_stream_flush
SQUASH_OPERATION_FINISH 

Finish processing the stream.

See also
squash_stream_finish
SQUASH_OPERATION_TERMINATE 

Abort.

This value is only passed to plugins with the SQUASH_CODEC_INFO_RUN_IN_THREAD flag set, and signals that the stream is being destroyed (likely before processing has completed). There will be no further input, and any output will be ignored.

Definition at line 51 of file stream.h.

Stream type.

Enumerator
SQUASH_STREAM_COMPRESS 

A compression stream.

SQUASH_STREAM_DECOMPRESS 

A decompression stream.

Definition at line 38 of file stream.h.

Function Documentation

void squash_stream_destroy ( void *  stream)
protected

Destroy a stream.

Parameters
streamThe stream.
See also
squash_object_destroy

Definition at line 342 of file stream.c.

SquashStatus squash_stream_finish ( SquashStream *  stream)

Finish writing to a stream.

Parameters
streamThe stream.
Returns
A status code.

Definition at line 743 of file stream.c.

SquashStatus squash_stream_flush ( SquashStream *  stream)

Flush a stream.

This method will attempt to process data in a stream. It should be squashled repeatedly, adding data to the avail_in field and removing data from the avail_out field as necessary.

Parameters
streamThe stream.
Returns
A status code.

Definition at line 732 of file stream.c.

void squash_stream_init ( void *  stream,
SquashCodec *  codec,
SquashStreamType  stream_type,
SquashOptions *  options,
SquashDestroyNotify  destroy_notify 
)
protected

Initialize a stream.

Parameters
streamThe stream to initialize.
codecThe codec to use.
stream_typeThe stream type.
optionsThe options.
destroy_notifyFunction to call to destroy the instance.
See also
squash_object_init

Definition at line 277 of file stream.c.

SquashStream* squash_stream_new ( const char *  codec,
SquashStreamType  stream_type,
  ... 
)

Create a new stream.

Parameters
codecThe name of the codec.
stream_typeStream type.
...List of key/value option pairs, followed by NULL
Returns
A new stream, or NULL on failure.

Definition at line 382 of file stream.c.

SquashStream* squash_stream_new_codec ( SquashCodec *  codec,
SquashStreamType  stream_type,
  ... 
)

Create a new stream using a codec instance.

Parameters
codecCodec to use
stream_typeStream type
...List of options
Returns
A new stream, or NULL on failure

Definition at line 471 of file stream.c.

SquashStream* squash_stream_new_codec_with_options ( SquashCodec *  codec,
SquashStreamType  stream_type,
SquashOptions *  options 
)

Create a new stream using codec and options intances.

Parameters
codecCodec to use
stream_typeStream type
optionsAn option group
Returns
A new stream, or NULL on failure

Definition at line 495 of file stream.c.

SquashStream* squash_stream_new_with_options ( const char *  codec,
SquashStreamType  stream_type,
SquashOptions *  options 
)

Create a new stream with options.

Parameters
codecThe name of the codec.
stream_typeStream type.
optionsAn option group.
Returns
A new stream, or NULL on failure.

Definition at line 449 of file stream.c.

SquashStream* squash_stream_newa ( const char *  codec,
SquashStreamType  stream_type,
const char *const *  keys,
const char *const *  values 
)

Create a new stream with key/value option arrays.

Parameters
codecThe name of the codec.
stream_typeStream type.
keysNULL-terminated array of option keys.
valuesArray of option values.
Returns
A new stream, or NULL on failure.

Definition at line 433 of file stream.c.

SquashStream* squash_stream_newv ( const char *  codec,
SquashStreamType  stream_type,
va_list  options 
)

Create a new stream with a variadic list of options.

Parameters
codecThe name of the codec.
stream_typeStream type.
optionsList of key/value option pairs, followed by NULL
Returns
A new stream, or NULL on failure.

Definition at line 404 of file stream.c.

SquashStatus squash_stream_process ( SquashStream *  stream)

Process a stream.

This method will attempt to process data in a stream. It should be squashled repeatedly, adding data to the avail_in field and removing data from the avail_out field as necessary.

Parameters
streamThe stream.
Returns
A status code.
Return values
SQUASH_OKAll input successfully consumed. Check the output buffer for data then proceed with new input.
SQUASH_PROCESSINGProgress was made, but not all input could be consumed. Remove some data from the output buffer and run squash_stream_process again.
SQUASH_END_OF_STREAMThe end of stream was reached. You shouldn't call squash_stream_process again. Decompression only.

Definition at line 717 of file stream.c.

SquashOperation squash_stream_yield ( SquashStream *  stream,
SquashStatus  status 
)
protected

Yield execution back to the main thread.

This function may only be called inside the processing thread spawned for thread-based plugins.

Parameters
streamThe stream
statusStatus code to return for the current request
Returns
The code of the next requested operation

Definition at line 223 of file stream.c.