1 /* Copyright (C) 1985, 1994 Free Software Foundation
3 This file is part of GNU Emacs.
5 GNU Emacs is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 GNU Emacs is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNU Emacs; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
21 * Program to convert oldstyle goslings emacs mail directories into
22 * gnu-rmail format. Program expects a directory called Messages to
23 * exist in your home directory, containing individual mail messages in
24 * separate files in the standard gosling emacs mail reader format.
26 * Program takes one argument: an output file. This file will contain
27 * all the messages in Messages directory, in berkeley mail format.
28 * If no output file is mentioned, messages are put in ~/OMAIL.
30 * In order to get rmail to read the messages, the resulting file must
31 * be mv'ed to ~/mbox, and then have rmail invoked on them.
33 * Author: Larry Kolodney, 1985
66 hd
= (char *) getenv ("HOME");
68 md
= (char *) xmalloc (strlen (hd
) + 10);
70 strcat (md
, "/Messages");
72 mdd
= (char *) xmalloc (strlen (md
) + 11);
74 strcat (mdd
, "/Directory");
77 cf
= (char *) xmalloc (cflen
);
79 mddf
= fopen (mdd
, "r");
86 mfile
= (char *) xmalloc (strlen (hd
) + 7);
88 strcat (mfile
, "/OMAIL");
90 mfilef
= fopen (mfile
, "w");
95 while (fscanf (mddf
, "%4c%14[0123456789]", pre
, name
) != EOF
)
97 if (cflen
< strlen (md
) + strlen (name
) + 2)
99 cflen
= strlen (md
) + strlen (name
) + 2;
100 cf
= (char *) xrealloc (cf
, cflen
);
105 cff
= fopen (cf
, "r");
110 while ((c
= getc(cff
)) != EOF
)
127 while ((c
= getc(stream
)) != EOF
&& c
!= '\n')
136 fprintf (stderr
, "cvtmail: ");
137 fprintf (stderr
, s1
, s2
);
138 fprintf (stderr
, "\n");
141 /* Print error message and exit. */
155 fprintf (stderr
, "cvtmail: ");
164 char *result
= malloc (size
);
166 fatal ("virtual memory exhausted", 0);
175 char *result
= realloc (ptr
, size
);
177 fatal ("virtual memory exhausted");