1 /* m_draft.c - construct the draft name */
3 static char ident[] = "@(#)$Id: m_draft.c,v 1.2 1992/12/15 00:20:22 jromine Exp $";
16 char *m_draft (folder, msg, use, isdf)
17 register char *folder,
23 register struct msgs *mp;
25 static char buffer[BUFSIZ];
27 if (*isdf == NOTOK || folder == NULL || *folder == 0) {
28 if (*isdf == NOTOK || (cp = m_find ("Draft-Folder")) == NULL) {
30 return m_maildir (msg && *msg ? msg : draft);
33 folder = path (*cp == '+' || *cp == '@' ? cp + 1 : cp,
34 *cp != '@' ? TFOLDER : TSUBCWF);
38 (void) chdir (m_maildir (""));
39 (void) strcpy (buffer, m_maildir (folder));
40 if (stat (buffer, &st) == NOTOK) {
42 adios (buffer, "error on folder");
43 cp = concat ("Create folder \"", buffer, "\"? ", NULLCP);
47 if (!makedir (buffer))
48 adios (NULLCP, "unable to create folder %s", buffer);
51 if (chdir (buffer) == NOTOK)
52 adios (buffer, "unable to change directory to");
53 if (!(mp = m_gmsg (folder)))
54 adios (NULLCP, "unable to read folder %s", folder);
56 if ((mp = m_remsg (mp, 0, MAXFOLDER)) == NULL)
57 adios (NULLCP, "unable to allocate folder storage");
58 mp -> msgflags |= MHPATH;
60 if (!m_convert (mp, msg && *msg ? msg : use ? "cur" : "new"))
64 adios (NULLCP, "only one message draft at a time!");
66 (void) sprintf (buffer, "%s/%s", mp -> foldpath, m_name (mp -> lowsel));
69 m_setcur (mp, mp -> lowsel);