Annotation of 43BSD/contrib/mh/sbr/m_draft.c, revision 1.1.1.1

1.1       root        1: /* m_draft.c - construct the draft name */
                      2: 
                      3: #include "../h/mh.h"
                      4: #include <errno.h>
                      5: #include <stdio.h>
                      6: #include <sys/types.h>
                      7: #include <sys/stat.h>
                      8: 
                      9: 
                     10: extern int errno;
                     11: 
                     12: 
                     13: char   *m_draft (folder, msg, use, isdf)
                     14: register char  *folder,
                     15:                *msg;
                     16: register int    use,
                     17:                *isdf;
                     18: {
                     19:     register char  *cp;
                     20:     register struct msgs   *mp;
                     21:     struct stat st;
                     22:     static char buffer[BUFSIZ];
                     23: 
                     24:     if (*isdf == NOTOK || folder == NULL || *folder == NULL) {
                     25:        if (*isdf == NOTOK || (cp = m_find ("Draft-Folder")) == NULL) {
                     26:            *isdf = 0;
                     27:            return m_maildir (msg && *msg ? msg : draft);
                     28:        }
                     29:        else
                     30:            folder = path (*cp == '+' || *cp == '@' ? cp + 1 : cp,
                     31:                    *cp != '@' ? TFOLDER : TSUBCWF);
                     32:     }
                     33:     *isdf = 1;
                     34:     
                     35:     (void) chdir (m_maildir (""));
                     36:     (void) strcpy (buffer, m_maildir (folder));
                     37:     if (stat (buffer, &st) == NOTOK) {
                     38:        if (errno != ENOENT)
                     39:            adios (buffer, "error on folder");
                     40:        cp = concat ("Create folder \"", buffer, "\"? ", NULLCP);
                     41:        if (!getanswer (cp))
                     42:            done (0);
                     43:        free (cp);
                     44:        if (!makedir (buffer))
                     45:            adios (NULLCP, "unable to create folder %s", buffer);
                     46:     }
                     47: 
                     48:     if (chdir (buffer) == NOTOK)
                     49:        adios (buffer, "unable to change directory to");
                     50:     if (!(mp = m_gmsg (folder)))
                     51:        adios (NULLCP, "unable to read folder %s", folder);
                     52: 
                     53:     if ((mp = m_remsg (mp, 0, MAXFOLDER)) == NULL)
                     54:        adios (NULLCP, "unable to allocate folder storage");
                     55:     mp -> msgflags |= MHPATH;
                     56: 
                     57:     if (!m_convert (mp, msg && *msg ? msg : use ? "cur" : "new"))
                     58:        done (1);
                     59:     m_setseq (mp);
                     60:     if (mp -> numsel > 1)
                     61:        adios (NULLCP, "only one message draft at a time!");
                     62: 
                     63:     (void) sprintf (buffer, "%s/%s", mp -> foldpath, m_name (mp -> lowsel));
                     64:     cp = buffer;
                     65: 
                     66:     m_setcur (mp, mp -> lowsel);
                     67:     m_sync (mp);
                     68:     m_fmsg (mp);
                     69: 
                     70:     return cp;
                     71: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.