Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / sbr / RCS / m_draft.c,v
1 head    1.2;
2 access;
3 symbols;
4 locks; strict;
5 comment @ * @;
6
7
8 1.2
9 date    92.12.15.00.20.22;      author jromine; state Exp;
10 branches;
11 next    1.1;
12
13 1.1
14 date    92.01.31.21.51.28;      author jromine; state Exp;
15 branches;
16 next    ;
17
18
19 desc
20 @@
21
22
23 1.2
24 log
25 @endif sugar
26 @
27 text
28 @/* m_draft.c - construct the draft name */
29 #ifndef lint
30 static char ident[] = "@@(#)$Id: m_draft.c,v 1.1 1992/01/31 21:51:28 jromine Exp jromine $";
31 #endif  /* lint */
32
33 #include "../h/mh.h"
34 #include <errno.h>
35 #include <stdio.h>
36 #include <sys/types.h>
37 #include <sys/stat.h>
38
39
40 extern int errno;
41
42
43 char   *m_draft (folder, msg, use, isdf)
44 register char  *folder,
45                *msg;
46 register int    use,
47                *isdf;
48 {
49     register char  *cp;
50     register struct msgs   *mp;
51     struct stat st;
52     static char buffer[BUFSIZ];
53
54     if (*isdf == NOTOK || folder == NULL || *folder == 0) {
55         if (*isdf == NOTOK || (cp = m_find ("Draft-Folder")) == NULL) {
56             *isdf = 0;
57             return m_maildir (msg && *msg ? msg : draft);
58         }
59         else
60             folder = path (*cp == '+' || *cp == '@@' ? cp + 1 : cp,
61                     *cp != '@@' ? TFOLDER : TSUBCWF);
62     }
63     *isdf = 1;
64     
65     (void) chdir (m_maildir (""));
66     (void) strcpy (buffer, m_maildir (folder));
67     if (stat (buffer, &st) == NOTOK) {
68         if (errno != ENOENT)
69             adios (buffer, "error on folder");
70         cp = concat ("Create folder \"", buffer, "\"? ", NULLCP);
71         if (!getanswer (cp))
72             done (0);
73         free (cp);
74         if (!makedir (buffer))
75             adios (NULLCP, "unable to create folder %s", buffer);
76     }
77
78     if (chdir (buffer) == NOTOK)
79         adios (buffer, "unable to change directory to");
80     if (!(mp = m_gmsg (folder)))
81         adios (NULLCP, "unable to read folder %s", folder);
82
83     if ((mp = m_remsg (mp, 0, MAXFOLDER)) == NULL)
84         adios (NULLCP, "unable to allocate folder storage");
85     mp -> msgflags |= MHPATH;
86
87     if (!m_convert (mp, msg && *msg ? msg : use ? "cur" : "new"))
88         done (1);
89     m_setseq (mp);
90     if (mp -> numsel > 1)
91         adios (NULLCP, "only one message draft at a time!");
92
93     (void) sprintf (buffer, "%s/%s", mp -> foldpath, m_name (mp -> lowsel));
94     cp = buffer;
95
96     m_setcur (mp, mp -> lowsel);
97     m_sync (mp);
98     m_fmsg (mp);
99
100     return cp;
101 }
102 @
103
104
105 1.1
106 log
107 @kerberos
108 @
109 text
110 @d3 2
111 a4 2
112 static char ident[] = "@@(#)$Id: m_getfld.c,v 1.9 1992/01/24 18:03:41 jromine Exp $";
113 #endif  lint
114 @