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 = pluspath(cp);
30 strncpy(buffer, m_maildir(folder), sizeof(buffer));
32 create_folder(buffer, 0, done);
34 if (chdir(buffer) == -1)
35 adios(buffer, "unable to change directory to");
37 if (!(mp = folder_read(folder)))
38 adios(NULL, "unable to read folder %s", folder);
41 ** Make sure we have enough message status space for all
42 ** the message numbers from 1 to "new", since we might
43 ** select an empty slot. If we add more space at the
44 ** end, go ahead and add 10 additional slots.
46 if (mp->hghmsg >= mp->hghoff) {
47 if (!(mp = folder_realloc(mp, 1, mp->hghmsg + 10)))
48 adios(NULL, "unable to allocate folder storage");
49 } else if (mp->lowoff > 1) {
50 if (!(mp = folder_realloc(mp, 1, mp->hghoff)))
51 adios(NULL, "unable to allocate folder storage");
54 mp->msgflags |= ALLOW_NEW; /* allow the "new" sequence */
57 ** The draft message name to return is defined by `which'.
58 ** Usually it is "cur" (for the current draft) or "new"
59 ** (to start a new draft).
61 if (!m_convert(mp, which))
65 snprintf(buffer, sizeof(buffer), "%s/%s", mp->foldpath,
67 seq_setcur(mp, mp->lowsel);