]> diplodocus.org Git - nmh/blobdiff - uip/msh.c
Document argsplit changes in mh-profile man page.
[nmh] / uip / msh.c
index aed4bc7dfc3d68d4fa2bcab512e1f0ee6bc3341a..4ab73286825fa15e15dd331176ec62b24affa938 100644 (file)
--- a/uip/msh.c
+++ b/uip/msh.c
 #include <h/mts.h>
 #include <h/utils.h>
 
-#ifdef HAVE_TERMIOS_H
-# include <termios.h>
-#else
-# ifdef HAVE_TERMIO_H
-#  include <termio.h>
-# else
-#  include <sgtty.h>
-# endif
-#endif
+#include <termios.h>
 
 #include <pwd.h>
 #include <setjmp.h>
 
 #define        QUOTE   '\\'            /* sigh */
 
-static struct swit switches[] = {
-#define        IDSW                  0
-    { "idstart number", -7 },          /* interface from bbc */
-#define        FDSW                  1
-    { "idstop number", -6 },           /*  .. */
-#define        QDSW                  2
-    { "idquit number", -6 },           /*  .. */
-#define        NMSW                  3
-    { "idname BBoard", -6 },           /*  .. */
-#define        PRMPTSW               4
-    { "prompt string", 0 },
-#define        SCANSW                5
-    { "scan", 0 },
-#define        NSCANSW               6
-    { "noscan", 0 },
-#define        READSW                7
-    { "vmhread fd", -7 },
-#define        WRITESW               8
-    { "vmhwrite fd", -8 },     
-#define        PREADSW               9
-    { "popread fd", -7 },
-#define        PWRITSW              10
-    { "popwrite fd", -8 },
-#define        TCURSW               11
-    { "topcur", 0 },
-#define        NTCURSW              12
-    { "notopcur", 0 },
-#define VERSIONSW            13
-    { "version", 0 },
-#define        HELPSW               14
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define MSH_SWITCHES \
+    X("idstart number", -7, IDSW) /* interface from bbc */ \
+    X("idstop number", -6, FDSW) /*  .. */ \
+    X("idquit number", -6, QDSW) /*  .. */ \
+    X("idname BBoard", -6, NMSW) /*  .. */ \
+    X("prompt string", 0, PRMPTSW) \
+    X("scan", 0, SCANSW) \
+    X("noscan", 0, NSCANSW) \
+    X("vmhread fd", -7, READSW) \
+    X("vmhwrite fd", -8, WRITESW) \
+    X("popread fd", -7, PREADSW) \
+    X("popwrite fd", -8, PWRITSW) \
+    X("topcur", 0, TCURSW) \
+    X("notopcur", 0, NTCURSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MSH);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MSH, switches);
+#undef X
 
 static int mbx_style = MMDF_FORMAT;
 
@@ -118,11 +101,6 @@ static int windows[NWIN + 1];
 
 static jmp_buf peerenv;
 
-#ifdef BPOP
-int pmsh = 0;                  /* BPOP enabled */
-extern char response[];
-#endif /* BPOP */
-
 /*
  * PARENT
  */
@@ -163,19 +141,11 @@ int interrupted;          /* SIGINT detected  */
 int broken_pipe;               /* SIGPIPE detected */
 int told_to_quit;              /* SIGQUIT detected */
 
-#ifdef BSD42
-int should_intr;               /* signal handler should interrupt call */
-jmp_buf sigenv;                        /* the environment pointer              */
-#endif
-
 /*
  * prototypes
  */
-int SOprintf (char *, ...);  /* from termsbr.c */
-int sc_width (void);         /* from termsbr.c */
 void fsetup (char *);
 void setup (char *);
-FILE *msh_ready (int, int);
 void readids (int);
 int readid (int);
 void display_info (int);
@@ -185,6 +155,8 @@ void seq_setcur (struct msgs *, int);
 void padios (char *, char *, ...);
 void padvise (char *, char *, ...);
 
