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.
16 ** `which' should either be the cur sequence to use the current draft
17 ** or the beyond sequence to start with a new draft.
23 static char buffer[BUFSIZ];
26 folder = mh_xstrdup(toabsdir(draftfolder));
27 create_folder(folder, 0, exit);
28 if (!(mp = folder_read(folder))) {
29 adios(EX_IOERR, NULL, "unable to read folder %s", folder);
34 ** Make sure we have enough message status space for all
35 ** the message numbers from 1 to one beyond last, since we might
36 ** select an empty slot. If we add more space at the
37 ** end, go ahead and add 10 additional slots.
39 if (mp->hghmsg >= mp->hghoff) {
40 if (!(mp = folder_realloc(mp, 1, mp->hghmsg + 10)))
41 adios(EX_OSERR, NULL, "unable to allocate folder storage");
42 } else if (mp->lowoff > 1) {
43 if (!(mp = folder_realloc(mp, 1, mp->hghoff)))
44 adios(EX_OSERR, NULL, "unable to allocate folder storage");
47 mp->msgflags |= ALLOW_BEYOND; /* allow the beyond sequence */
50 ** The draft message name to return is defined by `which'.
51 ** Usually it is seq_cur (for the current draft) or seq_beyond
52 ** (to start a new draft).
54 if (!m_convert(mp, which))
58 snprintf(buffer, sizeof(buffer), "%s/%s", mp->foldpath,
60 seq_setcur(mp, mp->lowsel);