mess822x 1.23
mess822x
Loading...
Searching...
No Matches
b64encode.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 "b64encode"
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,"b64encode [-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_b64urlencode(&out,&temp);
35 else r = mess822_b64encode(&out,&temp);
36 if (r > 0) buffer_put(buffer_1,out.s,out.len);
37 buffer_put(buffer_1,"\n",1);
38 buffer_flush(buffer_1);
39
40 _exit(0);
41}
stralloc out
Definition: b64encode.c:12
stralloc temp
Definition: b64encode.c:11
stralloc line
Definition: b64encode.c:10
int match
Definition: b64encode.c:13
#define WHO
Definition: b64encode.c:8
int main()
Definition: 822print.c:351
int mess822_b64urlencode(stralloc *, stralloc *)
int mess822_b64encode(stralloc *, stralloc *)
int flag
Definition: 822field.c:16