mess822x 1.23
mess822x
Loading...
Searching...
No Matches
b64decode.c
Go to the documentation of this file.
1#include "buffer.h"
2#include "logmsg.h"
3#include "getln.h"
4#include "mess822.h"
5#include "exit.h"
6#include "getoptb.h"
7
8#define WHO "b64decode"
9
10stralloc line = {0};
11stralloc temp = {0};
12stralloc out = {0};
14
15int main(int argc,char **argv)
16{
17 int r;
18 int opt;
19 int flag = 0;
20
21 while ((opt = getoptb(argc,argv,"u")) != opteof)
22 switch (opt) {
23 case 'u': flag = 4648; break;
24 default : logmsg(WHO,100,USAGE,"b64decode [-u] (reading from STDIN)");
25 }
26
27 for (;;) {
28 if (getln(buffer_0,&line,&match,'\n') == -1)
29 logmsg(WHO,111,FATAL,B("unable to read input: ",line.s));
30 if (!stralloc_cat(&temp,&line)) _exit(-1);
31 if (!match) break;
32 }
33
34 if (flag == 4648) r = mess822_b64decode(&out,temp.s,temp.len,4648);
35 else r = mess822_b64decode(&out,temp.s,temp.len,1);
36 if (r > 0) buffer_put(buffer_1,out.s,out.len);
37 buffer_flush(buffer_1);
38
39 _exit(0);
40}
int main()
Definition: 822print.c:351
stralloc out
Definition: b64decode.c:12
stralloc temp
Definition: b64decode.c:11
stralloc line
Definition: b64decode.c:10
int match
Definition: b64decode.c:13
#define WHO
Definition: b64decode.c:8
int mess822_b64decode(stralloc *, const char *, int, int)
int flag
Definition: 822field.c:16