Mercurial > hg > xemacs-beta
comparison lib-src/cvtmail.c @ 412:697ef44129c6 r21-2-14
Import from CVS: tag r21-2-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:20:41 +0200 |
parents | 74fd4e045ea6 |
children | 11054d720c21 |
comparison
equal
deleted
inserted
replaced
411:12e008d41344 | 412:697ef44129c6 |
---|---|
33 * | 33 * |
34 * Author: Larry Kolodney, 1985 | 34 * Author: Larry Kolodney, 1985 |
35 */ | 35 */ |
36 | 36 |
37 | 37 |
38 #include <config.h> | 38 #include <../src/config.h> |
39 | 39 |
40 #include <stdio.h> | 40 #include <stdio.h> |
41 #include <string.h> | 41 #include <string.h> |
42 #include <stdlib.h> | |
43 | 42 |
44 static void *xmalloc (size_t); | 43 #if __STDC__ || defined(STDC_HEADERS) |
45 static void *xrealloc (void *, size_t); | 44 # include <stdlib.h> |
45 #else | |
46 char *malloc (); | |
47 char *getenv (); | |
48 #endif | |
49 static void *xmalloc (unsigned int); | |
50 static void *xrealloc (char *ptr, unsigned int); | |
46 static void skip_to_lf (FILE *stream); | 51 static void skip_to_lf (FILE *stream); |
47 static void fatal (const char *s1, const char *s2); | 52 static void fatal (CONST char *s1, CONST char *s2); |
48 static void error (const char *s1, const char *s2); | 53 static void error (CONST char *s1, CONST char *s2); |
49 | 54 |
50 int | 55 int |
51 main (int argc, char *argv[]) | 56 main (argc, argv) |
57 int argc; | |
58 char *argv[]; | |
52 { | 59 { |
53 char *hd; | 60 char *hd; |
54 char *md; | 61 char *md; |
55 char *mdd; | 62 char *mdd; |
56 char *mfile; | 63 char *mfile; |
61 FILE *cff; | 68 FILE *cff; |
62 char pre[10]; | 69 char pre[10]; |
63 char name[14]; | 70 char name[14]; |
64 int c; | 71 int c; |
65 | 72 |
66 hd = getenv ("HOME"); | 73 hd = (char *) getenv ("HOME"); |
67 | 74 |
68 md = (char *) xmalloc (strlen (hd) + 10); | 75 md = (char *) xmalloc (strlen (hd) + 10); |
69 strcpy (md, hd); | 76 strcpy (md, hd); |
70 strcat (md, "/Messages"); | 77 strcat (md, "/Messages"); |
71 | 78 |
109 fclose (mfilef); | 116 fclose (mfilef); |
110 return 0; | 117 return 0; |
111 } | 118 } |
112 | 119 |
113 static void | 120 static void |
114 skip_to_lf (FILE *stream) | 121 skip_to_lf (stream) |
122 FILE *stream; | |
115 { | 123 { |
116 register int c; | 124 register int c; |
117 while ((c = getc(stream)) != '\n') | 125 while ((c = getc(stream)) != '\n') |
118 ; | 126 ; |
119 } | 127 } |
120 | 128 |
121 static void * | 129 static void * |
122 xmalloc (size_t size) | 130 xmalloc (size) |
131 unsigned size; | |
123 { | 132 { |
124 void *result = malloc (size); | 133 char *result = (char *) malloc (size); |
125 if (!result) | 134 if (!result) |
126 fatal ("virtual memory exhausted", 0); | 135 fatal ("virtual memory exhausted", 0); |
127 return result; | 136 return result; |
128 } | 137 } |
129 | 138 |
130 static void * | 139 static void * |
131 xrealloc (void *ptr, size_t size) | 140 xrealloc (ptr, size) |
141 char *ptr; | |
142 unsigned size; | |
132 { | 143 { |
133 void *result = realloc (ptr, size); | 144 char *result = (char *) realloc (ptr, size); |
134 if (!result) | 145 if (!result) |
135 fatal ("virtual memory exhausted", 0); | 146 fatal ("virtual memory exhausted", 0); |
136 return result; | 147 return result; |
137 } | 148 } |
138 | 149 |
139 /* Print error message and exit. */ | 150 /* Print error message and exit. */ |
140 | 151 |
141 static void | 152 static void |
142 fatal (const char *s1, const char *s2) | 153 fatal (CONST char *s1, CONST char *s2) |
143 { | 154 { |
144 error (s1, s2); | 155 error (s1, s2); |
145 exit (1); | 156 exit (1); |
146 } | 157 } |
147 | 158 |
148 static void | 159 static void |
149 error (const char *s1, const char *s2) | 160 error (CONST char *s1, CONST char *s2) |
150 { | 161 { |
151 fprintf (stderr, "cvtmail: "); | 162 fprintf (stderr, "cvtmail: "); |
152 fprintf (stderr, s1, s2); | 163 fprintf (stderr, s1, s2); |
153 fprintf (stderr, "\n"); | 164 fprintf (stderr, "\n"); |
154 } | 165 } |