Mercurial > emacs
annotate lib-src/b2m.c @ 6981:9d977a1a7147
Doc fixes.
(c-macro-expansion): Handle a and b comment styles.
(c-macro-shrink-window-flag): Renamed from c-macro-shrink-window-p.
(c-macro-prompt-flag): Renamed from c-macro-prompt-p.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 20 Apr 1994 06:19:14 +0000 |
parents | 226d490216f7 |
children | a4a9a0d9b53a |
rev | line source |
---|---|
440 | 1 /* |
2 * b2m - a filter for Babyl -> Unix mail files | |
3 * | |
4 * usage: b2m < babyl > mailbox | |
5 * | |
6 * I find this useful whenever I have to use a | |
7 * system which - shock horror! - doesn't run | |
8 * Gnu emacs. At least now I can read all my | |
9 * Gnumacs Babyl format mail files! | |
10 * | |
11 * it's not much but it's free! | |
12 * | |
13 * Ed Wilkinson | |
14 * E.Wilkinson@massey.ac.nz | |
15 * Mon Nov 7 15:54:06 PDT 1988 | |
16 */ | |
17 | |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
18 /* Serious bug: This program uses `gets', which is intrinsically |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
19 unreliable--long lines will cause crashes. |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
20 Someone should fix this program not to use `gets'. */ |
440 | 21 #include <stdio.h> |
22 #include <time.h> | |
4008
b43e59cb1d54
* b2m.c: #include <sys/types.h>.
Jim Blandy <jimb@redhat.com>
parents:
2101
diff
changeset
|
23 #include <sys/types.h> |
5448
18de002e47dd
(main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
24 #ifdef MSDOS |
18de002e47dd
(main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
25 #include <fcntl.h> |
18de002e47dd
(main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
26 #endif |
998 | 27 |
6214
512963eb02fe
(main): Change delimiter from "^L" to "^_^L".
Richard M. Stallman <rms@gnu.org>
parents:
6173
diff
changeset
|
28 #include <../src/config.h> |
998 | 29 |
30 #ifdef USG | |
31 #include <string.h> | |
32 #else | |
440 | 33 #include <strings.h> |
998 | 34 #endif |
440 | 35 |
36 /* BSD's strings.h does not declare the type of strtok. */ | |
37 extern char *strtok (); | |
38 | |
4572
beb5acbcd482
(TRUE, FALSE): Don't define if already defined.
Richard M. Stallman <rms@gnu.org>
parents:
4008
diff
changeset
|
39 #ifndef TRUE |
440 | 40 #define TRUE (1) |
4572
beb5acbcd482
(TRUE, FALSE): Don't define if already defined.
Richard M. Stallman <rms@gnu.org>
parents:
4008
diff
changeset
|
41 #endif |
beb5acbcd482
(TRUE, FALSE): Don't define if already defined.
Richard M. Stallman <rms@gnu.org>
parents:
4008
diff
changeset
|
42 #ifndef FALSE |
440 | 43 #define FALSE (0) |
4572
beb5acbcd482
(TRUE, FALSE): Don't define if already defined.
Richard M. Stallman <rms@gnu.org>
parents:
4008
diff
changeset
|
44 #endif |
440 | 45 |
46 int header = FALSE, printing; | |
4008
b43e59cb1d54
* b2m.c: #include <sys/types.h>.
Jim Blandy <jimb@redhat.com>
parents:
2101
diff
changeset
|
47 time_t ltoday; |
440 | 48 char from[256], labels[256], data[256], *p, *today; |
49 | |
2101
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
50 main (argc, argv) |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
51 int argc; |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
52 char **argv; |
440 | 53 { |
5448
18de002e47dd
(main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
54 #ifdef MSDOS |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
55 _fmode = O_BINARY; /* all of files are treated as binary files */ |
5448
18de002e47dd
(main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
56 (stdout)->_flag &= ~_IOTEXT; |
18de002e47dd
(main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
57 (stdin)->_flag &= ~_IOTEXT; |
18de002e47dd
(main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
58 #endif |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
59 if (strcmp (argv[1], "--help") == 0) |
6173
cbf3383981cb
(main): Change delimiter from "^L" to "^_^L".
Karl Heuer <kwzh@gnu.org>
parents:
5448
diff
changeset
|
60 { |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
61 fprintf (stderr, "Usage: %s <babylmailbox >unixmailbox\n", argv[0]); |
6173
cbf3383981cb
(main): Change delimiter from "^L" to "^_^L".
Karl Heuer <kwzh@gnu.org>
parents:
5448
diff
changeset
|
62 exit (0); |
cbf3383981cb
(main): Change delimiter from "^L" to "^_^L".
Karl Heuer <kwzh@gnu.org>
parents:
5448
diff
changeset
|
63 } |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
64 ltoday = time (0); |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
65 today = ctime (<oday); |
440 | 66 |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
67 /* BUG! Must not use gets in a reliable program! */ |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
68 if (gets (data)) |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
69 { |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
70 if (strncmp (data, "BABYL OPTIONS:", 14)) |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
71 { |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
72 fprintf (stderr, "%s: not a Babyl mailfile!\n", argv[0]); |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
73 exit (-1); |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
74 } |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
75 else |
6173
cbf3383981cb
(main): Change delimiter from "^L" to "^_^L".
Karl Heuer <kwzh@gnu.org>
parents:
5448
diff
changeset
|
76 printing = FALSE; |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
77 } |
440 | 78 else |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
79 exit (-1); |
440 | 80 if (printing) |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
81 puts (data); |
440 | 82 |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
83 while (gets (data)) |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
84 { |
2101
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
85 |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
86 #if 0 |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
87 /* What was this for? Does somebody have something against blank |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
88 lines? */ |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
89 if (!strcmp (data, "")) |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
90 exit (0); |
2101
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
91 #endif |
440 | 92 |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
93 if (!strcmp (data, "*** EOOH ***") && !printing) |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
94 { |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
95 printing = header = TRUE; |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
96 printf ("From %s %s", argv[0], today); |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
97 continue; |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
98 } |
6173
cbf3383981cb
(main): Change delimiter from "^L" to "^_^L".
Karl Heuer <kwzh@gnu.org>
parents:
5448
diff
changeset
|
99 |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
100 if (!strcmp (data, "\037\f")) |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
101 { |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
102 /* save labels */ |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
103 gets (data); |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
104 p = strtok (data, " ,\r\n\t"); |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
105 strcpy (labels, "X-Babyl-Labels: "); |
440 | 106 |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
107 while (p = strtok (NULL, " ,\r\n\t")) |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
108 { |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
109 strcat (labels, p); |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
110 strcat (labels, ", "); |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
111 } |
440 | 112 |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
113 labels[strlen (labels) - 2] = '\0'; |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
114 printing = header = FALSE; |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
115 continue; |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
116 } |
440 | 117 |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
118 if (!strlen (data) && header) |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
119 { |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
120 header = FALSE; |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
121 if (strcmp (labels, "X-Babyl-Labels")) |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
122 puts (labels); |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
123 } |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
124 |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
125 if (printing) |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
126 puts (data); |
440 | 127 } |
128 } |