+ /* check if "file" is really a Maildir folder */
+ struct stat st;
+ if (stat (file, &st) == NOTOK)
+ adios (file, "unable to stat");
+ if (!(st.st_mode & S_IFDIR)) {
+ if ((in = fopen (file, "r")) == NULL)
+ adios (file, "unable to open");
+ } else {
+ /*
+ * We are scanning a Maildir folder
+ */
+ struct Maildir_entry *Maildir;
+ int num_maildir_entries;
+ int msgnum = 0;
+ char *fnp;
+ FILE *in;
+ int i;
+
+ maildir_read_and_sort(file, &Maildir, &num_maildir_entries);
+ for (i = 0; i < num_maildir_entries; i++) {
+ msgnum++;
+ fnp = Maildir[i].filename;
+
+ if ((in = fopen (fnp, "r")) == NULL) {
+ admonish (fnp, "unable to open message");
+ continue;
+ }
+
+ switch (state = scan (in, msgnum, 0, nfs, width,
+ 0, 0, hdrflag ? file : NULL,
+ 0L, 1, &scanl)) {
+ case SCNMSG:
+ case SCNERR:
+ break;
+
+ default:
+ die("scan() botch (%d)", state);
+
+ case SCNEOF:
+ inform("message %d: empty", msgnum);
+ break;
+ }
+ if (scanl)
+ charstring_clear(scanl);
+ scan_finished ();
+ hdrflag = false;
+ fclose (in);
+ if (ontty)
+ fflush (stdout);
+ }
+ done (0);
+ }