9 date 95.12.06.21.04.47; author jromine; state Exp;
14 date 95.12.06.19.20.22; author jromine; state Exp;
19 date 92.12.15.00.20.22; author jromine; state Exp;
24 date 92.11.04.02.58.40; author jromine; state Exp;
29 date 92.11.04.01.02.08; author jromine; state Exp;
34 date 92.10.16.21.37.36; author jromine; state Exp;
39 date 92.10.16.16.52.07; author jromine; state Exp;
44 date 92.02.11.00.37.37; author jromine; state Exp;
49 date 92.02.10.17.33.44; author jromine; state Exp;
54 date 92.01.31.22.26.58; author jromine; state Exp;
59 date 92.01.31.16.34.50; author jromine; state Exp;
64 date 90.04.05.15.03.46; author sources; state Exp;
69 date 90.03.16.15.27.32; author sources; state Exp;
74 date 90.03.13.14.21.40; author sources; state Exp;
85 @add hidden -queued (for post?)
88 @/* send.c - send a composed message */
90 static char ident[] = "@@(#)$Id: send.c,v 1.13 1995/12/06 19:20:22 jromine Exp jromine $";
97 #include <sys/types.h>
106 #define TMAminc(a) (a)
112 #define MIMEminc(a) (a)
114 #define MIMEminc(a) 0
117 static struct swit switches[] = {
119 "alias aliasfile", 0,
128 "draftfolder +folder", 6,
130 "draftmessage msg", 6,
135 "encrypt", TMAminc (-7),
137 "noencrypt", TMAminc (-9),
140 "filter filterfile", 0,
155 "mime", MIMEminc(-4),
157 "nomime", MIMEminc(-6),
170 "split seconds", MIMEminc(-5),
213 "record program", -6,
220 static struct swit anyl[] = {
233 extern int debugsw; /* from sendsbr.c */
242 extern char *altmsg; /* .. */
243 extern char *annotext;
244 extern char *distfile;
279 setlocale(LC_ALL, "");
281 invo_name = r1bindex (argv[0], '/');
282 if ((cp = m_find (invo_name)) != NULL) {
283 ap = brkstring (cp = getcpy (cp), " ", "\n");
284 ap = copyip (ap, arguments);
288 (void) copyip (argv + 1, ap);
291 vec[vecp++] = "-library";
292 vec[vecp++] = getcpy (m_maildir (""));
296 while (cp = *argp++) {
298 switch (smatch (++cp, switches)) {
300 ambigsw (cp, switches);
303 adios (NULLCP, "-%s unknown\n", cp);
305 (void) sprintf (buf, "%s [file] [switches]", invo_name);
306 help (buf, switches);
307 done (1); /* thanks, phyl */
310 msgs[msgp++] = draft;
315 adios (NULLCP, "only one draft folder at a time!");
316 if (!(cp = *argp++) || *cp == '-')
317 adios (NULLCP, "missing argument to %s", argp[-2]);
318 dfolder = path (*cp == '+' || *cp == '@@' ? cp + 1 : cp,
319 *cp != '@@' ? TFOLDER : TSUBCWF);
322 if (!(cp = *argp++) || *cp == '-')
323 adios (NULLCP, "missing argument to %s", argp[-2]);
339 if (!(cp = *argp++) || sscanf (cp, "%d", &splitsw) != 1)
340 adios (NULLCP, "missing argument to %s", argp[-2]);
380 debugsw++; /* fall */
407 if (!(cp = *argp++) || *cp == '-')
408 adios (NULLCP, "missing argument to %s", argp[-2]);
415 if (cp = m_find ("Aliasfile")) { /* allow Aliasfile: profile entry */
418 for (ap = brkstring(dp = getcpy(cp), " ", "\n"); ap && *ap; ap++) {
419 vec[vecp++] = "-alias";
426 if (dfolder == NULL) {
429 if ((cp = getenv ("mhdraft")) && *cp) {
434 msgs[msgp++] = getcpy (m_draft (NULLCP, NULLCP, 1, &isdf));
435 if (stat (msgs[0], &st) == NOTOK)
436 adios (msgs[0], "unable to stat draft file");
437 cp = concat ("Use \"", msgs[0], "\"? ", NULLCP);
438 for (status = LISTDSW; status != YESW;) {
439 if (!(argp = getans (cp, anyl)))
441 switch (status = smatch (*argp, anyl)) {
447 (void) showfile (++argp, msgs[0]);
450 advise (NULLCP, "say what?");
456 for (msgnum = 0; msgnum < msgp; msgnum++)
457 msgs[msgnum] = getcpy (m_maildir (msgs[msgnum]));
460 if (!m_find ("path"))
461 free (path ("./", TFOLDER));
464 msgs[msgp++] = "cur";
465 maildir = m_maildir (dfolder);
467 if (chdir (maildir) == NOTOK)
468 adios (maildir, "unable to change directory to");
469 if (!(mp = m_gmsg (dfolder)))
470 adios (NULLCP, "unable to read folder %s", dfolder);
471 if (mp -> hghmsg == 0)
472 adios (NULLCP, "no messages in %s", dfolder);
474 for (msgnum = 0; msgnum < msgp; msgnum++)
475 if (!m_convert (mp, msgs[msgnum]))
479 for (msgp = 0, msgnum = mp -> lowsel; msgnum <= mp -> hghsel; msgnum++)
480 if (mp -> msgstats[msgnum] & SELECTED) {
481 msgs[msgp++] = getcpy (m_name (msgnum));
483 mp -> msgstats[msgnum] |= DELETED;
485 mp -> msgstats[msgnum] &= ~EXISTS;
487 mp -> msgflags |= SEQMOD;
498 if ((cp = getenv ("KDS")) == NULL || *cp == 0)
499 if ((cp = m_find ("kdsproc")) && *cp)
500 (void) m_putenv ("KDS", cp);
501 if ((cp = getenv ("TMADB")) == NULL || *cp == 0)
502 if ((cp = m_find ("tmadb")) && *cp)
503 (void) m_putenv ("TMADB", m_maildir (cp));
506 if ((cp = getenv ("SIGNATURE")) == NULL || *cp == 0)
507 if ((cp = m_find ("signature")) && *cp)
508 (void) m_putenv ("SIGNATURE", cp);
511 (void) sprintf (buf, "%s/.signature", mypath);
512 if ((fp = fopen (buf, "r")) != NULL
513 && fgets (buf, sizeof buf, fp) != NULL) {
515 if (cp = index (buf, '\n'))
517 (void) m_putenv ("SIGNATURE", buf);
522 for (msgnum = 0; msgnum < msgp; msgnum++)
523 if (stat (msgs[msgnum], &st) == NOTOK)
524 adios (msgs[msgnum], "unable to stat draft file");
526 if ((annotext = getenv ("mhannotate")) == NULL || *annotext == 0)
528 if (annotext && ((cp = getenv ("mhinplace")) != NULL && *cp != 0))
530 if ((altmsg = getenv ("mhaltmsg")) == NULL || *altmsg == 0)
531 altmsg = NULL; /* used by dist interface - see below */
533 if ((cp = getenv ("mhdist"))
535 && (distsw = atoi (cp))
537 vec[vecp++] = "-dist";
538 distfile = getcpy (m_scratch (altmsg, invo_name));
539 if (link (altmsg, distfile) == NOTOK) {
542 && errno != EISREMOTE
543 #endif /* EISREMOTE */
545 adios (distfile, "unable to link %s to", altmsg);
547 distfile = getcpy (m_tmpfil (invo_name));
552 if ((in = open (altmsg, 0)) == NOTOK)
553 adios (altmsg, "unable to open");
554 (void) fstat(in, &st);
555 if ((out = creat (distfile, (int) st.st_mode & 0777)) == NOTOK)
556 adios (distfile, "unable to write");
557 cpydata (in, out, altmsg, distfile);
566 if (altmsg == NULL || stat (altmsg, &st) == NOTOK)
567 st.st_mtime = 0, st.st_dev = 0, st.st_ino = 0;
572 vec[0] = r1bindex (postproc, '/');
575 for (msgnum = 0; msgnum < msgp; msgnum++)
576 switch (sendsbr (vec, vecp, msgs[msgnum], &st)) {
600 static char ident[] = "@@(#)$Id: send.c,v 1.12 1992/12/15 00:20:22 jromine Exp jromine $";
618 static char ident[] = "@@(#)$Id: send.c,v 1.11 1992/11/04 02:58:40 jromine Exp jromine $";
632 static char ident[] = "@@(#)$Id: send.c,v 1.10 1992/11/04 01:02:08 jromine Exp jromine $";
672 static char ident[] = "@@(#)$Id: send.c,v 1.9 1992/10/16 21:37:36 jromine Exp jromine $";
675 (void) putenv ("KDS", cp);
678 (void) putenv ("TMADB", m_maildir (cp));
681 (void) putenv ("SIGNATURE", buf);
692 static char ident[] = "@@(#)$Id: send.c,v 1.8 1992/10/16 16:52:07 jromine Exp jromine $";
697 (void) putenv ("SIGNATURE", cp);
708 static char ident[] = "@@(#)$Id: send.c,v 1.7 1992/02/11 00:37:37 jromine Exp jromine $";
776 @get mhaltmsg for -dist
781 static char ident[] = "@@(#)$Id: send.c,v 1.6 1992/02/10 17:33:44 jromine Exp jromine $";
791 @allow "Aliasfile" to be multiple files
796 static char ident[] = "@@(#)$Id: send.c,v 1.5 1992/01/31 22:26:58 jromine Exp jromine $";
799 && ((altmsg = getenv ("mhaltmsg")) == NULL || *altmsg == 0))
812 static char ident[] = "@@(#)$Id: send.c,v 1.4 1992/01/31 16:34:50 jromine Exp jromine $";
815 vec[vecp++] = "-alias";
816 vec[vecp++] = getcpy(cp);
827 static char ident[] = "@@(#)$Id: send.c,v 1.3 90/04/05 15:03:46 sources Exp $";
836 if ((cp = getenv ("KDS")) == NULL || *cp == NULL)
839 if ((cp = getenv ("TMADB")) == NULL || *cp == NULL)
842 if ((cp = getenv ("SIGNATURE")) == NULL || *cp == NULL)
848 if ((annotext = getenv ("mhannotate")) == NULL || *annotext == NULL)
851 && ((altmsg = getenv ("mhaltmsg")) == NULL || *altmsg == NULL))
854 if (annotext && ((cp = getenv ("mhinplace")) != NULL && *cp != NULL))
865 static char ident[] = "@@(#)$Id:$";
923 @add "Aliasfile: file" profile entry (like -alias file)