- }
-
- seqs[seqp] = NULL; /* NULL terminate list of sequences */
-
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
-
- /* if no folder is given, use default folder */
- if (!folder)
- folder = getfolder (0);
- maildir = m_maildir (folder);
-
- /* check if folder exists */
- if (stat (maildir, &st) == NOTOK) {
- if (errno != ENOENT)
- adios (maildir, "error on folder");
- if (!create)
- adios (NULL, "folder %s doesn't exist", maildir);
- if (!makedir (maildir))
- adios (NULL, "unable to create folder %s", maildir);
- }
-
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
-
- /* ignore a few signals */
- SIGNAL (SIGHUP, SIG_IGN);
- SIGNAL (SIGINT, SIG_IGN);
- SIGNAL (SIGQUIT, SIG_IGN);
- SIGNAL (SIGTERM, SIG_IGN);
-
- /* create a temporary file */
- tmpfilenam = m_mktemp (invo_name, &fd, NULL);
- if (tmpfilenam == NULL) {
- adios ("rcvstore", "unable to create temporary file");
- }
- chmod (tmpfilenam, m_gmprot());
-
- /* copy the message from stdin into temp file */
- cpydata (fileno (stdin), fd, "standard input", tmpfilenam);
-
- if (fstat (fd, &st) == NOTOK) {
- unlink (tmpfilenam);
- adios (tmpfilenam, "unable to fstat");
- }
- if (close (fd) == NOTOK)
- adios (tmpfilenam, "error closing");
-
- /* don't add file if it is empty */
- if (st.st_size == 0) {
- unlink (tmpfilenam);
- advise (NULL, "empty file");
- done (0);
- }
-
- /*
- * read folder and create message structure
- */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
-
- /*
- * 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)
- done (1);
-
- /*
- * Add the message to any extra sequences
- * that have been specified.
- */
- for (seqp = 0; seqs[seqp]; seqp++) {
- if (!seq_addmsg (mp, seqs[seqp], msgnum, publicsw, zerosw))
- done (1);
- }
-
- seq_setunseen (mp, 0); /* synchronize any Unseen-Sequence's */
- seq_save (mp); /* synchronize and save message sequences */
- folder_free (mp); /* free folder/message structure */
-
- context_save (); /* save the global context file */
- unlink (tmpfilenam); /* remove temporary file */
- tmpfilenam = NULL;
-
- done (0);
- return 1;
+ chmod(tmpfilenam, m_gmprot());
+
+ /* copy the message from stdin into temp file */
+ cpydata(fileno(stdin), fd, "standard input", tmpfilenam);
+
+ if (fstat(fd, &st) == NOTOK) {
+ unlink(tmpfilenam);
+ adios(tmpfilenam, "unable to fstat");
+ }
+ if (close(fd) == NOTOK)
+ adios(tmpfilenam, "error closing");
+
+ /* don't add file if it is empty */
+ if (st.st_size == 0) {
+ unlink(tmpfilenam);
+ advise(NULL, "empty file");
+ done(0);
+ }
+
+ /*
+ ** read folder and create message structure
+ */
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
+
+ /*
+ ** Link message into folder, and possibly add
+ ** to the Unseen-Sequence's.
+ */
+ if ((msgnum = folder_addmsg(&mp, tmpfilenam, 0, unseensw, 0, 0, NULL))
+ == -1)
+ done(1);
+
+ /*
+ ** Add the message to any extra sequences
+ ** that have been specified.
+ */
+ for (seqp = 0; seqs[seqp]; seqp++) {
+ if (!seq_addmsg(mp, seqs[seqp], msgnum, publicsw, zerosw))
+ done(1);
+ }
+
+ seq_setunseen(mp, 1); /* add new msgs to unseen sequences */
+ seq_save(mp); /* synchronize and save message sequences */
+ folder_free(mp); /* free folder/message structure */
+
+ context_save(); /* save the global context file */
+ unlink(tmpfilenam); /* remove temporary file */
+ tmpfilenam = NULL;
+
+ done(0);
+ return 1;