Mercurial > hg > xemacs-beta
annotate lib-src/cvtmail.c @ 5640:e6b5c49f9e13
Add autoload cookie to custom-set-face-bold
author | Vin Shelton <acs@xemacs.org> |
---|---|
date | Sun, 08 Jan 2012 22:29:06 -0500 |
parents | b9167d522a9a |
children |
rev | line source |
---|---|
428 | 1 /* Copyright (C) 1985, 1993, 1994 Free Software Foundation |
613 | 2 This file is part of XEmacs. |
428 | 3 |
5406
061f4f90f874
Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
613
diff
changeset
|
4 XEmacs is free software: you can redistribute it and/or modify it |
061f4f90f874
Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
613
diff
changeset
|
5 under the terms of the GNU General Public License as published by the |
061f4f90f874
Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
613
diff
changeset
|
6 Free Software Foundation, either version 3 of the License, or (at your |
061f4f90f874
Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
613
diff
changeset
|
7 option) any later version. |
428 | 8 |
5406
061f4f90f874
Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
613
diff
changeset
|
9 XEmacs is distributed in the hope that it will be useful, but WITHOUT |
061f4f90f874
Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
613
diff
changeset
|
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
061f4f90f874
Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
613
diff
changeset
|
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
061f4f90f874
Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
613
diff
changeset
|
12 for more details. |
428 | 13 |
14 You should have received a copy of the GNU General Public License | |
5406
061f4f90f874
Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
613
diff
changeset
|
15 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
428 | 16 |
17 /* Synched up with: FSF 19.28. */ | |
18 | |
19 /* cvtmail: | |
20 * Program to convert oldstyle goslings emacs mail directories into | |
21 * gnu-rmail format. Program expects a directory called Messages to | |
22 * exist in your home directory, containing individual mail messages in | |
23 * separate files in the standard gosling emacs mail reader format. | |
24 * | |
442 | 25 * Program takes one argument: an output file. This file will contain |
428 | 26 * all the messages in Messages directory, in berkeley mail format. |
27 * If no output file is mentioned, messages are put in ~/OMAIL. | |
28 * | |
29 * In order to get rmail to read the messages, the resulting file must | |
30 * be mv'ed to ~/mbox, and then have rmail invoked on them. | |
442 | 31 * |
428 | 32 * Author: Larry Kolodney, 1985 |
33 */ | |
34 | |
35 | |
438 | 36 #include <config.h> |
428 | 37 |
38 #include <stdio.h> | |
39 #include <string.h> | |
438 | 40 #include <stdlib.h> |
428 | 41 |
440 | 42 static void *xmalloc (size_t); |
43 static void *xrealloc (void *, size_t); | |
428 | 44 static void skip_to_lf (FILE *stream); |
442 | 45 static void fatal (const char *s1, const char *s2); |
46 static void error (const char *s1, const char *s2); | |
428 | 47 |
48 int | |
49 main (int argc, char *argv[]) | |
50 { | |
51 char *hd; | |
52 char *md; | |
53 char *mdd; | |
54 char *mfile; | |
55 char *cf; | |
56 int cflen; | |
57 FILE *mddf; | |
58 FILE *mfilef; | |
59 FILE *cff; | |
60 char pre[10]; | |
61 char name[14]; | |
62 int c; | |
63 | |
438 | 64 hd = getenv ("HOME"); |
428 | 65 |
66 md = (char *) xmalloc (strlen (hd) + 10); | |
67 strcpy (md, hd); | |
68 strcat (md, "/Messages"); | |
69 | |
70 mdd = (char *) xmalloc (strlen (md) + 11); | |
71 strcpy (mdd, md); | |
72 strcat (mdd, "/Directory"); | |
73 | |
74 cflen = 100; | |
75 cf = (char *) xmalloc (cflen); | |
76 | |
77 mddf = fopen (mdd, "r"); | |
78 if (argc > 1) | |
79 mfilef = fopen (argv[1], "w"); | |
80 else | |
81 { | |
82 mfile = (char *) xmalloc (strlen (hd) + 7); | |
83 strcpy (mfile, hd); | |
84 strcat (mfile, "/OMAIL"); | |
85 mfilef = fopen (mfile, "w"); | |
86 } | |
87 skip_to_lf (mddf); | |
88 while (fscanf (mddf, "%4c%14[0123456789]", pre, name) != EOF) | |
89 { | |
90 int comp_len = strlen (md) + strlen (name) + 2; | |
91 if (cflen < comp_len) | |
92 { | |
93 cflen = strlen (md) + strlen (name) + 2; | |
94 cf = (char *) xrealloc (cf, cflen); | |
95 } | |
96 strcpy (cf, md); | |
97 strcat (cf,"/"); | |
98 strcat (cf, name); | |
99 cff = fopen (cf, "r"); | |
100 while ((c = getc(cff)) != EOF) | |
101 putc (c, mfilef); | |
102 putc ('\n', mfilef); | |
103 skip_to_lf (mddf); | |
104 fclose (cff); | |
105 } | |
106 fclose (mddf); | |
442 | 107 fclose (mfilef); |
428 | 108 return 0; |
109 } | |
110 | |
111 static void | |
440 | 112 skip_to_lf (FILE *stream) |
428 | 113 { |
114 register int c; | |
115 while ((c = getc(stream)) != '\n') | |
116 ; | |
117 } | |
118 | |
119 static void * | |
440 | 120 xmalloc (size_t size) |
428 | 121 { |
440 | 122 void *result = malloc (size); |
428 | 123 if (!result) |
124 fatal ("virtual memory exhausted", 0); | |
125 return result; | |
126 } | |
127 | |
128 static void * | |
440 | 129 xrealloc (void *ptr, size_t size) |
428 | 130 { |
440 | 131 void *result = realloc (ptr, size); |
428 | 132 if (!result) |
133 fatal ("virtual memory exhausted", 0); | |
134 return result; | |
135 } | |
136 | |
137 /* Print error message and exit. */ | |
138 | |
139 static void | |
442 | 140 fatal (const char *s1, const char *s2) |
428 | 141 { |
142 error (s1, s2); | |
143 exit (1); | |
144 } | |
145 | |
146 static void | |
442 | 147 error (const char *s1, const char *s2) |
428 | 148 { |
149 fprintf (stderr, "cvtmail: "); | |
150 fprintf (stderr, s1, s2); | |
151 fprintf (stderr, "\n"); | |
152 } |