Welcome to the NetCologne GmbH open source mirroring service!

This machine mirrors various open-source projects. 20 Gbit/s uplink.

If there are any issues or you want another project mirrored, please contact mirror-service -=AT=- netcologne DOT de !

oRTP: src/b64.c File Reference
oRTP  0.24.0
Data Structures | Macros | Typedefs | Functions
b64.c File Reference
#include "ortp/port.h"
#include "ortp/b64.h"
#include <assert.h>
#include <string.h>

Data Structures

struct  b64ErrorString_t_
 

Macros

#define B64_VER_C_B64_MAJOR   1
 
#define B64_VER_C_B64_MINOR   2
 
#define B64_VER_C_B64_REVISION   3
 
#define B64_VER_C_B64_EDIT   17
 
#define NUM_PLAIN_DATA_BYTES   (3)
 
#define NUM_ENCODED_DATA_BYTES   (4)
 
#define NUM_ELEMENTS(x)   (sizeof(x) / sizeof(x[0]))
 
#define SEVERITY_STR_DECL(rc, desc)
 
#define SEVERITY_STR_ENTRY(rc)
 

Typedefs

typedef struct b64ErrorString_t_ b64ErrorString_t_
 

Functions

size_t b64_encode (void const *src, size_t srcSize, char *dest, size_t destLen)
 Encodes a block of binary data into Base-64. More...
 
size_t b64_encode2 (void const *src, size_t srcSize, char *dest, size_t destLen, unsigned flags, int lineLen, B64_RC *rc)
 Encodes a block of binary data into Base-64. More...
 
size_t b64_decode (char const *src, size_t srcLen, void *dest, size_t destSize)
 Decodes a sequence of Base-64 into a block of binary data. More...
 
size_t b64_decode2 (char const *src, size_t srcLen, void *dest, size_t destSize, unsigned flags, char const **badChar, B64_RC *rc)
 Decodes a sequence of Base-64 into a block of binary data. More...
 
char const * b64_getErrorString (B64_RC code)
 Returns the textual description of the error. More...
 
size_t b64_getErrorStringLength (B64_RC code)
 Returns the length of the textual description of the error. More...
 

Detailed Description

Implementation file for the b64 library

Macro Definition Documentation

#define SEVERITY_STR_DECL (   rc,
  desc 
)
Value:
\
static const char s_str##rc[] = desc; \
static const b64ErrorString_t_ s_rct##rc = { rc, s_str##rc, NUM_ELEMENTS(s_str##rc) - 1 }
Definition: b64.c:520
#define SEVERITY_STR_ENTRY (   rc)
Value:
\
&s_rct##rc

Function Documentation

size_t b64_decode ( char const *  src,
size_t  srcLen,
void *  dest,
size_t  destSize 
)

Decodes a sequence of Base-64 into a block of binary data.

Parameters
srcPointer to the Base-64 block to be decoded. May not be NULL, except when dest is NULL, in which case it is ignored. If dest is NULL, and src is not NULL, then the returned value is calculated exactly, otherwise a value is returned that is guaranteed to be large enough to hold the decoded block.
srcLenLength of block to be encoded. Must be an integral of 4, the Base-64 encoding quantum, otherwise the Base-64 block is assumed to be invalid
destPointer to the buffer into which the result is to be written. May be NULL, in which case the function returns the required length
destSizeLength of the buffer into which the result is to be written. Must be at least as large as that indicated by the return value from b64_decode(src, srcSize, NULL, 0), even in the case where the encoded form contains a number of characters that will be ignored, resulting in a lower total length of converted form.
Returns
0 if the size of the buffer was insufficient, or the length of the converted buffer was longer than destSize
Note
The function returns the required length if dest is NULL. The returned size might be larger than the actual required size, but will never be smaller.
The behaviour of both b64_encode2() and b64_decode2() are undefined if the line length is not a multiple of 4.
Threading: The function is fully re-entrant.
See Also
b64::decode()
size_t b64_decode2 ( char const *  src,
size_t  srcLen,
void *  dest,
size_t  destSize,
unsigned  flags,
char const **  badChar,
B64_RC *  rc 
)

