X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/64e8827c5d5def0325ab7181fe939623c77e807c..d3e11c5e9:/uip/rcvstore.c?ds=inline diff --git a/uip/rcvstore.c b/uip/rcvstore.c index 98f17503..e9654b48 100644 --- a/uip/rcvstore.c +++ b/uip/rcvstore.c @@ -1,6 +1,4 @@ - -/* - * rcvstore.c -- asynchronously add mail to a folder +/* rcvstore.c -- asynchronously add mail to a folder * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for @@ -11,6 +9,10 @@ #include #include #include +#include +#include "../sbr/m_maildir.h" +#include "../sbr/m_mktemp.h" +#include "../sbr/makedir.h" #define RCVSTORE_SWITCHES \ X("create", 0, CRETSW) \ @@ -54,15 +56,11 @@ main (int argc, char **argv) struct msgs *mp; struct stat st; - done=unlink_done; + if (nmh_init(argv[0], 2)) { return 1; } - setlocale(LC_ALL, ""); - invo_name = r1bindex (argv[0], '/'); - - /* read user profile/context */ - context_read(); + done=unlink_done; - mts_init (invo_name); + mts_init (); arguments = getarguments (invo_name, argc, argv, 1); argp = arguments; @@ -162,7 +160,7 @@ main (int argc, char **argv) /* create a temporary file */ tmpfilenam = m_mktemp (invo_name, &fd, NULL); if (tmpfilenam == NULL) { - adios ("rcvstore", "unable to create temporary file"); + adios(NULL, "unable to create temporary file in %s", get_temp_dir()); } chmod (tmpfilenam, m_gmprot()); @@ -170,7 +168,7 @@ main (int argc, char **argv) cpydata (fileno (stdin), fd, "standard input", tmpfilenam); if (fstat (fd, &st) == NOTOK) { - unlink (tmpfilenam); + (void) m_unlink (tmpfilenam); adios (tmpfilenam, "unable to fstat"); } if (close (fd) == NOTOK) @@ -178,8 +176,8 @@ main (int argc, char **argv) /* don't add file if it is empty */ if (st.st_size == 0) { - unlink (tmpfilenam); - advise (NULL, "empty file"); + (void) m_unlink (tmpfilenam); + inform("empty file"); done (0); } @@ -193,7 +191,7 @@ main (int argc, char **argv) * Link message into folder, and possibly add * to the Unseen-Sequence's. */ - if ((msgnum = folder_addmsg (&mp, tmpfilenam, 0, unseensw, 0, 0, (char *)0)) == -1) + if ((msgnum = folder_addmsg (&mp, tmpfilenam, 0, unseensw, 0, 0, NULL)) == -1) done (1); /* @@ -216,7 +214,7 @@ main (int argc, char **argv) folder_free (mp); /* free folder/message structure */ context_save (); /* save the global context file */ - unlink (tmpfilenam); /* remove temporary file */ + (void) m_unlink (tmpfilenam); /* remove temporary file */ tmpfilenam = NULL; done (0); @@ -226,10 +224,10 @@ main (int argc, char **argv) /* * Clean up and exit */ -static void +static void NORETURN unlink_done(int status) { if (tmpfilenam && *tmpfilenam) - unlink (tmpfilenam); + (void) m_unlink (tmpfilenam); exit (status); }