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>
36 /* BSD's strings.h does not declare the type of strtok. */
37 extern char *strtok ();
46 int header
= FALSE
, printing
;
48 char from
[256], labels
[256], data
[256], *p
, *today
;
55 _fmode
= O_BINARY
; /* all of files are treated as binary files */
56 (stdout
)->_flag
&= ~_IOTEXT
;
57 (stdin
)->_flag
&= ~_IOTEXT
;
59 if (strcmp (argv
[1], "--help") == 0)
61 fprintf (stderr
, "Usage: %s <babylmailbox >unixmailbox\n", argv
[0]);
65 today
= ctime (<oday
);
67 /* BUG! Must not use gets in a reliable program! */
70 if (strncmp (data
, "BABYL OPTIONS:", 14))
72 fprintf (stderr
, "%s: not a Babyl mailfile!\n", argv
[0]);
87 /* What was this for? Does somebody have something against blank
89 if (!strcmp (data
, ""))
93 if (!strcmp (data
, "*** EOOH ***") && !printing
)
95 printing
= header
= TRUE
;
96 printf ("From %s %s", argv
[0], today
);
100 if (!strcmp (data
, "\037\f"))
104 p
= strtok (data
, " ,\r\n\t");
105 strcpy (labels
, "X-Babyl-Labels: ");
107 while (p
= strtok (NULL
, " ,\r\n\t"))
110 strcat (labels
, ", ");
113 labels
[strlen (labels
) - 2] = '\0';
114 printing
= header
= FALSE
;
118 if (!strlen (data
) && header
)
121 if (strcmp (labels
, "X-Babyl-Labels"))