Mercurial > emacs
changeset 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 | 07dd35326963 |
children | dd3b83e4ceb0 |
files | lib-src/movemail.c |
diffstat | 1 files changed, 31 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/lib-src/movemail.c Wed Oct 12 16:03:28 1994 +0000 +++ b/lib-src/movemail.c Wed Oct 12 19:20:24 1994 +0000 @@ -58,6 +58,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <sys/file.h> +#include <stdio.h> #include <errno.h> #include <../src/syswait.h> #ifdef MAIL_USE_POP @@ -105,15 +106,28 @@ #undef write #undef close -char *concat (); -char *xmalloc (); #ifndef errno extern int errno; #endif +char *strerror (); +char *malloc (); + +void fatal (); +void error (); +void pfatal_with_name (); +void pfatal_and_delete (); +char *concat (); +char *xmalloc (); +int popmail (); +int pop_retr (); +int mbx_write (); +int mbx_delimit_begin (); +int mbx_delimit_end (); /* Nonzero means this is name of a lock file to delete on fatal error. */ char *delete_lockname; +int main (argc, argv) int argc; char **argv; @@ -135,7 +149,10 @@ delete_lockname = 0; if (argc < 3) - fatal ("two arguments required"); + { + fprintf (stderr, "Usage: movemail inbox destfile"); + exit(1); + } inname = argv[1]; outname = argv[2]; @@ -151,7 +168,7 @@ /* Also check that outname's directory is writeable to the real uid. */ { char *buf = (char *) xmalloc (strlen (outname) + 1); - char *p, q; + char *p; strcpy (buf, outname); p = buf + strlen (buf); while (p > buf && p[-1] != '/') @@ -351,11 +368,12 @@ #if !defined (MAIL_USE_MMDF) && !defined (MAIL_USE_SYSTEM_LOCK) unlink (lockname); #endif /* not MAIL_USE_MMDF and not MAIL_USE_SYSTEM_LOCK */ - exit (0); + return 0; } /* Print error message and exit. */ +void fatal (s1, s2) char *s1, *s2; { @@ -367,33 +385,28 @@ /* Print error message. `s1' is printf control string, `s2' is arg for it. */ +void error (s1, s2, s3) char *s1, *s2, *s3; { - printf ("movemail: "); - printf (s1, s2, s3); - printf ("\n"); + fprintf (stderr, "movemail: "); + fprintf (stderr, s1, s2, s3); + fprintf (stderr, "\n"); } +void pfatal_with_name (name) char *name; { - extern int errno; - extern char *strerror (); - char *s; - - s = concat ("", strerror (errno), " for %s"); + char *s = concat ("", strerror (errno), " for %s"); fatal (s, name); } +void pfatal_and_delete (name) char *name; { - extern int errno; - extern char *strerror (); - char *s; - - s = concat ("", strerror (errno), " for %s"); + char *s = concat ("", strerror (errno), " for %s"); unlink (name); fatal (s, name); }