- }
-
- 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_scratch ("", invo_name);
- if ((fd = creat (tmpfilenam, m_gmprot ())) == NOTOK)
- adios (tmpfilenam, "unable to create");
- 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");