aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorJim Blandy1991-12-04 20:23:21 +0000
committerJim Blandy1991-12-04 20:23:21 +0000
commitcc9940c72cd9350d430daa5c6ed7c5c688889538 (patch)
tree893f1f1dfed23134847f43df892a403ca789babc /lib-src
parent9453ea7be3e2bdd7a3ac8835f35c9f3463efd21d (diff)
downloademacs-cc9940c72cd9350d430daa5c6ed7c5c688889538.tar.gz
emacs-cc9940c72cd9350d430daa5c6ed7c5c688889538.zip
Initial revision
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/b2m.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/lib-src/b2m.c b/lib-src/b2m.c
new file mode 100644
index 00000000000..2aa79b8edc0
--- /dev/null
+++ b/lib-src/b2m.c
@@ -0,0 +1,84 @@
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
18#include <stdio.h>
19#include <time.h>
20#include <strings.h>
21
22/* BSD's strings.h does not declare the type of strtok. */
23extern char *strtok ();
24
25#define TRUE (1)
26#define FALSE (0)
27
28int header = FALSE, printing;
29long ltoday;
30char from[256], labels[256], data[256], *p, *today;
31
32main(argc, argv)
33char **argv;
34{
35 ltoday = time(0);
36 today = ctime(&ltoday);
37
38 if (gets(data))
39 if (strcmp(data, "BABYL OPTIONS:")) {
40 fprintf(stderr, "b2m: not a Babyl mailfile!\n");
41 exit(-1);
42 } else
43 printing = FALSE;
44 else
45 exit(-1);
46 if (printing)
47 puts(data);
48
49 while (gets(data)) {
50 if (!strcmp(data, ""))
51 exit(0);
52
53 if (!strcmp(data, "*** EOOH ***") && !printing) {
54 printing = header = TRUE;
55 printf("From b2m %s", today);
56 continue;
57 }
58
59 if (!strcmp(data, " ")) {
60 /* save labels */
61 gets(data);
62 p = strtok(data, " ,\r\n\t");
63 strcpy(labels, "X-Babyl-Labels: ");
64
65 while (p = strtok(NULL, " ,\r\n\t")) {
66 strcat(labels, p);
67 strcat(labels, ", ");
68 }
69
70 labels[strlen(labels) - 2] = '\0';
71 printing = header = FALSE;
72 continue;
73 }
74
75 if (!strlen(data) && header) {
76 header = FALSE;
77 if (strcmp(labels, "X-Babyl-Labels"))
78 puts(labels);
79 }
80
81 if (printing)
82 puts(data);
83 }
84}