+extern m_getfld_state_t gstate;        /* use the gstate in scansbr.c */
+
 
 /*
  * static prototypes
@@ -193,16 +165,7 @@ static void msh (int);
 static int read_map (char *, long);
 static int read_file (long, int);
 
-#ifdef BPOP
-# ifdef NNTP
-static int pop_statmsg (char *);
-# endif /* NNTP */
-static int read_pop (void);
-static int pop_action (char *);
-#endif /* BPOP */
-
 static void m_gMsgs (int);
-FILE *msh_ready (int, int);
 static int check_folder (int);
 static void scanrange (int, int);
 static void scanstring (char *);
@@ -216,10 +179,10 @@ static int initaux_io (struct Cmd *);
 static void fin_io (struct Cmd *, int);
 static void finaux_io (struct Cmd *);
 static void m_init (void);
-static RETSIGTYPE intrser (int);
-static RETSIGTYPE pipeser (int);
-static RETSIGTYPE quitser (int);
-static RETSIGTYPE alrmser (int);
+static void intrser (int);
+static void pipeser (int);
+static void quitser (int);
+static void alrmser (int);
 static int pINI (void);
 static int pQRY (char *, int);
 static int pQRY1 (int);
@@ -240,9 +203,6 @@ main (int argc, char **argv)
     int        id = 0, scansw = 0, vmh1 = 0, vmh2 = 0;
     char *cp, *file = NULL, *folder = NULL;
     char **argp, **arguments, buf[BUFSIZ];
-#ifdef BPOP
-    int        pmsh1 = 0, pmsh2 = 0;
-#endif
 
 #ifdef LOCALE
     setlocale(LC_ALL, "");
@@ -268,10 +228,10 @@ main (int argc, char **argv)
                case HELPSW: 
                    snprintf (buf, sizeof(buf), "%s [switches] file", invo_name);
                    print_help (buf, switches, 1);
-                   done (1);
+                   done (0);
                case VERSIONSW:
                    print_version(invo_name);
-                   done (1);
+                   done (0);
 
                case IDSW: 
                    if (!(cp = *argp++) || *cp == '-')
@@ -324,18 +284,10 @@ main (int argc, char **argv)
                case PREADSW: 
                    if (!(cp = *argp++) || *cp == '-')
                        adios (NULL, "missing argument to %s", argp[-2]);
-#ifdef BPOP
-                   if ((pmsh1 = atoi (cp)) < 1)
-                       adios (NULL, "bad argument %s %s", argp[-2], cp);
-#endif /* BPOP */
                    continue;
                case PWRITSW: 
                    if (!(cp = *argp++) || *cp == '-')
                        adios (NULL, "missing argument to %s", argp[-2]);
-#ifdef BPOP
-                   if ((pmsh2 = atoi (cp)) < 1)
-                       adios (NULL, "bad argument %s %s", argp[-2], cp);
-#endif /* BPOP */
                    continue;
 
                case TCURSW:
@@ -368,9 +320,6 @@ main (int argc, char **argv)
        ioctl (pfd, FIOCLEX, NULL);
 #endif /* FIOCLEX */
 
-#ifdef BSD42
-    should_intr = 0;
-#endif /* BSD42 */
     istat = SIGNAL2 (SIGINT, intrser);
     qstat = SIGNAL2 (SIGQUIT, quitser);
 
@@ -386,20 +335,6 @@ main (int argc, char **argv)
 #endif /* SIGTSTP */
     }
 
-#ifdef BPOP
-    if (pmsh = pmsh1 && pmsh2) {
-       cp = getenv ("MHPOPDEBUG");
-#ifdef NNTP
-       if (pop_set (pmsh1, pmsh2, cp && *cp, myname) == NOTOK)
-#else /* NNTP */
-       if (pop_set (pmsh1, pmsh2, cp && *cp) == NOTOK)
-#endif /* NNTP */
-           padios (NULL, "%s", response);
-       if (folder)
-           file = folder, folder = NULL;
-    }
-#endif /* BPOP */
-
     if (folder)
        fsetup (folder);
     else
@@ -408,6 +343,7 @@ main (int argc, char **argv)
     display_info (id > 0 ? scansw : 0);
 
     msh (id > 0 ? scansw : 0);
+    scan_finished ();
 
     m_reset ();
     
