216 |
preserve_mail++; |
preserve_mail++; |
217 |
break; |
break; |
218 |
default: |
default: |
219 |
exit(1); |
exit (EXIT_FAILURE); |
220 |
} |
} |
221 |
} |
} |
222 |
|
|
234 |
#else |
#else |
235 |
fprintf (stderr, "Usage: movemail [-p] inbox destfile%s\n", ""); |
fprintf (stderr, "Usage: movemail [-p] inbox destfile%s\n", ""); |
236 |
#endif |
#endif |
237 |
exit (1); |
exit (EXIT_FAILURE); |
238 |
} |
} |
239 |
|
|
240 |
inname = argv[optind]; |
inname = argv[optind]; |
536 |
if (spool_name) |
if (spool_name) |
537 |
mailunlock (); |
mailunlock (); |
538 |
#endif |
#endif |
539 |
exit (0); |
exit (EXIT_SUCCESS); |
540 |
} |
} |
541 |
|
|
542 |
wait (&status); |
wait (&status); |
543 |
if (!WIFEXITED (status)) |
if (!WIFEXITED (status)) |
544 |
exit (1); |
exit (EXIT_FAILURE); |
545 |
else if (WRETCODE (status) != 0) |
else if (WRETCODE (status) != 0) |
546 |
exit (WRETCODE (status)); |
exit (WRETCODE (status)); |
547 |
|
|
554 |
|
|
555 |
#endif /* ! DISABLE_DIRECT_ACCESS */ |
#endif /* ! DISABLE_DIRECT_ACCESS */ |
556 |
|
|
557 |
return 0; |
return EXIT_SUCCESS; |
558 |
} |
} |
559 |
|
|
560 |
#ifdef MAIL_USE_MAILLOCK |
#ifdef MAIL_USE_MAILLOCK |
607 |
if (delete_lockname) |
if (delete_lockname) |
608 |
unlink (delete_lockname); |
unlink (delete_lockname); |
609 |
error (s1, s2, 0); |
error (s1, s2, 0); |
610 |
exit (1); |
exit (EXIT_FAILURE); |
611 |
} |
} |
612 |
|
|
613 |
/* Print error message. `s1' is printf control string, `s2' and `s3' |
/* Print error message. `s1' is printf control string, `s2' and `s3' |
709 |
* If the mailbox is in the form "po:username:hostname", then it is |
* If the mailbox is in the form "po:username:hostname", then it is |
710 |
* modified by this function -- the second colon is replaced by a |
* modified by this function -- the second colon is replaced by a |
711 |
* null. |
* null. |
712 |
|
* |
713 |
|
* Return a value suitable for passing to `exit'. |
714 |
*/ |
*/ |
715 |
|
|
716 |
int |
int |
738 |
if (! server) |
if (! server) |
739 |
{ |
{ |
740 |
error ("Error connecting to POP server: %s", pop_error, 0); |
error ("Error connecting to POP server: %s", pop_error, 0); |
741 |
return (1); |
return EXIT_FAILURE; |
742 |
} |
} |
743 |
|
|
744 |
if (pop_stat (server, &nmsgs, &nbytes)) |
if (pop_stat (server, &nmsgs, &nbytes)) |
745 |
{ |
{ |
746 |
error ("Error getting message count from POP server: %s", pop_error, 0); |
error ("Error getting message count from POP server: %s", pop_error, 0); |
747 |
return (1); |
return EXIT_FAILURE; |
748 |
} |
} |
749 |
|
|
750 |
if (!nmsgs) |
if (!nmsgs) |
751 |
{ |
{ |
752 |
pop_close (server); |
pop_close (server); |
753 |
return (0); |
return EXIT_SUCCESS; |
754 |
} |
} |
755 |
|
|
756 |
mbfi = open (outfile, O_WRONLY | O_CREAT | O_EXCL, 0666); |
mbfi = open (outfile, O_WRONLY | O_CREAT | O_EXCL, 0666); |
758 |
{ |
{ |
759 |
pop_close (server); |
pop_close (server); |
760 |
error ("Error in open: %s, %s", strerror (errno), outfile); |
error ("Error in open: %s, %s", strerror (errno), outfile); |
761 |
return (1); |
return EXIT_FAILURE; |
762 |
} |
} |
763 |
fchown (mbfi, getuid (), -1); |
fchown (mbfi, getuid (), -1); |
764 |
|
|
768 |
error ("Error in fdopen: %s", strerror (errno), 0); |
error ("Error in fdopen: %s", strerror (errno), 0); |
769 |
close (mbfi); |
close (mbfi); |
770 |
unlink (outfile); |
unlink (outfile); |
771 |
return (1); |
return EXIT_FAILURE; |
772 |
} |
} |
773 |
|
|
774 |
if (reverse_order) |
if (reverse_order) |
791 |
{ |
{ |
792 |
error (Errmsg, 0, 0); |
error (Errmsg, 0, 0); |
793 |
close (mbfi); |
close (mbfi); |
794 |
return (1); |
return EXIT_FAILURE; |
795 |
} |
} |
796 |
mbx_delimit_end (mbf); |
mbx_delimit_end (mbf); |
797 |
fflush (mbf); |
fflush (mbf); |
800 |
error ("Error in fflush: %s", strerror (errno), 0); |
error ("Error in fflush: %s", strerror (errno), 0); |
801 |
pop_close (server); |
pop_close (server); |
802 |
close (mbfi); |
close (mbfi); |
803 |
return (1); |
return EXIT_FAILURE; |
804 |
} |
} |
805 |
} |
} |
806 |
|
|
814 |
if (fsync (mbfi) < 0) |
if (fsync (mbfi) < 0) |
815 |
{ |
{ |
816 |
error ("Error in fsync: %s", strerror (errno), 0); |
error ("Error in fsync: %s", strerror (errno), 0); |
817 |
return (1); |
return EXIT_FAILURE; |
818 |
} |
} |
819 |
#endif |
#endif |
820 |
|
|
821 |
if (close (mbfi) == -1) |
if (close (mbfi) == -1) |
822 |
{ |
{ |
823 |
error ("Error in close: %s", strerror (errno), 0); |
error ("Error in close: %s", strerror (errno), 0); |
824 |
return (1); |
return EXIT_FAILURE; |
825 |
} |
} |
826 |
|
|
827 |
if (! preserve) |
if (! preserve) |
831 |
{ |
{ |
832 |
error ("Error from POP server: %s", pop_error, 0); |
error ("Error from POP server: %s", pop_error, 0); |
833 |
pop_close (server); |
pop_close (server); |
834 |
return (1); |
return EXIT_FAILURE; |
835 |
} |
} |
836 |
} |
} |
837 |
|
|
838 |
if (pop_quit (server)) |
if (pop_quit (server)) |
839 |
{ |
{ |
840 |
error ("Error from POP server: %s", pop_error, 0); |
error ("Error from POP server: %s", pop_error, 0); |
841 |
return (1); |
return EXIT_FAILURE; |
842 |
} |
} |
843 |
|
|
844 |
return (0); |
return EXIT_SUCCESS; |
845 |
} |
} |
846 |
|
|
847 |
int |
int |
959 |
|
|
960 |
/* arch-tag: 1c323112-41fe-4fe5-8de9-494de631f73f |
/* arch-tag: 1c323112-41fe-4fe5-8de9-494de631f73f |
961 |
(do not change this comment) */ |
(do not change this comment) */ |
962 |
|
|
963 |
|
/* movemail.c ends here */ |