1 /* Copyright (C) 1985, 1994 Free Software Foundation
2 This file is part of GNU Emacs.
4 GNU Emacs is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 GNU Emacs is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with GNU Emacs; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
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.
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.
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.
31 * Author: Larry Kolodney, 1985
64 hd
= (char *) getenv ("HOME");
66 md
= (char *) xmalloc (strlen (hd
) + 10);
68 strcat (md
, "/Messages");
70 mdd
= (char *) xmalloc (strlen (md
) + 11);
72 strcat (mdd
, "/Directory");
75 cf
= (char *) xmalloc (cflen
);
77 mddf
= fopen (mdd
, "r");
84 mfile
= (char *) xmalloc (strlen (hd
) + 7);
86 strcat (mfile
, "/OMAIL");
88 mfilef
= fopen (mfile
, "w");
93 while (fscanf (mddf
, "%4c%14[0123456789]", pre
, name
) != EOF
)
95 if (cflen
< strlen (md
) + strlen (name
) + 2)
97 cflen
= strlen (md
) + strlen (name
) + 2;
98 cf
= (char *) xrealloc (cf
, cflen
);
103 cff
= fopen (cf
, "r");
108 while ((c
= getc(cff
)) != EOF
)
125 while ((c
= getc(stream
)) != EOF
&& c
!= '\n')
134 fprintf (stderr
, "cvtmail: ");
135 fprintf (stderr
, s1
, s2
);
136 fprintf (stderr
, "\n");
139 /* Print error message and exit. */
153 fprintf (stderr
, "cvtmail: ");
162 char *result
= malloc (size
);
164 fatal ("virtual memory exhausted", 0);
173 char *result
= realloc (ptr
, size
);
175 fatal ("virtual memory exhausted");