MeterLogger
Functions | Variables
base64.c File Reference
#include <esp8266.h>
#include "base64.h"
Include dependency graph for base64.c:

Go to the source code of this file.

Functions

int ICACHE_FLASH_ATTR base64_decode (size_t in_len, const char *in, size_t out_len, unsigned char *out)
 

Variables

static const uint8_t base64dec_tab [256]
 

Function Documentation

◆ base64_decode()

int ICACHE_FLASH_ATTR base64_decode ( size_t  in_len,
const char *  in,
size_t  out_len,
unsigned char *  out 
)

Definition at line 42 of file base64.c.

References base64dec_tab, and isspace.

Referenced by authBasic().

42  {
43  unsigned int ii, io;
44  uint32_t v;
45  unsigned int rem;
46 
47  for(io=0,ii=0,v=0,rem=0;ii<in_len;ii++) {
48  unsigned char ch;
49  if(isspace((int)in[ii])) continue;
50  if(in[ii]=='=') break; /* stop at = */
51  ch=base64dec_tab[(unsigned int)in[ii]];
52  if(ch==255) break; /* stop at a parse error */
53  v=(v<<6)|ch;
54  rem+=6;
55  if(rem>=8) {
56  rem-=8;
57  if(io>=out_len) return -1; /* truncation is failure */
58  out[io++]=(v>>rem)&255;
59  }
60  }
61  if(rem>=8) {
62  rem-=8;
63  if(io>=out_len) return -1; /* truncation is failure */
64  out[io++]=(v>>rem)&255;
65  }
66  return io;
67 }
#define isspace(c)
Definition: ip_addr.c:119
static const uint8_t base64dec_tab[256]
Definition: base64.c:6
Here is the caller graph for this function:

Variable Documentation

◆ base64dec_tab

const uint8_t base64dec_tab[256]
static
Initial value:
= {
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255, 62,255,255,255, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61,255,255,255, 0,255,255,
255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,255,255,255,255,255,
255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
}

Definition at line 6 of file base64.c.

Referenced by base64_decode().