Encode Stream

Base64 stream encoding. More...


typedef gos_result_t(* gos_base64_writer_t) (void *user, const void *data, uint32_t length)
 Base64 encode writer. More...
typedef void * gos_base64_encode_stream_t
 Base64 encoder context See gos_base64_stream_encode()


gos_result_t gos_base64_stream_encode_init (gos_base64_encode_stream_t **stream_ptr, void *user, uint32_t processing_buffer_size)
 Initialize gos_base64_encode_stream_t. More...
gos_result_t gos_base64_stream_encode (gos_base64_encode_stream_t *stream, const void *data, uint32_t data_len, gos_base64_writer_t writer)
 Base64 encode binary data with writer callback. More...
gos_result_t gos_base64_stream_encode_reset (gos_base64_encode_stream_t *stream)
 Reset gos_base64_encode_stream_t. More...
void gos_base64_stream_destroy (void *stream)
 Cleanup encode/decode context. More...

Detailed Description

Base64 stream encoding.

Typedef Documentation

◆ gos_base64_writer_t

typedef gos_result_t(* gos_base64_writer_t) (void *user, const void *data, uint32_t length)

Base64 encode writer.

This is a callback which writes base64 encoded data. See gos_base64_stream_encode()

[in]userUser specified argument, supplied in 'user' argument of gos_base64_stream_encode_init()
[in]database64 encoded data to write
[in]lengthLength of data buffer
return of writer callback, gos_result_t

Function Documentation

◆ gos_base64_stream_destroy()

void gos_base64_stream_destroy ( void *  stream)

Cleanup encode/decode context.

This cleans up (i.e de-allocates) a context allocated by gos_base64_stream_encode_init() or gos_base64_stream_decode_init()

[in]streamContext to be de-allocated

◆ gos_base64_stream_encode()

gos_result_t gos_base64_stream_encode ( gos_base64_encode_stream_t stream,
const void *  data,
uint32_t  data_len,
gos_base64_writer_t  writer 

Base64 encode binary data with writer callback.

Arbitrary chunks of binary data are base64 encoded and written using the supplied 'writer' callback. This API is useful as the supplied chunks may be any length. The API ensures the written data is properly base64 encoded as a continuous stream of data (i.e. it ensures no base64 encode padding is applied to the end of the data chunks).

To ensure proper base64 encode padding, once all data is written call this API a final time with a NULL data buffer, e.g. gos_base64_stream_encode(context, NULL, 0, base64_writer_callback);
[in]streamEncoding context pre-initialized with gos_base64_stream_encode_init()
[in]dataBinary data to base64 encode
[in]data_lenLength of supplied data buffer
[in]writerWriter callback to write base64 encoded data

◆ gos_base64_stream_encode_init()

gos_result_t gos_base64_stream_encode_init ( gos_base64_encode_stream_t **  stream_ptr,
void *  user,
uint32_t  processing_buffer_size 

Initialize gos_base64_encode_stream_t.

Use gos_base64_stream_destroy() to cleanup the context.

[out]stream_ptrPointer to hold allocated gos_base64_encode_stream_t
[in]userUser specified argument passed to gos_base64_writer_t
[in]processing_buffer_sizesize of encoding processing buffer. A larger buffer typically means faster encoding. Typical value is 1024.

◆ gos_base64_stream_encode_reset()

gos_result_t gos_base64_stream_encode_reset ( gos_base64_encode_stream_t stream)

Reset gos_base64_encode_stream_t.

This resets a gos_base64_encode_stream_t to its initial state. This allows for re-using the context after performing an encoding.

[in]streamgos_base64_encode_stream_t to reset to initial state