1 /* cvtmail.c --- convert Gosling Emacs mail directories into RMAIL format
3 Copyright (C) 1985, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
4 2008, 2009 Free Software Foundation, Inc.
9 This file is part of GNU Emacs.
11 GNU Emacs is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 GNU Emacs is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
27 Program to convert oldstyle goslings emacs mail directories into
28 gnu-rmail format. Program expects a directory called Messages to
29 exist in your home directory, containing individual mail messages in
30 separate files in the standard gosling emacs mail reader format.
32 Program takes one argument: an output file. This file will contain
33 all the messages in Messages directory, in berkeley mail format.
34 If no output file is mentioned, messages are put in ~/OMAIL.
36 In order to get rmail to read the messages, the resulting file must
37 be mv'ed to ~/mbox, and then have rmail invoked on them. */
49 char *xmalloc
__P ((unsigned));
50 char *xrealloc
__P ((char *, unsigned));
51 void skip_to_lf
__P ((FILE *));
52 void sysfail
__P ((char *));
72 hd
= (char *) getenv ("HOME");
74 md
= (char *) xmalloc (strlen (hd
) + 10);
76 strcat (md
, "/Messages");
78 mdd
= (char *) xmalloc (strlen (md
) + 11);
80 strcat (mdd
, "/Directory");
83 cf
= (char *) xmalloc (cflen
);
85 mddf
= fopen (mdd
, "r");
92 mfile
= (char *) xmalloc (strlen (hd
) + 7);
94 strcat (mfile
, "/OMAIL");
96 mfilef
= fopen (mfile
, "w");
101 while (fscanf (mddf
, "%4c%14[0123456789]", pre
, name
) != EOF
)
103 if (cflen
< strlen (md
) + strlen (name
) + 2)
105 cflen
= strlen (md
) + strlen (name
) + 2;
106 cf
= (char *) xrealloc (cf
, cflen
);
111 cff
= fopen (cf
, "r");
116 while ((c
= getc(cff
)) != EOF
)
133 while ((c
= getc(stream
)) != EOF
&& c
!= '\n')
142 fprintf (stderr
, "cvtmail: ");
143 fprintf (stderr
, s1
, s2
);
144 fprintf (stderr
, "\n");
147 /* Print error message and exit. */
161 fprintf (stderr
, "cvtmail: ");
170 char *result
= (char *) malloc (size
);
172 fatal ("virtual memory exhausted", 0);
181 char *result
= (char *) realloc (ptr
, size
);
183 fatal ("virtual memory exhausted", 0);
187 /* arch-tag: b93c25a9-9012-44f1-b78b-9cc7aed44a7a
188 (do not change this comment) */
190 /* cvtmail.c ends here */