Mercurial > emacs
annotate lib-src/b2m.c @ 6098:b91e19be1513
(OVERLAY_POSITION): Don't check which buffer it points to.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Sat, 26 Feb 1994 04:05:17 +0000 |
parents | 18de002e47dd |
children | cbf3383981cb |
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> |
5448
18de002e47dd
(main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
21 #ifdef MSDOS |
18de002e47dd
(main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
22 #include <fcntl.h> |
18de002e47dd
(main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
23 #endif |
998 | 24 |
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
4572
diff
changeset
|
25 #include <../src/config.h> |
998 | 26 |
27 #ifdef USG | |
28 #include <string.h> | |
29 #else | |
440 | 30 #include <strings.h> |
998 | 31 #endif |
440 | 32 |
33 /* BSD's strings.h does not declare the type of strtok. */ | |
34 extern char *strtok (); | |
35 | |
4572
beb5acbcd482
(TRUE, FALSE): Don't define if already defined.
Richard M. Stallman <rms@gnu.org>
parents:
4008
diff
changeset
|
36 #ifndef TRUE |
440 | 37 #define TRUE (1) |
4572
beb5acbcd482
(TRUE, FALSE): Don't define if already defined.
Richard M. Stallman <rms@gnu.org>
parents:
4008
diff
changeset
|
38 #endif |
beb5acbcd482
(TRUE, FALSE): Don't define if already defined.
Richard M. Stallman <rms@gnu.org>
parents:
4008
diff
changeset
|
39 #ifndef FALSE |
440 | 40 #define FALSE (0) |
4572
beb5acbcd482
(TRUE, FALSE): Don't define if already defined.
Richard M. Stallman <rms@gnu.org>
parents:
4008
diff
changeset
|
41 #endif |
440 | 42 |
43 int header = FALSE, printing; | |
4008
b43e59cb1d54
* b2m.c: #include <sys/types.h>.
Jim Blandy <jimb@redhat.com>
parents:
2101
diff
changeset
|
44 time_t ltoday; |
440 | 45 char from[256], labels[256], data[256], *p, *today; |
46 | |
2101
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
47 main (argc, argv) |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
48 int argc; |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
49 char **argv; |
440 | 50 { |
5448
18de002e47dd
(main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
51 #ifdef MSDOS |
18de002e47dd
(main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
52 _fmode = O_BINARY; /* all of files are treated as binary files */ |
18de002e47dd
(main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
53 (stdout)->_flag &= ~_IOTEXT; |
18de002e47dd
(main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
54 (stdin)->_flag &= ~_IOTEXT; |
18de002e47dd
(main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
55 #endif |
440 | 56 ltoday = time(0); |
57 today = ctime(<oday); | |
58 | |
59 if (gets(data)) | |
60 if (strcmp(data, "BABYL OPTIONS:")) { | |
61 fprintf(stderr, "b2m: not a Babyl mailfile!\n"); | |
62 exit(-1); | |
63 } else | |
64 printing = FALSE; | |
65 else | |
66 exit(-1); | |
67 if (printing) | |
68 puts(data); | |
69 | |
70 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
|
71 |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
72 #if 0 |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
73 /* 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
|
74 lines? */ |
440 | 75 if (!strcmp(data, "")) |
76 exit(0); | |
2101
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
77 #endif |
440 | 78 |
79 if (!strcmp(data, "*** EOOH ***") && !printing) { | |
80 printing = header = TRUE; | |
81 printf("From b2m %s", today); | |
82 continue; | |
83 } | |
84 | |
85 if (!strcmp(data, "")) { | |
86 /* save labels */ | |
87 gets(data); | |
88 p = strtok(data, " ,\r\n\t"); | |
89 strcpy(labels, "X-Babyl-Labels: "); | |
90 | |
91 while (p = strtok(NULL, " ,\r\n\t")) { | |
92 strcat(labels, p); | |
93 strcat(labels, ", "); | |
94 } | |
95 | |
96 labels[strlen(labels) - 2] = '\0'; | |
97 printing = header = FALSE; | |
98 continue; | |
99 } | |
100 | |
101 if (!strlen(data) && header) { | |
102 header = FALSE; | |
103 if (strcmp(labels, "X-Babyl-Labels")) | |
104 puts(labels); | |
105 } | |
106 | |
107 if (printing) | |
108 puts(data); | |
109 } | |
110 } |