Mercurial > emacs
annotate lib-src/b2m.c @ 4124:a91cdccf5458
* Makefile.in (src/Makefile): Propagate C_SWITCH_SYSTEM to the src
directory's makefile. This allows the invocation of CPP which
builds xmakefile to receive these switches. The SunSoft C
preprocessor inserts spaces between tokens if it doesn't get the
-Xs flag requested in src/s/sol2.h.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Sun, 18 Jul 1993 06:10:46 +0000 |
parents | b43e59cb1d54 |
children | beb5acbcd482 |
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> | |
4008
b43e59cb1d54
* b2m.c: #include <sys/types.h>.
Jim Blandy <jimb@redhat.com>
parents:
2101
diff
changeset
|
20 #include <sys/types.h> |
998 | 21 |
22 #include "../src/config.h" | |
23 | |
24 #ifdef USG | |
25 #include <string.h> | |
26 #else | |
440 | 27 #include <strings.h> |
998 | 28 #endif |
440 | 29 |
30 /* BSD's strings.h does not declare the type of strtok. */ | |
31 extern char *strtok (); | |
32 | |
33 #define TRUE (1) | |
34 #define FALSE (0) | |
35 | |
36 int header = FALSE, printing; | |
4008
b43e59cb1d54
* b2m.c: #include <sys/types.h>.
Jim Blandy <jimb@redhat.com>
parents:
2101
diff
changeset
|
37 time_t ltoday; |
440 | 38 char from[256], labels[256], data[256], *p, *today; |
39 | |
2101
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
40 main (argc, argv) |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
41 int argc; |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
42 char **argv; |
440 | 43 { |
44 ltoday = time(0); | |
45 today = ctime(<oday); | |
46 | |
47 if (gets(data)) | |
48 if (strcmp(data, "BABYL OPTIONS:")) { | |
49 fprintf(stderr, "b2m: not a Babyl mailfile!\n"); | |
50 exit(-1); | |
51 } else | |
52 printing = FALSE; | |
53 else | |
54 exit(-1); | |
55 if (printing) | |
56 puts(data); | |
57 | |
58 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
|
59 |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
60 #if 0 |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
61 /* 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
|
62 lines? */ |
440 | 63 if (!strcmp(data, "")) |
64 exit(0); | |
2101
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
65 #endif |
440 | 66 |
67 if (!strcmp(data, "*** EOOH ***") && !printing) { | |
68 printing = header = TRUE; | |
69 printf("From b2m %s", today); | |
70 continue; | |
71 } | |
72 | |
73 if (!strcmp(data, "")) { | |
74 /* save labels */ | |
75 gets(data); | |
76 p = strtok(data, " ,\r\n\t"); | |
77 strcpy(labels, "X-Babyl-Labels: "); | |
78 | |
79 while (p = strtok(NULL, " ,\r\n\t")) { | |
80 strcat(labels, p); | |
81 strcat(labels, ", "); | |
82 } | |
83 | |
84 labels[strlen(labels) - 2] = '\0'; | |
85 printing = header = FALSE; | |
86 continue; | |
87 } | |
88 | |
89 if (!strlen(data) && header) { | |
90 header = FALSE; | |
91 if (strcmp(labels, "X-Babyl-Labels")) | |
92 puts(labels); | |
93 } | |
94 | |
95 if (printing) | |
96 puts(data); | |
97 } | |
98 } |