X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fscan.c;h=f53cf1dd1209369b7d373dfe5b0d574459efc923;hp=1b58eb5b563c692c020e6c1df50a7b2491970637;hb=2abb9a7cfb0930e27062088734d306e7d78e4cc2;hpb=e57b17343dcb3ff373ef4dd089fbe778f0c7c270 diff --git a/uip/scan.c b/uip/scan.c index 1b58eb5..f53cf1d 100644 --- a/uip/scan.c +++ b/uip/scan.c @@ -12,6 +12,8 @@ #include #include #include +#include +#include static struct swit switches[] = { #define FORMSW 0 @@ -19,9 +21,9 @@ static struct swit switches[] = { #define WIDTHSW 1 { "width columns", 0 }, #define FILESW 2 - { "file file", 4 }, + { "file file", 0 }, #define VERSIONSW 3 - { "version", 0 }, + { "Version", 0 }, #define HELPSW 4 { "help", 0 }, { NULL, 0 } @@ -31,20 +33,17 @@ static struct swit switches[] = { int main(int argc, char **argv) { - int ontty; int width = 0; int i, state, msgnum; int seqnum[NUMATTRS], unseen, num_unseen_seq = 0; char *cp, *maildir, *file = NULL, *folder = NULL; char *form = NULL, buf[BUFSIZ]; - char **argp, *nfs, **arguments; + char **argp, *fmtstr, **arguments; struct msgs_array msgs = { 0, 0, NULL }; struct msgs *mp; FILE *in; -#ifdef LOCALE setlocale(LC_ALL, ""); -#endif invo_name = mhbasename(argv[0]); /* read user profile/context */ @@ -61,17 +60,17 @@ main(int argc, char **argv) switch (smatch(++cp, switches)) { case AMBIGSW: ambigsw(cp, switches); - done(1); + exit(1); case UNKWNSW: adios(NULL, "-%s unknown", cp); case HELPSW: snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name); print_help(buf, switches, 1); - done(1); + exit(0); case VERSIONSW: print_version(invo_name); - done(1); + exit(0); case FORMSW: if (!(form = *argp++) || *form == '-') @@ -107,7 +106,7 @@ main(int argc, char **argv) /* ** Get new format string. Must be before chdir(). */ - nfs = new_fs(form, FORMAT); + fmtstr = new_fs(form, FORMAT); /* ** We are scanning a maildrop file @@ -126,15 +125,14 @@ main(int argc, char **argv) adios(file, "unable to open"); } - m_unknown(in); + thisisanmbox(in); for (msgnum = 1; ; ++msgnum) { - state = scan(in, msgnum, -1, nfs, width, 0, 0, - NULL, 0L, 1); - if (state != SCNMSG && state != SCNENC) + state = scan(in, msgnum, SCN_MBOX, fmtstr, width, 0, 0); + if (state != SCNMSG) break; } fclose(in); - done(0); + exit(0); } /* @@ -161,7 +159,7 @@ main(int argc, char **argv) /* parse all the message ranges/sequences and set SELECTED */ for (msgnum = 0; msgnum < msgs.size; msgnum++) if (!m_convert(mp, msgs.msgs[msgnum])) - done(1); + exit(1); seq_setprev(mp); /* set the Previous-Sequence */ context_replace(curfolder, folder); /* update current folder */ @@ -188,8 +186,6 @@ main(int argc, char **argv) } } - ontty = isatty(fileno(stdout)); - for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) { if (is_selected(mp, msgnum)) { if ((in = fopen(cp = m_name(msgnum), "r")) == NULL) { @@ -209,11 +205,9 @@ main(int argc, char **argv) } } - switch (state = scan(in, msgnum, 0, nfs, width, - msgnum == mp->curmsg, unseen, - folder, 0L, 1)) { + switch (state = scan(in, msgnum, SCN_FOLD, fmtstr, + width, msgnum==mp->curmsg, unseen)) { case SCNMSG: - case SCNENC: case SCNERR: break; @@ -225,13 +219,10 @@ main(int argc, char **argv) break; } fclose(in); - if (ontty) - fflush(stdout); } } folder_free(mp); /* free folder/message structure */ - done(0); - return 1; + return 0; }