/* m_draft.c - construct the draft name */
static char ident
[] = "@(#)$Id: m_draft.c,v 1.2 1992/12/15 00:20:22 jromine Exp $";
char *m_draft (folder
, msg
, use
, isdf
)
register struct msgs
*mp
;
static char buffer
[BUFSIZ
];
if (*isdf
== NOTOK
|| folder
== NULL
|| *folder
== 0) {
if (*isdf
== NOTOK
|| (cp
= m_find ("Draft-Folder")) == NULL
) {
return m_maildir (msg
&& *msg
? msg
: draft
);
folder
= path (*cp
== '+' || *cp
== '@' ? cp
+ 1 : cp
,
*cp
!= '@' ? TFOLDER
: TSUBCWF
);
(void) chdir (m_maildir (""));
(void) strcpy (buffer
, m_maildir (folder
));
if (stat (buffer
, &st
) == NOTOK
) {
adios (buffer
, "error on folder");
cp
= concat ("Create folder \"", buffer
, "\"? ", NULLCP
);
adios (NULLCP
, "unable to create folder %s", buffer
);
if (chdir (buffer
) == NOTOK
)
adios (buffer
, "unable to change directory to");
if (!(mp
= m_gmsg (folder
)))
adios (NULLCP
, "unable to read folder %s", folder
);
if ((mp
= m_remsg (mp
, 0, MAXFOLDER
)) == NULL
)
adios (NULLCP
, "unable to allocate folder storage");
mp
-> msgflags
|= MHPATH
;
if (!m_convert (mp
, msg
&& *msg
? msg
: use
? "cur" : "new"))
adios (NULLCP
, "only one message draft at a time!");
(void) sprintf (buffer
, "%s/%s", mp
-> foldpath
, m_name (mp
-> lowsel
));
m_setcur (mp
, mp
-> lowsel
);