Mercurial > emacs
annotate lib-src/b2m.c @ 3504:5fb4eefbd7ac
(menu-bar-help-menu): Add defvar.
(menu-bar-edit-menu, menu-bar-file-menu): Likewise.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 05 Jun 1993 19:13:03 +0000 |
parents | df8249aa4901 |
children | b43e59cb1d54 |
rev | line source |
---|---|
440 | 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> | |
998 | 20 |
21 #include "../src/config.h" | |
22 | |
23 #ifdef USG | |
24 #include <string.h> | |
25 #else | |
440 | 26 #include <strings.h> |
998 | 27 #endif |
440 | 28 |
29 /* BSD's strings.h does not declare the type of strtok. */ | |
30 extern char *strtok (); | |
31 | |
32 #define TRUE (1) | |
33 #define FALSE (0) | |
34 | |
35 int header = FALSE, printing; | |
36 long ltoday; | |
37 char from[256], labels[256], data[256], *p, *today; | |
38 | |
2101
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
39 main (argc, argv) |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
40 int argc; |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
41 char **argv; |
440 | 42 { |
43 ltoday = time(0); | |
44 today = ctime(<oday); | |
45 | |
46 if (gets(data)) | |
47 if (strcmp(data, "BABYL OPTIONS:")) { | |
48 fprintf(stderr, "b2m: not a Babyl mailfile!\n"); | |
49 exit(-1); | |
50 } else | |
51 printing = FALSE; | |
52 else | |
53 exit(-1); | |
54 if (printing) | |
55 puts(data); | |
56 | |
57 while (gets(data)) { | |
2101
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
58 |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
59 #if 0 |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
60 /* What was this for? Does somebody have something against blank |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
61 lines? */ |
440 | 62 if (!strcmp(data, "")) |
63 exit(0); | |
2101
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
64 #endif |
440 | 65 |
66 if (!strcmp(data, "*** EOOH ***") && !printing) { | |
67 printing = header = TRUE; | |
68 printf("From b2m %s", today); | |
69 continue; | |
70 } | |
71 | |
72 if (!strcmp(data, "")) { | |
73 /* save labels */ | |
74 gets(data); | |
75 p = strtok(data, " ,\r\n\t"); | |
76 strcpy(labels, "X-Babyl-Labels: "); | |
77 | |
78 while (p = strtok(NULL, " ,\r\n\t")) { | |
79 strcat(labels, p); | |
80 strcat(labels, ", "); | |
81 } | |
82 | |
83 labels[strlen(labels) - 2] = '\0'; | |
84 printing = header = FALSE; | |
85 continue; | |
86 } | |
87 | |
88 if (!strlen(data) && header) { | |
89 header = FALSE; | |
90 if (strcmp(labels, "X-Babyl-Labels")) | |
91 puts(labels); | |
92 } | |
93 | |
94 if (printing) | |
95 puts(data); | |
96 } | |
97 } |