X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fwhom.c;h=ef0b684d2a011817a34dd01cc7c86ba3b26190a6;hb=refs%2Fheads%2Fmaster;hp=e02994f139ebdb4151bb780afd7423b88ff5377c;hpb=ac3066d2d563ce3b9de66195f6818eecb594fec2;p=mmh diff --git a/uip/whom.c b/uip/whom.c index e02994f..ef0b684 100644 --- a/uip/whom.c +++ b/uip/whom.c @@ -37,6 +37,7 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; #define NFILES 32 @@ -75,11 +76,15 @@ static void printone(struct mailname *); int main(int argc, char **argv) { - int filep=0, naddrs=0, n; + int naddrs=0, n; char *cp; char buf[BUFSIZ], **argp; - char **arguments, *files[NFILES]; + char **arguments; + char *folder = NULL; FILE *in; + struct msgs_array msgs = {0}; + struct msgs_array files = {0}; + size_t filep; setlocale(LC_ALL, ""); invo_name = mhbasename(argv[0]); @@ -139,22 +144,27 @@ main(int argc, char **argv) continue; } } - if (filep > NFILES) { - adios(EX_USAGE, NULL, "too many files (more than %d)", - NFILES); + if (*cp == '+' || *cp == '@') { + if (folder) { + adios(EX_USAGE, NULL, "only one folder at a time!"); + } else { + folder = mh_xstrdup(expandfol(cp)); + } } else { - files[filep++] = cp; + app_msgarg(&msgs, cp); } } - files[filep] = NULL; - if (!filep) { + if (!msgs.size) { adios(EX_USAGE, NULL, "usage: %s [switches] file ...", invo_name); } if (!toccsw && !dccsw && !bccsw) { adios(EX_USAGE, NULL, "use at least one of: -tocc -dcc -bcc"); } - for (filep=0; files[filep]; filep++) { - process(files[filep]); + if (parse_msgs(&msgs, folder, &files) < 0) { + exit(EX_IOERR); + } + for (filep = 0; filep < files.size; filep++) { + process(files.msgs[filep]); } cmd = add("ali -list", NULL); @@ -216,7 +226,6 @@ process(char *file) for (compnum=1, state=FLD2;; compnum++) { switch (state = m_getfld2(state, &f, in)) { case LENERR2: - advise(NULL, "field %d contains a to long line", f.name); state = FLD2; /* FALL */ case FLD2: @@ -228,6 +237,9 @@ process(char *file) break; case FMTERR2: + advise(NULL, "message format error in component #%d", compnum); + continue; + case IOERR2: adios(EX_DATAERR, NULL, "message format error in component #%d", compnum);