Decodes a sequence of Base-64 into a block of binary data.

Parameters
srcPointer to the Base-64 block to be decoded. May not be NULL, except when dest is NULL, in which case it is ignored. If dest is NULL, and src is not NULL, then the returned value is calculated exactly, otherwise a value is returned that is guaranteed to be large enough to hold the decoded block.
srcLenLength of block to be encoded. Must be an integral of 4, the Base-64 encoding quantum, otherwise the Base-64 block is assumed to be invalid
destPointer to the buffer into which the result is to be written. May be NULL, in which case the function returns the required length
destSizeLength of the buffer into which the result is to be written. Must be at least as large as that indicated by the return value from b64_decode(src, srcSize, NULL, 0), even in the case where the encoded form contains a number of characters that will be ignored, resulting in a lower total length of converted form.
flagsA combination of the B64_FLAGS enumeration, that moderate the behaviour of the function.
rcThe return code representing the status of the operation. May be NULL.
badCharIf the flags parameter does not contain B64_F_STOP_ON_NOTHING, this parameter specifies the address of a pointer that will be set to point to any character in the sequence that stops the parsing, as dictated by the flags parameter. May be NULL.
Returns
0 if the size of the buffer was insufficient, or the length of the converted buffer was longer than destSize, or a bad character stopped parsing.
Note
The function returns the required length if dest is NULL. The returned size might be larger than the actual required size, but will never be smaller.
The behaviour of both b64_encode2() and b64_decode2() are undefined if the line length is not a multiple of 4.
Threading: The function is fully re-entrant.
See Also
b64::decode()
size_t b64_encode ( void const *  src,
size_t  srcSize,
char *  dest,
size_t  destLen 
)

Encodes a block of binary data into Base-64.

Parameters
srcPointer to the block to be encoded. May not be NULL, except when dest is NULL, in which case it is ignored.
srcSizeLength of block to be encoded
destPointer to the buffer into which the result is to be written. May be NULL, in which case the function returns the required length
destLenLength of the buffer into which the result is to be written. Must be at least as large as that indicated by the return value from b64_encode(NULL, srcSize, NULL, 0).
Returns
0 if the size of the buffer was insufficient, or the length of the converted buffer was longer than destLen
Note
The function returns the required length if dest is NULL
The function returns the required length if dest is NULL. The returned size might be larger than the actual required size, but will never be smaller.
Threading: The function is fully re-entrant.
See Also
b64::encode()
size_t b64_encode2 ( void const *  src,
size_t  srcSize,
char *  dest,
size_t  destLen,
unsigned  flags,
int  lineLen,
B64_RC *  rc 
)

Encodes a block of binary data into Base-64.

Parameters
srcPointer to the block to be encoded. May not be NULL, except when dest is NULL, in which case it is ignored.
srcSizeLength of block to be encoded
destPointer to the buffer into which the result is to be written. May be NULL, in which case the function returns the required length
destLenLength of the buffer into which the result is to be written. Must be at least as large as that indicated by the return value from b64_encode2(NULL, srcSize, NULL, 0, flags, lineLen, rc).
flagsA combination of the B64_FLAGS enumeration, that moderate the behaviour of the function
lineLenIf the flags parameter contains B64_F_LINE_LEN_USE_PARAM, then this parameter represents the length of the lines into which the encoded form is split, with a hard line break ('\r\n'). If this value is 0, then the line is not split. If it is <0, then the RFC-1113 recommended line length of 64 is used
rcThe return code representing the status of the operation. May be NULL.
Returns
0 if the size of the buffer was insufficient, or the length of the converted buffer was longer than destLen
Note
The function returns the required length if dest is NULL. The returned size might be larger than the actual required size, but will never be smaller.
Threading: The function is fully re-entrant.
See Also
b64::encode()
char const* b64_getErrorString ( B64_RC  code)

Returns the textual description of the error.

Parameters
codeThe error code
size_t b64_getErrorStringLength ( B64_RC  code)

Returns the length of the textual description of the error.

See Also
b64_getErrorString()
Parameters
codeThe error code