Commit 0be82334 0be823341497fc06a89d50168a9fc73050128fc6 by Sergey Poznyakoff

(main): Add option -E (encoding). The program

can now be used to test any encoder/decoder filters, so its name
is kind of misnomer.
1 parent f5cfcc6f
...@@ -35,8 +35,9 @@ main (int argc, char * argv []) ...@@ -35,8 +35,9 @@ main (int argc, char * argv [])
35 size_t size, total = 0; 35 size_t size, total = 0;
36 int mode = MU_FILTER_ENCODE; 36 int mode = MU_FILTER_ENCODE;
37 char *input = NULL, *output = NULL; 37 char *input = NULL, *output = NULL;
38 char *encoding = "base64";
38 39
39 while ((c = getopt (argc, argv, "dehi:o:pv")) != EOF) 40 while ((c = getopt (argc, argv, "deE:hi:o:pv")) != EOF)
40 switch (c) 41 switch (c)
41 { 42 {
42 case 'i': 43 case 'i':
...@@ -51,6 +52,10 @@ main (int argc, char * argv []) ...@@ -51,6 +52,10 @@ main (int argc, char * argv [])
51 mode = MU_FILTER_DECODE; 52 mode = MU_FILTER_DECODE;
52 break; 53 break;
53 54
55 case 'E':
56 encoding = optarg;
57 break;
58
54 case 'e': 59 case 'e':
55 mode = MU_FILTER_ENCODE; 60 mode = MU_FILTER_ENCODE;
56 break; 61 break;
...@@ -64,7 +69,7 @@ main (int argc, char * argv []) ...@@ -64,7 +69,7 @@ main (int argc, char * argv [])
64 break; 69 break;
65 70
66 case 'h': 71 case 'h':
67 printf ("usage: base64 [-vpde][-i infile][-o outfile]\n"); 72 printf ("usage: base64 [-vpde][-E encoding][-i infile][-o outfile]\n");
68 exit (0); 73 exit (0);
69 74
70 default: 75 default:
...@@ -76,7 +81,7 @@ main (int argc, char * argv []) ...@@ -76,7 +81,7 @@ main (int argc, char * argv [])
76 else 81 else
77 c = stdio_stream_create (&in, stdin, 0); 82 c = stdio_stream_create (&in, stdin, 0);
78 assert (c == 0); 83 assert (c == 0);
79 assert (filter_create (&flt, in, "base64", mode, MU_STREAM_READ) == 0); 84 assert (filter_create (&flt, in, encoding, mode, MU_STREAM_READ) == 0);
80 assert (stream_open (in) == 0); 85 assert (stream_open (in) == 0);
81 86
82 if (output) 87 if (output)
......