2 * b2m - a filter for Babyl -> Unix mail files
4 * usage: b2m < babyl > mailbox
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!
11 * it's not much but it's free!
14 * E.Wilkinson@massey.ac.nz
15 * Mon Nov 7 15:54:06 PDT 1988
18 /* Serious bug: This program uses `gets', which is intrinsically
19 unreliable--long lines will cause crashes.
20 Someone should fix this program not to use `gets'. */
23 #include <sys/types.h>
28 #include <../src/config.h>
30 /* BSD's strings.h does not declare the type of strtok. */
31 extern char *strtok ();
40 int header
= FALSE
, printing
;
42 char from
[256], labels
[256], data
[256], *p
, *today
;
49 _fmode
= O_BINARY
; /* all of files are treated as binary files */
50 (stdout
)->_flag
&= ~_IOTEXT
;
51 (stdin
)->_flag
&= ~_IOTEXT
;
53 if (argc
>= 2 && strcmp (argv
[1], "--help") == 0)
55 fprintf (stderr
, "Usage: %s <babylmailbox >unixmailbox\n", argv
[0]);
59 today
= ctime (<oday
);
61 /* BUG! Must not use gets in a reliable program! */
64 if (strncmp (data
, "BABYL OPTIONS:", 14))
66 fprintf (stderr
, "%s: not a Babyl mailfile!\n", argv
[0]);
81 /* What was this for? Does somebody have something against blank
83 if (!strcmp (data
, ""))
87 if (!strcmp (data
, "*** EOOH ***") && !printing
)
89 printing
= header
= TRUE
;
90 printf ("From %s %s", argv
[0], today
);
94 if (!strcmp (data
, "\037\f"))
98 p
= strtok (data
, " ,\r\n\t");
99 strcpy (labels
, "X-Babyl-Labels: ");
101 while (p
= strtok (NULL
, " ,\r\n\t"))
104 strcat (labels
, ", ");
107 labels
[strlen (labels
) - 2] = '\0';
108 printing
= header
= FALSE
;
112 if (!strlen (data
) && header
)
115 if (strcmp (labels
, "X-Babyl-Labels"))