/* show.c - list messages */
static char ident
[] = "@(#)$Id: show.c,v 1.14 1993/10/26 20:09:21 jromine Exp $";
static struct swit switches
[] = {
"file file", -4, /* interface from showfile */
invo_name
= r1bindex (argv
[0], '/');
if (uleq (invo_name
, "next"))
if (uleq (invo_name
, "prev"))
if ((cp
= m_find (invo_name
)) != NULL
) {
ap
= brkstring (cp
= getcpy (cp
), " ", "\n");
ap
= copyip (ap
, arguments
);
(void) copyip (argv
+ 1, ap
);
switch (smatch (++cp
, switches
)) {
"%s [+folder] %s[switches] [switches for showproc]",
invo_name
, mode
== SHOW
? "[msgs] ": "");
adios (NULLCP
, "only one file at a time!");
"usage: %s [+folder] [switches] [switches for showproc]",
adios (NULLCP
, "only one file at a time!");
if (!(cp
= *argp
++) || *cp
== '-')
adios (NULLCP
, "missing argument to %s", argp
[-2]);
if (!(cp
= *argp
++) || *cp
== '-')
adios (NULLCP
, "missing argument to %s", argp
[-2]);
vec
[vecp
++] = getcpy (libpath(cp
));
if (!(cp
= *argp
++) || *cp
== '-')
adios (NULLCP
, "missing argument to %s", argp
[-2]);
if (!(showproc
= *argp
++) || *showproc
== '-')
adios (NULLCP
, "missing argument to %s", argp
[-2]);
if (*cp
== '+' || *cp
== '@') {
adios (NULLCP
, "only one folder at a time!");
folder
= path (cp
+ 1, *cp
== '+' ? TFOLDER
: TSUBCWF
);
free (path ("./", TFOLDER
));
adios (NULLCP
, "only one file at a time!");
? getcpy (m_draft (folder
, msgp
? msgs
[0] : NULL
, 1, &isdf
))
if (!msgp
&& !folder
&& mode
== SHOW
&& (cp
= getenv ("mhdraft")) && *cp
) {
msgs
[msgp
++] = mode
== NEXT
? "next" : mode
== PREV
? "prev" : "cur";
maildir
= m_maildir (folder
);
if (chdir (maildir
) == NOTOK
)
adios (maildir
, "unable to change directory to");
if (!(mp
= m_gmsg (folder
)))
adios (NULLCP
, "unable to read folder %s", folder
);
adios (NULLCP
, "no messages in %s", folder
);
for (msgnum
= 0; msgnum
< msgp
; msgnum
++)
if (!m_convert (mp
, msgs
[msgnum
]))
for (msgnum
= mp
-> lowsel
; msgnum
<= mp
-> hghsel
; msgnum
++)
if (mp
-> msgstats
[msgnum
] & SELECTED
)
mp
-> msgstats
[msgnum
] |= UNSEEN
;
if (mp
-> numsel
> MAXARGS
- 2)
adios (NULLCP
, "more than %d messages for show exec", MAXARGS
- 2);
for (msgnum
= mp
-> lowsel
; msgnum
<= mp
-> hghsel
; msgnum
++)
if (mp
-> msgstats
[msgnum
] & SELECTED
)
vec
[vecp
++] = getcpy (m_name (msgnum
));
m_replace (pfolder
, folder
);
if (mp
-> hghsel
!= mp
-> curmsg
)
m_setcur (mp
, mp
-> hghsel
);
if (vecp
== 2 && headersw
)
printf ("(Message %s:%s)\n", folder
, vec
[1]);
if (!nshow
&& !getenv ("NOMHNPROC")) {
if (!(cp
= m_find ("mhnproc")))
if (nontext (vec
[vecp
- 1])) {
vec
[vecp
] = vec
[vecp
- 1];
for (msgnum
= mp
-> lowsel
; msgnum
<= mp
-> hghsel
; msgnum
++)
if ((mp
-> msgstats
[msgnum
] & SELECTED
)
&& nontext (m_name (msgnum
))) {
if (folder
&& !draftsw
&& !file
)
(void) m_putenv ("mhfolder", folder
);
if (strcmp (r1bindex (showproc
, '/'), "mhl") == 0) {
&& chdir (maildir
= concat (m_maildir (""), "/", NULLCP
))
mp
-> foldpath
= concat (mp
-> foldpath
, "/", NULLCP
);
cp
= ssequal (maildir
, mp
-> foldpath
)
? mp
-> foldpath
+ strlen (maildir
)
for (msgnum
= procp
; msgnum
< vecp
; msgnum
++)
vec
[msgnum
] = concat (cp
, vec
[msgnum
], NULLCP
);
vec
[0] = r1bindex (proc
, '/');
adios (proc
, "unable to exec");
/* Cheat: we are loaded with adrparse, which wants a routine called
OfficialName(). We call adrparse:getm() with the correct arguments
to prevent OfficialName() from being called. Hence, the following
is to keep the loader happy.
char *OfficialName (name
)
static int nontext (msgnam
)
if ((fp
= fopen (msgnam
, "r")) == NULL
)
if (!(chset
= getenv ("MM_CHARSET")))
switch (state
= m_getfld (state
, name
, buf
, sizeof buf
, fp
)) {
if (uleq (name
, TYPE_FIELD
)) {
while (state
== FLDPLUS
) {
state
= m_getfld (state
, name
, buf
, sizeof buf
, fp
);
for (; isspace (*bp
); bp
++)
for (dp
= bp
; istoken (*dp
); dp
++)
if (result
= !uleq (bp
, "plain"))
for (dp
++; isspace (*dp
); dp
++)
if (result
= !uprf (dp
, "charset"))
dp
+= sizeof "charset" - 1;
if (bp
= index (++dp
, '"'))
if ((result
= !uleq (dp
, chset
))
&& uleq (chset
, "iso-8859-1"))
if (!(result
= !uleq (bp
, "text"))) {
if (uleq (name
, ENCODING_FIELD
)) {
while (state
== FLDPLUS
) {
state
= m_getfld (state
, name
, buf
, sizeof buf
, fp
);
for (bp
= cp
; isspace (*bp
); bp
++)
for (dp
= bp
; istoken (*dp
); dp
++)
result
= !uleq (bp
, "7bit")
state
= m_getfld (state
, name
, buf
, sizeof buf
, fp
);