- if (*cp == '+' || *cp == '@') {
- if (folder)
- adios (NULL, "only one folder at a time!");
- else
- folder = pluspath (cp);
- } else
- app_msgarg(&msgs, cp);
- }
-
- /*
- * If we haven't specified -add, -delete, or -list,
- * then use -add if a sequence was specified, else
- * use -list.
- */
- if (!addsw && !deletesw && !listsw) {
- if (seqp)
- addsw++;
- else
- listsw++;
- }
-
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
- if (!msgs.size)
- app_msgarg(&msgs, listsw ? "all" :"cur");
- if (!folder)
- folder = getfolder (1);
- maildir = m_maildir (folder);
-
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
-
- /* read folder and create message structure */
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
-
- /* print some general debugging info */
- if (debugsw)
- print_debug(mp);
-
- /* check for empty folder */
- if (mp->nummsg == 0)
- adios (NULL, "no messages in %s", folder);
-
- /* parse all the message ranges/sequences and set SELECTED */
- for (msgnum = 0; msgnum < msgs.size; msgnum++)
- if (!m_convert (mp, msgs.msgs[msgnum]))
- done (1);
-
- if (publicsw == 1 && is_readonly(mp))
- adios (NULL, "folder %s is read-only, so -public not allowed", folder);
-
- /*
- * Make sure at least one sequence has been
- * specified if we are adding or deleting.
- */
- if (seqp == 0 && (addsw || deletesw))
- adios (NULL, "-%s requires at least one -sequence argument",
- addsw ? "add" : "delete");
- seqs[seqp] = NULL;
-
- /* Adding messages to sequences */
- if (addsw) {
- for (seqp = 0; seqs[seqp]; seqp++)
- if (!seq_addsel (mp, seqs[seqp], publicsw, zerosw))
- done (1);
- }
-
- /* Deleting messages from sequences */
- if (deletesw) {
- for (seqp = 0; seqs[seqp]; seqp++)
- if (!seq_delsel (mp, seqs[seqp], publicsw, zerosw))
- done (1);
- }
-
- /* Listing messages in sequences */
- if (listsw) {
- if (seqp) {
- /* print the sequences given */
- for (seqp = 0; seqs[seqp]; seqp++)
- seq_print (mp, seqs[seqp]);
- } else {
- /* else print them all */
- seq_printall (mp);