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