annotate lib-src/cvtmail.c @ 35127:501e704b34bc

*** empty log message ***
author Gerd Moellmann <gerd@gnu.org>
date Mon, 08 Jan 2001 14:55:06 +0000
parents fdac027af4e1
children e3eadbc9fda7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6107
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
1 /* Copyright (C) 1985, 1994 Free Software Foundation
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 11425
diff changeset
2
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3 This file is part of GNU Emacs.
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5 GNU Emacs is free software; you can redistribute it and/or modify
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
6107
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
7 the Free Software Foundation; either version 2, or (at your option)
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 any later version.
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 GNU Emacs is distributed in the hope that it will be useful,
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 GNU General Public License for more details.
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 along with GNU Emacs; see the file COPYING. If not, write to
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 11425
diff changeset
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 11425
diff changeset
18 Boston, MA 02111-1307, USA. */
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 /* cvtmail:
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 * Program to convert oldstyle goslings emacs mail directories into
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 * gnu-rmail format. Program expects a directory called Messages to
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 * exist in your home directory, containing individual mail messages in
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 * separate files in the standard gosling emacs mail reader format.
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 *
11425
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
26 * Program takes one argument: an output file. This file will contain
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 * all the messages in Messages directory, in berkeley mail format.
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 * If no output file is mentioned, messages are put in ~/OMAIL.
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 *
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 * In order to get rmail to read the messages, the resulting file must
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 * be mv'ed to ~/mbox, and then have rmail invoked on them.
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 *
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 * Author: Larry Kolodney, 1985
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 */
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 #include <stdio.h>
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38
6107
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
39 char *malloc ();
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
40 char *realloc ();
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
41 char *getenv ();
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
42
6107
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
43 char *xmalloc ();
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
44 char *xrealloc ();
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
45 void skip_to_lf ();
11425
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
46 void sysfail ();
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
48 int
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 main (argc, argv)
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 int argc;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 char *argv[];
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 {
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 char *hd;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 char *md;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 char *mdd;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 char *mfile;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 char *cf;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 int cflen;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 FILE *mddf;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 FILE *mfilef;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 FILE *cff;
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
62 char pre[10];
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 char name[14];
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 int c;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 hd = (char *) getenv ("HOME");
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 md = (char *) xmalloc (strlen (hd) + 10);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 strcpy (md, hd);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 strcat (md, "/Messages");
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 mdd = (char *) xmalloc (strlen (md) + 11);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 strcpy (mdd, md);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 strcat (mdd, "/Directory");
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 cflen = 100;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 cf = (char *) xmalloc (cflen);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 mddf = fopen (mdd, "r");
11425
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
80 if (!mddf)
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
81 sysfail (mdd);
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 if (argc > 1)
11425
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
83 mfile = argv[1];
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 else
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 {
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 mfile = (char *) xmalloc (strlen (hd) + 7);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 strcpy (mfile, hd);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 strcat (mfile, "/OMAIL");
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 }
11425
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
90 mfilef = fopen (mfile, "w");
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
91 if (!mfilef)
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
92 sysfail (mfile);
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
93
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 skip_to_lf (mddf);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 while (fscanf (mddf, "%4c%14[0123456789]", pre, name) != EOF)
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 {
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 if (cflen < strlen (md) + strlen (name) + 2)
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 {
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 cflen = strlen (md) + strlen (name) + 2;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 cf = (char *) xrealloc (cf, cflen);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 }
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 strcpy (cf, md);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 strcat (cf,"/");
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 strcat (cf, name);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 cff = fopen (cf, "r");
11425
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
106 if (!cff)
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
107 perror (cf);
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
108 else
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
109 {
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
110 while ((c = getc(cff)) != EOF)
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
111 putc (c, mfilef);
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
112 putc ('\n', mfilef);
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
113 skip_to_lf (mddf);
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
114 fclose (cff);
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
115 }
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 }
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 fclose (mddf);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 fclose (mfilef);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 return 0;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 }
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
122 void
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 skip_to_lf (stream)
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 FILE *stream;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 {
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 register int c;
11425
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
127 while ((c = getc(stream)) != EOF && c != '\n')
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 ;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 }
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
131
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
132 void
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
133 error (s1, s2)
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
134 char *s1, *s2;
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
135 {
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
136 fprintf (stderr, "cvtmail: ");
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
137 fprintf (stderr, s1, s2);
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
138 fprintf (stderr, "\n");
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
139 }
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
140
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
141 /* Print error message and exit. */
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
142
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
143 void
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
144 fatal (s1, s2)
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
145 char *s1, *s2;
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
146 {
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
147 error (s1, s2);
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
148 exit (1);
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
149 }
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
150
11425
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
151 void
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
152 sysfail (s)
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
153 char *s;
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
154 {
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
155 fprintf (stderr, "cvtmail: ");
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
156 perror (s);
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
157 exit (1);
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
158 }
bcb88697b70b (main, skip_to_lf): Improve error handling.
Karl Heuer <kwzh@gnu.org>
parents: 9491
diff changeset
159
6107
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
160 char *
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 xmalloc (size)
6107
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
162 unsigned size;
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 {
6107
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
164 char *result = malloc (size);
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 if (!result)
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 fatal ("virtual memory exhausted", 0);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 return result;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 }
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169
6107
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
170 char *
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 xrealloc (ptr, size)
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 char *ptr;
6107
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
173 unsigned size;
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 {
6107
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
175 char *result = realloc (ptr, size);
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 if (!result)
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 fatal ("virtual memory exhausted");
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 return result;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 }