annotate lib-src/cvtmail.c @ 9831:b64a82db92a3

(Fset_frame_height): Compare against height, not width.
author Karl Heuer <kwzh@gnu.org>
date Tue, 08 Nov 1994 02:43:25 +0000
parents dd3b83e4ceb0
children bcb88697b70b
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
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2 This file is part of GNU Emacs.
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 GNU Emacs is free software; you can redistribute it and/or modify
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5 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
6 the Free Software Foundation; either version 2, or (at your option)
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 any later version.
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 GNU Emacs is distributed in the hope that it will be useful,
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 GNU General Public License for more details.
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 along with GNU Emacs; see the file COPYING. If not, write to
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 /* cvtmail:
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 * Program to convert oldstyle goslings emacs mail directories into
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 * gnu-rmail format. Program expects a directory called Messages to
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 * exist in your home directory, containing individual mail messages in
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 * separate files in the standard gosling emacs mail reader format.
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 *
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 * Program takes one argument: an output file. THis file will contain
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 * all the messages in Messages directory, in berkeley mail format.
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 * If no output file is mentioned, messages are put in ~/OMAIL.
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 *
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 * 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
29 * be mv'ed to ~/mbox, and then have rmail invoked on them.
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 *
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 * Author: Larry Kolodney, 1985
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
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 #include <stdio.h>
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36
6107
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
37 char *malloc ();
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
38 char *realloc ();
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
39 char *getenv ();
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
40
6107
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
41 char *xmalloc ();
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
42 char *xrealloc ();
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
43 void skip_to_lf ();
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
45 int
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 main (argc, argv)
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 int argc;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 char *argv[];
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 {
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 char *hd;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 char *md;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 char *mdd;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 char *mfile;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 char *cf;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 int cflen;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 FILE *mddf;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 FILE *mfilef;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 FILE *cff;
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
59 char pre[10];
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 char name[14];
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 int c;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 hd = (char *) getenv ("HOME");
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 md = (char *) xmalloc (strlen (hd) + 10);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 strcpy (md, hd);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 strcat (md, "/Messages");
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 mdd = (char *) xmalloc (strlen (md) + 11);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 strcpy (mdd, md);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 strcat (mdd, "/Directory");
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 cflen = 100;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 cf = (char *) xmalloc (cflen);
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 mddf = fopen (mdd, "r");
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 if (argc > 1)
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 mfilef = fopen (argv[1], "w");
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 else
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 {
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 mfile = (char *) xmalloc (strlen (hd) + 7);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 strcpy (mfile, hd);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 strcat (mfile, "/OMAIL");
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 mfilef = fopen (mfile, "w");
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 skip_to_lf (mddf);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 while (fscanf (mddf, "%4c%14[0123456789]", pre, name) != EOF)
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 {
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 if (cflen < strlen (md) + strlen (name) + 2)
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 {
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 cflen = strlen (md) + strlen (name) + 2;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 cf = (char *) xrealloc (cf, cflen);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 }
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 strcpy (cf, md);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 strcat (cf,"/");
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 strcat (cf, name);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 cff = fopen (cf, "r");
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 while ((c = getc(cff)) != EOF)
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 putc (c, mfilef);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 putc ('\n', mfilef);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 skip_to_lf (mddf);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 fclose (cff);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 }
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 fclose (mddf);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 fclose (mfilef);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 return 0;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 }
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
109 void
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 skip_to_lf (stream)
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 FILE *stream;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 {
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 register int c;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 while ((c = getc(stream)) != '\n')
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 ;
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
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
118
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
119 void
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
120 error (s1, s2)
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
121 char *s1, *s2;
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
122 {
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
123 fprintf (stderr, "cvtmail: ");
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
124 fprintf (stderr, s1, s2);
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
125 fprintf (stderr, "\n");
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
126 }
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
127
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
128 /* Print error message and exit. */
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
129
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
130 void
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
131 fatal (s1, s2)
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
132 char *s1, *s2;
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
133 {
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
134 error (s1, s2);
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
135 exit (1);
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
136 }
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 6107
diff changeset
137
6107
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
138 char *
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 xmalloc (size)
6107
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
140 unsigned size;
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 {
6107
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
142 char *result = malloc (size);
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 if (!result)
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 fatal ("virtual memory exhausted", 0);
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 return result;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 }
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147
6107
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
148 char *
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 xrealloc (ptr, size)
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 char *ptr;
6107
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
151 unsigned size;
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 {
6107
8cc2a5d2e728 * cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents: 37
diff changeset
153 char *result = realloc (ptr, size);
37
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 if (!result)
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 fatal ("virtual memory exhausted");
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 return result;
e48c0f5e6696 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 }