Include <config.h> instead of "config.h".
[bpt/emacs.git] / lib-src / b2m.c
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 <sys/types.h>
21
22 #include <../src/config.h>
23
24 #ifdef USG
25 #include <string.h>
26 #else
27 #include <strings.h>
28 #endif
29
30 /* BSD's strings.h does not declare the type of strtok. */
31 extern char *strtok ();
32
33 #ifndef TRUE
34 #define TRUE (1)
35 #endif
36 #ifndef FALSE
37 #define FALSE (0)
38 #endif
39
40 int header = FALSE, printing;
41 time_t ltoday;
42 char from[256], labels[256], data[256], *p, *today;
43
44 main (argc, argv)
45 int argc;
46 char **argv;
47 {
48 ltoday = time(0);
49 today = ctime(&ltoday);
50
51 if (gets(data))
52 if (strcmp(data, "BABYL OPTIONS:")) {
53 fprintf(stderr, "b2m: not a Babyl mailfile!\n");
54 exit(-1);
55 } else
56 printing = FALSE;
57 else
58 exit(-1);
59 if (printing)
60 puts(data);
61
62 while (gets(data)) {
63
64 #if 0
65 /* What was this for? Does somebody have something against blank
66 lines? */
67 if (!strcmp(data, ""))
68 exit(0);
69 #endif
70
71 if (!strcmp(data, "*** EOOH ***") && !printing) {
72 printing = header = TRUE;
73 printf("From b2m %s", today);
74 continue;
75 }
76
77 if (!strcmp(data, "\f")) {
78 /* save labels */
79 gets(data);
80 p = strtok(data, " ,\r\n\t");
81 strcpy(labels, "X-Babyl-Labels: ");
82
83 while (p = strtok(NULL, " ,\r\n\t")) {
84 strcat(labels, p);
85 strcat(labels, ", ");
86 }
87
88 labels[strlen(labels) - 2] = '\0';
89 printing = header = FALSE;
90 continue;
91 }
92
93 if (!strlen(data) && header) {
94 header = FALSE;
95 if (strcmp(labels, "X-Babyl-Labels"))
96 puts(labels);
97 }
98
99 if (printing)
100 puts(data);
101 }
102 }