Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / miscellany / multi-media / misc / RCS / rt2raw.c,v
1 head    1.2;
2 access;
3 symbols;
4 locks; strict;
5 comment @ * @;
6
7
8 1.2
9 date    95.12.06.19.20.22;      author jromine; state Exp;
10 branches;
11 next    1.1;
12
13 1.1
14 date    95.12.06.19.18.19;      author jromine; state Exp;
15 branches;
16 next    ;
17
18
19 desc
20 @@
21
22
23 1.2
24 log
25 @fixes from mtr
26 @
27 text
28 @/* taken straight from the MIME specification, to use with multi-media MH, do:
29
30         mhn-show-text/richtext: rt2raw < %f | fmt -78 | more
31
32    in your .mhn_profile.
33
34    Note that MTR doesn't use this program.  He uses NB's richtext program
35    instead (the one that comes with MetaMail).  See RICHTEXT.setup for the
36    details.
37  */
38
39 #include <stdio.h>
40 #include <ctype.h>
41 main() {
42     int c, i;
43     char token[50];
44
45     while((c = getc(stdin)) != EOF) {
46         if (c == '<') {
47             for (i=0; (c = getc(stdin)) != '>'
48                       && c != EOF; ++i) {
49                 token[i] = isupper(c) ? tolower(c) : c;
50             }
51             if (c == EOF) break;
52             token[i] = NULL;
53             if (!strcmp(token, "lt")) {
54                 putc('<', stdout);
55             } else if (!strcmp(token, "nl")) {
56                 putc('\n', stdout);
57             } else if (!strcmp(token, "/paragraph")) {
58                 puts("\n\n", stdout);
59             } else if (!strcmp(token, "comment")) {
60                 int commct=1;
61                 while (commct > 0) {
62                     while ((c = getc(stdin)) != '<'
63                      && c != EOF) ;
64                     if (c == EOF) break;
65                     for (i=0; (c = getc(stdin)) != '>'
66                        && c != EOF; ++i) {
67                         token[i] = isupper(c) ?
68                          tolower(c) : c;
69                     }
70                     if (c== EOF) break;
71                     token[i] = NULL;
72                     if (!strcmp(token, "/comment")) --commct;
73                     if (!strcmp(token, "comment"))  ++commct;
74                 }
75             } /* Ignore all other tokens */
76         } else if (c != '\n') {
77             putc(c, stdout);
78         } else putc (' ', stdout);
79     }
80     putc('\n', stdout); /* for good measure */
81     exit(0);
82 }
83 @
84
85
86 1.1
87 log
88 @Initial revision
89 @
90 text
91 @d51 1
92 a51 1
93         }
94 @