paraslash Paraslash Audio Streaming
About   News   Download   Documentation   Development

Macros | Functions
base64.c File Reference

Uudecode and base64decode implementation. More...

#include <regex.h>
#include "para.h"
#include "error.h"
#include "base64.h"
#include "string.h"

Macros

#define BASE64_MAX_DECODED_SIZE(_encoded_size)   ((_encoded_size) / 4 * 3)
 Maximal possible size of the decoded data. More...
 
#define PAD64   '='
 

Functions

int base64_decode (char const *src, size_t encoded_size, char **result, size_t *decoded_size)
 base64-decode a buffer. More...
 
int uudecode (char const *src, size_t encoded_size, char **result, size_t *decoded_size)
 Decode a buffer using the uuencode Base64 algorithm. More...
 

Detailed Description

Uudecode and base64decode implementation.

Macro Definition Documentation

◆ BASE64_MAX_DECODED_SIZE

#define BASE64_MAX_DECODED_SIZE (   _encoded_size)    ((_encoded_size) / 4 * 3)

Maximal possible size of the decoded data.

◆ PAD64

#define PAD64   '='

Function Documentation

◆ base64_decode()

int base64_decode ( char const *  src,
size_t  encoded_size,
char **  result,
size_t *  decoded_size 
)

base64-decode a buffer.

Parameters
srcThe buffer to decode.
encoded_sizeThe special value -1 means: look for terminating zero byte.
resultPoints to dynamically allocated target buffer on success.
decoded_sizeNumber of bytes written to result.

Skips all whitespace anywhere. Converts characters, four at a time, starting at (or after) src from base - 64 numbers into three 8 bit bytes in the target area.

It is OK to pass a NULL pointer as decoded_size. The result is terminated with a zero byte.

Returns
Standard. The contents of result and decoded_size are undefined on failure.

References alloc(), BASE64_MAX_DECODED_SIZE, PAD64, and para_isspace.

Referenced by decode_private_key(), and uudecode().

◆ uudecode()

int uudecode ( char const *  src,
size_t  encoded_size,
char **  result,
size_t *  decoded_size 
)

Decode a buffer using the uuencode Base64 algorithm.

Parameters
srcThe buffer to decode.
encoded_sizeNumber of input bytes in the source buffer.
resultContains the decoded data on success.
decoded_sizeNumber of output bytes on success.

This is just a simple wrapper for base64_decode() which strips whitespace.

Returns
The return value of the underlying call to base64_decode().
See also
uuencode(1), uudecode(1).

References base64_decode().