Instrument Neutral Distributed Interface INDI  2.0.2
Macros | Functions
base64.c File Reference

Pair of functions to convert to/from base64. More...

#include <ctype.h>
#include <stdint.h>
#include "base64.h"
#include "base64_luts.h"
#include <stdio.h>
#include <arpa/inet.h>

Go to the source code of this file.

Macros

#define bswap_16(x)   ((uint16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)))
 
#define IS_BIG_ENDIAN   (1 == htons(1))
 
#define IS_LITTLE_ENDIAN   (!IS_BIG_ENDIAN)
 

Functions

int to64frombits_s (unsigned char *out, const unsigned char *in, int inlen, size_t outlen)
 Convert bytes array to base64. More...
 
int to64frombits (unsigned char *out, const unsigned char *in, int inlen)
 
int from64tobits (char *out, const char *in)
 Convert base64 to bytes array. More...
 
int from64tobits_fast (char *out, const char *in, int inlen)
 
int from64tobits_fast_with_bug (char *out, const char *in, int inlen)
 

Detailed Description

Pair of functions to convert to/from base64.

Definition in file base64.c.

Macro Definition Documentation

◆ bswap_16

#define bswap_16 (   x)    ((uint16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)))

Definition at line 48 of file base64.c.

◆ IS_BIG_ENDIAN

#define IS_BIG_ENDIAN   (1 == htons(1))

Definition at line 54 of file base64.c.

◆ IS_LITTLE_ENDIAN

#define IS_LITTLE_ENDIAN   (!IS_BIG_ENDIAN)

Definition at line 57 of file base64.c.

Function Documentation

◆ from64tobits()

int from64tobits ( char *  out,
const char *  in 
)

Convert base64 to bytes array.

Parameters
outoutput buffer in bytes. The buffer size must be at least (3 * size_of_in_buffer / 4) bytes long.
ininput base64 buffer
inlenbase64 buffer lenght
Returns
0 on success, -1 on failure.

Definition at line 114 of file base64.c.

◆ from64tobits_fast()

int from64tobits_fast ( char *  out,
const char *  in,
int  inlen 
)

Definition at line 122 of file base64.c.

◆ from64tobits_fast_with_bug()

int from64tobits_fast_with_bug ( char *  out,
const char *  in,
int  inlen 
)

Definition at line 199 of file base64.c.

◆ to64frombits()

int to64frombits ( unsigned char *  out,
const unsigned char *  in,
int  inlen 
)

Definition at line 77 of file base64.c.

◆ to64frombits_s()

int to64frombits_s ( unsigned char *  out,
const unsigned char *  in,
int  inlen,
size_t  outlen 
)

Convert bytes array to base64.

Parameters
outoutput buffer in base64. The buffer size must be at least (4 * inlen / 3 + 4) bytes long.
ininput binary buffer
inlennumber of bytes to convert
Returns
0 on success, -1 on failure.

Definition at line 63 of file base64.c.