base64Binary¶
A base64Binary is arbitrary binary data in base64 encoding.
Strings consist of characters from the base64 alphabet ([0-9], [A-Z], [a-z], “+”, “/”, and “=”) with whitespace (tab, newline, carriage return, or space) allowed anywhere. Strings are padded to a multiple of four non-whitespace characters with with trailing “=” characters. For example, the base64 encoding of the string “data” is “ZGF0YQo=”.
Canonical form contains no whitespace.
-
size_t exess_decoded_base64_size(size_t length)¶
Return the maximum number of bytes required to decode
lengthbytes of base64.The returned value is an upper bound which is only exact for canonical strings.
- Parameters:
length – Number of input (text) bytes to decode.
- Returns:
The maximum size of a decoded value in bytes.
-
ExessVariableResult exess_read_base64(const char *str, size_t out_size, void *out)¶
Read a binary value from a base64 string.
Canonical syntax is a multiple of 4 base64 characters, with either 1 or 2 trailing “=” characters as necessary, like “Zm9vYg==”, with no whitespace. All whitespace is skipped when reading.
The caller must allocate a large enough buffer to read the value, otherwise an
ExessStatus.EXESS_NO_SPACEerror will be returned. The required space can be calculated withexess_decoded_base64_size().When this is called,
outmust point to a buffer of at leastout_sizebytes. The returned result contains the exact size of the decoded data, which may be smaller thanout_size. Only these first bytes are written, the rest of the buffer isn’t modified.- Parameters:
str – String to read.
out_size – Size of
outin bytes.out – Decoded binary data.
- Returns:
The
read_countof characters read,write_countof bytes written, and astatus.
-
ExessResult exess_write_base64(size_t data_size, const void *data, size_t buf_size, char *buf)¶
Write a canonical
base64Binarystring.The data is always written in canonical form, as a multiple of 4 characters with no whitespace and 1 or 2 trailing “=” characters as padding if necessary.
- Parameters:
data_size – Size of
datain bytes.data – Data to write.
buf_size – Size of
bufin bytes.buf – Output buffer, or null to only measure.
- Returns:
The
countof characters in the output, and astatus(ExessStatus.EXESS_SUCCESS, orExessStatus.EXESS_NO_SPACEif the buffer is too small).