Mercurial > emacs
annotate lib-src/b2m.c @ 5209:7fdef355cdc2
(vc-locking-user): Don't assume that the umask permits
group-write and other-write.
author | Paul Eggert <eggert@twinsun.com> |
---|---|
date | Thu, 02 Dec 1993 07:47:48 +0000 |
parents | 1fc792473491 |
children | 18de002e47dd |
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 |
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
4572
diff
changeset
|
22 #include <../src/config.h> |
998 | 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 | |
4572
beb5acbcd482
(TRUE, FALSE): Don't define if already defined.
Richard M. Stallman <rms@gnu.org>
parents:
4008
diff
changeset
|
33 #ifndef TRUE |
440 | 34 #define TRUE (1) |
4572
beb5acbcd482
(TRUE, FALSE): Don't define if already defined.
Richard M. Stallman <rms@gnu.org>
parents:
4008
diff
changeset
|
35 #endif |
beb5acbcd482
(TRUE, FALSE): Don't define if already defined.
Richard M. Stallman <rms@gnu.org>
parents:
4008
diff
changeset
|
36 #ifndef FALSE |
440 | 37 #define FALSE (0) |
4572
beb5acbcd482
(TRUE, FALSE): Don't define if already defined.
Richard M. Stallman <rms@gnu.org>
parents:
4008
diff
changeset
|
38 #endif |
440 | 39 |
40 int header = FALSE, printing; | |
4008
b43e59cb1d54
* b2m.c: #include <sys/types.h>.
Jim Blandy <jimb@redhat.com>
parents:
2101
diff
changeset
|
41 time_t ltoday; |
440 | 42 char from[256], labels[256], data[256], *p, *today; |
43 | |
2101
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
44 main (argc, argv) |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
45 int argc; |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
46 char **argv; |
440 | 47 { |
48 ltoday = time(0); | |
49 today = ctime(<oday); | |
50 | |
51 if (gets(data)) | |
52 if (strcmp(data, "BABYL OPTIONS:")) { | |
53 fprintf(stderr, "b2m: not a Babyl mailfile!\n"); | |
54 exit(-1); | |
55 } else | |
56 printing = FALSE; | |
57 else | |
58 exit(-1); | |
59 if (printing) | |
60 puts(data); | |
61 | |
62 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
|
63 |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
64 #if 0 |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
65 /* 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
|
66 lines? */ |
440 | 67 if (!strcmp(data, "")) |
68 exit(0); | |
2101
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
69 #endif |
440 | 70 |
71 if (!strcmp(data, "*** EOOH ***") && !printing) { | |
72 printing = header = TRUE; | |
73 printf("From b2m %s", today); | |
74 continue; | |
75 } | |
76 | |
77 if (!strcmp(data, "")) { | |
78 /* save labels */ | |
79 gets(data); | |
80 p = strtok(data, " ,\r\n\t"); | |
81 strcpy(labels, "X-Babyl-Labels: "); | |
82 | |
83 while (p = strtok(NULL, " ,\r\n\t")) { | |
84 strcat(labels, p); | |
85 strcat(labels, ", "); | |
86 } | |
87 | |
88 labels[strlen(labels) - 2] = '\0'; | |
89 printing = header = FALSE; | |
90 continue; | |
91 } | |
92 | |
93 if (!strlen(data) && header) { | |
94 header = FALSE; | |
95 if (strcmp(labels, "X-Babyl-Labels")) | |
96 puts(labels); | |
97 } | |
98 | |
99 if (printing) | |
100 puts(data); | |
101 } | |
102 } |