This is a collection base64 encoding/decoding functions used in Wget2.
◆ wget_base64_is_string()
int wget_base64_is_string |
( |
const char * |
src | ) |
|
- Parameters
-
[in] | src | String to be checked |
- Returns
- 1 if
src
is a base64 string, 0 otherwise
Checks wether src
is a base64 string. Returns 0 if src
is NULL.
◆ wget_base64_decode()
size_t wget_base64_decode |
( |
char * |
dst, |
|
|
const char * |
src, |
|
|
size_t |
n |
|
) |
| |
- Parameters
-
[out] | dst | Output buffer |
[in] | src | Base64 string to be decoded |
[in] | n | Length of src |
- Returns
- Number of bytes written into
dst
Decodes n
bytes of the base64 string src
. The decoded bytes are written into dst
and are 0-terminated.
The size of dst
has to be at minimum ((n
+ 3) / 4) * 3 + 1 bytes.
◆ wget_base64_decode_alloc()
char* wget_base64_decode_alloc |
( |
const char * |
src, |
|
|
size_t |
n |
|
) |
| |
- Parameters
-
[in] | src | Base64 string to be decoded |
[in] | n | Length of src |
- Returns
- Decoded bytes, zero terminated
Decodes n
bytes of the base64 string src
. The decoded bytes are returned in an allocated buffer.
You should free() the returned string when not needed any more.
◆ wget_base64_encode()
size_t wget_base64_encode |
( |
char * |
dst, |
|
|
const char * |
src, |
|
|
size_t |
n |
|
) |
| |
- Parameters
-
[out] | dst | Base64 output string |
[in] | src | Input buffer |
[in] | n | Number of bytes to be encoded |
- Returns
- Length of output string
dst
Encodes n
bytes from src
into a base64 string. The encoded string is written into dst
(0-terminated).
The length of dst
has to be at minimum ((n
+ 2) / 3) * 4 + 1 bytes.
◆ wget_base64_encode_alloc()
char* wget_base64_encode_alloc |
( |
const char * |
src, |
|
|
size_t |
n |
|
) |
| |
- Parameters
-
[in] | src | Input buffer |
[in] | n | Number of bytes to be encoded |
- Returns
- Base64 encoded string
Encodes n
bytes from input buffer src
. The encoded string is returned in an allocated buffer.
You should free() the returned string when not needed any more.
◆ wget_base64_encode_vprintf_alloc()
char* wget_base64_encode_vprintf_alloc |
( |
const char * |
fmt, |
|
|
va_list |
args |
|
) |
| |
- Parameters
-
[in] | fmt | Printf-like format string |
[in] | args | Argument list |
- Returns
- Base64 encoded string
Encodes the string constructed by fmt
and args
. The encoded string is returned in an allocated buffer.
You should free() the returned string when not needed any more.
◆ wget_base64_encode_printf_alloc()
char* wget_base64_encode_printf_alloc |
( |
const char * |
fmt, |
|
|
|
... |
|
) |
| |
- Parameters
-
[in] | fmt | Printf-like format string |
[in] | ... | Argument list |
- Returns
- Base64 encoded string
Encodes the string constructed by fmt
and the arguments. The encoded string is returned in an allocated buffer.
You should free() the returned string when not needed any more.