libxputty 0.1
Loading...
Searching...
No Matches
Functions
b64_encode.h File Reference

Go to the source code of this file.

Functions

void b64_encode (char *clrstr, char *b64dst)
 b64_encode - encode a b64 based char
 
void b64_decode (char *b64src, char *clrdst)
 b64_decode - decode to a b64 based char
 

Function Documentation

◆ b64_decode()

void b64_decode ( char *  b64src,
char *  clrdst 
)

b64_decode - decode to a b64 based char

Parameters
*b64src- the char to decode
*clrdst- the decoded char

Definition at line 26 of file b64_encode.c.

26 {
27 int c, phase, i;
28 unsigned char in[4];
29 char *p;
30
31 clrdst[0] = '\0';
32 phase = 0;
33 i=0;
34 while(b64src[i]) {
35 c = (int) b64src[i];
36 if(c == '=') {
37 decodeblock(in, (unsigned char **) &clrdst);
38 break;
39 }
40 p = strchr(b64, c);
41 if(p) {
42 in[phase] = p - b64;
43 phase = (phase + 1) % 4;
44 if(phase == 0) {
45 decodeblock(in, (unsigned char **) &clrdst);
46 in[0]=in[1]=in[2]=in[3]=0;
47 }
48 }
49 i++;
50 }
51}
void decodeblock(unsigned char in[], unsigned char **clrstr)
Definition b64_encode.c:20
char b64[]
Definition b64_encode.c:17

References b64, and decodeblock().

Referenced by widget_get_scaled_svg(), and widget_get_svg().

◆ b64_encode()

void b64_encode ( char *  clrstr,
char *  b64dst 
)

b64_encode - encode a b64 based char

Parameters
*clrstr- the char to encode
*b64dst- the encoded char

Definition at line 66 of file b64_encode.c.

66 {
67 unsigned char in[3];
68 int i, len = 0;
69 int j = 0;
70
71 b64dst[0] = '\0';
72 while(clrstr[j]) {
73 len = 0;
74 for(i=0; i<3; i++) {
75 in[i] = (unsigned char) clrstr[j];
76 if(clrstr[j]) {
77 len++;
78 j++;
79 }
80 else in[i] = 0;
81 }
82 if( len ) {
83 encodeblock( in, b64dst, len );
84 }
85 }
86}
void encodeblock(unsigned char in[], char b64str[], int len)
Definition b64_encode.c:54

References encodeblock().