Decode Stream

Base64 stream decoding. More...

Typedefs

typedef gos_result_t (* gos_base64_reader_t ) (void *user, void *data, uint32_t length, uint32_t *bytes_read)
Base64 decode reader callback. More...
typedef void * gos_base64_decode_stream_t
Base64 decoder context. More...

Functions

gos_result_t gos_base64_stream_decode_init ( gos_base64_decode_stream_t **stream_ptr, void *user, uint32_t processing_buffer_size)
Initialize gos_base64_decode_stream_t . More...
gos_result_t gos_base64_stream_decode ( gos_base64_decode_stream_t *stream, void *data, uint32_t data_len, gos_base64_reader_t reader)
Base64 decode string into binary data with reader callback. More...
gos_result_t gos_base64_stream_decode_reset ( gos_base64_decode_stream_t *stream)
Reset gos_base64_decode_stream_t . More...

Detailed Description

Base64 stream decoding.

Typedef Documentation

gos_base64_decode_stream_t

Base64 decoder context.

See gos_base64_stream_decode()

gos_base64_reader_t

typedef gos_result_t (* gos_base64_reader_t) (void *user, void *data, uint32_t length, uint32_t *bytes_read)

Base64 decode reader callback.

This is a callback which reads base64 encoded data. See gos_base64_stream_decode()

Parameters
[in] user User specified argument, supplied in 'user' argument of gos_base64_stream_decode_init()
[out] data Buffer to hold base64 encoded data
[in] length Length of data buffer
[out] bytes_read Pointer to hold number of bytes read
Returns
return of reader callback, gos_result_t

Function Documentation

gos_base64_stream_decode()

gos_result_t gos_base64_stream_decode ( gos_base64_decode_stream_t * stream,
void * data,
uint32_t data_len,
gos_base64_reader_t reader
)

Base64 decode string into binary data with reader callback.

Chunks of base64 encoded data are read using the supplied reader callback and decoded into the supplied buffer. This API is useful as it ensures each chunk of arbitrary length data is properly decoded without requiring base64 padding of the chunks.

Note
This API requires that the length of the non-base64 encoded data is known a priori. While this API may be called as many times as needed. The total sum of the supplied 'data_len' arguments must equal length of the non-base64 encoded binary data in bytes.
Parameters
[in] stream Decoding context pre-initialized with gos_base64_stream_decode_init()
[in] data Buffer to hold decoded binary data
[in] data_len Length of supplied data buffer
[in] reader Reader callback to read base64 encoded data, see gos_base64_reader_t
Returns
gos_result_t

gos_base64_stream_decode_init()

gos_result_t gos_base64_stream_decode_init ( gos_base64_decode_stream_t ** stream_ptr,
void * user,
uint32_t processing_buffer_size
)

Initialize gos_base64_decode_stream_t .

This must be called before gos_base64_stream_decode()

Use gos_base64_stream_destroy() to cleanup the context.

Parameters
[out] stream_ptr Pointer to hold allocated gos_base64_decode_stream_t
[in] user User specified argument passed to gos_base64_reader_t
[in] processing_buffer_size size of decode processing buffer. A larger buffer typically means faster decoding. Typical value is 1024.

gos_base64_stream_decode_reset()

gos_result_t gos_base64_stream_decode_reset ( gos_base64_decode_stream_t * stream )

Reset gos_base64_decode_stream_t .

This resets a gos_base64_decode_stream_t to its initial state. This allows for re-using the context after performing a decoding.

Parameters
[in] stream gos_base64_decode_stream_t to reset to initial state
Returns
gos_result_t