-static struct swit sendswitches[] = {
-#define ALIASW 0
- { "alias aliasfile", 0 },
-#define DEBUGSW 1
- { "debug", -5 },
-#define FILTSW 2
- { "filter filterfile", 0 },
-#define NFILTSW 3
- { "nofilter", 0 },
-#define FRMTSW 4
- { "format", 0 },
-#define NFRMTSW 5
- { "noformat", 0 },
-#define FORWSW 6
- { "forward", 0 },
-#define NFORWSW 7
- { "noforward", 0 },
-#define SPSHSW 8
- { "push", 0 },
-#define NSPSHSW 9
- { "nopush", 0 },
-#define VERBSW 10
- { "verbose", 0 },
-#define NVERBSW 11
- { "noverbose", 0 },
-#define WATCSW 12
- { "watch", 0 },
-#define NWATCSW 13
- { "nowatch", 0 },
-#define WIDTHSW 14
- { "width columns", 0 },
-#define SVERSIONSW 15
- { "version", 0 },
-#define SHELPSW 16
- { "help", 0 },
- { NULL, 0 }
-};
-
-
-extern int debugsw; /* from sendsbr.c */
-extern int forwsw;
-extern int inplace;
-extern int pushsw;
-extern int verbsw;
-
-extern char *altmsg; /* .. */
-extern char *annotext;
-extern char *distfile;
-
-
-static void
-sendit(char *sp, char **arg, char *file, int pushed)
-{
- int vecp, n = 1;
- char *cp, buf[BUFSIZ], **argp;
- char **arguments, *vec[MAXARGS];
- struct stat st;
-
-#ifndef lint
- int distsw = 0;
-#endif
-
- /*
- ** Make sure these are defined. In particular, we need
- ** vec[1] to be NULL, in case "arg" is NULL below. It
- ** doesn't matter what is the value of vec[0], but we
- ** set it to NULL, to help catch "off-by-one" errors.
- */
- vec[0] = NULL;
- vec[1] = NULL;
-
- /*
- ** Temporarily copy arg to vec, since the brkstring() call in
- ** getarguments() will wipe it out before it is merged in.
- ** Also, we skip the first element of vec, since getarguments()
- ** skips it. Then we count the number of arguments
- ** copied. The value of "n" will be one greater than
- ** this in order to simulate the standard argc/argv.
- */
- if (arg) {
- char **bp;
-
- copyip(arg, vec+1, MAXARGS-1);
- bp = vec+1;
- while (*bp++)
- n++;
- }
-
- /*
- ** Merge any arguments from command line (now in vec)
- ** and arguments from profile.
- */
- arguments = getarguments(sp, n, vec, 1);
- argp = arguments;
-
- debugsw = 0;
- forwsw = 1;
- inplace = 1;
-
- altmsg = NULL;
- annotext = NULL;
- distfile = NULL;
-
- vecp = 1; /* we'll get the zero'th element later */
- vec[vecp++] = "-library";
- vec[vecp++] = getcpy(toabsdir("+"));
-
- while ((cp = *argp++)) {
- if (*cp == '-') {
- switch (smatch(++cp, sendswitches)) {
- case AMBIGSW:
- ambigsw(cp, sendswitches);
- return;
- case UNKWNSW:
- advise(NULL, "-%s unknown\n", cp);
- return;
-
- case SHELPSW:
- snprintf(buf, sizeof(buf),
- "%s [switches]", sp);
- print_help(buf, sendswitches, 1);
- return;
- case SVERSIONSW:
- print_version(invo_name);
- return;
-
- case SPSHSW:
- pushed++;
- continue;
- case NSPSHSW:
- pushed = 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 DEBUGSW:
- debugsw++; /* fall */
- case NFILTSW:
- case FRMTSW:
- case NFRMTSW:
- case WATCSW:
- case NWATCSW:
- vec[vecp++] = --cp;
- continue;
-
- case ALIASW:
- case FILTSW:
- case WIDTHSW:
- vec[vecp++] = --cp;
- if (!(cp = *argp++) || *cp == '-') {
- advise(NULL, "missing argument to %s",
- argp[-2]);
- return;
- }
- vec[vecp++] = cp;
- continue;
-
- }
- }
- advise(NULL, "usage: %s [switches]", sp);
- return;
- }
-
- /* allow Aliasfile: profile entry */
- if ((cp = context_find("Aliasfile"))) {
- char **ap, *dp;
-
- dp = getcpy(cp);
- for (ap = brkstring(dp, " ", "\n"); ap && *ap; ap++) {
- vec[vecp++] = "-alias";
- vec[vecp++] = getcpy(etcpath(*ap));
- }
- }
-
- if (!(cp = getenv("SIGNATURE")) || !*cp)
- if ((cp = context_find("signature")) && *cp)
- m_putenv("SIGNATURE", cp);
-
- if ((annotext = getenv("mhannotate")) == NULL || *annotext == 0)
- annotext = NULL;
- if ((altmsg = getenv("mhaltmsg")) == NULL || *altmsg == 0)
- altmsg = NULL;
- if (annotext && ((cp = getenv("mhinplace")) != NULL && *cp != 0))
- inplace = atoi(cp);
-
- if ((cp = getenv("mhdist")) && *cp
-#ifndef lint
- && (distsw = atoi (cp))
-#endif /* not lint */
- && altmsg) {
- vec[vecp++] = "-dist";
- distfile = getcpy(m_mktemp2(altmsg, invo_name, NULL, NULL));
- if (link(altmsg, distfile) == NOTOK)
- adios(distfile, "unable to link %s to", altmsg);
- } else {
- distfile = NULL;
- }
-
- if (altmsg == NULL || stat(altmsg, &st) == NOTOK) {
- st.st_mtime = 0;
- st.st_dev = 0;
- st.st_ino = 0;
- }
- if ((pushsw = pushed))
- push();
-
- vec[0] = mhbasename(postproc);
- closefds(3);
-
- if (sendsbr(vec, vecp, file, &st, 1) == OK)
- done(0);
-}
-
-