9 date 92.12.15.00.20.22; author jromine; state Exp;
14 date 92.11.04.00.40.01; author jromine; state Exp;
19 date 92.02.04.17.46.56; author jromine; state Exp;
24 date 92.01.31.22.07.37; author jromine; state Exp;
29 date 90.04.05.15.03.07; author sources; state Exp;
34 date 90.02.09.09.44.16; author sources; state Exp;
39 date 90.02.09.09.44.01; author sources; state Exp;
53 @/* comp.c - compose a message */
55 static char ident[] = "@@(#)$Id: comp.c,v 1.6 1992/11/04 00:40:01 jromine Exp jromine $";
60 #include <sys/types.h>
68 static struct swit switches[] = {
70 "draftfolder +folder", 0,
72 "draftmessage msg", 0,
92 "whatnowproc program", 0,
105 static struct swit aqrunl[] = {
123 static struct swit aqrul[] = {
162 struct msgs *mp = NULL;
166 setlocale(LC_ALL, "");
168 invo_name = r1bindex (argv[0], '/');
169 if ((cp = m_find (invo_name)) != NULL) {
170 ap = brkstring (cp = getcpy (cp), " ", "\n");
171 ap = copyip (ap, arguments);
175 (void) copyip (argv + 1, ap);
180 while (cp = *argp++) {
182 switch (smatch (++cp, switches)) {
184 ambigsw (cp, switches);
187 adios (NULLCP, "-%s unknown", cp);
189 (void) sprintf (buf, "%s [+folder] [msg] [switches]",
191 help (buf, switches);
195 if (!(ed = *argp++) || *ed == '-')
196 adios (NULLCP, "missing argument to %s", argp[-2]);
204 if (!(whatnowproc = *argp++) || *whatnowproc == '-')
205 adios (NULLCP, "missing argument to %s", argp[-2]);
213 if (!(form = *argp++) || *form == '-')
214 adios (NULLCP, "missing argument to %s", argp[-2]);
224 case FILESW: /* compatibility */
226 adios (NULLCP, "only one file at a time!");
227 if (!(file = *argp++) || *file == '-')
228 adios (NULLCP, "missing argument to %s", argp[-2]);
234 adios (NULLCP, "only one draft folder at a time!");
235 if (!(cp = *argp++) || *cp == '-')
236 adios (NULLCP, "missing argument to %s", argp[-2]);
237 dfolder = path (*cp == '+' || *cp == '@@' ? cp + 1 : cp,
238 *cp != '@@' ? TFOLDER : TSUBCWF);
242 adios (NULLCP, "only one draft message at a time!");
243 if (!(file = *argp++) || *file == '-')
244 adios (NULLCP, "missing argument to %s", argp[-2]);
251 if (*cp == '+' || *cp == '@@') {
253 adios (NULLCP, "only one folder at a time!");
255 folder = path (cp + 1, *cp == '+' ? TFOLDER : TSUBCWF);
259 adios (NULLCP, "only one message at a time!");
266 cwd = getcpy (pwd ());
268 if (!m_find ("path"))
269 free (path ("./", TFOLDER));
271 if ((dfolder || m_find ("Draft-Folder")) && !folder && msg && !file)
272 file = msg, msg = NULL;
273 if (form && (folder || msg))
274 adios (NULLCP, "can't mix forms and folders/msgs");
280 folder = m_getfolder ();
281 maildir = m_maildir (folder);
283 if (chdir (maildir) == NOTOK)
284 adios (maildir, "unable to change directory to");
285 if (!(mp = m_gmsg (folder)))
286 adios (NULLCP, "unable to read folder %s", folder);
287 if (mp -> hghmsg == 0)
288 adios (NULLCP, "no messages in %s", folder);
290 if (!m_convert (mp, msg))
294 if (mp -> numsel > 1)
295 adios (NULLCP, "only one message at a time!");
297 if ((in = open (form = getcpy (m_name (mp -> lowsel)), 0)) == NOTOK)
298 adios (form, "unable to open message");
302 if ((in = open (libpath (form), 0)) == NOTOK)
303 adios (form, "unable to open form file");
306 if ((in = open (libpath (components), 0)) == NOTOK)
307 adios (components, "unable to open default components file");
314 (void) strcpy (drft, m_draft (dfolder, file, use, &isdf));
315 if ((out = open (drft, 0)) != NOTOK) {
316 i = fdcompare (in, out);
321 if (stat (drft, &st) == NOTOK)
322 adios (drft, "unable to stat");
323 printf ("Draft \"%s\" exists (%ld bytes).", drft, st.st_size);
324 for (i = LISTDSW; i != YESW;) {
325 if (!(argp = getans ("\nDisposition? ", isdf ? aqrunl : aqrul)))
327 switch (i = smatch (*argp, isdf ? aqrunl : aqrul)) {
340 (void) showfile (++argp, drft);
343 if (refile (++argp, drft) == 0)
347 advise (NULLCP, "say what?");
354 adios (drft, "unable to open");
356 if ((out = creat (drft, m_gmprot ())) == NOTOK)
357 adios (drft, "unable to create");
358 cpydata (in, out, form, drft);
367 (void) what_now (ed, nedit, use, drft, NULLCP, 0, NULLMP, NULLCP, 0, cwd);
380 static char ident[] = "@@(#)$Id: comp.c,v 1.5 1992/02/04 17:46:56 jromine Exp jromine $";
387 @rename m_whatnow() to what_now() since it's not a m_ routine
392 static char ident[] = "@@(#)$Id: comp.c,v 1.4 1992/01/31 22:07:37 jromine Exp jromine $";
405 static char ident[] = "@@(#)$Id: comp.c,v 1.3 1990/04/05 15:03:07 sources Exp jromine $";
408 (void) m_whatnow (ed, nedit, use, drft, NULLCP, 0, NULLMP, NULLCP, 0, cwd);
419 static char ident[] = "@@(#)$Id:$";
434 @Fixes from Van Jacobson