9 date 94.04.21.18.20.50; author jromine; state Exp;
14 date 92.12.15.00.20.22; author jromine; state Exp;
19 date 92.11.04.01.01.43; author jromine; state Exp;
24 date 92.02.09.07.13.34; author jromine; state Exp;
29 date 92.02.05.22.50.17; author jromine; state Exp;
34 date 92.02.05.07.26.30; author jromine; state Exp;
39 date 92.02.03.22.45.20; author jromine; state Exp;
44 date 92.01.31.22.26.24; author jromine; state Exp;
49 date 92.01.23.23.06.45; author jromine; state Exp;
54 date 90.04.05.14.59.58; author sources; state Exp;
59 date 90.04.02.14.43.19; author sources; state Exp;
64 date 90.03.12.11.07.47; author sources; state Exp;
69 date 90.02.21.15.36.00; author sources; state Exp;
74 date 90.02.09.10.34.35; author sources; state Exp;
79 date 90.02.09.10.17.36; author sources; state Exp;
84 date 90.02.01.14.28.48; author sources; state Exp;
89 date 90.02.01.14.19.44; author sources; state Exp;
100 @update for scansbr.c -- overload {folder}.c_flags with hdrflg
103 @/* scan.c - display a one-line "scan" listing */
105 static char ident[] = "@@(#)$Id: scan.c,v 1.16 1992/12/15 00:20:22 jromine Exp jromine $";
109 #include "../h/formatsbr.h"
110 #include "../h/scansbr.h"
111 #include "../zotnet/tws.h"
120 static struct swit switches[] = {
127 "form formatfile", 0,
156 #ifdef LBL /* global for sbr/formatsbr.c - yech! */
157 extern struct msgs *fmt_current_folder;
161 void clear_screen ();
173 revflag = 0, /* used to be #ifdef BERK */
176 bits, /* should match mp->msgstats[] type */
197 setlocale(LC_ALL, "");
199 invo_name = r1bindex (argv[0], '/');
200 mts_init (invo_name);
201 if ((cp = m_find (invo_name)) != NULL) {
202 ap = brkstring (cp = getcpy (cp), " ", "\n");
203 ap = copyip (ap, arguments);
207 (void) copyip (argv + 1, ap);
212 while (cp = *argp++) {
214 switch (smatch (++cp, switches)) {
216 ambigsw (cp, switches);
219 adios (NULLCP, "-%s unknown", cp);
221 (void) sprintf (buf, "%s [+folder] [msgs] [switches]",
223 help (buf, switches);
234 if (!(form = *argp++) || *form == '-')
235 adios (NULLCP, "missing argument to %s", argp[-2]);
239 if (!(format = *argp++) || *format == '-')
240 adios (NULLCP, "missing argument to %s", argp[-2]);
252 if (!(cp = *argp++) || *cp == '-')
253 adios (NULLCP, "missing argument to %s", argp[-2]);
264 if (!(cp = *argp++) || (cp[0] == '-' && cp[1]))
265 adios (NULLCP, "missing argument to %s", argp[-2]);
266 if (strcmp (file = cp, "-"))
267 file = path (cp, TFILE);
270 if (*cp == '+' || *cp == '@@') {
272 adios (NULLCP, "only one folder at a time!");
274 folder = path (cp + 1, *cp == '+' ? TFOLDER : TSUBCWF);
281 if (!m_find ("path"))
282 free (path ("./", TFOLDER));
283 nfs = new_fs (form, format, FORMAT); /* must be before chdir() */
287 adios (NULLCP, "\"msgs\" not allowed with -file");
289 adios (NULLCP, "\"+folder\" not allowed with -file");
290 /* we've been asked to scan a maildrop file */
291 if (strcmp (file, "-")) {
292 in = fopen (file, "r");
294 adios (file, "unable to open");
303 (void) time (&clock);
304 printf ("Folder %-32s%s\n\n", file,
305 dasctime (dlocaltime (&clock), TW_NULL));
309 for (msgnum = 1; ; ++msgnum) {
310 state = scan (in, msgnum, -1, nfs, width, 0, 0,
311 hdrflag, file, 0L, 1);
312 if (state != SCNMSG && state != SCNENC)
320 msgs[msgp++] = "all";
322 folder = m_getfolder ();
323 maildir = m_maildir (folder);
325 if (chdir (maildir) == NOTOK)
326 adios (maildir, "unable to change directory to");
327 if (!(mp = m_gmsg (folder)))
328 adios (NULLCP, "unable to read folder %s", folder);
329 if (mp -> hghmsg == 0)
330 adios (NULLCP, "no messages in %s", folder);
332 for (msgnum = 0; msgnum < msgp; msgnum++)
333 if (!m_convert (mp, msgs[msgnum]))
337 m_replace (pfolder, folder);
341 if (cp = m_find(usequence)) { /* set bits for each unseen sequence */
345 for (ap = brkstring(dp = getcpy(cp), " ", "\n"); ap && *ap; ap++)
346 bits |= m_seqflag(mp, *ap);
352 ontty = isatty (fileno (stdout));
356 fmt_current_folder = mp;
361 for (msgnum = revflag ? mp -> hghsel : mp -> lowsel;
362 (revflag ? msgnum >= mp -> lowsel : msgnum <= mp -> hghsel);
363 msgnum += revflag ? (-1) : 1)
364 if (mp -> msgstats[msgnum] & SELECTED) {
365 if ((in = fopen (cp = m_name (msgnum), "r")) == NULL) {
369 admonish (cp, "unable to open message");
372 printf ("%*d unreadable\n", DMAXFOLDER, msgnum);
379 (void) time (&clock);
380 printf ("Folder %-32s%s\n\n", folder,
381 dasctime (dlocaltime (&clock), TW_NULL));
384 switch (state = scan (in, msgnum, 0, nfs, width,
385 msgnum == mp -> curmsg,
386 mp -> msgstats[msgnum] & bits,
387 hdrflag, folder, 0L, 1)) {
394 adios (NULLCP, "scan() botch (%d)", state);
398 printf ("%*d empty\n", DMAXFOLDER, msgnum);
400 advise (NULLCP, "message %d: empty", msgnum);
407 (void) fflush (stdout);
410 m_sync (mp); /* because formatsbr might have made changes */
430 static char ident[] = "@@(#)$Id: scan.c,v 1.15 1992/11/04 01:01:43 jromine Exp jromine $";
433 hdrflag ? file : (char *)0, 0L, 1);
436 hdrflag ? folder : (char *)0, 0L, 1)) {
447 static char ident[] = "@@(#)$Id: scan.c,v 1.14 1992/02/09 07:13:34 jromine Exp jromine $";
454 @allow headers with -file
455 allow "-file -" to mean read stdin
456 put V.Jacobson changes under "options LBL"
461 static char ident[] = "@@(#)$Id: scan.c,v 1.13 1992/02/05 22:50:17 jromine Exp jromine $";
469 @allow "-file -" for stdin
474 static char ident[] = "@@(#)$Id: scan.c,v 1.12 1992/02/05 07:26:30 jromine Exp jromine $";
477 #ifdef VAN /* global for sbr/formatsbr.c - yech! */
480 if (!(cp = *argp++) || *cp == '-')
483 file = path (cp, TFILE);
496 @put unseen sequence in mh-format
501 static char ident[] = "@@(#)$Id: scan.c,v 1.11 1992/02/03 22:45:20 jromine Exp jromine $";
504 in = fopen (file, "r");
506 adios (file, "unable to open");
512 @move -file up so folder context doesn't happen
517 static char ident[] = "@@(#)$Id: scan.c,v 1.10 1992/01/31 22:26:24 jromine Exp jromine $";
521 state = scan (in, msgnum, -1, nfs, width, 0,
534 static char ident[] = "@@(#)$Id: scan.c,v 1.9 1992/01/23 23:06:45 jromine Exp jromine $";
537 nfs = new_fs (form, format, FORMAT); /* must be before chdir() */
541 /* we've been asked to scan a maildrop file */
542 in = fopen (file, "r");
544 adios (NULLCP, "can't open %s (%d)", file, errno);
547 for (msgnum = 1; ; ++msgnum) {
548 state = scan (in, msgnum, -1, nfs, width, 0,
549 hdrflag ? file : (char *)0, 0L, 1);
550 if (state != SCNMSG && state != SCNENC)
561 @new formatsbr changes under JLR
566 static char ident[] = "@@(#)$Id: scan.c,v 1.8 1990/04/05 14:59:58 sources Exp jromine $";
580 static char ident[] = "@@(#)$Id:$";
583 state = scan (in, msgnum, -1, nfs, width, 0, hdrflag, 0L, 1);
603 @change "empty" and "unreadable" message to be error messages
604 via advise(). I don't agree with this change -- eventually,
605 formatsbr should have to deal with these errors.
631 @Fixes from Van Jacobson
636 extern struct msgs *fmt_current_folder; /* global for sbr/formatsbr.c - yech! */
662 @relent and add -[no]reverse
668 firstlim = mp -> hghsel;
669 lastlim = mp -> lowsel;
673 firstlim = mp -> lowsel;
674 lastlim = mp -> hghsel;
695 register int revflag = 0,
710 for (msgnum = firstlim;
711 (revflag ? msgnum >= lastlim : msgnum <= lastlim);
714 for (msgnum = mp -> lowsel; msgnum <= mp -> hghsel; msgnum++)