annotate lib-src/b2m.c @ 728:2d5acaebbe7e

*** empty log message ***
author Jim Blandy <jimb@redhat.com>
date Wed, 24 Jun 1992 21:56:16 +0000
parents c1abcb55a546
children 61c6983219ff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
440
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 /*
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2 * b2m - a filter for Babyl -> Unix mail files
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3 *
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 * usage: b2m < babyl > mailbox
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5 *
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 * I find this useful whenever I have to use a
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 * system which - shock horror! - doesn't run
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 * Gnu emacs. At least now I can read all my
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 * Gnumacs Babyl format mail files!
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 *
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 * it's not much but it's free!
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 *
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 * Ed Wilkinson
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 * E.Wilkinson@massey.ac.nz
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 * Mon Nov 7 15:54:06 PDT 1988
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 */
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 #include <stdio.h>
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 #include <time.h>
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 #include <strings.h>
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 /* BSD's strings.h does not declare the type of strtok. */
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 extern char *strtok ();
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 #define TRUE (1)
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 #define FALSE (0)
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 int header = FALSE, printing;
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 long ltoday;
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 char from[256], labels[256], data[256], *p, *today;
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 main(argc, argv)
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 char **argv;
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 {
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 ltoday = time(0);
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 today = ctime(&ltoday);
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 if (gets(data))
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 if (strcmp(data, "BABYL OPTIONS:")) {
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 fprintf(stderr, "b2m: not a Babyl mailfile!\n");
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 exit(-1);
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 } else
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 printing = FALSE;
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 else
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 exit(-1);
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 if (printing)
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 puts(data);
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 while (gets(data)) {
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 if (!strcmp(data, ""))
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 exit(0);
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 if (!strcmp(data, "*** EOOH ***") && !printing) {
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 printing = header = TRUE;
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 printf("From b2m %s", today);
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 continue;
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 }
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 if (!strcmp(data, " ")) {
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 /* save labels */
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 gets(data);
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 p = strtok(data, " ,\r\n\t");
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 strcpy(labels, "X-Babyl-Labels: ");
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 while (p = strtok(NULL, " ,\r\n\t")) {
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 strcat(labels, p);
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 strcat(labels, ", ");
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 }
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 labels[strlen(labels) - 2] = '\0';
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 printing = header = FALSE;
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 continue;
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 }
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 if (!strlen(data) && header) {
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 header = FALSE;
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 if (strcmp(labels, "X-Babyl-Labels"))
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 puts(labels);
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 }
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 if (printing)
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 puts(data);
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 }
c1abcb55a546 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 }