9 date 95.12.06.21.07.03; author jromine; state Exp;
14 date 92.12.15.00.20.22; author jromine; state Exp;
19 date 92.11.04.00.58.27; author jromine; state Exp;
24 date 92.02.04.17.46.56; author jromine; state Exp;
29 date 92.01.31.22.25.39; author jromine; state Exp;
34 date 90.04.05.15.03.54; author sources; state Exp;
39 date 90.04.04.21.30.31; author sources; state Exp;
44 date 90.03.18.20.28.26; author sources; state Exp;
49 date 90.03.18.20.27.44; author sources; state Exp;
63 @/* repl.c - reply to a message */
65 static char ident[] = "@@(#)$Id: repl.c,v 1.8 1992/12/15 00:20:22 jromine Exp jromine $";
70 #include <sys/types.h>
77 #define MIMEminc(a) (a)
84 static struct swit switches[] = {
96 "draftfolder +folder", 0,
98 "draftmessage msg", 0,
111 "filter filterfile", 0,
126 "mime", MIMEminc(-4),
128 "nomime", MIMEminc(-6),
136 "whatnowproc program", 0,
147 "file file", -4, /* interface from msh */
151 "build", -5, /* interface from mhe */
158 static struct swit ccswitches[] = {
173 static struct swit aqrnl[] = {
189 static struct swit aqrl[] = {
206 short ccto = CCDFLT; /* global for replsbr */
210 short outputlinelen = OUTPUTLINELEN;
215 char *fcc = NULL; /* global for replsbr */
251 struct msgs *mp = NULL;
256 setlocale(LC_ALL, "");
258 invo_name = r1bindex (argv[0], '/');
259 if ((cp = m_find (invo_name)) != NULL) {
260 ap = brkstring (cp = getcpy (cp), " ", "\n");
261 ap = copyip (ap, arguments);
265 (void) copyip (argv + 1, ap);
270 while (cp = *argp++) {
272 switch (smatch (++cp, switches)) {
274 ambigsw (cp, switches);
277 adios (NULLCP, "-%s unknown", cp);
279 (void) sprintf (buf, "%s: [+folder] [msg] [switches]",
281 help (buf, switches);
292 if (!(cp = *argp++) || *cp == '-')
293 adios (NULLCP, "missing argument to %s", argp[-2]);
297 if (!(cp = *argp++) || *cp == '-')
298 adios (NULLCP, "missing argument to %s", argp[-2]);
303 if (!(ed = *argp++) || *ed == '-')
304 adios (NULLCP, "missing argument to %s", argp[-2]);
312 if (!(whatnowproc = *argp++) || *whatnowproc == '-')
313 adios (NULLCP, "missing argument to %s", argp[-2]);
318 buildsw++; /* fall... */
325 if (!(cp = *argp++) || *cp == '-')
326 adios (NULLCP, "missing argument to %s", argp[-2]);
329 cp = dp = path (cp + 1, TSUBCWF);
331 fcc = add (", ", fcc);
339 adios (NULLCP, "only one file at a time!");
340 if (!(cp = *argp++) || *cp == '-')
341 adios (NULLCP, "missing argument to %s", argp[-2]);
342 file = path (cp, TFILE);
345 if (!(cp = *argp++) || *cp == '-')
346 adios (NULLCP, "missing argument to %s", argp[-2]);
347 filter = getcpy (libpath (cp));
351 if (!(form = *argp++) || *form == '-')
352 adios (NULLCP, "missing argument to %s", argp[-2]);
387 if (!(cp = *argp++) || *cp == '-')
388 adios (NULLCP, "missing argument to %s", argp[-2]);
389 if ((outputlinelen = atoi (cp)) < 10)
390 adios (NULLCP, "impossible width %d", outputlinelen);
395 adios (NULLCP, "only one draft folder at a time!");
396 if (!(cp = *argp++) || *cp == '-')
397 adios (NULLCP, "missing argument to %s", argp[-2]);
398 dfolder = path (*cp == '+' || *cp == '@@' ? cp + 1 : cp,
399 *cp != '@@' ? TFOLDER : TSUBCWF);
403 adios (NULLCP, "only one draft message at a time!");
404 if (!(dmsg = *argp++) || *dmsg == '-')
405 adios (NULLCP, "missing argument to %s", argp[-2]);
412 if (*cp == '+' || *cp == '@@') {
414 adios (NULLCP, "only one folder at a time!");
416 folder = path (cp + 1, *cp == '+' ? TFOLDER : TSUBCWF);
420 adios (NULLCP, "only one message at a time!");
427 cwd = getcpy (pwd ());
429 if (!m_find ("path"))
430 free (path ("./", TFOLDER));
431 if (file && (msg || folder))
432 adios (NULLCP, "can't mix files and folders/msgs");
436 (void) strcpy (drft, m_draft (dfolder, dmsg, NOUSE, &isdf));
437 if (stat (drft, &st) != NOTOK) {
439 (void) strcpy (drft, buildsw ? m_maildir ("reply")
440 : m_draft (dfolder, NULLCP, NOUSE, &isdf));
441 if (!buildsw && stat (drft, &st) != NOTOK) {
443 printf ("Draft \"%s\" exists (%ld bytes).", drft, st.st_size);
444 for (i = LISTDSW; i != YESW;) {
445 if (!(argp = getans ("\nDisposition? ", isdf ? aqrnl : aqrl)))
447 switch (i = smatch (*argp, isdf ? aqrnl : aqrl)) {
456 (void) showfile (++argp, drft);
459 if (refile (++argp, drft) == 0)
463 advise (NULLCP, "say what?");
479 folder = m_getfolder ();
480 maildir = m_maildir (folder);
482 if (chdir (maildir) == NOTOK)
483 adios (maildir, "unable to change directory to");
484 if (!(mp = m_gmsg (folder)))
485 adios (NULLCP, "unable to read folder %s", folder);
486 if (mp -> hghmsg == 0)
487 adios (NULLCP, "no messages in %s", folder);
489 if (!m_convert (mp, msg))
493 if (mp -> numsel > 1)
494 adios (NULLCP, "only one message at a time!");
496 m_replace (pfolder, folder);
497 if (mp -> lowsel != mp -> curmsg)
498 m_setcur (mp, mp -> lowsel);
503 msg = file ? file : getcpy (m_name (mp -> lowsel));
505 if ((in = fopen (msg, "r")) == NULL)
506 adios (msg, "unable to open");
508 replout (in, msg, drft, mp);
513 (void) what_now (ed, nedit, NOUSE, drft, msg, 0, mp,
514 anot ? "Replied" : NULLCP, inplace, cwd);
524 switch (smatch (cp, ccswitches)) {
526 ambigsw (cp, ccswitches);
529 adios (NULLCP, "-%scc %s unknown", ccflag ? "" : "no", cp);
544 ccto = cccc = ccme = ccflag;
558 static char ident[] = "@@(#)$Id: repl.c,v 1.7 1992/11/04 00:58:27 jromine Exp jromine $";
589 replout (in, msg, drft);
600 static char ident[] = "@@(#)$Id: repl.c,v 1.6 1992/02/04 17:46:56 jromine Exp jromine $";
628 @rename m_whatnow() to what_now() since it's not a m_ routine
633 static char ident[] = "@@(#)$Id: repl.c,v 1.5 1992/01/31 22:25:39 jromine Exp jromine $";
646 static char ident[] = "@@(#)$Id: repl.c,v 1.4 1990/04/05 15:03:54 sources Exp jromine $";
649 (void) m_whatnow (ed, nedit, NOUSE, drft, msg, 0, mp,
660 static char ident[] = "@@(#)$Id:$";
678 @search for filter file with libpath
687 @make -[no]format invisible. they don't seem to used anymore
692 filter = getcpy (m_maildir (cp));