Mercurial > emacs
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 |
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 | 2 This file is part of GNU Emacs. |
3 | |
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 | |
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 | 7 any later version. |
8 | |
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. | |
13 | |
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 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
17 | |
18 /* cvtmail: | |
19 * Program to convert oldstyle goslings emacs mail directories into | |
20 * gnu-rmail format. Program expects a directory called Messages to | |
21 * exist in your home directory, containing individual mail messages in | |
22 * separate files in the standard gosling emacs mail reader format. | |
23 * | |
24 * Program takes one argument: an output file. THis file will contain | |
25 * all the messages in Messages directory, in berkeley mail format. | |
26 * If no output file is mentioned, messages are put in ~/OMAIL. | |
27 * | |
28 * In order to get rmail to read the messages, the resulting file must | |
29 * be mv'ed to ~/mbox, and then have rmail invoked on them. | |
30 * | |
31 * Author: Larry Kolodney, 1985 | |
32 */ | |
33 | |
34 | |
35 #include <stdio.h> | |
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 | 44 |
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
45 int |
37 | 46 main (argc, argv) |
47 int argc; | |
48 char *argv[]; | |
49 { | |
50 char *hd; | |
51 char *md; | |
52 char *mdd; | |
53 char *mfile; | |
54 char *cf; | |
55 int cflen; | |
56 FILE *mddf; | |
57 FILE *mfilef; | |
58 FILE *cff; | |
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
59 char pre[10]; |
37 | 60 char name[14]; |
61 int c; | |
62 | |
63 hd = (char *) getenv ("HOME"); | |
64 | |
65 md = (char *) xmalloc (strlen (hd) + 10); | |
66 strcpy (md, hd); | |
67 strcat (md, "/Messages"); | |
68 | |
69 mdd = (char *) xmalloc (strlen (md) + 11); | |
70 strcpy (mdd, md); | |
71 strcat (mdd, "/Directory"); | |
72 | |
73 cflen = 100; | |
74 cf = (char *) xmalloc (cflen); | |
75 | |
76 mddf = fopen (mdd, "r"); | |
77 if (argc > 1) | |
78 mfilef = fopen (argv[1], "w"); | |
79 else | |
80 { | |
81 mfile = (char *) xmalloc (strlen (hd) + 7); | |
82 strcpy (mfile, hd); | |
83 strcat (mfile, "/OMAIL"); | |
84 mfilef = fopen (mfile, "w"); | |
85 } | |
86 skip_to_lf (mddf); | |
87 while (fscanf (mddf, "%4c%14[0123456789]", pre, name) != EOF) | |
88 { | |
89 if (cflen < strlen (md) + strlen (name) + 2) | |
90 { | |
91 cflen = strlen (md) + strlen (name) + 2; | |
92 cf = (char *) xrealloc (cf, cflen); | |
93 } | |
94 strcpy (cf, md); | |
95 strcat (cf,"/"); | |
96 strcat (cf, name); | |
97 cff = fopen (cf, "r"); | |
98 while ((c = getc(cff)) != EOF) | |
99 putc (c, mfilef); | |
100 putc ('\n', mfilef); | |
101 skip_to_lf (mddf); | |
102 fclose (cff); | |
103 } | |
104 fclose (mddf); | |
105 fclose (mfilef); | |
106 return 0; | |
107 } | |
108 | |
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
6107
diff
changeset
|
109 void |
37 | 110 skip_to_lf (stream) |
111 FILE *stream; | |
112 { | |
113 register int c; | |
114 while ((c = getc(stream)) != '\n') | |
115 ; | |
116 } | |
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 | 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 | 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 | 143 if (!result) |
144 fatal ("virtual memory exhausted", 0); | |
145 return result; | |
146 } | |
147 | |
6107
8cc2a5d2e728
* cvtmail.c: Declare malloc, realloc, xmalloc, xrealloc.
David J. MacKenzie <djm@gnu.org>
parents:
37
diff
changeset
|
148 char * |
37 | 149 xrealloc (ptr, size) |
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 | 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 | 154 if (!result) |
155 fatal ("virtual memory exhausted"); | |
156 return result; | |
157 } |