Nigel Rantor / azure_c_shared_utility

Fork of azure_c_shared_utility by Azure IoT

Embed: (wiki syntax)

« Back to documentation index

base64.h File Reference

base64.h File Reference

Prototypes for functions related to encoding/decoding a buffer using standard base64 encoding. More...

Go to the source code of this file.

Functions

 MOCKABLE_FUNCTION (, STRING_HANDLE, Base64_Encoder, BUFFER_HANDLE, input)
 Base64 encodes a buffer and returns the resulting string.
 MOCKABLE_FUNCTION (, STRING_HANDLE, Base64_Encode_Bytes, const unsigned char *, source, size_t, size)
 Base64 encodes the buffer pointed to by source and returns the resulting string.
 MOCKABLE_FUNCTION (, BUFFER_HANDLE, Base64_Decoder, const char *, source)
 Base64 decodes the buffer pointed to by source and returns the resulting buffer.

Detailed Description

Prototypes for functions related to encoding/decoding a buffer using standard base64 encoding.

Definition in file base64.h.


Function Documentation

MOCKABLE_FUNCTION ( STRING_HANDLE  ,
Base64_Encoder  ,
BUFFER_HANDLE  ,
input   
)

Base64 encodes a buffer and returns the resulting string.

Parameters:
inputThe buffer that needs to be base64 encoded.

Base64_Encoder takes as a parameter a pointer to a BUFFER. If input is NULL then Base64_Encoder returns NULL. The size of the BUFFER pointed to by input may be zero. If when allocating memory to produce the encoding a failure occurs, then Base64_Encoder returns NULL. Otherwise Base64_Encoder returns a pointer to a STRING. That string contains the base 64 encoding of the input. This encoding of input will not contain embedded line feeds.

Returns:
A STRING_HANDLE containing the base64 encoding of input.
MOCKABLE_FUNCTION ( BUFFER_HANDLE  ,
Base64_Decoder  ,
const char *  ,
source   
)

Base64 decodes the buffer pointed to by source and returns the resulting buffer.

Parameters:
sourceA base64 encoded string buffer.

This function decodes the string pointed at by source using base64 decoding and returns the resulting buffer. If source is NULL then Base64_Decoder returns NULL. If the string pointed to by source is zero length then the handle returned refers to a zero length buffer. If there is any memory allocation failure during the decode or if the source string has an invalid length for a base 64 encoded string then Base64_Decoder returns NULL.

Returns:
A BUFFER_HANDLE pointing to a buffer containing the result of base64 decoding source.
MOCKABLE_FUNCTION ( STRING_HANDLE  ,
Base64_Encode_Bytes  ,
const unsigned char *  ,
source  ,
size_t  ,
size   
)

Base64 encodes the buffer pointed to by source and returns the resulting string.

Parameters:
sourceThe buffer that needs to be base64 encoded.
sizeThe size.

This function produces a STRING_HANDLE containing the base64 encoding of the buffer pointed to by source, having the size as given by size. If source is NULL then Base64_Encode_Bytes returns NULL If source is not NULL and size is zero, then Base64_Encode_Bytes produces an empty STRING_HANDLE. Otherwise, Base64_Encode_Bytes produces a STRING_HANDLE containing the Base64 representation of the buffer. In case of any errors, Base64_Encode_Bytes returns NULL.].

Returns:
NULL in case an error occurs or a STRING_HANDLE containing the base64 encoding of input.