Mercurial > emacs
comparison lib-src/movemail.c @ 9490:4e70299f958d
Make functions that return nothing void, not implicitly int.
(main): Improve usage message.
(error): Write to stderr, not stdout.
author | David J. MacKenzie <djm@gnu.org> |
---|---|
date | Wed, 12 Oct 1994 19:20:24 +0000 |
parents | 29f4cce05fa5 |
children | dd3b83e4ceb0 |
comparison
equal
deleted
inserted
replaced
9489:07dd35326963 | 9490:4e70299f958d |
---|---|
56 #define NO_SHORTNAMES /* Tell config not to load remap.h */ | 56 #define NO_SHORTNAMES /* Tell config not to load remap.h */ |
57 #include <../src/config.h> | 57 #include <../src/config.h> |
58 #include <sys/types.h> | 58 #include <sys/types.h> |
59 #include <sys/stat.h> | 59 #include <sys/stat.h> |
60 #include <sys/file.h> | 60 #include <sys/file.h> |
61 #include <stdio.h> | |
61 #include <errno.h> | 62 #include <errno.h> |
62 #include <../src/syswait.h> | 63 #include <../src/syswait.h> |
63 #ifdef MAIL_USE_POP | 64 #ifdef MAIL_USE_POP |
64 #include "pop.h" | 65 #include "pop.h" |
65 #endif | 66 #endif |
103 #undef open | 104 #undef open |
104 #undef read | 105 #undef read |
105 #undef write | 106 #undef write |
106 #undef close | 107 #undef close |
107 | 108 |
109 #ifndef errno | |
110 extern int errno; | |
111 #endif | |
112 char *strerror (); | |
113 char *malloc (); | |
114 | |
115 void fatal (); | |
116 void error (); | |
117 void pfatal_with_name (); | |
118 void pfatal_and_delete (); | |
108 char *concat (); | 119 char *concat (); |
109 char *xmalloc (); | 120 char *xmalloc (); |
110 #ifndef errno | 121 int popmail (); |
111 extern int errno; | 122 int pop_retr (); |
112 #endif | 123 int mbx_write (); |
124 int mbx_delimit_begin (); | |
125 int mbx_delimit_end (); | |
113 | 126 |
114 /* Nonzero means this is name of a lock file to delete on fatal error. */ | 127 /* Nonzero means this is name of a lock file to delete on fatal error. */ |
115 char *delete_lockname; | 128 char *delete_lockname; |
116 | 129 |
130 int | |
117 main (argc, argv) | 131 main (argc, argv) |
118 int argc; | 132 int argc; |
119 char **argv; | 133 char **argv; |
120 { | 134 { |
121 char *inname, *outname; | 135 char *inname, *outname; |
133 #endif /* not MAIL_USE_SYSTEM_LOCK */ | 147 #endif /* not MAIL_USE_SYSTEM_LOCK */ |
134 | 148 |
135 delete_lockname = 0; | 149 delete_lockname = 0; |
136 | 150 |
137 if (argc < 3) | 151 if (argc < 3) |
138 fatal ("two arguments required"); | 152 { |
153 fprintf (stderr, "Usage: movemail inbox destfile"); | |
154 exit(1); | |
155 } | |
139 | 156 |
140 inname = argv[1]; | 157 inname = argv[1]; |
141 outname = argv[2]; | 158 outname = argv[2]; |
142 | 159 |
143 #ifdef MAIL_USE_MMDF | 160 #ifdef MAIL_USE_MMDF |
149 pfatal_with_name (outname); | 166 pfatal_with_name (outname); |
150 | 167 |
151 /* Also check that outname's directory is writeable to the real uid. */ | 168 /* Also check that outname's directory is writeable to the real uid. */ |
152 { | 169 { |
153 char *buf = (char *) xmalloc (strlen (outname) + 1); | 170 char *buf = (char *) xmalloc (strlen (outname) + 1); |
154 char *p, q; | 171 char *p; |
155 strcpy (buf, outname); | 172 strcpy (buf, outname); |
156 p = buf + strlen (buf); | 173 p = buf + strlen (buf); |
157 while (p > buf && p[-1] != '/') | 174 while (p > buf && p[-1] != '/') |
158 *--p = 0; | 175 *--p = 0; |
159 if (p == buf) | 176 if (p == buf) |
349 exit (WRETCODE (status)); | 366 exit (WRETCODE (status)); |
350 | 367 |
351 #if !defined (MAIL_USE_MMDF) && !defined (MAIL_USE_SYSTEM_LOCK) | 368 #if !defined (MAIL_USE_MMDF) && !defined (MAIL_USE_SYSTEM_LOCK) |
352 unlink (lockname); | 369 unlink (lockname); |
353 #endif /* not MAIL_USE_MMDF and not MAIL_USE_SYSTEM_LOCK */ | 370 #endif /* not MAIL_USE_MMDF and not MAIL_USE_SYSTEM_LOCK */ |
354 exit (0); | 371 return 0; |
355 } | 372 } |
356 | 373 |
357 /* Print error message and exit. */ | 374 /* Print error message and exit. */ |
358 | 375 |
376 void | |
359 fatal (s1, s2) | 377 fatal (s1, s2) |
360 char *s1, *s2; | 378 char *s1, *s2; |
361 { | 379 { |
362 if (delete_lockname) | 380 if (delete_lockname) |
363 unlink (delete_lockname); | 381 unlink (delete_lockname); |
365 exit (1); | 383 exit (1); |
366 } | 384 } |
367 | 385 |
368 /* Print error message. `s1' is printf control string, `s2' is arg for it. */ | 386 /* Print error message. `s1' is printf control string, `s2' is arg for it. */ |
369 | 387 |
388 void | |
370 error (s1, s2, s3) | 389 error (s1, s2, s3) |
371 char *s1, *s2, *s3; | 390 char *s1, *s2, *s3; |
372 { | 391 { |
373 printf ("movemail: "); | 392 fprintf (stderr, "movemail: "); |
374 printf (s1, s2, s3); | 393 fprintf (stderr, s1, s2, s3); |
375 printf ("\n"); | 394 fprintf (stderr, "\n"); |
376 } | 395 } |
377 | 396 |
397 void | |
378 pfatal_with_name (name) | 398 pfatal_with_name (name) |
379 char *name; | 399 char *name; |
380 { | 400 { |
381 extern int errno; | 401 char *s = concat ("", strerror (errno), " for %s"); |
382 extern char *strerror (); | |
383 char *s; | |
384 | |
385 s = concat ("", strerror (errno), " for %s"); | |
386 fatal (s, name); | 402 fatal (s, name); |
387 } | 403 } |
388 | 404 |
405 void | |
389 pfatal_and_delete (name) | 406 pfatal_and_delete (name) |
390 char *name; | 407 char *name; |
391 { | 408 { |
392 extern int errno; | 409 char *s = concat ("", strerror (errno), " for %s"); |
393 extern char *strerror (); | |
394 char *s; | |
395 | |
396 s = concat ("", strerror (errno), " for %s"); | |
397 unlink (name); | 410 unlink (name); |
398 fatal (s, name); | 411 fatal (s, name); |
399 } | 412 } |
400 | 413 |
401 /* Return a newly-allocated string whose contents concatenate those of s1, s2, s3. */ | 414 /* Return a newly-allocated string whose contents concatenate those of s1, s2, s3. */ |