@@ -416,65 +352,43 @@ main (int argc, char **argv)
 }
 
 
-static struct swit mshcmds[] = {
-#define        ADVCMD  0
-    { "advance", -7 },
-#define        ALICMD  1
-    { "ali", 0 },
-#define        EXPLCMD 2
-    { "burst", 0 },
-#define        COMPCMD 3
-    { "comp", 0 },
-#define        DISTCMD 4
-    { "dist", 0 },
-#define        EXITCMD 5
-    { "exit", 0 },
-#define        FOLDCMD 6
-    { "folder", 0 },
-#define        FORWCMD 7
-    { "forw", 0 },
-#define        HELPCMD 8
-    { "help", 0 },
-#define        INCMD   9
-    { "inc", 0 },
-#define        MARKCMD 10
-    { "mark", 0 },
-#define        MAILCMD 11
-    { "mhmail", 0 },
-#define        MHNCMD  12
-    { "mhn", 0 },
-#define        MSGKCMD 13
-    { "msgchk", 0 },
-#define        NEXTCMD 14
-    { "next", 0 },
-#define        PACKCMD 15
-    { "packf", 0 },
-#define        PICKCMD 16
-    { "pick", 0 },
-#define        PREVCMD 17
-    { "prev", 0 },
-#define        QUITCMD 18
-    { "quit", 0 },
-#define        FILECMD 19
-    { "refile", 0 },
-#define        REPLCMD 20
-    { "repl", 0 },
-#define        RMMCMD  21
-    { "rmm", 0 },
-#define        SCANCMD 22
-    { "scan", 0 },
-#define        SENDCMD 23
-    { "send", 0 },
-#define        SHOWCMD 24
-    { "show", 0 },
-#define        SORTCMD 25
-    { "sortm", 0 },
-#define        WHATCMD 26
-    { "whatnow", 0 },
-#define        WHOMCMD 27
-    { "whom", 0 },
-    { NULL, 0 }
-};
+#define MSHCMDS_SWITCHES \
+    X("advance", -7, ADVCMD) \
+    X("ali", 0, ALICMD) \
+    X("burst", 0, EXPLCMD) \
+    X("comp", 0, COMPCMD) \
+    X("dist", 0, DISTCMD) \
+    X("exit", 0, EXITCMD) \
+    X("folder", 0, FOLDCMD) \
+    X("forw", 0, FORWCMD) \
+    X("help", 0, HELPCMD) \
+    X("inc", 0, INCMD) \
+    X("mark", 0, MARKCMD) \
+    X("mhmail", 0, MAILCMD) \
+    X("mhn", 0, MHNCMD) \
+    X("msgchk", 0, MSGKCMD) \
+    X("next", 0, NEXTCMD) \
+    X("packf", 0, PACKCMD) \
+    X("pick", 0, PICKCMD) \
+    X("prev", 0, PREVCMD) \
+    X("quit", 0, QUITCMD) \
+    X("refile", 0, FILECMD) \
+    X("repl", 0, REPLCMD) \
+    X("rmm", 0, RMMCMD) \
+    X("scan", 0, SCANCMD) \
+    X("send", 0, SENDCMD) \
+    X("show", 0, SHOWCMD) \
+    X("sortm", 0, SORTCMD) \
+    X("whatnow", 0, WHATCMD) \
+    X("whom", 0, WHOMCMD) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MSHCMDS);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MSHCMDS, mshcmds);
+#undef X
 
 
 static void
