X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fscan.c;h=69c2da97a13b4eeb9ff4176f6f34396ba4198b76;hp=80addfccbed6dceeb9effd6753f0d426a95f56c6;hb=5b792c4424571f05bc2008e3109797d18d7d00d1;hpb=3d78b9c80a95f4e7885ed607018f9b1b9be559b4 diff --git a/uip/scan.c b/uip/scan.c index 80addfc..69c2da9 100644 --- a/uip/scan.c +++ b/uip/scan.c @@ -88,73 +88,76 @@ main(int argc, char **argv) while ((cp = *argp++)) { if (*cp == '-') { switch (smatch(++cp, switches)) { - case AMBIGSW: - ambigsw(cp, switches); - done(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); - case VERSIONSW: - print_version(invo_name); - done(1); - - case CLRSW: - clearflag++; - continue; - case NCLRSW: - clearflag = 0; - continue; - - case FORMSW: - if (!(form = *argp++) || *form == '-') - adios(NULL, "missing argument to %s", argp[-2]); - format = NULL; - continue; - case FMTSW: - if (!(format = *argp++) || - *format == '-') - adios(NULL, "missing argument to %s", argp[-2]); - form = NULL; - continue; - - case HEADSW: - hdrflag++; - continue; - case NHEADSW: - hdrflag = 0; - continue; - - case WIDTHSW: - if (!(cp = *argp++) || *cp == '-') - adios(NULL, "missing argument to %s", argp[-2]); - width = atoi(cp); - continue; - case REVSW: - revflag++; - continue; - case NREVSW: - revflag = 0; - continue; - - case FILESW: - if (!(cp = *argp++) || (cp[0] == '-' && cp[1])) - adios(NULL, "missing argument to %s", argp[-2]); - if (strcmp(file = cp, "-")) - file = path(cp, TFILE); - continue; + case AMBIGSW: + ambigsw(cp, switches); + done(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); + case VERSIONSW: + print_version(invo_name); + done(1); + + case CLRSW: + clearflag++; + continue; + case NCLRSW: + clearflag = 0; + continue; + + case FORMSW: + if (!(form = *argp++) || *form == '-') + adios(NULL, "missing argument to %s", + argp[-2]); + format = NULL; + continue; + case FMTSW: + if (!(format = *argp++) || *format == '-') + adios(NULL, "missing argument to %s", + argp[-2]); + form = NULL; + continue; + + case HEADSW: + hdrflag++; + continue; + case NHEADSW: + hdrflag = 0; + continue; + + case WIDTHSW: + if (!(cp = *argp++) || *cp == '-') + adios(NULL, "missing argument to %s", + argp[-2]); + width = atoi(cp); + continue; + case REVSW: + revflag++; + continue; + case NREVSW: + revflag = 0; + continue; + + case FILESW: + if (!(cp = *argp++) || (cp[0] == '-' && cp[1])) + adios(NULL, "missing argument to %s", + argp[-2]); + if (strcmp(file = cp, "-")!=0) + file = getcpy(expanddir(cp)); + continue; } } if (*cp == '+' || *cp == '@') { if (folder) adios(NULL, "only one folder at a time!"); else - folder = pluspath(cp); + folder = getcpy(expandfol(cp)); } else - app_msgarg(&msgs, cp); + app_msgarg(&msgs, cp); } /* @@ -175,9 +178,8 @@ main(int argc, char **argv) if (strcmp(file, "-") == 0) { in = stdin; file = "stdin"; - } else { - if ((in = fopen(file, "r")) == NULL) - adios(file, "unable to open"); + } else if (!(in = fopen(file, "r"))) { + adios(file, "unable to open"); } #ifndef JLR @@ -204,8 +206,8 @@ main(int argc, char **argv) if (!msgs.size) app_msgarg(&msgs, "all"); if (!folder) - folder = getfolder(FCUR); - maildir = m_maildir(folder); + folder = getcurfol(); + maildir = toabsdir(folder); if (chdir(maildir) == NOTOK) adios(maildir, "unable to change directory to"); @@ -224,7 +226,7 @@ main(int argc, char **argv) done(1); seq_setprev(mp); /* set the Previous-Sequence */ - context_replace(pfolder, folder); /* update current folder */ + context_replace(curfolder, folder); /* update current folder */ seq_save(mp); /* synchronize message sequences */ context_save(); /* save the context file */ @@ -290,23 +292,21 @@ main(int argc, char **argv) switch (state = scan(in, msgnum, 0, nfs, width, msgnum == mp->curmsg, unseen, folder, 0L, 1)) { - case SCNMSG: - case SCNENC: - case SCNERR: - break; + case SCNMSG: + case SCNENC: + case SCNERR: + break; - default: - adios(NULL, "scan() botch(%d)", state); + default: + adios(NULL, "scan() botch(%d)", state); - case SCNEOF: + case SCNEOF: #if 0 - printf("%*d empty\n", DMAXFOLDER, - msgnum); + printf("%*d empty\n", DMAXFOLDER, msgnum); #else - advise(NULL, "message %d: empty", - msgnum); + advise(NULL, "message %d: empty", msgnum); #endif - break; + break; } hdrflag = 0; fclose(in);