.TH "libwget-base64" 3 "Version 2.1.0" "wget2" \" -*- nroff -*- .ad l .nh .SH NAME libwget-base64 \- Base64 functions .SH SYNOPSIS .br .PP .SS "Macros" .in +1c .ti -1c .RI "#define \fBWGET_BASE64_URLENCODE\fP 1" .br .in -1c .SS "Functions" .in +1c .ti -1c .RI "bool \fBwget_base64_is_string\fP (const char *src)" .br .ti -1c .RI "size_t \fBwget_base64_decode\fP (char *dst, const char *src, size_t n)" .br .ti -1c .RI "char * \fBwget_base64_decode_alloc\fP (const char *src, size_t n, size_t *outlen)" .br .ti -1c .RI "size_t \fBwget_base64_encode\fP (char *dst, const char *src, size_t n)" .br .ti -1c .RI "size_t \fBwget_base64_urlencode\fP (char *dst, const char *src, size_t n)" .br .ti -1c .RI "char * \fBwget_base64_encode_alloc\fP (const char *src, size_t n)" .br .ti -1c .RI "char * \fBwget_base64_encode_vprintf_alloc\fP (const char *fmt, va_list args)" .br .ti -1c .RI "char * \fBwget_base64_encode_printf_alloc\fP (const char *fmt,\&.\&.\&.)" .br .ti -1c .RI "size_t \fBwget_base64_get_decoded_length\fP (size_t len)" .br .ti -1c .RI "size_t \fBwget_base64_get_encoded_length\fP (size_t len)" .br .in -1c .SH "Detailed Description" .PP This is a collection base64 encoding/decoding functions used in Wget2\&. .SH "Function Documentation" .PP .SS "bool wget_base64_is_string (const char * src)" .PP \fBParameters\fP .RS 4 \fIsrc\fP String to be checked .RE .PP \fBReturns\fP .RS 4 1 if \fCsrc\fP is a base64 string, 0 otherwise .RE .PP Checks whether \fCsrc\fP is a base64 string\&. Returns 0 if \fCsrc\fP is NULL\&. .SS "size_t wget_base64_decode (char * dst, const char * src, size_t n)" .PP \fBParameters\fP .RS 4 \fIdst\fP Output buffer .br \fIsrc\fP Base64 string to be decoded .br \fIn\fP Length of \fCsrc\fP .RE .PP \fBReturns\fP .RS 4 Number of bytes written into \fCdst\fP .RE .PP Decodes \fCn\fP bytes of the base64 string \fCsrc\fP\&. The decoded bytes are written into \fCdst\fP and are 0-terminated\&. .PP The size of \fCdst\fP has to be at minimum ((\fCn\fP + 3) / 4) * 3 + 1 bytes\&. .SS "char * wget_base64_decode_alloc (const char * src, size_t n, size_t * outlen)" .PP \fBParameters\fP .RS 4 \fIsrc\fP Base64 string to be decoded .br \fIn\fP Length of \fCsrc\fP .br \fIoutlen\fP Length of returned string, may be NULL\&. .RE .PP \fBReturns\fP .RS 4 Decoded bytes, zero terminated\&. Returns NULL if memory allocation failed\&. .RE .PP Decodes \fCn\fP bytes of the base64 string \fCsrc\fP\&. The decoded bytes are returned in an allocated buffer\&. .PP You should free() the returned string when not needed any more\&. .SS "size_t wget_base64_encode (char * dst, const char * src, size_t n)" .PP \fBParameters\fP .RS 4 \fIdst\fP Base64 output string .br \fIsrc\fP Input buffer .br \fIn\fP Number of bytes to be encoded .RE .PP \fBReturns\fP .RS 4 Length of output string \fCdst\fP .RE .PP Encodes \fCn\fP bytes from \fCsrc\fP into a base64 string\&. The encoded string is written into \fCdst\fP (0-terminated)\&. .PP The length of \fCdst\fP has to be at minimum ((\fCn\fP + 2) / 3) * 4 + 1 bytes\&. .SS "size_t wget_base64_urlencode (char * dst, const char * src, size_t n)" .PP \fBParameters\fP .RS 4 \fIdst\fP Base64 output string (URL and filename safe) .br \fIsrc\fP Input buffer .br \fIn\fP Number of bytes to be encoded .RE .PP \fBReturns\fP .RS 4 Length of output string \fCdst\fP .RE .PP Encodes \fCn\fP bytes from \fCsrc\fP into a base64 URL and filename safe string (see RFC 4648, 5\&.)\&. The encoded string is written into \fCdst\fP (0-terminated)\&. .PP The length of \fCdst\fP has to be at minimum ((\fCn\fP + 2) / 3) * 4 + 1 bytes\&. .SS "char * wget_base64_encode_alloc (const char * src, size_t n)" .PP \fBParameters\fP .RS 4 \fIsrc\fP Input buffer .br \fIn\fP Number of bytes to be encoded .RE .PP \fBReturns\fP .RS 4 Base64 encoded string or NULL if memory allocation failed .RE .PP Encodes \fCn\fP bytes from input buffer \fCsrc\fP\&. The encoded string is returned in an allocated buffer\&. .PP You should free() the returned string when not needed any more\&. .SS "char * wget_base64_encode_vprintf_alloc (const char * fmt, va_list args)" .PP \fBParameters\fP .RS 4 \fIfmt\fP Printf-like format string .br \fIargs\fP Argument list .RE .PP \fBReturns\fP .RS 4 Base64 encoded string .RE .PP Encodes the string constructed by \fCfmt\fP and \fCargs\fP\&. The encoded string is returned in an allocated buffer\&. .PP You should free() the returned string when not needed any more\&. .SS "char * wget_base64_encode_printf_alloc (const char * fmt, \&.\&.\&.)" .PP \fBParameters\fP .RS 4 \fIfmt\fP Printf-like format string .br \fI\&.\&.\&.\fP Argument list .RE .PP \fBReturns\fP .RS 4 Base64 encoded string .RE .PP Encodes the string constructed by \fCfmt\fP and the arguments\&. The encoded string is returned in an allocated buffer\&. .PP You should free() the returned string when not needed any more\&. .SS "static inline size_t wget_base64_get_decoded_length (size_t len)" .PP \fBParameters\fP .RS 4 \fIlen\fP Length of base64 sequence .RE .PP \fBReturns\fP .RS 4 Number of decoded bytes plus one (for 0-byte termination) .RE .PP Calculate the number of bytes needed for decoding a base64 sequence with length \fClen\fP\&. .SS "static inline size_t wget_base64_get_encoded_length (size_t len)" .PP \fBParameters\fP .RS 4 \fIlen\fP Number of (un-encoded) bytes .RE .PP \fBReturns\fP .RS 4 Length of base64 encoding plus one (for 0-byte termination) .RE .PP Calculate the number of bytes needed for base64 encoding a byte sequence with length \fClen\fP, including the padding and 0-termination bytes\&. .SH "Author" .PP Generated automatically by Doxygen for wget2 from the source code\&.