head 1.14; access; symbols; locks; strict; comment @ * @; 1.14 date 95.12.06.21.04.47; author jromine; state Exp; branches; next 1.13; 1.13 date 95.12.06.19.20.22; author jromine; state Exp; branches; next 1.12; 1.12 date 92.12.15.00.20.22; author jromine; state Exp; branches; next 1.11; 1.11 date 92.11.04.02.58.40; author jromine; state Exp; branches; next 1.10; 1.10 date 92.11.04.01.02.08; author jromine; state Exp; branches; next 1.9; 1.9 date 92.10.16.21.37.36; author jromine; state Exp; branches; next 1.8; 1.8 date 92.10.16.16.52.07; author jromine; state Exp; branches; next 1.7; 1.7 date 92.02.11.00.37.37; author jromine; state Exp; branches; next 1.6; 1.6 date 92.02.10.17.33.44; author jromine; state Exp; branches; next 1.5; 1.5 date 92.01.31.22.26.58; author jromine; state Exp; branches; next 1.4; 1.4 date 92.01.31.16.34.50; author jromine; state Exp; branches; next 1.3; 1.3 date 90.04.05.15.03.46; author sources; state Exp; branches; next 1.2; 1.2 date 90.03.16.15.27.32; author sources; state Exp; branches; next 1.1; 1.1 date 90.03.13.14.21.40; author sources; state Exp; branches; next ; desc @@ 1.14 log @add hidden -queued (for post?) @ text @/* send.c - send a composed message */ #ifndef lint static char ident[] = "@@(#)$Id: send.c,v 1.13 1995/12/06 19:20:22 jromine Exp jromine $"; #endif /* lint */ #include "../h/mh.h" #include #include #include #include #include #ifdef LOCALE #include #endif /* */ #ifndef TMA #define TMAminc(a) (a) #else /* TMA */ #define TMAminc(a) 0 #endif /* TMA */ #ifdef MIME #define MIMEminc(a) (a) #else #define MIMEminc(a) 0 #endif static struct swit switches[] = { #define ALIASW 0 "alias aliasfile", 0, #define DEBUGSW 1 "debug", -5, #define DRAFTSW 2 "draft", 0, #define DFOLDSW 3 "draftfolder +folder", 6, #define DMSGSW 4 "draftmessage msg", 6, #define NDFLDSW 5 "nodraftfolder", 0, #define ENCRSW 6 "encrypt", TMAminc (-7), #define NENCRSW 7 "noencrypt", TMAminc (-9), #define FILTSW 8 "filter filterfile", 0, #define NFILTSW 9 "nofilter", 0, #define FRMTSW 10 "format", 0, #define NFRMTSW 11 "noformat", 0, #define FORWSW 12 "forward", 0, #define NFORWSW 13 "noforward", 0, #define MIMESW 14 "mime", MIMEminc(-4), #define NMIMESW 15 "nomime", MIMEminc(-6), #define MSGDSW 16 "msgid", 0, #define NMSGDSW 17 "nomsgid", 0, #define PUSHSW 18 "push", 0, #define NPUSHSW 19 "nopush", 0, #define SPLITSW 20 "split seconds", MIMEminc(-5), #define UNIQSW 21 "unique", -6, #define NUNIQSW 22 "nounique", -8, #define VERBSW 23 "verbose", 0, #define NVERBSW 24 "noverbose", 0, #define WATCSW 25 "watch", 0, #define NWATCSW 26 "nowatch", 0, #define WIDTHSW 27 "width columns", 0, #define HELPSW 28 "help", 4, #define MAILSW 29 "mail", -4, #define SAMLSW 30 "saml", -4, #define SENDSW 31 "send", -4, #define SOMLSW 32 "soml", -4, #define CLIESW 33 "client host", -6, #define SERVSW 34 "server host", -6, #define SNOOPSW 35 "snoop", -5, #define QUEUESW 36 "queued", -6, #define RECORSW 37 "record program", -6, #define NRECOSW 38 "norecord", -8, NULL, 0 }; static struct swit anyl[] = { #define NOSW 0 "no", 0, #define YESW 1 "yes", 0, #define LISTDSW 2 "list", 0, NULL, 0 }; /* */ extern int debugsw; /* from sendsbr.c */ extern int forwsw; extern int inplace; extern int mime; extern int pushsw; extern int splitsw; extern int unique; extern int verbsw; extern char *altmsg; /* .. */ extern char *annotext; extern char *distfile; extern int errno; /* */ /* ARGSUSED */ main (argc, argv) int argc; char *argv[]; { int msgp = 0, distsw = 0, vecp = 1, isdf = 0, msgnum, status; char *cp, *dfolder = NULL, *maildir = NULL, buf[100], **ap, **argp, *arguments[MAXARGS], *msgs[MAXARGS], *vec[MAXARGS]; struct msgs *mp; struct stat st; #ifdef UCI FILE *fp; #endif /* UCI */ #ifdef LOCALE setlocale(LC_ALL, ""); #endif invo_name = r1bindex (argv[0], '/'); if ((cp = m_find (invo_name)) != NULL) { ap = brkstring (cp = getcpy (cp), " ", "\n"); ap = copyip (ap, arguments); } else ap = arguments; (void) copyip (argv + 1, ap); argp = arguments; vec[vecp++] = "-library"; vec[vecp++] = getcpy (m_maildir ("")); /* */ while (cp = *argp++) { if (*cp == '-') switch (smatch (++cp, switches)) { case AMBIGSW: ambigsw (cp, switches); done (1); case UNKWNSW: adios (NULLCP, "-%s unknown\n", cp); case HELPSW: (void) sprintf (buf, "%s [file] [switches]", invo_name); help (buf, switches); done (1); /* thanks, phyl */ case DRAFTSW: msgs[msgp++] = draft; continue; case DFOLDSW: if (dfolder) adios (NULLCP, "only one draft folder at a time!"); if (!(cp = *argp++) || *cp == '-') adios (NULLCP, "missing argument to %s", argp[-2]); dfolder = path (*cp == '+' || *cp == '@@' ? cp + 1 : cp, *cp != '@@' ? TFOLDER : TSUBCWF); continue; case DMSGSW: if (!(cp = *argp++) || *cp == '-') adios (NULLCP, "missing argument to %s", argp[-2]); msgs[msgp++] = cp; continue; case NDFLDSW: dfolder = NULL; isdf = NOTOK; continue; case PUSHSW: pushsw++; continue; case NPUSHSW: pushsw = 0; continue; case SPLITSW: if (!(cp = *argp++) || sscanf (cp, "%d", &splitsw) != 1) adios (NULLCP, "missing argument to %s", argp[-2]); continue; case UNIQSW: unique++; continue; case NUNIQSW: unique = 0; continue; case FORWSW: forwsw++; continue; case NFORWSW: forwsw = 0; continue; case VERBSW: verbsw++; vec[vecp++] = --cp; continue; case NVERBSW: verbsw = 0; vec[vecp++] = --cp; continue; case MIMESW: #ifdef MIME mime++; vec[vecp++] = --cp; #endif continue; case NMIMESW: #ifdef MIME mime = 0; vec[vecp++] = --cp; #endif continue; case DEBUGSW: debugsw++; /* fall */ case NFILTSW: case FRMTSW: case NFRMTSW: case MSGDSW: case NMSGDSW: case WATCSW: case NWATCSW: case MAILSW: case SAMLSW: case SENDSW: case SOMLSW: case ENCRSW: case NENCRSW: case SNOOPSW: case QUEUESW: case NRECOSW: vec[vecp++] = --cp; continue; case ALIASW: case FILTSW: case WIDTHSW: case CLIESW: case SERVSW: case RECORSW: vec[vecp++] = --cp; if (!(cp = *argp++) || *cp == '-') adios (NULLCP, "missing argument to %s", argp[-2]); vec[vecp++] = cp; continue; } else msgs[msgp++] = cp; } if (cp = m_find ("Aliasfile")) { /* allow Aliasfile: profile entry */ char *dp = NULL; for (ap = brkstring(dp = getcpy(cp), " ", "\n"); ap && *ap; ap++) { vec[vecp++] = "-alias"; vec[vecp++] = *ap; } } /* */ if (dfolder == NULL) { if (msgp == 0) { #ifdef WHATNOW if ((cp = getenv ("mhdraft")) && *cp) { msgs[msgp++] = cp; goto go_to_it; } #endif /* WHATNOW */ msgs[msgp++] = getcpy (m_draft (NULLCP, NULLCP, 1, &isdf)); if (stat (msgs[0], &st) == NOTOK) adios (msgs[0], "unable to stat draft file"); cp = concat ("Use \"", msgs[0], "\"? ", NULLCP); for (status = LISTDSW; status != YESW;) { if (!(argp = getans (cp, anyl))) done (1); switch (status = smatch (*argp, anyl)) { case NOSW: done (0); case YESW: break; case LISTDSW: (void) showfile (++argp, msgs[0]); break; default: advise (NULLCP, "say what?"); break; } } } else for (msgnum = 0; msgnum < msgp; msgnum++) msgs[msgnum] = getcpy (m_maildir (msgs[msgnum])); } else { if (!m_find ("path")) free (path ("./", TFOLDER)); if (!msgp) msgs[msgp++] = "cur"; maildir = m_maildir (dfolder); if (chdir (maildir) == NOTOK) adios (maildir, "unable to change directory to"); if (!(mp = m_gmsg (dfolder))) adios (NULLCP, "unable to read folder %s", dfolder); if (mp -> hghmsg == 0) adios (NULLCP, "no messages in %s", dfolder); for (msgnum = 0; msgnum < msgp; msgnum++) if (!m_convert (mp, msgs[msgnum])) done (1); m_setseq (mp); for (msgp = 0, msgnum = mp -> lowsel; msgnum <= mp -> hghsel; msgnum++) if (mp -> msgstats[msgnum] & SELECTED) { msgs[msgp++] = getcpy (m_name (msgnum)); #ifdef notdef mp -> msgstats[msgnum] |= DELETED; #endif /* notdef */ mp -> msgstats[msgnum] &= ~EXISTS; } mp -> msgflags |= SEQMOD; m_sync (mp); } #ifdef WHATNOW go_to_it: ; #endif /* WHATNOW */ /* */ #ifdef TMA if ((cp = getenv ("KDS")) == NULL || *cp == 0) if ((cp = m_find ("kdsproc")) && *cp) (void) m_putenv ("KDS", cp); if ((cp = getenv ("TMADB")) == NULL || *cp == 0) if ((cp = m_find ("tmadb")) && *cp) (void) m_putenv ("TMADB", m_maildir (cp)); #endif /* TMA */ if ((cp = getenv ("SIGNATURE")) == NULL || *cp == 0) if ((cp = m_find ("signature")) && *cp) (void) m_putenv ("SIGNATURE", cp); #ifdef UCI else { (void) sprintf (buf, "%s/.signature", mypath); if ((fp = fopen (buf, "r")) != NULL && fgets (buf, sizeof buf, fp) != NULL) { (void) fclose (fp); if (cp = index (buf, '\n')) *cp = 0; (void) m_putenv ("SIGNATURE", buf); } } #endif /* UCI */ for (msgnum = 0; msgnum < msgp; msgnum++) if (stat (msgs[msgnum], &st) == NOTOK) adios (msgs[msgnum], "unable to stat draft file"); if ((annotext = getenv ("mhannotate")) == NULL || *annotext == 0) annotext = NULL; if (annotext && ((cp = getenv ("mhinplace")) != NULL && *cp != 0)) inplace = atoi (cp); if ((altmsg = getenv ("mhaltmsg")) == NULL || *altmsg == 0) altmsg = NULL; /* used by dist interface - see below */ if ((cp = getenv ("mhdist")) && *cp && (distsw = atoi (cp)) && altmsg) { vec[vecp++] = "-dist"; distfile = getcpy (m_scratch (altmsg, invo_name)); if (link (altmsg, distfile) == NOTOK) { if (errno != EXDEV #ifdef EISREMOTE && errno != EISREMOTE #endif /* EISREMOTE */ ) adios (distfile, "unable to link %s to", altmsg); free (distfile); distfile = getcpy (m_tmpfil (invo_name)); { int in, out; struct stat st; if ((in = open (altmsg, 0)) == NOTOK) adios (altmsg, "unable to open"); (void) fstat(in, &st); if ((out = creat (distfile, (int) st.st_mode & 0777)) == NOTOK) adios (distfile, "unable to write"); cpydata (in, out, altmsg, distfile); (void) close (in); (void) close (out); } } } else distfile = NULL; if (altmsg == NULL || stat (altmsg, &st) == NOTOK) st.st_mtime = 0, st.st_dev = 0, st.st_ino = 0; if (pushsw) push (); status = 0; vec[0] = r1bindex (postproc, '/'); closefds (3); for (msgnum = 0; msgnum < msgp; msgnum++) switch (sendsbr (vec, vecp, msgs[msgnum], &st)) { case DONE: done (++status); case NOTOK: status++; /* fall */ case OK: break; } m_update (); done (status); } @ 1.13 log @fixes from mtr @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id: send.c,v 1.12 1992/12/15 00:20:22 jromine Exp jromine $"; d122 4 a125 1 #define RECORSW 36 d127 1 a127 1 #define NRECOSW 37 d308 1 @ 1.12 log @endif sugar @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id: send.c,v 1.11 1992/11/04 02:58:40 jromine Exp jromine $"; d122 5 d305 1 d314 1 @ 1.11 log @m_putenv @ text @d3 2 a4 2 static char ident[] = "@@(#)$Id: send.c,v 1.10 1992/11/04 01:02:08 jromine Exp jromine $"; #endif lint d20 1 a20 1 #else TMA d22 1 a22 1 #endif TMA d181 1 a181 1 #endif UCI d335 1 a335 1 #endif WHATNOW d386 1 a386 1 #endif notdef d395 1 a395 1 #endif WHATNOW d406 1 a406 1 #endif TMA d422 1 a422 1 #endif UCI d445 1 a445 1 #endif EISREMOTE @ 1.10 log @LOCALE putenv @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id: send.c,v 1.9 1992/10/16 21:37:36 jromine Exp jromine $"; d402 1 a402 1 (void) putenv ("KDS", cp); d405 1 a405 1 (void) putenv ("TMADB", m_maildir (cp)); d419 1 a419 1 (void) putenv ("SIGNATURE", buf); @ 1.9 log @MIME changes @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id: send.c,v 1.8 1992/10/16 16:52:07 jromine Exp jromine $"; d12 3 d183 3 d410 1 a410 1 (void) putenv ("SIGNATURE", cp); @ 1.8 log @MIME ifdefs @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id: send.c,v 1.7 1992/02/11 00:37:37 jromine Exp jromine $"; d64 6 a69 1 #define MSGDSW 14 d71 1 a71 1 #define NMSGDSW 15 d74 1 a74 1 #define PUSHSW 16 d76 1 a76 1 #define NPUSHSW 17 d79 1 a79 1 #define SPLITSW 18 d82 1 a82 1 #define UNIQSW 19 d84 1 a84 1 #define NUNIQSW 20 d87 1 a87 1 #define VERBSW 21 d89 1 a89 1 #define NVERBSW 22 d92 1 a92 1 #define WATCSW 23 d94 1 a94 1 #define NWATCSW 24 d97 1 a97 1 #define WIDTHSW 25 d100 1 a100 1 #define HELPSW 26 d103 1 a103 1 #define MAILSW 27 d105 1 a105 1 #define SAMLSW 28 d107 1 a107 1 #define SENDSW 29 d109 1 a109 1 #define SOMLSW 30 d112 1 a112 1 #define CLIESW 31 d114 1 a114 1 #define SERVSW 32 d116 1 a116 1 #define SNOOPSW 33 d138 1 d263 13 @ 1.7 log @get mhaltmsg for -dist @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id: send.c,v 1.6 1992/02/10 17:33:44 jromine Exp jromine $"; d21 6 d75 1 a75 1 "split seconds", 0, @ 1.6 log @allow "Aliasfile" to be multiple files @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id: send.c,v 1.5 1992/01/31 22:26:58 jromine Exp jromine $"; a398 3 if (annotext && ((altmsg = getenv ("mhaltmsg")) == NULL || *altmsg == 0)) altmsg = NULL; d401 2 @ 1.5 log @kerberos @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id: send.c,v 1.4 1992/01/31 16:34:50 jromine Exp jromine $"; d287 6 a292 2 vec[vecp++] = "-alias"; vec[vecp++] = getcpy(cp); @ 1.4 log @Multimedia MH @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id: send.c,v 1.3 90/04/05 15:03:46 sources Exp $"; d108 1 a108 1 NULL, NULL d119 1 a119 1 NULL, NULL d365 1 a365 1 if ((cp = getenv ("KDS")) == NULL || *cp == NULL) d368 1 a368 1 if ((cp = getenv ("TMADB")) == NULL || *cp == NULL) d373 1 a373 1 if ((cp = getenv ("SIGNATURE")) == NULL || *cp == NULL) d383 1 a383 1 *cp = NULL; d393 1 a393 1 if ((annotext = getenv ("mhannotate")) == NULL || *annotext == NULL) d396 1 a396 1 && ((altmsg = getenv ("mhaltmsg")) == NULL || *altmsg == NULL)) d398 1 a398 1 if (annotext && ((cp = getenv ("mhinplace")) != NULL && *cp != NULL)) @ 1.3 log @add ID @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id:$"; d68 4 a71 1 #define UNIQSW 18 d73 1 a73 1 #define NUNIQSW 19 d76 1 a76 1 #define VERBSW 20 d78 1 a78 1 #define NVERBSW 21 d81 1 a81 1 #define WATCSW 22 d83 1 a83 1 #define NWATCSW 23 d86 1 a86 1 #define WIDTHSW 24 d89 1 a89 1 #define HELPSW 25 d92 1 a92 1 #define MAILSW 26 d94 1 a94 1 #define SAMLSW 27 d96 1 a96 1 #define SENDSW 28 d98 1 a98 1 #define SOMLSW 29 d101 1 a101 1 #define CLIESW 30 d103 1 a103 1 #define SERVSW 31 d105 1 a105 1 #define SNOOPSW 32 d128 1 d130 1 d225 5 d244 9 a259 2 case VERBSW: case NVERBSW: @ 1.2 log @add "Aliasfile: file" profile entry (like -alias file) @ text @d2 3 @ 1.1 log @Initial revision @ text @d266 4 @