]> diplodocus.org Git - nmh/blobdiff - uip/rcvstore.c
Newer versions of Automake want to include the test-driver script,
[nmh] / uip / rcvstore.c
index 5875c21a1ccb58aff1421ceb607420227601841b..be0ac396641494eed665bf6396c6271a221eb869 100644 (file)
@@ -10,8 +10,6 @@
 #include <h/mh.h>
 #include <fcntl.h>
 #include <h/signals.h>
 #include <h/mh.h>
 #include <fcntl.h>
 #include <h/signals.h>
-#include <errno.h>
-#include <signal.h>
 #include <h/mts.h>
 
 #define RCVSTORE_SWITCHES \
 #include <h/mts.h>
 
 #define RCVSTORE_SWITCHES \
@@ -56,15 +54,9 @@ main (int argc, char **argv)
     struct msgs *mp;
     struct stat st;
 
     struct msgs *mp;
     struct stat st;
 
-    done=unlink_done;
-
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
+    if (nmh_init(argv[0], 1)) { return 1; }
 
 
-    /* read user profile/context */
-    context_read();
+    done=unlink_done;
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 1);
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 1);
@@ -166,7 +158,7 @@ main (int argc, char **argv)
     /* create a temporary file */
     tmpfilenam = m_mktemp (invo_name, &fd, NULL);
     if (tmpfilenam == NULL) {
     /* 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());
 
     }
     chmod (tmpfilenam, m_gmprot());
 
@@ -174,7 +166,7 @@ main (int argc, char **argv)
     cpydata (fileno (stdin), fd, "standard input", tmpfilenam);
 
     if (fstat (fd, &st) == NOTOK) {
     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)
        adios (tmpfilenam, "unable to fstat");
     }
     if (close (fd) == NOTOK)
@@ -182,7 +174,7 @@ main (int argc, char **argv)
 
     /* don't add file if it is empty */
     if (st.st_size == 0) {
 
     /* don't add file if it is empty */
     if (st.st_size == 0) {
-       unlink (tmpfilenam);
+       (void) m_unlink (tmpfilenam);
        advise (NULL, "empty file");
        done (0);
     }
        advise (NULL, "empty file");
        done (0);
     }
@@ -220,7 +212,7 @@ main (int argc, char **argv)
     folder_free (mp);          /* free folder/message structure          */
 
     context_save ();           /* save the global context file           */
     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);
     tmpfilenam = NULL;
 
     done (0);
@@ -234,6 +226,6 @@ static void
 unlink_done(int status)
 {
     if (tmpfilenam && *tmpfilenam)
 unlink_done(int status)
 {
     if (tmpfilenam && *tmpfilenam)
-       unlink (tmpfilenam);
+       (void) m_unlink (tmpfilenam);
     exit (status);
 }
     exit (status);
 }