- int length = 0, nomore = 0;
- int i, width = 0, vecp = 0;
- char *cp, *folder = NULL, *form = NULL;
- char buf[BUFSIZ], *files[MAXARGS];
- char **argp, **arguments;
-
- invo_name = r1bindex (argv[0], '/');
-
- /* read user profile/context */
- context_read();
-
- arguments = getarguments (invo_name, argc, argv, 1);
- argp = arguments;
-
- if ((cp = getenv ("MHLDEBUG")) && *cp)
- mhldebug++;
-
- if ((cp = getenv ("FACEPROC")))
- faceproc = cp;
-
- while ((cp = *argp++)) {
- if (*cp == '-') {
- switch (smatch (++cp, mhlswitches)) {
- case AMBIGSW:
- ambigsw (cp, mhlswitches);
- done (1);
- case UNKWNSW:
- adios (NULL, "-%s unknown\n", cp);
-
- case HELPSW:
- snprintf (buf, sizeof(buf), "%s [switches] [files ...]", invo_name);
- print_help (buf, mhlswitches, 1);
- done (1);
- case VERSIONSW:
- print_version(invo_name);
- done (1);
-
- case BELLSW:
- bellflg = 1;
- continue;
- case NBELLSW:
- bellflg = -1;
- continue;
-
- case CLRSW:
- clearflg = 1;
- continue;
- case NCLRSW:
- clearflg = -1;
- continue;
-
- case FOLDSW:
- if (!(folder = *argp++) || *folder == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- continue;
- case FORMSW:
- if (!(form = *argp++) || *form == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- continue;
-
- case FACESW:
- if (!(faceproc = *argp++) || *faceproc == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- continue;
- case NFACESW:
- faceproc = NULL;
- continue;
- case SLEEPSW:
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- sleepsw = atoi (cp);/* ZERO ok! */
- continue;
-
- case PROGSW:
- if (!(moreproc = *argp++) || *moreproc == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- continue;
- case NPROGSW:
- nomore++;
- continue;
-
- case LENSW:
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- if ((length = atoi (cp)) < 1)
- adios (NULL, "bad argument %s %s", argp[-2], cp);
- continue;
- case WIDTHSW:
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- if ((width = atoi (cp)) < 1)
- adios (NULL, "bad argument %s %s", argp[-2], cp);
- continue;
-
- case DGSTSW:
- if (!(digest = *argp++) || *digest == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- continue;
- case ISSUESW:
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- if ((issue = atoi (cp)) < 1)
- adios (NULL, "bad argument %s %s", argp[-2], cp);
- continue;
- case VOLUMSW:
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- if ((volume = atoi (cp)) < 1)
- adios (NULL, "bad argument %s %s", argp[-2], cp);
- continue;
-
- case FORW2SW:
- forwall++; /* fall */
- case FORW1SW:
- forwflg++;
- clearflg = -1;/* XXX */
- continue;
-
- case BITSTUFFSW:
- dashstuff = 1; /* trinary logic */
- continue;
- case NBITSTUFFSW:
- dashstuff = -1; /* trinary logic */
- continue;
-
- case NBODYSW:
- dobody = 0;
- continue;
- }
+ int length = 0, nomore = 0;
+ int i, width = 0, vecp = 0;
+ char *cp, *folder = NULL, *form = NULL;
+ char buf[BUFSIZ], *files[MAXARGS];
+ char **argp, **arguments;
+
+ invo_name = mhbasename(argv[0]);
+
+ /* read user profile/context */
+ context_read();
+
+ arguments = getarguments(invo_name, argc, argv, 1);
+ argp = arguments;
+
+ if ((cp = getenv("MHLDEBUG")) && *cp)
+ mhldebug++;
+
+ if ((cp = getenv("FACEPROC")))
+ faceproc = cp;
+
+ while ((cp = *argp++)) {
+ if (*cp == '-') {
+ switch (smatch(++cp, mhlswitches)) {
+ case AMBIGSW:
+ ambigsw(cp, mhlswitches);
+ done(1);
+ case UNKWNSW:
+ adios(NULL, "-%s unknown\n", cp);
+
+ case HELPSW:
+ snprintf(buf, sizeof(buf), "%s [switches] [files ...]", invo_name);
+ print_help(buf, mhlswitches, 1);
+ done(1);
+ case VERSIONSW:
+ print_version(invo_name);
+ done(1);
+
+ case BELLSW:
+ bellflg = 1;
+ continue;
+ case NBELLSW:
+ bellflg = -1;
+ continue;
+
+ case CLRSW:
+ clearflg = 1;
+ continue;
+ case NCLRSW:
+ clearflg = -1;
+ continue;
+
+ case FOLDSW:
+ if (!(folder = *argp++) ||
+ *folder == '-')
+ adios(NULL, "missing argument to %s", argp[-2]);
+ continue;
+ case FORMSW:
+ if (!(form = *argp++) || *form == '-')
+ adios(NULL, "missing argument to %s", argp[-2]);
+ continue;
+
+ case FACESW:
+ if (!(faceproc = *argp++) || *faceproc == '-')
+ adios(NULL, "missing argument to %s", argp[-2]);
+ continue;
+ case NFACESW:
+ faceproc = NULL;
+ continue;
+ case SLEEPSW:
+ if (!(cp = *argp++) || *cp == '-')
+ adios(NULL, "missing argument to %s", argp[-2]);
+ sleepsw = atoi(cp); /* ZERO ok! */
+ continue;
+
+ case PROGSW:
+ if (!(moreproc = *argp++) || *moreproc == '-')
+ adios(NULL, "missing argument to %s", argp[-2]);
+ continue;
+ case NPROGSW:
+ nomore++;
+ continue;
+
+ case LENSW:
+ if (!(cp = *argp++) || *cp == '-')
+ adios(NULL, "missing argument to %s", argp[-2]);
+ if ((length = atoi(cp)) < 1)
+ adios(NULL, "bad argument %s %s", argp[-2], cp);
+ continue;
+ case WIDTHSW:
+ if (!(cp = *argp++) || *cp == '-')
+ adios(NULL, "missing argument to %s", argp[-2]);
+ if ((width = atoi(cp)) < 1)
+ adios(NULL, "bad argument %s %s", argp[-2], cp);
+ continue;
+
+ case DGSTSW:
+ if (!(digest = *argp++) ||
+ *digest == '-')
+ adios(NULL, "missing argument to %s", argp[-2]);
+ continue;
+ case ISSUESW:
+ if (!(cp = *argp++) || *cp == '-')
+ adios(NULL, "missing argument to %s", argp[-2]);
+ if ((issue = atoi(cp)) < 1)
+ adios(NULL, "bad argument %s %s", argp[-2], cp);
+ continue;
+ case VOLUMSW:
+ if (!(cp = *argp++) || *cp == '-')
+ adios(NULL, "missing argument to %s", argp[-2]);
+ if ((volume = atoi(cp)) < 1)
+ adios(NULL, "bad argument %s %s", argp[-2], cp);
+ continue;
+
+ case FORW2SW:
+ forwall++; /* fall */
+ case FORW1SW:
+ forwflg++;
+ clearflg = -1;/* XXX */
+ continue;
+
+ case BITSTUFFSW:
+ dashstuff = 1; /* trinary logic */
+ continue;
+ case NBITSTUFFSW:
+ dashstuff = -1; /* trinary logic */
+ continue;
+
+ case NBODYSW:
+ dobody = 0;
+ continue;
+ }
+ }
+ files[vecp++] = cp;
+ }
+
+ if (!folder)
+ folder = getenv("mhfolder");
+
+ if (isatty(fileno(stdout))) {
+ if (!nomore && !sc_hardcopy() && moreproc && *moreproc != '\0') {
+ if (mhl_action) {
+ SIGNAL(SIGINT, SIG_IGN);
+ SIGNAL2(SIGQUIT, quitser);
+ }
+ SIGNAL2(SIGPIPE, pipeser);
+ m_popen(moreproc);
+ ontty = PITTY;
+ } else {
+ SIGNAL(SIGINT, SIG_IGN);
+ SIGNAL2(SIGQUIT, quitser);
+ ontty = ISTTY;
+ }
+ } else {
+ ontty = NOTTY;