2 * A Program For Manipulation With Base224 Encoded Files
4 * (c) 2002 Martin Mares <mj@ucw.cz>
8 #include "ucw/fastbuf.h"
9 #include "ucw/base224.h"
13 int main(int argc, char **argv)
15 struct fastbuf *in = bfdopen_shared(0, 4096);
16 struct fastbuf *out = bfdopen_shared(1, 4096);
17 byte ib[BASE224_IN_CHUNK*10], ob[BASE224_OUT_CHUNK*10], *b;
20 if (argc != 2 || argv[1][0] != '-')
25 case 'e': /* Plain encoding */
26 while (il = bread(in, ib, sizeof(ib)))
28 ol = base224_encode(ob, ib, il);
32 case 'E': /* Line block encoding */
33 while (il = bread(in, ib, BASE224_IN_CHUNK*6))
35 ol = base224_encode(ob, ib, il);
41 case 'd': /* Plain decoding */
42 while (ol = bread(in, ob, sizeof(ob)))
44 il = base224_decode(ib, ob, ol);
48 case 'D': /* Line block decoding */
49 while (b = bgets(in, ob, sizeof(ob)))
52 die("Invalid line syntax");
53 il = base224_decode(ib, ob+1, b-ob-1);
59 fputs("Usage: b224 (-e|-E|-d|-D)\n", stderr);