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.
21 register struct msgs *mp;
22 static char buffer[BUFSIZ];
25 folder = getcpy(toabsdir(draftfolder));
26 create_folder(folder, 0, done);
27 if (!(mp = folder_read(folder))) {
28 adios(NULL, "unable to read folder %s", folder);
32 ** Make sure we have enough message status space for all
33 ** the message numbers from 1 to "new", since we might
34 ** select an empty slot. If we add more space at the
35 ** end, go ahead and add 10 additional slots.
37 if (mp->hghmsg >= mp->hghoff) {
38 if (!(mp = folder_realloc(mp, 1, mp->hghmsg + 10)))
39 adios(NULL, "unable to allocate folder storage");
40 } else if (mp->lowoff > 1) {
41 if (!(mp = folder_realloc(mp, 1, mp->hghoff)))
42 adios(NULL, "unable to allocate folder storage");
45 mp->msgflags |= ALLOW_NEW; /* allow the "new" sequence */
48 ** The draft message name to return is defined by `which'.
49 ** Usually it is "cur" (for the current draft) or "new"
50 ** (to start a new draft).
52 if (!m_convert(mp, which))
56 snprintf(buffer, sizeof(buffer), "%s/%s", mp->foldpath,
58 seq_setcur(mp, mp->lowsel);