2 * m_draft.c -- construct the name of a draft message
4 * This code is Copyright (c) 2002, by the authors of nmh. See the
5 * COPYRIGHT file in the root directory of the nmh distribution for
6 * complete copyright information.
15 ** `which' should either be "cur" to use the current draft
16 ** or "new" to start with a new draft.
22 register struct msgs *mp;
23 static char buffer[BUFSIZ];
27 folder = path (*cp == '+' || *cp == '@' ? cp + 1 : cp,
28 *cp != '@' ? TFOLDER : TSUBCWF);
30 chdir (m_maildir (""));
31 strncpy (buffer, m_maildir (folder), sizeof(buffer));
33 create_folder (buffer, 0, done);
35 if (chdir (buffer) == -1)
36 adios (buffer, "unable to change directory to");
38 if (!(mp = folder_read (folder)))
39 adios (NULL, "unable to read folder %s", folder);
42 * Make sure we have enough message status space for all
43 * the message numbers from 1 to "new", since we might
44 * select an empty slot. If we add more space at the
45 * end, go ahead and add 10 additional slots.
47 if (mp->hghmsg >= mp->hghoff) {
48 if (!(mp = folder_realloc (mp, 1, mp->hghmsg + 10)))
49 adios (NULL, "unable to allocate folder storage");
50 } else if (mp->lowoff > 1) {
51 if (!(mp = folder_realloc (mp, 1, mp->hghoff)))
52 adios (NULL, "unable to allocate folder storage");
55 mp->msgflags |= ALLOW_NEW; /* allow the "new" sequence */
58 * The draft message name to return is defined by `which'.
59 * Usually it is "cur" (for the current draft) or "new"
60 * (to start a new draft).
62 if (!m_convert (mp, which))
66 snprintf (buffer, sizeof(buffer), "%s/%s", mp->foldpath,
68 seq_setcur (mp, mp->lowsel);