📄 forw.c
字号:
/* forw.c - forward messages */#ifndef lintstatic char ident[] = "@(#)$Id: forw.c,v 1.3 90/11/25 19:04:41 sharpe Exp $";#endif lint#include "../h/mh.h"#include "../h/formatsbr.h"#include "../zotnet/tws.h"#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#define IFMT "digest-issue-%s"#define VFMT "digest-volume-%s"static mhl_draft(), copy_draft(), build_form();/* */static struct swit switches[] = {#define ANNOSW 0 "annotate", 0,#define NANNOSW 1 "noannotate", 0,#define DFOLDSW 2 "draftfolder +folder", 0,#define DMSGSW 3 "draftmessage msg", 0,#define NDFLDSW 4 "nodraftfolder", 0,#define EDITRSW 5 "editor editor", 0,#define NEDITSW 6 "noedit", 0,#define FILTSW 7 "filter filterfile", 0,#define FORMSW 8 "form formfile", 0,#define FRMTSW 9 "format", 5,#define NFRMTSW 10 "noformat", 7,#define INPLSW 11 "inplace", 0,#define NINPLSW 12 "noinplace", 0,#define DGSTSW 13 "digest list", 0,#define ISSUESW 14 "issue number", 0,#define VOLUMSW 15 "volume number", 0,#define WHATSW 16 "whatnowproc program", 0,#define NWHATSW 17 "nowhatnowproc", 0,#define HELPSW 18 "help", 4,#define FILESW 19 "file file", -4, /* interface from msh */#define DASHSW 20 "dashmunging", -4, /* interface to mhl */#define NDASHSW 21 "nodashmunging", -6,#ifdef MHE#define BILDSW 22 "build", -5, /* interface from mhe */#endif MHE#ifdef X400#define TMPLTSW 23 "template", 0, /* interface to X.400: NB Number 23! */#endif X400 NULL, NULL};/* */static struct swit aqrnl[] = {#define NOSW 0 "quit", 0,#define YESW 1 "replace", 0,#define LISTDSW 2 "list", 0,#define REFILSW 3 "refile +folder", 0,#define NEWSW 4 "new", 0, NULL, NULL};static struct swit aqrl[] = { "quit", 0, "replace", 0, "list", 0, "refile +folder", 0, NULL, NULL};/* */static char drft[BUFSIZ];static char delim3[] = "\n------------------------------------------------------------\n\n";static char delim4[] = "\n------------------------------\n\n";static struct msgs *mp = NULL; /* used a lot */long lseek (), time ();/* *//* ARGSUSED */main (argc, argv)int argc;char *argv[];{ int msgp = 0, anot = 0, inplace = 0, issue = 0, volume = 0, dashflg = 1,#ifdef MHE buildsw = 0,#endif MHE nedit = 0, nwhat = 0, i, in, out, isdf = 0,#ifdef X400 tmplt = 0,#endif X400 msgnum; char *cp, *cwd, *maildir, *dfolder = NULL, *dmsg = NULL, *digest = NULL, *ed = NULL,#ifdef X400 *ted = NULL,#endif X400 *file = NULL, *filter = NULL, *folder = NULL, *form = NULL, buf[100], value[10], **ap, **argp, *arguments[MAXARGS], *msgs[MAXARGS]; struct stat st; 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;/* */ while (cp = *argp++) { if (*cp == '-') switch (smatch (++cp, switches)) { case AMBIGSW: ambigsw (cp, switches); done (1); case UNKWNSW: adios (NULLCP, "-%s unknown", cp); case HELPSW: (void) sprintf (buf, "%s [+folder] [msgs] [switches]", invo_name); help (buf, switches); done (1); case ANNOSW: anot++; continue; case NANNOSW: anot = 0; continue; case EDITRSW: if (!(ed = *argp++) || *ed == '-') adios (NULLCP, "missing argument to %s", argp[-2]); nedit = 0; continue; case NEDITSW: nedit++; continue; case WHATSW: if (!(whatnowproc = *argp++) || *whatnowproc == '-') adios (NULLCP, "missing argument to %s", argp[-2]); nwhat = 0; continue;#ifdef MHE case BILDSW: buildsw++; /* fall... */#endif MHE case NWHATSW: nwhat++; continue; case FILESW: if (file) adios (NULLCP, "only one file at a time!"); if (!(cp = *argp++) || *cp == '-') adios (NULLCP, "missing argument to %s", argp[-2]); file = path (cp, TFILE); continue; case FILTSW: if (!(cp = *argp++) || *cp == '-') adios (NULLCP, "missing argument to %s", argp[-2]); filter = getcpy (libpath (cp)); continue; case FORMSW: if (!(form = *argp++) || *form == '-') adios (NULLCP, "missing argument to %s", argp[-2]); continue; case FRMTSW: filter = getcpy (libpath (mhlforward)); continue; case NFRMTSW: filter = NULL; continue; case INPLSW: inplace++; continue; case NINPLSW: inplace = 0; continue; case DGSTSW: if (!(digest = *argp++) || *digest == '-') adios (NULLCP, "missing argument to %s", argp[-2]); continue; case ISSUESW: if (!(cp = *argp++) || *cp == '-') adios (NULLCP, "missing argument to %s", argp[-2]); if ((issue = atoi (cp)) < 1) adios (NULLCP, "bad argument %s %s", argp[-2], cp); continue; case VOLUMSW: if (!(cp = *argp++) || *cp == '-') adios (NULLCP, "missing argument to %s", argp[-2]); if ((volume = atoi (cp)) < 1) adios (NULLCP, "bad argument %s %s", argp[-2], cp); 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 (dmsg) adios (NULLCP, "only one draft message at a time!"); if (!(dmsg = *argp++) || *dmsg == '-') adios (NULLCP, "missing argument to %s", argp[-2]); continue; case NDFLDSW: dfolder = NULL; isdf = NOTOK; continue; case DASHSW: dashflg++; continue; case NDASHSW: dashflg = 0; continue;#ifdef X400 case TMPLTSW: cp = *(argp+1); if (cp && *(cp+1) != '-') ted = *argp++; ++tmplt; continue;#endif X400 } if (*cp == '+' || *cp == '@') { if (folder) adios (NULLCP, "only one folder at a time!"); else folder = path (cp + 1, *cp == '+' ? TFOLDER : TSUBCWF); } else msgs[msgp++] = cp; }/* */ cwd = getcpy (pwd ()); if (!m_find ("path")) free (path ("./", TFOLDER)); if (file && (msgp || folder)) adios (NULLCP, "can't mix files and folders/msgs");try_it_again: ;#ifndef MHE (void) strcpy (drft, m_draft (dfolder, dmsg, NOUSE, &isdf)); if (stat (drft, &st) != NOTOK) {#else MHE (void) strcpy (drft, buildsw ? m_maildir ("draft") : m_draft (dfolder, NULLCP, NOUSE, &isdf)); if (!buildsw && stat (drft, &st) != NOTOK) {#endif MHE printf ("Draft \"%s\" exists (%ld bytes).", drft, st.st_size); for (i = LISTDSW; i != YESW;) { if (!(argp = getans ("\nDisposition? ", isdf ? aqrnl : aqrl))) done (1); switch (i = smatch (*argp, isdf ? aqrnl : aqrl)) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -