1 /* Copyright (C) 1985, 1994, 2001, 2002, 2003, 2004,
2 2005, 2006, 2007 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
22 * Program to convert oldstyle goslings emacs mail directories into
23 * gnu-rmail format. Program expects a directory called Messages to
24 * exist in your home directory, containing individual mail messages in
25 * separate files in the standard gosling emacs mail reader format.
27 * Program takes one argument: an output file. This file will contain
28 * all the messages in Messages directory, in berkeley mail format.
29 * If no output file is mentioned, messages are put in ~/OMAIL.
31 * In order to get rmail to read the messages, the resulting file must
32 * be mv'ed to ~/mbox, and then have rmail invoked on them.
34 * Author: Larry Kolodney, 1985
47 char *xmalloc
__P ((unsigned));
48 char *xrealloc
__P ((char *, unsigned));
49 void skip_to_lf
__P ((FILE *));
50 void sysfail
__P ((char *));
70 hd
= (char *) getenv ("HOME");
72 md
= (char *) xmalloc (strlen (hd
) + 10);
74 strcat (md
, "/Messages");
76 mdd
= (char *) xmalloc (strlen (md
) + 11);
78 strcat (mdd
, "/Directory");
81 cf
= (char *) xmalloc (cflen
);
83 mddf
= fopen (mdd
, "r");
90 mfile
= (char *) xmalloc (strlen (hd
) + 7);
92 strcat (mfile
, "/OMAIL");
94 mfilef
= fopen (mfile
, "w");
99 while (fscanf (mddf
, "%4c%14[0123456789]", pre
, name
) != EOF
)
101 if (cflen
< strlen (md
) + strlen (name
) + 2)
103 cflen
= strlen (md
) + strlen (name
) + 2;
104 cf
= (char *) xrealloc (cf
, cflen
);
109 cff
= fopen (cf
, "r");
114 while ((c
= getc(cff
)) != EOF
)
131 while ((c
= getc(stream
)) != EOF
&& c
!= '\n')
140 fprintf (stderr
, "cvtmail: ");
141 fprintf (stderr
, s1
, s2
);
142 fprintf (stderr
, "\n");
145 /* Print error message and exit. */
159 fprintf (stderr
, "cvtmail: ");
168 char *result
= (char *) malloc (size
);
170 fatal ("virtual memory exhausted", 0);
179 char *result
= (char *) realloc (ptr
, size
);
181 fatal ("virtual memory exhausted", 0);
185 /* arch-tag: b93c25a9-9012-44f1-b78b-9cc7aed44a7a
186 (do not change this comment) */
188 /* cvtmail.c ends here */