9 date 95.12.06.21.07.46; author jromine; state Exp;
14 date 93.10.26.20.09.21; author jromine; state Exp;
19 date 93.10.26.16.25.19; author jromine; state Exp;
24 date 92.12.15.00.20.22; author jromine; state Exp;
29 date 92.11.24.18.26.39; author jromine; state Exp;
34 date 92.11.04.01.02.58; author jromine; state Exp;
39 date 92.10.16.22.41.36; author jromine; state Exp;
44 date 92.05.19.21.04.45; author jromine; state Exp;
49 date 92.03.03.17.13.54; author jromine; state Exp;
54 date 92.02.01.00.34.45; author jromine; state Exp;
59 date 92.01.31.22.27.23; author jromine; state Exp;
64 date 92.01.31.16.35.17; author jromine; state Exp;
69 date 90.12.19.08.48.39; author mh; state Exp;
74 date 90.04.05.15.03.16; author sources; state Exp;
79 date 90.02.09.10.50.48; author sources; state Exp;
93 @/* show.c - list messages */
95 static char ident[] = "@@(#)$Id: show.c,v 1.14 1993/10/26 20:09:21 jromine Exp jromine $";
107 static struct swit switches[] = {
114 "moreproc program", 4,
123 "showproc program", 4,
133 "file file", -4, /* interface from showfile */
142 static int nontext();
180 setlocale(LC_ALL, "");
182 invo_name = r1bindex (argv[0], '/');
183 if (uleq (invo_name, "next"))
186 if (uleq (invo_name, "prev"))
188 if ((cp = m_find (invo_name)) != NULL) {
189 ap = brkstring (cp = getcpy (cp), " ", "\n");
190 ap = copyip (ap, arguments);
194 (void) copyip (argv + 1, ap);
199 while (cp = *argp++) {
201 switch (smatch (++cp, switches)) {
203 ambigsw (cp, switches);
211 "%s [+folder] %s[switches] [switches for showproc]",
212 invo_name, mode == SHOW ? "[msgs] ": "");
213 help (buf, switches);
218 adios (NULLCP, "only one file at a time!");
224 "usage: %s [+folder] [switches] [switches for showproc]",
230 adios (NULLCP, "only one file at a time!");
231 if (!(cp = *argp++) || *cp == '-')
232 adios (NULLCP, "missing argument to %s", argp[-2]);
233 file = path (cp, TFILE);
245 if (!(cp = *argp++) || *cp == '-')
246 adios (NULLCP, "missing argument to %s", argp[-2]);
247 vec[vecp++] = getcpy (libpath(cp));
254 if (!(cp = *argp++) || *cp == '-')
255 adios (NULLCP, "missing argument to %s", argp[-2]);
260 if (!(showproc = *argp++) || *showproc == '-')
261 adios (NULLCP, "missing argument to %s", argp[-2]);
268 if (*cp == '+' || *cp == '@@') {
270 adios (NULLCP, "only one folder at a time!");
272 folder = path (cp + 1, *cp == '+' ? TFOLDER : TSUBCWF);
284 if (!m_find ("path"))
285 free (path ("./", TFOLDER));
287 if (draftsw || file) {
289 adios (NULLCP, "only one file at a time!");
290 vec[vecp++] = draftsw
291 ? getcpy (m_draft (folder, msgp ? msgs[0] : NULL, 1, &isdf))
297 if (!msgp && !folder && mode == SHOW && (cp = getenv ("mhdraft")) && *cp) {
305 msgs[msgp++] = mode == NEXT ? "next" : mode == PREV ? "prev" : "cur";
307 folder = m_getfolder ();
308 maildir = m_maildir (folder);
310 if (chdir (maildir) == NOTOK)
311 adios (maildir, "unable to change directory to");
312 if (!(mp = m_gmsg (folder)))
313 adios (NULLCP, "unable to read folder %s", folder);
314 if (mp -> hghmsg == 0)
315 adios (NULLCP, "no messages in %s", folder);
317 for (msgnum = 0; msgnum < msgp; msgnum++)
318 if (!m_convert (mp, msgs[msgnum]))
320 for (msgnum = mp -> lowsel; msgnum <= mp -> hghsel; msgnum++)
321 if (mp -> msgstats[msgnum] & SELECTED)
322 mp -> msgstats[msgnum] |= UNSEEN;
326 if (mp -> numsel > MAXARGS - 2)
327 adios (NULLCP, "more than %d messages for show exec", MAXARGS - 2);
328 for (msgnum = mp -> lowsel; msgnum <= mp -> hghsel; msgnum++)
329 if (mp -> msgstats[msgnum] & SELECTED)
330 vec[vecp++] = getcpy (m_name (msgnum));
332 m_replace (pfolder, folder);
333 if (mp -> hghsel != mp -> curmsg)
334 m_setcur (mp, mp -> hghsel);
338 if (vecp == 2 && headersw)
339 printf ("(Message %s:%s)\n", folder, vec[1]);
344 (void) fflush (stdout);
349 if (!nshow && !getenv ("NOMHNPROC")) {
350 if (!(cp = m_find ("mhnproc")))
353 if (draftsw || file) {
354 if (nontext (vec[vecp - 1])) {
355 vec[vecp] = vec[vecp - 1];
356 vec[vecp - 1] = "-file";
362 for (msgnum = mp -> lowsel; msgnum <= mp -> hghsel; msgnum++)
363 if ((mp -> msgstats[msgnum] & SELECTED)
364 && nontext (m_name (msgnum))) {
367 vec[vecp++] = "-show";
376 if (folder && !draftsw && !file)
377 (void) m_putenv ("mhfolder", folder);
378 if (strcmp (r1bindex (showproc, '/'), "mhl") == 0) {
380 (void) mhl (vecp, vec);
388 && chdir (maildir = concat (m_maildir (""), "/", NULLCP))
390 mp -> foldpath = concat (mp -> foldpath, "/", NULLCP);
391 cp = ssequal (maildir, mp -> foldpath)
392 ? mp -> foldpath + strlen (maildir)
394 for (msgnum = procp; msgnum < vecp; msgnum++)
395 vec[msgnum] = concat (cp, vec[msgnum], NULLCP);
399 vec[0] = r1bindex (proc, '/');
401 adios (proc, "unable to exec");
406 /* Cheat: we are loaded with adrparse, which wants a routine called
407 OfficialName(). We call adrparse:getm() with the correct arguments
408 to prevent OfficialName() from being called. Hence, the following
409 is to keep the loader happy.
412 char *OfficialName (name)
421 #include "../h/mhn.h"
424 static int nontext (msgnam)
437 if ((fp = fopen (msgnam, "r")) == NULL)
440 if (!(chset = getenv ("MM_CHARSET")))
444 switch (state = m_getfld (state, name, buf, sizeof buf, fp)) {
448 if (uleq (name, TYPE_FIELD)) {
452 cp = add (buf, NULLCP);
453 while (state == FLDPLUS) {
454 state = m_getfld (state, name, buf, sizeof buf, fp);
461 for (; isspace (*bp); bp++)
466 for (bp++, i = 0;;) {
496 for (dp = bp; istoken (*dp); dp++)
502 if (result = !uleq (bp, "plain"))
505 for (dp++; isspace (*dp); dp++)
507 if (result = !uprf (dp, "charset"))
509 dp += sizeof "charset" - 1;
510 while (isspace (*dp))
514 while (isspace (*dp))
517 if (bp = index (++dp, '"'))
521 for (bp = dp; *bp; bp++)
526 if ((result = !uleq (dp, chset))
527 && uleq (dp, "us-ascii")
528 && uleq (chset, "iso-8859-1"))
532 if (!(result = !uleq (bp, "text"))) {
547 if (uleq (name, ENCODING_FIELD)) {
548 cp = add (buf, NULLCP);
549 while (state == FLDPLUS) {
550 state = m_getfld (state, name, buf, sizeof buf, fp);
553 for (bp = cp; isspace (*bp); bp++)
555 for (dp = bp; istoken (*dp); dp++)
558 result = !uleq (bp, "7bit")
559 && !uleq (bp, "8bit")
560 && !uleq (bp, "binary");
569 while (state == FLDPLUS)
570 state = m_getfld (state, name, buf, sizeof buf, fp);
584 @test for iso-8859-1 (and us-ascii) charsets
589 static char ident[] = "@@(#)$Id: show.c,v 1.12 1992/12/15 00:20:22 jromine Exp $";
603 static char ident[] = "@@(#)$Id: show.c,v 1.12 1992/12/15 00:20:22 jromine Exp jromine $";
610 chlen = strlen (chset);
614 if (strlen (dp) >= chlen + 1
615 && *(bp = dp + chlen) == '"')
618 if (strlen (dp) >= chlen
619 && isspace (*(bp = dp + chlen)))
621 result = !uleq (dp, chset);
632 static char ident[] = "@@(#)$Id: show.c,v 1.11 1992/11/24 18:26:39 jromine Exp jromine $";
642 if (strlen (dp) >= sizeof "us-ascii\""
643 && *(bp = dp + sizeof "us-ascii" - 1)=='"')
646 if (strlen (dp) >= sizeof "us-ascii"
648 dp + sizeof "us-ascii" - 1)))
651 result = !uleq (dp, "us-ascii");
654 result = !uleq (bp, "7bit");
665 static char ident[] = "@@(#)$Id: show.c,v 1.10 1992/11/04 01:02:58 jromine Exp jromine $";
684 static char ident[] = "@@(#)$Id: show.c,v 1.9 1992/10/16 22:41:36 jromine Exp jromine $";
696 static char ident[] = "@@(#)$Id: show.c,v 1.8 1992/05/19 21:04:45 jromine Exp jromine $";
701 (void) putenv ("mhfolder", folder);
712 static char ident[] = "@@(#)$Id: show.c,v 1.7 1992/03/03 17:13:54 jromine Exp jromine $";
715 if (!nshow && (cp = m_find ("mhnproc")) && !getenv ("NOMHNPROC"))
743 result = !uleq (bp, "plain");
760 static char ident[] = "@@(#)$Id: show.c,v 1.6 1992/02/01 00:34:45 jromine Exp jromine $";
781 static char ident[] = "@@(#)$Id: show.c,v 1.5 1992/01/31 22:27:23 jromine Exp jromine $";
793 static char ident[] = "@@(#)$Id: show.c,v 1.4 1992/01/31 16:35:17 jromine Exp jromine $";
805 static char ident[] = "@@(#)$Id: show.c,v 1.3 90/12/19 08:48:39 mh Exp $";
820 static char ident[] = "@@(#)$Id: show.c,v 1.2 90/04/05 15:03:16 sources Exp Locker: mh $";
826 if (!msgp && mode == SHOW && (cp = getenv ("mhdraft")) && *cp) {
842 static char ident[] = "@@(#)$Id:$";
845 (void) putenv ("mhfolder", folder);