aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorJim Blandy1989-10-31 16:00:11 +0000
committerJim Blandy1989-10-31 16:00:11 +0000
commit518dd7224679f6c48ff331d8b304d2f7f784f96b (patch)
tree794893d6e73cada2676540e8f33d2d88555a9cf2 /lib-src
parenta2535589a9b419920395f37ef658a3c88bf13ecb (diff)
downloademacs-518dd7224679f6c48ff331d8b304d2f7f784f96b.tar.gz
emacs-518dd7224679f6c48ff331d8b304d2f7f784f96b.zip
entered into RCS
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/cvtmail.c147
-rw-r--r--lib-src/fakemail.c25
2 files changed, 159 insertions, 13 deletions
diff --git a/lib-src/cvtmail.c b/lib-src/cvtmail.c
new file mode 100644
index 00000000000..1f3b8ff9f9e
--- /dev/null
+++ b/lib-src/cvtmail.c
@@ -0,0 +1,147 @@
1/* Copyright (C) 1985 Free Software Foundation
2This file is part of GNU Emacs.
3
4GNU Emacs is free software; you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation; either version 1, or (at your option)
7any later version.
8
9GNU Emacs is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with GNU Emacs; see the file COPYING. If not, write to
16the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18/* cvtmail:
19 * Program to convert oldstyle goslings emacs mail directories into
20 * gnu-rmail format. Program expects a directory called Messages to
21 * exist in your home directory, containing individual mail messages in
22 * separate files in the standard gosling emacs mail reader format.
23 *
24 * Program takes one argument: an output file. THis file will contain
25 * all the messages in Messages directory, in berkeley mail format.
26 * If no output file is mentioned, messages are put in ~/OMAIL.
27 *
28 * In order to get rmail to read the messages, the resulting file must
29 * be mv'ed to ~/mbox, and then have rmail invoked on them.
30 *
31 * Author: Larry Kolodney, 1985
32
33 * RMS, 2 Sept 85: Removed fix maximums on file name sizes.
34 */
35
36
37#include <stdio.h>
38
39
40main (argc, argv)
41 int argc;
42 char *argv[];
43{
44 char *hd;
45 char *md;
46 char *mdd;
47 char *mfile;
48 char *cf;
49 int cflen;
50 FILE *mddf;
51 FILE *mfilef;
52 FILE *cff;
53 char pre[10], post[100];
54 char name[14];
55 int c;
56
57 hd = (char *) getenv ("HOME");
58
59 md = (char *) xmalloc (strlen (hd) + 10);
60 strcpy (md, hd);
61 strcat (md, "/Messages");
62
63 mdd = (char *) xmalloc (strlen (md) + 11);
64 strcpy (mdd, md);
65 strcat (mdd, "/Directory");
66
67 cflen = 100;
68 cf = (char *) xmalloc (cflen);
69
70 mddf = fopen (mdd, "r");
71 if (argc > 1)
72 mfilef = fopen (argv[1], "w");
73 else
74 {
75 mfile = (char *) xmalloc (strlen (hd) + 7);
76 strcpy (mfile, hd);
77 strcat (mfile, "/OMAIL");
78 mfilef = fopen (mfile, "w");
79 }
80 skip_to_lf (mddf);
81 while (fscanf (mddf, "%4c%14[0123456789]", pre, name) != EOF)
82 {
83 if (cflen < strlen (md) + strlen (name) + 2)
84 {
85 cflen = strlen (md) + strlen (name) + 2;
86 cf = (char *) xrealloc (cf, cflen);
87 }
88 strcpy (cf, md);
89 strcat (cf,"/");
90 strcat (cf, name);
91 cff = fopen (cf, "r");
92 while ((c = getc(cff)) != EOF)
93 putc (c, mfilef);
94 putc ('\n', mfilef);
95 skip_to_lf (mddf);
96 fclose (cff);
97 }
98 fclose (mddf);
99 fclose (mfilef);
100 return 0;
101}
102
103skip_to_lf (stream)
104 FILE *stream;
105{
106 register int c;
107 while ((c = getc(stream)) != '\n')
108 ;
109}
110
111int
112xmalloc (size)
113 int size;
114{
115 int result = malloc (size);
116 if (!result)
117 fatal ("virtual memory exhausted", 0);
118 return result;
119}
120
121int
122xrealloc (ptr, size)
123 char *ptr;
124 int size;
125{
126 int result = realloc (ptr, size);
127 if (!result)
128 fatal ("virtual memory exhausted");
129 return result;
130}
131
132/* Print error message and exit. */
133
134fatal (s1, s2)
135 char *s1, *s2;
136{
137 error (s1, s2);
138 exit (1);
139}
140
141error (s1, s2)
142 char *s1, *s2;
143{
144 printf ("cvtmail: ");
145 printf (s1, s2);
146 printf ("\n");
147}
diff --git a/lib-src/fakemail.c b/lib-src/fakemail.c
index 19b053abaa3..464a739e998 100644
--- a/lib-src/fakemail.c
+++ b/lib-src/fakemail.c
@@ -3,20 +3,19 @@
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 1, or (at your option)
9any later version.
10
6GNU Emacs is distributed in the hope that it will be useful, 11GNU Emacs is distributed in the hope that it will be useful,
7but WITHOUT ANY WARRANTY. No author or distributor 12but WITHOUT ANY WARRANTY; without even the implied warranty of
8accepts responsibility to anyone for the consequences of using it 13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9or for whether it serves any particular purpose or works at all, 14GNU General Public License for more details.
10unless he says so in writing. Refer to the GNU Emacs General Public 15
11License for full details. 16You should have received a copy of the GNU General Public License
12 17along with GNU Emacs; see the file COPYING. If not, write to
13Everyone is granted permission to copy, modify and redistribute 18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
14GNU Emacs, but only under the conditions described in the
15GNU Emacs General Public License. A copy of this license is
16supposed to have been given to you along with GNU Emacs so you
17can know your rights and responsibilities. It should be in a
18file named COPYING. Among other things, the copyright notice
19and this notice must be preserved on all copies. */
20 19
21 20
22#define NO_SHORTNAMES 21#define NO_SHORTNAMES