1 /* Copyright (C) 1985, 1993, 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 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
19 /* Synched up with: FSF 19.28. */
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
44 static void *xmalloc (size_t);
45 static void *xrealloc (void *, size_t);
46 static void skip_to_lf (FILE *stream);
47 static void fatal (const char *s1, const char *s2);
48 static void error (const char *s1, const char *s2);
51 main (int argc, char *argv[])
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");
81 mfilef = fopen (argv[1], "w");
84 mfile = (char *) xmalloc (strlen (hd) + 7);
86 strcat (mfile, "/OMAIL");
87 mfilef = fopen (mfile, "w");
90 while (fscanf (mddf, "%4c%14[0123456789]", pre, name) != EOF)
92 int comp_len = strlen (md) + strlen (name) + 2;
95 cflen = strlen (md) + strlen (name) + 2;
96 cf = (char *) xrealloc (cf, cflen);
101 cff = fopen (cf, "r");
102 while ((c = getc(cff)) != EOF)
114 skip_to_lf (FILE *stream)
117 while ((c = getc(stream)) != '\n')
122 xmalloc (size_t size)
124 void *result = malloc (size);
126 fatal ("virtual memory exhausted", 0);
131 xrealloc (void *ptr, size_t size)
133 void *result = realloc (ptr, size);
135 fatal ("virtual memory exhausted", 0);
139 /* Print error message and exit. */
142 fatal (const char *s1, const char *s2)
149 error (const char *s1, const char *s2)
151 fprintf (stderr, "cvtmail: ");
152 fprintf (stderr, s1, s2);
153 fprintf (stderr, "\n");