X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/de4636bb664106d9932ae7acb517e471b848f1f3..be6c3984:/uip/msh.c?ds=sidebyside diff --git a/uip/msh.c b/uip/msh.c index 6069cac4..e91924c3 100644 --- a/uip/msh.c +++ b/uip/msh.c @@ -26,7 +26,6 @@ #include #include -#include #include #include @@ -155,6 +154,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 @@ -202,13 +203,7 @@ main (int argc, char **argv) char *cp, *file = NULL, *folder = NULL; char **argp, **arguments, buf[BUFSIZ]; -#ifdef LOCALE - setlocale(LC_ALL, ""); -#endif - invo_name = r1bindex (argv[0], '/'); - - /* read user profile/context */ - context_read(); + if (nmh_init(argv[0], 1)) { return 1; } mts_init (invo_name); arguments = getarguments (invo_name, argc,argv, 1); @@ -341,6 +336,7 @@ main (int argc, char **argv) display_info (id > 0 ? scansw : 0); msh (id > 0 ? scansw : 0); + scan_finished (); m_reset (); @@ -601,7 +597,7 @@ fsetup (char *folder) padios (maildir, "unable to change directory to"); /* read folder and create message structure */ - if (!(mp = folder_read (folder))) + if (!(mp = folder_read (folder, 0))) padios (NULL, "unable to read folder %s", folder); /* check for empty folder */ @@ -679,10 +675,9 @@ setup (char *file) } m_init (); - mp->msgattrs[0] = getcpy ("unseen"); - mp->msgattrs[1] = NULL; + svector_push_back (mp->msgattrs, getcpy ("unseen")); - m_unknown (fp); /* the MAGIC invocation */ + scan_detect_mbox_style (fp); /* the MAGIC invocation */ if (fmsh) { free (fmsh); fmsh = NULL; @@ -805,7 +800,8 @@ msh_ready (int msgnum, int full) return yp; } - 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; } @@ -827,7 +823,7 @@ check_folder (int scansw) low = mp->hghmsg + 1; folder_free (mp); /* free folder/message structure */ - if (!(mp = folder_read (fmsh))) + if (!(mp = folder_read (fmsh, 0))) padios (NULL, "unable to re-read folder %s", fmsh); hgh = mp->hghmsg; @@ -974,15 +970,16 @@ readid (int msgnum) return Msgs[msgnum].m_bboard_id; 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)) { + if (!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); @@ -992,14 +989,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; } + } } @@ -1090,7 +1089,7 @@ quit (void) if (vmh) ttyNaux (NULLCMD, "FAST"); cp = NULL; - if ((dp = lkfopen (mp->foldpath, "r")) == NULL) { + if ((dp = lkfopendata (mp->foldpath, "r")) == NULL) { advise (mp->foldpath, "unable to lock"); if (vmh) { ttyR (NULLCMD); @@ -1115,7 +1114,7 @@ quit (void) close (i); else advise (mp->foldpath, "error zero'ing"); - unlink (map_name (mp->foldpath));/* XXX */ + (void) m_unlink (map_name (mp->foldpath));/* XXX */ } goto release; } @@ -1132,8 +1131,8 @@ quit (void) for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++) if (does_exist(mp, msgnum) && pack (tmpfil, md, msgnum) == NOTOK) { mbx_close (tmpfil, md); - unlink (tmpfil); - unlink (map_name (tmpfil)); + (void) m_unlink (tmpfil); + (void) m_unlink (map_name (tmpfil)); goto release; } mbx_close (tmpfil, md); @@ -1146,15 +1145,15 @@ quit (void) if (rename (map1, map2) == NOTOK) { admonish (map2, "unable to rename %s to", map1); - unlink (map1); - unlink (map2); + (void) m_unlink (map1); + (void) m_unlink (map2); } } release: ; if (cp) free (cp); - lkfclose (dp, mp->foldpath); + lkfclosedata (dp, mp->foldpath); if (vmh) { ttyR (NULLCMD); pFIN (); @@ -1267,8 +1266,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; @@ -1277,7 +1275,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') { @@ -1287,8 +1285,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; @@ -1343,7 +1341,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 @@ -1354,7 +1352,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; } @@ -1586,7 +1584,7 @@ static int pINI (void) { int i, vrsn; - unsigned char *bp; + char *bp; struct record rcs, *rc; rc = &rcs; @@ -1595,7 +1593,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: ; @@ -1607,9 +1605,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; @@ -1617,9 +1615,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;