diff options
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/movemail.c | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/lib-src/movemail.c b/lib-src/movemail.c index 5c5b85ce921..c971c9f2b11 100644 --- a/lib-src/movemail.c +++ b/lib-src/movemail.c | |||
| @@ -58,6 +58,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |||
| 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 |
| @@ -105,15 +106,28 @@ extern int lk_open (), lk_close (); | |||
| 105 | #undef write | 106 | #undef write |
| 106 | #undef close | 107 | #undef close |
| 107 | 108 | ||
| 108 | char *concat (); | ||
| 109 | char *xmalloc (); | ||
| 110 | #ifndef errno | 109 | #ifndef errno |
| 111 | extern int errno; | 110 | extern int errno; |
| 112 | #endif | 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 (); | ||
| 119 | char *concat (); | ||
| 120 | char *xmalloc (); | ||
| 121 | int popmail (); | ||
| 122 | int pop_retr (); | ||
| 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; |
| @@ -135,7 +149,10 @@ main (argc, argv) | |||
| 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]; |
| @@ -151,7 +168,7 @@ main (argc, argv) | |||
| 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] != '/') |
| @@ -351,11 +368,12 @@ main (argc, argv) | |||
| 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 | { |
| @@ -367,33 +385,28 @@ fatal (s1, s2) | |||
| 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 | } |