Commit d4cd9300 d4cd9300d4f3ba5411f0bf54be676272e7702169 by Sergey Poznyakoff

Allow to specify charset and encoding from the command line.

1 parent 1241e8b4
...@@ -26,7 +26,26 @@ ...@@ -26,7 +26,26 @@
26 int 26 int
27 main (int argc, char *argv[]) 27 main (int argc, char *argv[])
28 { 28 {
29 int c;
29 char buf[256]; 30 char buf[256];
31 char *charset = "iso-8859-1";
32 char *encoding = "quoted-printable";
33
34 while ((c = getopt (argc, argv, "c:e:h")) != EOF)
35 switch (c)
36 {
37 case 'c':
38 charset = optarg;
39 break;
40 case 'e':
41 encoding = optarg;
42 break;
43 case 'h':
44 printf ("usage: %s [-c charset] [-e encoding]\n", argv[0]);
45 exit (0);
46 default:
47 exit (1);
48 }
30 49
31 while (fgets (buf, sizeof (buf), stdin)) 50 while (fgets (buf, sizeof (buf), stdin))
32 { 51 {
...@@ -36,7 +55,7 @@ main (int argc, char *argv[]) ...@@ -36,7 +55,7 @@ main (int argc, char *argv[])
36 len = strlen (buf); 55 len = strlen (buf);
37 if (len > 0 && buf[len - 1] == '\n') 56 if (len > 0 && buf[len - 1] == '\n')
38 buf[len - 1] = 0; 57 buf[len - 1] = 0;
39 rc = mu_rfc2047_encode ("iso-8859-1", "quoted-printable", buf, &p); 58 rc = mu_rfc2047_encode (charset, encoding, buf, &p);
40 printf ("%s=> %s\n", buf, mu_strerror (rc)); 59 printf ("%s=> %s\n", buf, mu_strerror (rc));
41 if (p) 60 if (p)
42 printf ("%s\n", p); 61 printf ("%s\n", p);
......