New "Layout" configuration dialog is fully described.
[free-mc.git] / src / mfmt.c
blobd79f00c93443cdb452b8b6358f2b91c208fda5bf
1 /* mfmt: sets bold and underline for mail files
2 (c) 1995 miguel de icaza
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 /** \file mfmt.c
20 * \brief Source: sets bold and underline for mail files
23 #include <stdio.h>
25 enum states {
26 header,
27 definition,
28 plain,
29 newline,
30 seen_f,
31 seen_r,
32 seen_o,
33 header_new,
34 seen_m
37 int
38 main (void)
40 int c;
41 int state = newline;
42 int space_seen = 0;
44 while ((c = getchar ()) != EOF){
45 switch (state){
46 case plain:
47 if (c == '\n')
48 state = newline;
49 putchar (c);
50 break;
52 case newline:
53 if (c == 'F')
54 state = seen_f;
55 else if (c == '\n')
56 putchar ('\n');
57 else {
58 state = plain;
59 putchar (c);
61 break;
63 case seen_f:
64 if (c == 'r')
65 state = seen_r;
66 else {
67 printf ("F%c", c);
68 state = plain;
70 break;
72 case seen_r:
73 if (c == 'o')
74 state = seen_o;
75 else {
76 state = plain;
77 printf ("Fr%c", c);
79 break;
81 case seen_o:
82 if (c == 'm'){
83 state = seen_m;
84 } else {
85 state = plain;
86 printf ("Fro%c", c);
88 break;
90 case seen_m:
91 if (c == ' '){
92 state = definition;
93 printf ("_\bF_\br_\bo_\bm ");
94 } else {
95 state = plain;
96 printf ("From%c", c);
98 break;
100 case header_new:
101 space_seen = 0;
102 if (c == ' ' || c == '\t') {
103 state = definition;
104 putchar (c);
105 break;
107 if (c == '\n'){
108 state = plain;
109 putchar (c);
110 break;
113 case header:
114 if (c == '\n'){
115 putchar (c);
116 state = header_new;
117 break;
119 printf ("_\b%c", c);
120 if (c == ' ')
121 space_seen = 1;
122 if (c == ':' && !space_seen)
123 state = definition;
124 break;
126 case definition:
127 if (c == '\n'){
128 putchar (c);
129 state = header_new;
130 break;
132 printf ("%c\b%c", c, c);
133 break;
136 return (0);