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
50 char *xmalloc
__P ((unsigned));
51 char *xrealloc
__P ((char *, unsigned));
52 void skip_to_lf
__P ((FILE *));
53 void sysfail
__P ((char *));
73 hd
= (char *) getenv ("HOME");
75 md
= (char *) xmalloc (strlen (hd
) + 10);
77 strcat (md
, "/Messages");
79 mdd
= (char *) xmalloc (strlen (md
) + 11);
81 strcat (mdd
, "/Directory");
84 cf
= (char *) xmalloc (cflen
);
86 mddf
= fopen (mdd
, "r");
93 mfile
= (char *) xmalloc (strlen (hd
) + 7);
95 strcat (mfile
, "/OMAIL");
97 mfilef
= fopen (mfile
, "w");
102 while (fscanf (mddf
, "%4c%14[0123456789]", pre
, name
) != EOF
)
104 if (cflen
< strlen (md
) + strlen (name
) + 2)
106 cflen
= strlen (md
) + strlen (name
) + 2;
107 cf
= (char *) xrealloc (cf
, cflen
);
112 cff
= fopen (cf
, "r");
117 while ((c
= getc(cff
)) != EOF
)
134 while ((c
= getc(stream
)) != EOF
&& c
!= '\n')
143 fprintf (stderr
, "cvtmail: ");
144 fprintf (stderr
, s1
, s2
);
145 fprintf (stderr
, "\n");
148 /* Print error message and exit. */
162 fprintf (stderr
, "cvtmail: ");
171 char *result
= malloc (size
);
173 fatal ("virtual memory exhausted", 0);
182 char *result
= realloc (ptr
, size
);
184 fatal ("virtual memory exhausted", 0);