]>
code.delx.au - gnu-emacs/blob - lib-src/b2m.c
dc0d81b6a9311f7945c610c19ff7510f48d09dd6
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
20 #include <sys/types.h>
25 #include <../src/config.h>
33 /* BSD's strings.h does not declare the type of strtok. */
34 extern char *strtok ();
43 int header
= FALSE
, printing
;
45 char from
[256], labels
[256], data
[256], *p
, *today
;
52 _fmode
= O_BINARY
; /* all of files are treated as binary files */
53 (stdout
)->_flag
&= ~_IOTEXT
;
54 (stdin
)->_flag
&= ~_IOTEXT
;
56 if (strcmp(argv
[1], "--help") == 0)
58 fprintf(stderr
, "Usage: %s <babylmailbox >unixmailbox\n", argv
[0]);
62 today
= ctime(<oday
);
65 if (strncmp(data
, "BABYL OPTIONS:", 14))
67 fprintf(stderr
, "%s: not a Babyl mailfile!\n", argv
[0]);
79 /* What was this for? Does somebody have something against blank
81 if (!strcmp(data
, ""))
85 if (!strcmp(data
, "*** EOOH ***") && !printing
) {
86 printing
= header
= TRUE
;
87 printf("From %s %s", argv
[0], today
);
91 if (!strcmp(data
, "\037\f")) {
94 p
= strtok(data
, " ,\r\n\t");
95 strcpy(labels
, "X-Babyl-Labels: ");
97 while (p
= strtok(NULL
, " ,\r\n\t")) {
102 labels
[strlen(labels
) - 2] = '\0';
103 printing
= header
= FALSE
;
107 if (!strlen(data
) && header
) {
109 if (strcmp(labels
, "X-Babyl-Labels"))