aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/cvtmail.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/lib-src/cvtmail.c b/lib-src/cvtmail.c
index b6e0c58ceb3..d2123291d18 100644
--- a/lib-src/cvtmail.c
+++ b/lib-src/cvtmail.c
@@ -21,7 +21,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 * exist in your home directory, containing individual mail messages in 21 * exist in your home directory, containing individual mail messages in
22 * separate files in the standard gosling emacs mail reader format. 22 * separate files in the standard gosling emacs mail reader format.
23 * 23 *
24 * Program takes one argument: an output file. THis file will contain 24 * Program takes one argument: an output file. This file will contain
25 * all the messages in Messages directory, in berkeley mail format. 25 * all the messages in Messages directory, in berkeley mail format.
26 * If no output file is mentioned, messages are put in ~/OMAIL. 26 * If no output file is mentioned, messages are put in ~/OMAIL.
27 * 27 *
@@ -41,6 +41,7 @@ char *getenv ();
41char *xmalloc (); 41char *xmalloc ();
42char *xrealloc (); 42char *xrealloc ();
43void skip_to_lf (); 43void skip_to_lf ();
44void sysfail ();
44 45
45int 46int
46main (argc, argv) 47main (argc, argv)
@@ -74,15 +75,20 @@ main (argc, argv)
74 cf = (char *) xmalloc (cflen); 75 cf = (char *) xmalloc (cflen);
75 76
76 mddf = fopen (mdd, "r"); 77 mddf = fopen (mdd, "r");
78 if (!mddf)
79 sysfail (mdd);
77 if (argc > 1) 80 if (argc > 1)
78 mfilef = fopen (argv[1], "w"); 81 mfile = argv[1];
79 else 82 else
80 { 83 {
81 mfile = (char *) xmalloc (strlen (hd) + 7); 84 mfile = (char *) xmalloc (strlen (hd) + 7);
82 strcpy (mfile, hd); 85 strcpy (mfile, hd);
83 strcat (mfile, "/OMAIL"); 86 strcat (mfile, "/OMAIL");
84 mfilef = fopen (mfile, "w");
85 } 87 }
88 mfilef = fopen (mfile, "w");
89 if (!mfilef)
90 sysfail (mfile);
91
86 skip_to_lf (mddf); 92 skip_to_lf (mddf);
87 while (fscanf (mddf, "%4c%14[0123456789]", pre, name) != EOF) 93 while (fscanf (mddf, "%4c%14[0123456789]", pre, name) != EOF)
88 { 94 {
@@ -95,11 +101,16 @@ main (argc, argv)
95 strcat (cf,"/"); 101 strcat (cf,"/");
96 strcat (cf, name); 102 strcat (cf, name);
97 cff = fopen (cf, "r"); 103 cff = fopen (cf, "r");
98 while ((c = getc(cff)) != EOF) 104 if (!cff)
99 putc (c, mfilef); 105 perror (cf);
100 putc ('\n', mfilef); 106 else
101 skip_to_lf (mddf); 107 {
102 fclose (cff); 108 while ((c = getc(cff)) != EOF)
109 putc (c, mfilef);
110 putc ('\n', mfilef);
111 skip_to_lf (mddf);
112 fclose (cff);
113 }
103 } 114 }
104 fclose (mddf); 115 fclose (mddf);
105 fclose (mfilef); 116 fclose (mfilef);
@@ -111,7 +122,7 @@ skip_to_lf (stream)
111 FILE *stream; 122 FILE *stream;
112{ 123{
113 register int c; 124 register int c;
114 while ((c = getc(stream)) != '\n') 125 while ((c = getc(stream)) != EOF && c != '\n')
115 ; 126 ;
116} 127}
117 128
@@ -135,6 +146,15 @@ fatal (s1, s2)
135 exit (1); 146 exit (1);
136} 147}
137 148
149void
150sysfail (s)
151 char *s;
152{
153 fprintf (stderr, "cvtmail: ");
154 perror (s);
155 exit (1);
156}
157
138char * 158char *
139xmalloc (size) 159xmalloc (size)
140 unsigned size; 160 unsigned size;