{ "width columns", 0 },
#define THREADSW 24
{ "thread", 0 },
-#define VERSIONSW 25
+#define FILESW 25
+ { "file file", 0 },
+#define VERSIONSW 26
{ "Version", 0 },
-#define HELPSW 26
+#define HELPSW 27
{ "help", 0 },
{ NULL, 0 }
};
static int pmatches(FILE *, int);
static struct nexus * createonethread(char *);
static struct nexus * createpickthread(char *);
+static void scan_mbox(char *, char *, int);
static int listsw = -1;
char *form = NULL;
char *fmtstr;
FILE *fp;
+ char *file = NULL;
if (atexit(putzero_done) != 0) {
adios(EX_OSERR, NULL, "atexit failed");
}
width = atoi(cp);
continue;
+ case FILESW:
+ if (!(cp = *argp++) || (cp[0] == '-' && cp[1])) {
+ adios(EX_USAGE, NULL, "missing argument to %s",
+ argp[-2]);
+ }
+ if (strcmp(file = cp, "-")!=0) {
+ file = mh_xstrdup(expanddir(cp));
+ }
+ continue;
}
}
if (*cp == '+' || *cp == '@') {
fmtstr = new_fs(form, "pick.default");
+ if (file) {
+ if (folder) {
+ adios(EX_USAGE, NULL, "\"+folder\" not allowed with -file");
+ }
+ if (msgs.size) {
+ adios(EX_USAGE, NULL, "\"msgs\" not allowed with -file");
+ }
+ if (vecp) {
+ adios(EX_USAGE, NULL, "section arguments not allowed with -file");
+ }
+
+ scan_mbox(file, fmtstr, width);
+ exit(EX_OK);
+ }
+
/*
** If we didn't specify which messages to search,
** then search the whole folder.
return 0;
}
+static void
+scan_mbox(char *file, char *fmtstr, int width)
+{
+ FILE *in;
+ int msgnum;
+ int state;
+
+ if (strcmp(file, "-") == 0) {
+ in = stdin;
+ file = "stdin";
+ } else if (!(in = fopen(file, "r"))) {
+ adios(EX_IOERR, file, "unable to open");
+ }
+
+ for (msgnum = 1; ;msgnum++) {
+ state = scan(in, msgnum, SCN_MBOX, fmtstr, width, 0, 0);
+ if (state != SCNMSG) {
+ break;
+ }
+ }
+ fclose(in);
+}
+
void
putzero_done()