@@ -725,19 +639,6 @@ setup (char *file)
 {
     int i, msgp;
     struct stat st;
-#ifdef BPOP
-    char tmpfil[BUFSIZ];
-#endif
-
-#ifdef BPOP
-    if (pmsh) {
-        char *tfile = m_mktemp2(NULL, invo_name, NULL, &fp);
-        if (tfile == NULL) padios("msh", "unable to create temporary file");
-        unlink(tfile);
-       strncpy(tmpfil, tfile, sizeof(tmpfil));
-    }
-    else
-#endif /* BPOP */
     if ((fp = fopen (file, "r")) == NULL)
        padios (file, "unable to read");
 #ifdef FIOCLEX
@@ -768,41 +669,13 @@ setup (char *file)
     mp->foldpath = getcpy (myname ? myname : file);
     clear_folder_flags (mp);
 
-#ifdef BPOP
-    if (pmsh)
-       set_readonly (mp);
-    else {
-#endif /* BPOP */
        stat (file, &st);
        if (st.st_uid != getuid () || access (file, W_OK) == NOTOK)
            set_readonly (mp);
-#ifdef BPOP
-    }
-#endif /* BPOP */
 
     mp->lowoff = 1;
     mp->hghoff = mp->hghmsg + 1;
 
-#ifdef BPOP
-    if (pmsh) {
-#ifndef        NNTP
-       for (i = mp->lowmsg; i <= mp->hghmsg; i++) {
-           Msgs[i].m_top = i;
-           clear_msg_flags (mp, i);
-           set_exists (mp, i);
-           set_virtual (mp, i);
-       }
-#else /* NNTP */
-       for (i = mp->lowmsg; i <= mp->hghmsg; i++) {
-           if (Msgs[i].m_top)                  /* set in read_pop() */
-               clear_msg_flags (mp, i);
-               set_exists (mp, i);
-               set_virtual (mp, i);
-       }
-#endif /* NNTP */
-    }
-    else
-#endif /* BPOP */
     for (i = mp->lowmsg; i <= mp->hghmsg; i++) {
        clear_msg_flags (mp, i);
        set_exists (mp, i);
@@ -812,7 +685,7 @@ setup (char *file)
     mp->msgattrs[0] = getcpy ("unseen");
     mp->msgattrs[1] = NULL;
 
-    m_unknown (fp);            /* the MAGIC invocation */    
+    scan_detect_mbox_style (fp);               /* the MAGIC invocation */
     if (fmsh) {
        free (fmsh);
        fmsh = NULL;
@@ -827,11 +700,6 @@ read_map (char *file, long size)
     register struct drop *dp, *mp;
     struct drop *rp;
 
-#ifdef BPOP
-    if (pmsh)
-       return read_pop ();
-#endif /* BPOP */
-
     if ((i = map_read (file, size, &rp, 1)) == 0)
        return 0;
 
@@ -859,11 +727,6 @@ read_file (long pos, int msgp)
     register struct drop *dp, *mp;
     struct drop *rp;
 
-#ifdef BPOP
-    if (pmsh)
-       return (msgp - 1);
-#endif /* BPOP */
-
     if ((i = mbx_read (fp, pos, &rp, 1)) <= 0)
        return (msgp - 1);
 
@@ -883,47 +746,6 @@ read_file (long pos, int msgp)
 }
 
 
-#ifdef BPOP
-#ifdef NNTP
-static int pop_base = 0;
-
-static int
-pop_statmsg (char *s)
-{
-    register int i, n;
-
-    n = (i = atoi (s)) - pop_base;      /* s="nnn header-line..." */
-    Msgs[n].m_top = Msgs[n].m_bboard_id = i;
-}
-
-#endif /* NNTP */
-
-static int
-read_pop (void)
-{
-    int        nmsgs, nbytes;
-
-    if (pop_stat (&nmsgs, &nbytes) == NOTOK)
-       padios (NULL, "%s", response);
-
-    m_gMsgs (nmsgs);
-
-#ifdef NNTP    /* this makes read_pop() do some real work... */
-    pop_base = nbytes - 1;     /* nmsgs=last-first+1, nbytes=first */
-    pop_exists (pop_statmsg);
-#endif /* NNTP */
-    return nmsgs;
-}
-
-
-static int
-pop_action (char *s)
-{
-    fprintf (yp, "%s\n", s);
-}
-#endif /* BPOP */
-
-
 static void
 m_gMsgs (int n)
 {
@@ -954,10 +776,7 @@ msh_ready (int msgnum, int full)
     register int msgp;
     int fd;
     char *cp;
-#ifdef BPOP
-    char tmpfil[BUFSIZ];
-    long pos1, pos2;
-#endif
+    NMH_UNUSED (full);
 
     if (yp) {
        fclose (yp);
@@ -989,51 +808,8 @@ msh_ready (int msgnum, int full)
        return yp;
     }
 
-#ifdef BPOP
-    if (pmsh && is_virtual (mp, msgnum)) {
-       if (Msgs[msgnum].m_top == 0)
-           padios (NULL, "msh_ready (%d, %d) botch", msgnum, full);
-       if (!full) {
-            char *tfile = m_mktemp2(NULL, invo_name, NULL, &yp);
-            if (tfile == NULL) padios("msh", "unable to create temporary file");
-            unlink(tfile);
-            strncpy(tmpfil, tfile, sizeof(tmpfil));
-
-           if (pop_top (Msgs[msgnum].m_top, 4, pop_action) == NOTOK)
-               padios (NULL, "%s", response);
-
-           m_eomsbr ((int (*)()) 0);   /* XXX */
-           msg_style = MS_DEFAULT;     /*  .. */
-           fseek (yp, 0L, SEEK_SET);
-           return yp;
-       }
-
-       fseek (fp, 0L, SEEK_END);
-       fwrite (mmdlm1, 1, strlen (mmdlm1), fp);
-       if (fflush (fp))
-           padios ("temporary file", "write error on");
-       fseek (fp, 0L, SEEK_END);
-       pos1 = ftell (fp);
-
-       yp = fp;
-       if (pop_retr (Msgs[msgnum].m_top, pop_action) == NOTOK)
-           padios (NULL, "%s", response);
-       yp = NULL;
-
-       fseek (fp, 0L, SEEK_END);
-       pos2 = ftell (fp);
-       fwrite (mmdlm2, 1, strlen (mmdlm2), fp);
-       if (fflush (fp))
-           padios ("temporary file", "write error on");
-
-       Msgs[msgnum].m_start = pos1;
-       Msgs[msgnum].m_stop = pos2;
-
-       unset_virtual (mp, msgnum);
-    }
-#endif /* BPOP */
-
-    m_eomsbr ((int (*)()) 0);  /* XXX */
+    scan_reset_m_getfld_state ();
+    scan_eom_action ((int (*)()) 0);   /* XXX */
     fseek (fp, Msgs[msgnum].m_start, SEEK_SET);
     return fp;
 }
@@ -1045,11 +821,6 @@ check_folder (int scansw)
     int seqnum, i, low, hgh, msgp;
     struct stat st;
 
-#ifdef BPOP
-    if (pmsh)
-       return 0;
-#endif /* BPOP */
-
     if (fmsh) {
        if (stat (mp->foldpath, &st) == NOTOK)
            padios (mp->foldpath, "unable to stat");
@@ -1202,32 +973,21 @@ readid (int msgnum)
     int i, state;
     char *bp, buf[BUFSIZ], name[NAMESZ];
     register FILE *zp;
-#ifdef BPOP
-    int        arg1, arg2, arg3;
-#endif
 
     if (Msgs[msgnum].m_bboard_id)
        return Msgs[msgnum].m_bboard_id;
-#ifdef BPOP
-    if (pmsh) {
-       if (Msgs[msgnum].m_top == 0)
-           padios (NULL, "readid (%d) botch", msgnum);
-       if (pop_list (Msgs[msgnum].m_top, (int *) 0, &arg1, &arg2, &arg3) == OK
-               && arg3 > 0)
-           return (Msgs[msgnum].m_bboard_id = arg3);
-    }
-#endif /* BPOP */
 
     zp = msh_ready (msgnum, 0);
-    for (state = FLD;;)
-       switch (state = m_getfld (state, name, buf, sizeof(buf), zp)) {
+    for (;;) {
+       int bufsz = sizeof buf;
+       switch (state = m_getfld (&gstate, name, buf, &bufsz, zp)) {
            case FLD: 
-           case FLDEOF: 
            case FLDPLUS: 
                if (!mh_strcasecmp (name, BBoard_ID)) {
                    bp = getcpy (buf);
                    while (state == FLDPLUS) {
-                       state = m_getfld (state, name, buf, sizeof(buf), zp);
+                       bufsz = sizeof buf;
+                       state = m_getfld (&gstate, name, buf, &bufsz, zp);
                        bp = add (buf, bp);
                    }
                    i = atoi (bp);
@@ -1237,14 +997,16 @@ readid (int msgnum)
                    else
                        continue;
                }
-               while (state == FLDPLUS)
-                   state = m_getfld (state, name, buf, sizeof(buf), zp);
-               if (state != FLDEOF)
-                   continue;
+               while (state == FLDPLUS) {
+                   bufsz = sizeof buf;
+                   state = m_getfld (&gstate, name, buf, &bufsz, zp);
+               }
+               continue;
 
            default: 
                return 0;
        }
+    }
 }
 
 
@@ -1257,11 +1019,9 @@ display_info (int scansw)
     if (sp == NULL) {
        if ((sd = dup (fileno (stdout))) == NOTOK)
            padios ("standard output", "unable to dup");
-#ifndef BSD42                  /* XXX */
 #ifdef FIOCLEX
        ioctl (sd, FIOCLEX, NULL);
 #endif /* FIOCLEX */
-#endif /* not BSD42 */
        if ((sp = fdopen (sd, "w")) == NULL)
            padios ("standard output", "unable to fdopen");
     }
@@ -1419,33 +1179,11 @@ getargs (char *prompt, struct swit *sw, struct Cmd *cmdp)
     told_to_quit = 0;
     for (;;) {
        interrupted = 0;
-#ifdef BSD42
-       switch (setjmp (sigenv)) {
-           case OK:
-               should_intr = 1;
-               break;
-
-           default:
-               should_intr = 0;
-               if (interrupted && !told_to_quit) {
-                   putchar ('\n');
-                   continue;
-               }
-               if (ppid > 0)
-#ifdef SIGEMT
-                   kill (ppid, SIGEMT);
-#else
-                   kill (ppid, SIGTERM);
-#endif
-               return EOF;
-       }
-#endif /* BSD42 */
        if (interactive) {
            printf ("%s", prompt);
            fflush (stdout);
        }
        for (cp = buffer; (i = getchar ()) != '\n';) {
-#ifndef BSD42
            if (interrupted && !told_to_quit) {
                buffer[0] = '\0';
                putchar ('\n');
@@ -1460,10 +1198,6 @@ getargs (char *prompt, struct swit *sw, struct Cmd *cmdp)
 #endif
                return EOF;
            }
-#else /* BSD42 */
-           if (i == EOF)
-               longjmp (sigenv, DONE);
-#endif /* BSD42 */
            if (cp < &buffer[sizeof buffer - 2])
                *cp++ = i;
        }
@@ -1491,9 +1225,6 @@ getargs (char *prompt, struct swit *sw, struct Cmd *cmdp)
                        cmdp->args[0]);
                continue;
            default: 
-#ifdef BSD42
-               should_intr = 0;
-#endif /* BSD42 */
                return i;
        }
     }
@@ -1543,8 +1274,7 @@ static int
 parse (char *buffer, struct Cmd *cmdp)
 {
     int argp = 0;
-    unsigned char c, *cp;
-    char *pp;
+    char c, *cp, *pp;
 
     cmdp->line[0] = 0;
     pp = cmdp->args[argp++] = cmdp->line;
@@ -1553,7 +1283,7 @@ parse (char *buffer, struct Cmd *cmdp)
     cmdp->stream = NULL;
 
     for (cp = buffer; (c = *cp); cp++) {
-       if (!isspace (c))
+       if (!isspace ((unsigned char) c))
            break;
     }
     if (c == '\0') {
@@ -1563,8 +1293,8 @@ parse (char *buffer, struct Cmd *cmdp)
     }
 
     while ((c = *cp++)) {
-       if (isspace (c)) {
-           while (isspace (c))
+       if (isspace ((unsigned char) c)) {
+           while (isspace ((unsigned char) c))
                c = *cp++;
            if (c == 0)
                break;
@@ -1619,7 +1349,7 @@ parse (char *buffer, struct Cmd *cmdp)
                }
                cmdp->redirect = pp + 1;/* sigh */
                for (; (c = *cp); cp++)
-                   if (!isspace (c))
+                   if (!isspace ((unsigned char) c))
                        break;
                if (c == 0) {
                    padvise (NULL, cmdp->direction != PIPIO
@@ -1630,7 +1360,7 @@ parse (char *buffer, struct Cmd *cmdp)
                strcpy (cmdp->redirect, cp);
                if (cmdp->direction != PIPIO) {
                    for (; *cp; cp++)
-                       if (isspace (*cp)) {
+                       if (isspace ((unsigned char) *cp)) {
                            padvise (NULL, "bad name for redirect");
                            return NOTOK;
                        }
@@ -1798,12 +1528,6 @@ m_reset (void)
     write_ids ();
     folder_free (mp);  /* free folder/message structure */
     myname = NULL;
-#ifdef BPOP
-    if (pmsh) {
-       pop_done ();
-       pmsh = 0;
-    }
-#endif /* BPOP */
 }
 
 
@@ -1827,62 +1551,39 @@ seq_setcur (struct msgs *mp, int msgnum)
 
 
 
-static RETSIGTYPE
+static void
 intrser (int i)
 {
-#ifndef RELIABLE_SIGNALS
-    SIGNAL (SIGINT, intrser);
-#endif
-
+    NMH_UNUSED (i);
     discard (stdout);
     interrupted++;
-
-#ifdef BSD42
-    if (should_intr)
-       longjmp (sigenv, NOTOK);
-#endif
 }
 
 
-static RETSIGTYPE
+static void
 pipeser (int i)
 {
-#ifndef RELIABLE_SIGNALS
-    SIGNAL (SIGPIPE, pipeser);
-#endif
-
+    NMH_UNUSED (i);
     if (broken_pipe++ == 0)
        fprintf (stderr, "broken pipe\n");
     told_to_quit++;
     interrupted++;
-
-#ifdef BSD42
-    if (should_intr)
-       longjmp (sigenv, NOTOK);
-#endif
 }
 
 
-static RETSIGTYPE
+static void
 quitser (int i)
 {
-#ifndef RELIABLE_SIGNALS
-    SIGNAL (SIGQUIT, quitser);
-#endif
-
+    NMH_UNUSED (i);
     told_to_quit++;
     interrupted++;
-
-#ifdef BSD42
-    if (should_intr)
-       longjmp (sigenv, NOTOK);
-#endif
 }
 
 
-static RETSIGTYPE
+static void
 alrmser (int i)
 {
+    NMH_UNUSED (i);
     longjmp (peerenv, DONE);
 }
 
@@ -1891,7 +1592,7 @@ static int
 pINI (void)
 {
     int i, vrsn;
-    unsigned char *bp;
+    char *bp;
     struct record rcs, *rc;
 
     rc = &rcs;
@@ -1900,7 +1601,7 @@ pINI (void)
     switch (peer2rc (rc)) {
        case RC_INI: 
            bp = rc->rc_data;
-           while (isspace (*bp))
+           while (isspace ((unsigned char) *bp))
                bp++;
            if (sscanf (bp, "%d", &vrsn) != 1) {
        bad_init: ;
@@ -1912,9 +1613,9 @@ pINI (void)
                done (1);
            }
 
-           while (*bp && !isspace (*bp))
+           while (*bp && !isspace ((unsigned char) *bp))
                bp++;
-           while (isspace (*bp))
+           while (isspace ((unsigned char) *bp))
                bp++;
            if (sscanf (bp, "%d", &numwins) != 1 || numwins <= 0)
                goto bad_init;
@@ -1922,9 +1623,9 @@ pINI (void)
                numwins = NWIN;
 
            for (i = 1; i <= numwins; i++) {
-               while (*bp && !isspace (*bp))
+               while (*bp && !isspace ((unsigned char) *bp))
                    bp++;
-               while (isspace (*bp))
+               while (isspace ((unsigned char) *bp))
                    bp++;
                if (sscanf (bp, "%d", &windows[i]) != 1 || windows[i] <= 0)
                    goto bad_init;
@@ -1947,6 +1648,7 @@ pINI (void)
 static int
 pQRY (char *str, int scansw)
 {
+    NMH_UNUSED (str);
     if (pQRY1 (scansw) == NOTOK || pQRY2 () == NOTOK)
        return NOTOK;