test/scan/test-scan test/scan/test-scan-multibyte \
test/sequences/test-flist test/sequences/test-mark \
test/sequences/test-out-of-range \
+ test/show/test-show \
test/slocal/test-slocal \
test/whatnow/test-attach-detach test/whatnow/test-cd \
test/whatnow/test-ls test/whom/test-whom \
char *mhlproc = nmhlibexecdir (/mhl);
-/*
- * This is the super handy BBoard reading program, which is
- * really just the nmh shell program.
- */
-
-char *mshproc = nmhbindir (/msh);
-
/*
* This program is called to pack a folder.
*/
char *showproc = nmhlibexecdir (/mhl);
-/*
- * This program is called by vmh as the back-end to the window management
- * protocol
- */
-
-char *vmhproc = nmhbindir (/msh);
-
/*
* This program is called after comp, et. al., have built a draft
*/
dnl If mailspool is not world-writable and dotlockfile is not setgid,
dnl we need to #define MAILGROUP to 1 and make inc setgid.
-if test x"$LOCKTYPE" = x"dot" -a x"$nmh_cv_mailspool_world_writable" = x"no" -a x"$nmh_cv_dotlockfile_setgid" != x"yes" ; then
+if test x"$with_locking" = x"dot" -a x"$nmh_cv_mailspool_world_writable" = x"no" -a x"$nmh_cv_dotlockfile_setgid" != x"yes" ; then
dnl do we really need both of these?
AC_DEFINE([MAILGROUP],[1],
[Define to 1 if you need to make `inc' set-group-id because your mail spool is not world writable. There are no guarantees as to the safety of doing this, but this #define will add some extra security checks.])dnl
else
PGM=`$SEARCHPROG "$SEARCHPATH" elinks`
if [ ! -z "$PGM" ]; then
- echo "mhshow-show-text/html: $PGM -dump -force-html \
+ echo "mhshow-show-text/html: %l$PGM -dump -force-html \
-eval 'set document.browse.margin_width = 0' %F" >> $TMP
echo "mhfixmsg-format-text/html: $PGM -dump -force-html \
-no-numbering -eval 'set document.browse.margin_width = 0' %F" >> $TMP
--- /dev/null
+%;
+%; This is provided as reference only; it shows the default content marker
+%; used by mhshow when it decides to not display content.
+%;
+[ Message %{folder}%<{folder}:%>%(msg) ]
#define MS_UNKNOWN 1 /* type not known yet */
#define MS_MBOX 2 /* Unix-style "from" lines */
#define MS_MMDF 3 /* string mmdlm2 */
-#define MS_MSH 4 /* whacko msh */
#define NOUSE 0 /* draft being re-used */
* markerform - The name of a file containg mh-format(5) code used to
* display markers about non-displayed MIME parts.
*/
-void show_all_messages(CT *cts, int concat, int textonly, int inlineonly,
- char *markerform);
+void show_all_messages(CT *cts, int concat, int textonly, int inlineonly);
/*
* Display (or store) a single MIME part using the specified command
#define DEFAULT_PAGER "more"
#define DEFAULT_EDITOR "vi"
-
-#include <signal.h>
if the function return or component value is
a non-empty string, and false for an empty string.
.PP
-The `%?' control escape is optional, and may there may be more
+The `%?' control escape is optional, and there may be more
than one `%?' control escape in a conditional block.
The `%|' control escape
is also optional, but may be included at most once.
-.TH MHLIST %manext1% "August 20, 2014" "%nmhversion%"
+.TH MHLIST %manext1% "February 6, 2015" "%nmhversion%"
.\"
.\" %nmhwarning%
.\"
.B mhlist
will list information about the entire
message (all of its parts). By using the
-.B \-part
+.BR \-part ,
+.BR \-type ,
and
-.B \-type
-switches, you may limit the scope of this command to particular
-subparts (of a multipart content) and/or particular content types.
-.PP
-A part specification consists of a series of numbers separated by dots.
-For example, in a multipart content containing three parts, these
-would be named as 1, 2, and 3, respectively. If part 2 was also a
-multipart content containing two parts, these would be named as 2.1 and
-2.2, respectively. Note that the
+.B \-prefer
+switches, you may limit and reorder the set of parts to be listed,
+based on part number and/or content type.
+.PP
+A part specification consists of a series of numbers separated by
+dots. For example, in a multipart content containing three parts,
+these would be named as 1, 2, and 3, respectively. If part 2 was also
+a multipart content containing two parts, these would be named as 2.1
+and 2.2, respectively. Note that the
.B \-part
-switch is effective for only
-messages containing a multipart content. If a message has some other
-kind of content, or if the part is itself another multipart content, the
+switch is effective for only messages containing a multipart content.
+If a message has some other kind of content, or if the part is itself
+another multipart content, the
.B \-part
switch will not prevent the content from being acted upon.
.PP
+The
+.B \-type
+switch can also be used to restrict (or, when used in conjunction with
+.BR \-part ,
+to further restrict) the selection of parts according to content type.
+One or more
+.B \-type
+switches part will only select the first match
+from a multipart/alternative, even if there is more than one
+subpart that matches (one of) the given content type(s).
+.PP
+Using either
+.B \-part
+or
+.B -type
+switches alone will cause either to select
+the part(s) they match. Using them together will select only
+the part(s) matched by both (sets of) switches. In other
+words, the result is the intersection, and not the union, of their
+separate match results.
+.PP
A content specification consists of a content type and a subtype.
The initial list of \*(lqstandard\*(rq content types and subtypes can
be found in RFC 2046.
.B mhlist
and
.B mhstore
-to make common part number ordering possible across all three programs.
+to make common part numbering possible across all three programs.
.SS "Checking the Contents"
The
.B \-check
-.TH MHSHOW %manext1% "April 9, 2014" "%nmhversion%"
+.TH MHSHOW %manext1% "February 8, 2015" "%nmhversion%"
.\"
.\" %nmhwarning%
.\"
.RB [ \-concat " | " \-noconcat ]
.RB [ \-textonly " | " \-notextonly ]
.RB [ \-inlineonly " | " \-noinlineonly ]
+.RB [ \-header " | " \-noheader ]
.RB [ \-form
.IR formfile ]
.RB [ \-markform
.B \-noinlineonly
switches.
In addition, by using the
-.B \-part
+.BR \-part ,
+.BR \-type ,
and
-.B \-type
-switches, you may
-further limit the scope of
-.B mhshow
-to particular subparts (of a
-multipart content) and/or particular content types. The inclusion of any
+.B \-prefer
+switches, you may limit and reorder the set of parts to be displayed,
+based on part number and/or content type.
+The inclusion of any
.B \-part
or
.B \-type
and
.BR \-inlineonly.
.PP
+The
+.B \-header
+switch control whether
+.B mhshow
+will print a message separator header before each message that it
+displays. The header format can be controlled using
+.B \-headerform
+to specify a file containing
+.IR mh\-format (5)
+instructions. A copy of the built-in default
+headerform can be found in %nmhetcdir%/mhshow.header, for reference.
+In addition to the normal set of
+.IR mh\-format (5)
+instructions, a "%{folder}" escape provides a
+string representing the current folder.
+.PP
By default
.B mhshow
will concatenate all content under one pager. If you which each part to
from a multipart/alternative, even if there is more than one
subpart that matches (one of) the given content type(s).
.PP
+Using either
+.B \-part
+or
+.B -type
+switches alone will cause either to select
+the part(s) they match. Using them together will select only
+the part(s) matched by both (sets of) switches. In other
+words, the result is the intersection, and not the union, of their
+separate match results.
+.PP
A content specification consists of a content type and a subtype.
The initial list of \*(lqstandard\*(rq content types and subtypes can
be found in RFC 2046.
.B \-markform
switch to specify a file containing
.IR mh\-format (5)
-instructions to use when displaying the content marker. In addition to
-the normal set of
+instructions to use when displaying the content marker. A copy of the
+default markform can be found in %nmhetcdir%/mhshow.marker, for
+reference. In addition to the normal set of
.IR mh\-format (5)
instructions, the following
.I component
^%nmhetcdir%/mhn.defaults~^System default MIME profile entries
^%nmhetcdir%/mhl.headers~^The headers template
^%nmhetcdir%/mhshow.marker~^Example content marker
+^%nmhetcdir%/mhshow.header~^Example message separator header
.fi
.SH "PROFILE COMPONENTS"
.fc ^ ~
-.TH MHSTORE %manext1% "March 2, 2014" "%nmhversion%"
+.TH MHSTORE %manext1% "February 6, 2015" "%nmhversion%"
.\"
.\" %nmhwarning%
.\"
will store all the parts of each message.
Each part will be store in a separate file. The header fields of
the message are not stored. By using the
-.B \-part
+.BR \-part ,
+.BR \-type ,
and
-.B \-type
-switches, you may limit the scope of
-.B mhstore
-to particular
-subparts (of a multipart content) and/or particular content types.
+.B \-prefer
+switches, you may limit and reorder the set of parts to be stored,
+based on part number and/or content type.
.PP
The
.B \-file
.PP
A part specification consists of a series of numbers separated by
dots. For example, in a multipart content containing three parts,
-these would be named as 1, 2, and 3, respectively. If part 2 was
-also a multipart content containing two parts, these would be named
-as 2.1 and 2.2, respectively. Note that the
+these would be named as 1, 2, and 3, respectively. If part 2 was also
+a multipart content containing two parts, these would be named as 2.1
+and 2.2, respectively. Note that the
.B \-part
-switch is
-effective for only messages containing a multipart content. If a
-message has some other kind of content, or if the part is itself
+switch is effective for only messages containing a multipart content.
+If a message has some other kind of content, or if the part is itself
another multipart content, the
.B \-part
-switch will not prevent
-the content from being acted upon.
+switch will not prevent the content from being acted upon.
+.PP
+The
+.B \-type
+switch can also be used to restrict (or, when used in conjunction with
+.BR \-part ,
+to further restrict) the selection of parts according to content type.
+One or more
+.B \-type
+switches part will only select the first match
+from a multipart/alternative, even if there is more than one
+subpart that matches (one of) the given content type(s).
+.PP
+Using either
+.B \-part
+or
+.B -type
+switches alone will cause either to select
+the part(s) they match. Using them together will select only
+the part(s) matched by both (sets of) switches. In other
+words, the result is the intersection, and not the union, of their
+separate match results.
.PP
A content specification consists of a content type and a subtype.
-The initial list of \*(lqstandard\*(rq content types and subtypes
-can be found in RFC 2046.
+The initial list of \*(lqstandard\*(rq content types and subtypes can
+be found in RFC 2046.
.PP
A list of commonly used contents is briefly reproduced here:
.PP
.B mhlist
and
.B mhstore
-to make common part number ordering possible across all three programs.
+to make common part numbering possible across all three programs.
See
.IR mhlist (1)
and
-.TH SHOW %manext1% "June 6, 2012" "%nmhversion%"
+.TH SHOW %manext1% "February 8, 2015" "%nmhversion%"
.\"
.\" %nmhwarning%
.\"
command. This default can be changed by defining the
.I showproc
profile component. Any switches not recognized by
-.B show
+.BR show ,
+as well as
+.B \-header
+and
+.BR \-noheader ,
are
passed along to that program. To override the default and the
.I showproc
* complete copyright information.
*/
-#include <h/mh.h>
-#include <h/signals.h>
-
/*
- * static prototypes
+ * This function used to support setuid/setgid programs by writing
+ * the file as the user. But that code, m_chkids(), was removed
+ * because there no longer are setuid/setgid programs in nmh.
*/
-static int m_chkids(void);
+#include <h/mh.h>
+#include <h/signals.h>
void
context_save (void)
{
- int action;
register struct node *np;
FILE *out;
sigset_t set, oset;
return;
ctxflags &= ~CTXMOD;
- if ((action = m_chkids ()) > 0)
- return; /* child did it for us */
-
/* block a few signals */
sigemptyset (&set);
sigaddset (&set, SIGHUP);
lkfclosedata (out, ctxpath);
sigprocmask (SIG_SETMASK, &oset, &set); /* reset the signal mask */
-
- if (action == 0)
- /* This must be _exit(), not exit(), because the child didn't
- call unregister_for_removal() in m_chkids(). */
- _exit (0); /* we are child, time to die */
-}
-
-/*
- * This hack brought to you so we can handle set[ug]id MH programs.
- * If we return -1, then no fork is made, we update .mh_profile
- * normally, and return to the caller normally. If we return 0,
- * then the child is executing, .mh_profile is modified after
- * we set our [ug]ids to the norm. If we return > 0, then the
- * parent is executed and .mh_profile has already be modified.
- * We can just return to the caller immediately.
- */
-
-static int
-m_chkids (void)
-{
- int i;
- pid_t pid;
-
- if (getuid () == geteuid ())
- return (-1);
-
- for (i = 0; (pid = fork ()) == -1 && i < 5; i++)
- sleep (5);
-
- switch (pid) {
- case -1:
- break;
-
- case 0:
- /* It's not necessary to call unregister_for_removal(0)
- because the child calls _exit() in context_save(). */
- break;
-
- default:
- pidwait (pid, -1);
- break;
- }
-
- return pid;
}
*/
#include <h/mh.h>
-#include <h/signals.h>
#ifdef READLINE_SUPPORT
#include <readline/readline.h>
curlock = li->curlock;
if ((tmpfile = m_mktemp(li->tmplock, &fd, NULL)) == NULL) {
- advise(NULL, "unable to create temporary file in %s", get_temp_dir());
+ advise(NULL, "unable to create temporary file in %s", li->tmplock);
return -1;
}
11 12/18 foo@example.edu test<<This is a multi-part message in MIME format
EOF
run_prog scan -width 80 last > "$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : scan with bogus header field
# check show (mhl)
cat >"$expected" <<EOF
I am a stupid spammer.
EOF
run_prog show last > "$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : "show (mhl) with bogus header field"
# check mhshow
cat >"$expected" <<EOF
+[ Message inbox:11 ]
Date: Sun, 18 Dec 2005 00:52:39 +0100
To: bar@example.edu
From: foo@example.edu
I am a stupid spammer.
EOF
run_prog mhshow last > "$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : mhshow with bogus header field
# check m_getfld() handling of empty header field
msgfile="$MH_TEST_DIR/Mail/inbox/12"
EOF
run_prog scan -width 13 last >"$actual" 2>"$actual_err"
-check "$expected" "$actual"
-check "$expected_err" "$actual_err"
+check "$expected" "$actual" : m_getfld, empty header output
+check "$expected_err" "$actual_err" : m_getfld, empty header error
# check m_getfld() handling of excessively long header field name
msgfile="$MH_TEST_DIR/Mail/inbox/13"
EOF
run_prog scan -width 13 last >"$actual" 2>"$actual_err"
-check "$expected" "$actual"
+check "$expected" "$actual" : m_getfld with excessively long header field name
# Cygwin has a BUFSIZ of 1024 so the error message gets truncated.
# Deal with that by grepping to verify that scan showed the proper error.
verify_string_in_file() {
EOF
run_prog scan -width 13 last >"$actual" 2>"$actual_err"
-check "$expected" "$actual"
-check "$expected_err" "$actual_err"
+check "$expected" "$actual" : m_getfld with long header, no colon output
+check "$expected_err" "$actual_err" : m_getfld with long header, no colon error
exit $failed
#### check() requires two arguments, each the name of a file to be
#### diff'ed.
-#### If the contents are same, the second file is removed. And the
-#### first file is removed unless there's an optional argument with
-#### a value of 'keep first'.
-#### If different, global variable "failed" is incremented.
-#### If there's an optional 'ignore space' argument, spacing differences
-#### will not be considered signficant, emulating GNU diff -w. It
-#### is assumed that the first file has already been run through
-#### prepare_space.
+#### If the contents are same, the second file is removed. If different,
+#### global variable "failed" is incremented.
+#### Optional arguments:
+#### 'keep first' -- first file is removed unless this is present.
+#### 'ignore space' -- spacing differences will not be considered
+#### signficant, emulating GNU diff -w. It is assumed that the
+#### first file has already been run through prepare_space.
+#### ':' <test name> -- will print '<test name>' in the failure message,
+#### to make it easier to tell which of multiple tests has failed.
check() {
first=$1; shift
second=$1; shift
keepfirst=
ignorespace=
+ label=test
while [ $# -gt 0 ]; do
case $1 in
'keep first') keepfirst=1 ;;
'ignore space') ignorespace=1 ;;
+ ':') shift; label=\'"$*"\'; break ;;
*) echo "$0: invalid check() argument \"$1\" in test suite" >&2 ;;
esac
shift
#### POSIX diff should support -c.
diff -c "$first" "$second" || true
echo
- echo "$0: test failed, outputs are in $first and $second."
+ echo "$0: $label failed, outputs are in $first and $second."
failed=`expr ${failed:-0} + 1`
#### Set return status of the function.
[ $failed -eq 0 ]
mhlproc: ${MH_LIBEXEC_DIR}/mhl
moreproc: cat
postproc: ${MH_LIBEXEC_DIR}/post
+showmimeproc: ${MH_INST_DIR}${bindir}/mhshow
showproc: ${MH_LIBEXEC_DIR}/mhl
+#: The following aren't currently used by the test suite, but are
+#: defined here in case they are in the future:
+mailproc: ${MH_INST_DIR}${bindir}/mhmail
+rcvstoreproc: ${MH_LIBEXEC_DIR}/rcvstore
+sendproc: ${MH_INST_DIR}${bindir}/send
+whatnowproc: ${MH_INST_DIR}${bindir}/whatnow
+whomproc: ${MH_INST_DIR}${bindir}/whom
+#: incproc and packproc are defined in config.c but not used by any code.
EOF
if test -z '@nmhetcdirinst@'; then
700
$bindir/inc
more
-$bindir/mhmail
+$MH_INST_DIR$bindir/mhmail
$MH_INST_DIR$nmhlibexecdir/mhl
cat
600
$bindir/packf
$MH_INST_DIR$nmhlibexecdir/post
-$bindir/send
-$bindir/mhshow
+$MH_INST_DIR$bindir/send
+$MH_INST_DIR$bindir/mhshow
$MH_INST_DIR$nmhlibexecdir/mhl
nmh-`cat ${srcdir}/VERSION`
-$bindir/whatnow
-$bindir/whom
+$MH_INST_DIR$bindir/whatnow
+$MH_INST_DIR$bindir/whom
$nmhetcdirinst
$MH_LIBEXEC_DIR
fcntl
EOF
cat > $expected <<EOF
+[ Message inbox:11 ]
Date: Sun, 18 Dec 2005 00:52:39 +0100
To: bar@example.edu
From: foo@example.edu
EOF
run_prog mhshow $msgnum > $actual 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : bogus quoted-printable data
exit $failed
# check it
cat > $expected <<EOF
+[ Message inbox:11 ]
Date: Tue, 05 Mar 2002 18:20:35 +0000
To: bar@example.edu
From: foo@example.edu
This is a test; this is the body.
EOF
run_prog mhshow $msgnum > $actual 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : C-T-E binary text
exit $failed
# Write the expected output.
cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
[ part 1.1 - text/plain - 29B ]
This is the text/plain part.
EOF
run_prog mhshow -part 1.1 -form mhl.null $msgnum >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : check number 1
# check a boundary condition in m_getfld(): its internal message
# buffer holds exactly up to the end of a header field name in a
# Write the expected output.
cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
[ part 1.1 - text/plain - 29B ]
This is the text/plain part.
EOF
run_prog mhshow -part 1.1 -form mhl.null $msgnum >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : check number 2
# check a boundary condition in m_getfld(): its internal message
# buffer holds exactly up to the end of a message part boundary
# Write the expected output.
cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
[ part 1.1 - text/plain - the text/plain part 29B ]
This is the text/plain part.
EOF
run_prog mhshow -part 1.1 -form mhl.null $msgnum >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : check number 3
exit $failed
# check it
cat > $expected <<EOF
+[ Message inbox:11 ]
Date: Sun, 18 Dec 2005 00:52:39 +0100
To: bar@example.edu
From: foo@example.edu
=\b ^H (backspace) character, probably erased = in diff output
EOF
run_prog mhshow $msgnum > $actual 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : bogus quoted-printable data
exit $failed
# Write the expected output.
cat > $expected <<EOF
+[ Message inbox:11 ]
[ part 1.1 - text/plain - 29B ]
This is the text/plain part.
EOF
# check it
run_prog mhshow -part 1.1 -form mhl.null $msgnum > $actual 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : part 1.1
+
+
+# tests of -part/-type/-prefer
cat > $msgfile <<EOF
To: example@example.org
From: someone <someone@example.com>
-Subject: mhshow -part/-type/prefer test
+Subject: mhshow -part/-type/-prefer test
Date: Thu, 29 Jan 2015 18:12:21 +0000 (GMT)
Content-Type: multipart/mixed; boundary="BoundaryMixed"
boundary="BoundaryAlternative1"
--BoundaryAlternative1
-Content-type: text/plain; charset=ISO-8859-1; format=flowed
+Content-type: text/plain; charset=US-ASCII; format=flowed
Content-transfer-encoding: 8bit
This is the body text/plain part.
# Write the expected output.
cat > $expected <<EOF
+[ Message inbox:11 ]
[ part 1.1.1 - text/html - 111B ]
This is the text/html body part.
EOF
# check it
-run_prog mhshow -part 1.1.1 -form mhl.null $msgnum > $actual 2>&1
-check "$expected" "$actual"
+# The sed command removes blank lines and leading space that lynx inserts.
+run_prog mhshow -part 1.1.1 -form mhl.null $msgnum |
+ sed '/^$/D; s/^ *//;' > $actual 2>&1
+check "$expected" "$actual" : part 1.1.1
# Write the expected output.
cat > $expected <<EOF
+[ Message inbox:11 ]
[ part 1.2 - text/plain - 33B ]
This is the body text/plain part.
EOF
# check it
run_prog mhshow -part 1.2 -form mhl.null $msgnum > $actual 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : part 1.2
# Write the expected output.
cat > $expected <<EOF
+[ Message inbox:11 ]
[ part 1.1 - text/plain - 33B ]
This is the body text/plain part.
EOF
# check it
run_prog mhshow -prefer text/plain -part 1 -form mhl.null $msgnum > $actual 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : part conflicting text/plain, part 1 switches
# Write the expected output.
cat > $expected <<EOF
+[ Message inbox:11 ]
[ part 2 - text/plain - 93B ]
_______________________________________________
This is the final text/plain signature part.
# check it
run_prog mhshow -part 2 -form mhl.null $msgnum > $actual 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : part 2
# Write the expected output.
cat > $expected <<EOF
+[ Message inbox:11 ]
[ part 1.2 - text/plain - 33B ]
This is the body text/plain part.
[ part 2 - text/plain - 93B ]
# check it
run_prog mhshow -type text/plain -form mhl.null $msgnum > $actual 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : type text/plain
# Write the expected output.
cat > $expected <<EOF
+[ Message inbox:11 ]
[ part 1.1 - text/plain - 33B ]
This is the body text/plain part.
[ part 2 - text/plain - 93B ]
EOF
run_prog mhshow -prefer text/plain -form mhl.null $msgnum > $actual 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : prefer text/plain
exit $failed
# check charset conversion
msgfile=`mhpath new`
+msgnum=`basename $msgfile`
cat >"$msgfile" <<'EOF'
From: foo@example.edu
To: bar@example.edu
4 =F7 2 =3D 2
EOF
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
Date: Sun, 18 Dec 2005 00:52:39 +0100
To: bar@example.edu
From: foo@example.edu
EOF
run_prog mhshow last >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : check charset conversion
cat >>"$MH" <<'EOF'
mhshow-show-text/plain: echo %{charset}
# check expansion of %{charset} by itself
msgfile=`mhpath new`
+msgnum=`basename $msgfile`
cat >"$msgfile" <<'EOF'
From: foo@example.edu
To: bar@example.edu
4 =F7 2 =3D 2
EOF
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
Date: Sun, 18 Dec 2005 00:52:39 +0100
To: bar@example.edu
From: foo@example.edu
EOF
run_prog mhshow last >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : check %{charset} by itself
# check expansion of empty %{charset} by itself
msgfile=`mhpath new`
+omsgnum=$msgnum
+msgnum=`basename $msgfile`
cat >"$msgfile" <<'EOF'
From: foo@example.edu
To: bar@example.edu
4 =F7 2 =3D 2
EOF
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
Date: Sun, 18 Dec 2005 00:52:39 +0100
To: bar@example.edu
From: foo@example.edu
EOF
run_prog mhshow last >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : check empty %{charset} by itself
grep -v 'mhshow-show-text/plain:' "$MH" >"$MH.new"
EOF
# check expansion of embedded %{charset} with no text following
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$omsgnum ]
Date: Sun, 18 Dec 2005 00:52:39 +0100
To: bar@example.edu
From: foo@example.edu
-I UTF-8
EOF
-run_prog mhshow prev >"$actual" 2>&1
-check "$expected" "$actual"
+run_prog mhshow prev >"$actual" 2>&1 # NB: "mhshow prev" !!!
+check "$expected" "$actual" : check embedded %{charset} with no text
# check expansion of empty embedded %{charset} with no text following
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
Date: Sun, 18 Dec 2005 00:52:39 +0100
To: bar@example.edu
From: foo@example.edu
EOF
run_prog mhshow last >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : check empty embedded %{charset} with no text following
sed -e 's%\(mhshow-show-text/plain:.*\)%\1 file%' "$MH" >"$MH.new"
mv -f "$MH.new" "$MH"
# check expansion of embedded %{charset} with text following
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$omsgnum ]
Date: Sun, 18 Dec 2005 00:52:39 +0100
To: bar@example.edu
From: foo@example.edu
-I UTF-8 file
EOF
-run_prog mhshow prev >"$actual" 2>&1
-check "$expected" "$actual"
+run_prog mhshow prev >"$actual" 2>&1 # NB: "mhshow prev" !!!
+check "$expected" "$actual" : check embedded %{charset} with text following
# check expansion of empty embedded %{charset} with text following
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
Date: Sun, 18 Dec 2005 00:52:39 +0100
To: bar@example.edu
From: foo@example.edu
EOF
run_prog mhshow last >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : check empty embedded %{charset} with text following
sed -e 's/charset/method/g' "$MH" >"$MH.new"
# check parameter value quoting
msgfile=`mhpath new`
+msgnum=`basename $msgfile`
cat >"$msgfile" <<'EOF'
From: foo@example.edu
To: bar@example.edu
4 =F7 2 =3D 2
EOF
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
+EOF
+cat >>"$expected" <<'EOF'
Date: Sun, 18 Dec 2005 00:52:39 +0100
To: bar@example.edu
From: foo@example.edu
EOF
run_prog mhshow last >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : check parameter value quoting
sed -e 's/method/unknown/g' "$MH" >"$MH.new"
# check that unknown parameter is not expanded
msgfile=`mhpath new`
+msgnum=`basename $msgfile`
cat >"$msgfile" <<'EOF'
From: foo@example.edu
To: bar@example.edu
4 =F7 2 =3D 2
EOF
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
Date: Sun, 18 Dec 2005 00:52:39 +0100
To: bar@example.edu
From: foo@example.edu
EOF
run_prog mhshow last >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : check unknown parameter is not expanded
grep -v '^mhshow-show-text/plain: ' "$MH" >>"$MH.new"
# check parameter value quoting with text following
msgfile=`mhpath new`
+msgnum=`basename $msgfile`
cat >"$msgfile" <<'EOF'
From: foo@example.edu
To: bar@example.edu
This is a test.
EOF
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
Date: Sun, 18 Dec 2005 00:52:39 +0100
To: bar@example.edu
From: foo@example.edu
EOF
run_prog mhshow last >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : parameter value quoting with text following
#
# test a large file that needs to be converted to UTF-8
grep -v '^mhshow-show-text/plain: ' "$MH" >>"$MH.new"
mv -f "$MH.new" "$MH"
msgfile=`mhpath new`
+msgnum=`basename $msgfile`
cat >"$msgfile" <<'EOF'
From: foo@example.edu
To: bar@example.edu
=93How strange!=94 she exclaimed, drawing a long breath.
EOF
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
Date: Sun, 18 Dec 2005 00:52:39 +0100
To: bar@example.edu
From: foo@example.edu
EOF
run_prog mhshow last >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : large file conversion to UTF-8
exit $failed
--- /dev/null
+#!/bin/sh
+
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname "$0"`/../..
+ MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
+fi
+
+. "$MH_OBJ_DIR/test/common.sh"
+
+setup_test
+
+expected=$MH_TEST_DIR/$$.expected
+actual=$MH_TEST_DIR/$$.actual
+
+# Write message with a text/plain subpart.
+msgfile=`mhpath new`
+msgnum=`basename $msgfile`
+cat > $msgfile <<EOF
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="NextPart_001"
+Content-class: urn:content-classes:message
+Date: Thu, 19 May 2011 00:00:00
+From: sender@example.com
+To: recipient@example.com
+
+This is a multi-part message in MIME format.
+
+--NextPart_001
+Content-Type: multipart/related;
+ type="multipart/alternative";
+ boundary="NextPart_002"
+
+--NextPart_002
+Content-Type: text/plain;
+ charset="utf-8"
+
+This is the text/plain part.
+
+--NextPart_002--
+
+--NextPart_001--
+EOF
+
+# Test showing multiple non-MIME messages shows message numbers.
+
+cat > $expected <<EOF
+>>> inbox:1
+
+
+Date: Fri, 29 Sep 2006 00:00:00
+To: Some User <user@example.com>
+From: Test1 <test1@example.com>
+Subject: Testing message 1
+
+
+This is message number 1
+
+
+
+>>> inbox:2
+
+
+Date: Fri, 29 Sep 2006 00:00:00
+To: Some User <user@example.com>
+From: Test2 <test2@example.com>
+Subject: Testing message 2
+
+
+This is message number 2
+EOF
+
+show +inbox 1 2 > $actual || exit 1
+
+check "$expected" "$actual" : show two non-mime
+
+# Test showing one MIME message shows message number.
+# Format is different; why?
+
+cat > $expected <<EOF
+[ Message inbox:$msgnum ]
+Date: Thu, 19 May 2011 00:00:00
+To: recipient@example.com
+From: sender@example.com
+
+MIME-Version: 1.0
+Content-class: urn:content-classes:message
+
+[ part 1.1 - text/plain - 29B ]
+This is the text/plain part.
+EOF
+
+show +inbox $msgnum > $actual || exit 1
+
+check "$expected" "$actual" : show one MIME
+
+# Test showing multiple MIME messages shows message numbers.
+# Currently fails.
+
+cat > $expected <<EOF
+[ Message inbox:1 ]
+Date: Fri, 29 Sep 2006 00:00:00
+To: Some User <user@example.com>
+From: Test1 <test1@example.com>
+Subject: Testing message 1
+
+
+[ part - text/plain - 25B ]
+This is message number 1
+[ Message inbox:11 ]
+Date: Thu, 19 May 2011 00:00:00
+To: recipient@example.com
+From: sender@example.com
+
+MIME-Version: 1.0
+Content-class: urn:content-classes:message
+
+[ part 1.1 - text/plain - 29B ]
+This is the text/plain part.
+EOF
+
+show +inbox 1 $msgnum > $actual || exit 1
+
+check "$expected" "$actual" : show multiple mime
+
+exit $failed
*/
#ifdef MAILGROUP
-/* Revised: Sat Apr 14 17:08:17 PDT 1990 (marvit@hplabs)
+/*
+ * Thu Feb 12 21:00 CST 2015 Marcin Cieslak <saper@saper.info>
+ * Replaced setgid() calls with setegid() so that it works with dot
+ * locking on FreeBSD. setegid() should be supported on modern POSIX
+ * systems.
+ *
+ * Revised: Sat Apr 14 17:08:17 PDT 1990 (marvit@hplabs)
* Added hpux hacks to set and reset gid to be "mail" as needed. The reset
* is necessary so inc'ed mail is the group of the inc'er, rather than
* "mail". We setgid to egid only when [un]locking the mail file. This
* For setting and returning to "mail" gid
*/
#ifdef MAILGROUP
-static int return_gid;
+static gid_t return_gid;
#define TRYDROPGROUPPRIVS() DROPGROUPPRIVS()
-#define DROPGROUPPRIVS() setgid(getgid())
-#define GETGROUPPRIVS() setgid(return_gid)
+#define DROPGROUPPRIVS() \
+ if (setegid(getgid()) != 0) { \
+ adios ("setegid", "unable to restore group to %ld", (long) getgid()); \
+ }
+#define GETGROUPPRIVS() \
+ if (setegid(return_gid) != 0) { \
+ adios ("setegid", "unable to set group to %ld", (long) return_gid); \
+ }
#define SAVEGROUPPRIVS() return_gid = getegid()
#else
/* define *GROUPPRIVS() as null; this avoids having lots of "#ifdef MAILGROUP"s */
static void
inc_done (int status)
{
+ done = exit;
if (packfile && pd != NOTOK)
mbx_close (packfile, pd);
if (locked)
#include <h/mh.h>
#include <fcntl.h>
-#include <h/signals.h>
#include <h/md5.h>
#include <h/mts.h>
#include <h/tws.h>
#include <h/mh.h>
#include <fcntl.h>
-#include <h/signals.h>
#include <h/md5.h>
#include <h/mts.h>
#include <h/tws.h>
#include <h/mh.h>
#include <fcntl.h>
-#include <h/signals.h>
#include <h/md5.h>
#include <h/mts.h>
#include <h/tws.h>
#include <h/mh.h>
#include <fcntl.h>
-#include <h/signals.h>
#include <h/mts.h>
#include <h/tws.h>
#include <h/mime.h>
* Show the message content
*/
if (showsw)
- show_all_messages (cts, 0, 0, 0, NULL);
+ show_all_messages (cts, 0, 0, 0);
/* Now free all the structures for the content */
for (ctp = cts; *ctp; ctp++)
#include <h/mh.h>
#include <fcntl.h>
-#include <h/signals.h>
#include <h/md5.h>
#include <h/mts.h>
#include <h/tws.h>
#include <h/mh.h>
#include <fcntl.h>
-#include <h/signals.h>
#include <h/md5.h>
#include <h/mts.h>
#include <h/tws.h>
X("noinlineonly", 0, NINLINESW) \
X("file file", 0, FILESW) \
X("form formfile", 0, FORMSW) \
+ X("header", 0, HEADSW) \
+ X("noheader", 0, NHEADSW) \
+ X("headerform formfile", 0, HEADFORMSW) \
X("markform formfile", 0, MARKFORMSW) \
X("part number", 0, PARTSW) \
X("type content", 0, TYPESW) \
extern char *progsw;
extern int nomore; /* flags for moreproc/header display */
extern char *formsw;
+extern char *folder;
+extern char *headerform;
+extern char *markerform;
+extern int headersw;
/* mhmisc.c */
extern int npart;
main (int argc, char **argv)
{
int msgnum, *icachesw, concatsw = -1, textonly = -1, inlineonly = -1;
- char *cp, *file = NULL, *folder = NULL, *markform = NULL;
+ char *cp, *file = NULL;
char *maildir, buf[100], **argp;
char **arguments;
struct msgs_array msgs = { 0, 0, NULL };
while ((cp = *argp++)) {
if (*cp == '-') {
switch (smatch (++cp, switches)) {
- case AMBIGSW:
+ case AMBIGSW:
ambigsw (cp, switches);
done (1);
- case UNKWNSW:
+ case UNKWNSW:
adios (NULL, "-%s unknown", cp);
- case HELPSW:
+ case HELPSW:
snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]",
invo_name);
print_help (buf, switches, 1);
formsw = getcpy (etcpath (cp));
continue;
+ case HEADSW:
+ headersw = 1;
+ continue;
+ case NHEADSW:
+ headersw = 0;
+ continue;
+
+ case HEADFORMSW:
+ if (!(headerform = *argp++) || *headerform == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
+ continue;
+
case MARKFORMSW:
- if (!(markform = *argp++) || *markform == '-')
+ if (!(markerform = *argp++) || *markerform == '-')
adios (NULL, "missing argument to %s", argp[-2]);
continue;
adios (NULL, "missing argument to %s", argp[-2]);
continue;
- case VERBSW:
+ case VERBSW:
verbosw = 1;
continue;
- case NVERBSW:
+ case NVERBSW:
verbosw = 0;
continue;
case DEBUGSW:
if ((ct = parse_mime (file)))
*ctp++ = ct;
+
+ headersw = 0;
} else {
/*
* message(s) are coming from a folder
/*
* Show the message content
*/
- show_all_messages (cts, concatsw, textonly, inlineonly, markform);
+ show_all_messages (cts, concatsw, textonly, inlineonly);
/* Now free all the structures for the content */
for (ctp = cts; *ctp; ctp++)
int nomore = 0;
char *formsw = NULL;
+/* for output markerss and headers */
+char *folder = NULL;
+char *markerform;
+char *headerform;
+int headersw = -1;
+
/* mhmisc.c */
int part_ok (CT);
static int parse_display_string (CT, char *, int *, int *, char *, char *,
size_t, int multipart);
static int convert_content_charset (CT, char **);
+static struct format *compile_header(char *);
static struct format *compile_marker(char *);
+static void output_header (CT, struct format *);
static void output_marker (CT, struct format *, int);
static void free_markercomps (void);
static int pidcheck(int);
* content marker display.
*/
+static struct comp *folder_comp = NULL;
static struct comp *part_comp = NULL;
static struct comp *ctype_comp = NULL;
static struct comp *description_comp = NULL;
*/
void
-show_all_messages (CT *cts, int concatsw, int textonly, int inlineonly,
- char *markerform)
+show_all_messages (CT *cts, int concatsw, int textonly, int inlineonly)
{
CT ct, *ctp;
- struct format *fmt;
+ struct format *hfmt, *mfmt;
/*
* If form is not specified, then get default form
formsw = getcpy (etcpath ("mhl.headers"));
/*
- * Compile the content marker format line
+ * Compile the content marker and header format lines
*/
- fmt = compile_marker(markerform);
+ mfmt = compile_marker(markerform);
+ hfmt = compile_header(headerform);
/*
* If form is "mhl.null", suppress display of header.
/* if top-level type is ok, then display message */
if (type_ok (ct, 1))
+ if (headersw) output_header(ct, hfmt);
+
show_single_message (ct, formsw, concatsw, textonly, inlineonly,
- fmt);
+ mfmt);
}
free_markercomps();
- fmt_free(fmt, 1);
+ fmt_free(hfmt, 1);
+ fmt_free(mfmt, 1);
}
* Compile our format string and save any parameters we care about.
*/
+#define DEFAULT_HEADER "[ Message %{folder}%<{folder}:%>%(msg) ]"
#define DEFAULT_MARKER "[ part %{part} - %{content-type} - " \
"%<{description}%{description}" \
"%?{cdispo-filename}%{cdispo-filename}" \
"%(kilo(size))B %<(unseen)\\(suppressed\\)%> ]"
static struct format *
-compile_marker(char *markerform)
+compile_header(char *form)
+{
+ struct format *fmt;
+ char *fmtstring;
+ struct comp *comp = NULL;
+ unsigned int bucket;
+
+ fmtstring = new_fs(form, NULL, DEFAULT_HEADER);
+
+ (void) fmt_compile(fmtstring, &fmt, 1);
+ free_fs();
+
+ while ((comp = fmt_nextcomp(comp, &bucket)) != NULL) {
+ if (strcasecmp(comp->c_name, "folder") == 0) {
+ folder_comp = comp;
+ }
+ }
+
+ return fmt;
+}
+
+static struct format *
+compile_marker(char *form)
{
struct format *fmt;
char *fmtstring;
unsigned int bucket;
struct param_comp_list *pc_entry;
- fmtstring = new_fs(markerform, NULL, DEFAULT_MARKER);
+ fmtstring = new_fs(form, NULL, DEFAULT_MARKER);
(void) fmt_compile(fmtstring, &fmt, 1);
- free(fmtstring);
+ free_fs();
/*
* Things we care about:
* Output on stdout an appropriate marker for this content, using mh-format
*/
+static void
+output_header(CT ct, struct format *fmt)
+{
+ charstring_t outbuf = charstring_create (BUFSIZ);
+ int dat[5] = { 0 };
+ char *endp;
+ int message = 0;
+
+ if (folder_comp)
+ folder_comp->c_text = getcpy(folder);
+
+ if (ct->c_file && *ct->c_file) {
+ message = strtol(ct->c_file, &endp, 10);
+ if (*endp) message = 0;
+ dat[0] = message;
+ }
+
+ /* it would be nice to populate dat[2], for %(size) here,
+ * but it's not available. it might also be nice to know
+ * if the message originally had any mime parts or not -- but
+ * there's also no record of that. (except for MIME-version:)
+ */
+
+ fmt_scan(fmt, outbuf, BUFSIZ, dat, NULL);
+
+ fputs(charstring_buffer (outbuf), stdout);
+ charstring_free (outbuf);
+
+ fmt_freecomptext();
+}
+
static void
output_marker(CT ct, struct format *fmt, int hidden)
{
charstring_t outbuf = charstring_create (BUFSIZ);
struct param_comp_list *pcentry;
int partsize;
- int dat[5];
+ int message = 0;
+ char *endp;
+ int dat[5] = { 0 };
/*
* Grab any items we care about.
else
partsize = ct->c_end - ct->c_begin;
+ if (ct->c_file && *ct->c_file) {
+ message = strtol(ct->c_file, &endp, 10);
+ if (*endp) message = 0;
+ dat[0] = message;
+ }
+ dat[2] = partsize;
+
/* make the part's hidden aspect available by overloading the
* %(unseen) function. make the part's size available via %(size).
* see comments in h/fmt_scan.h.
*/
- dat[2] = partsize;
dat[4] = hidden;
- dat[0] = dat[1] = dat[3] = 0;
fmt_scan(fmt, outbuf, BUFSIZ, dat, NULL);
{
struct param_comp_list *pc_entry, *pc2;
+ folder_comp = NULL;
part_comp = NULL;
ctype_comp = NULL;
description_comp = NULL;
#include <h/mh.h>
#include <fcntl.h>
-#include <h/signals.h>
#include <h/md5.h>
#include <h/mts.h>
#include <h/tws.h>
-
/*
* show.c -- show/list messages
*
while ((cp = *argp++)) {
if (*cp == '-') {
switch (smatch (++cp, switches)) {
- case AMBIGSW:
+ case AMBIGSW:
ambigsw (cp, switches);
done (1);
+ case HEADSW:
+ headersw = 1;
+ goto non_mhl_switches;
+ case NHEADSW:
+ headersw = 0;
case CONCATSW:
case NCONCATSW:
+non_mhl_switches:
/* mhl can't handle these, so keep them separate. */
app_msgarg(&non_mhl_vec, --cp);
continue;
- case UNKWNSW:
+ case UNKWNSW:
case NPROGSW:
case NFMTPROCSW:
app_msgarg(&vec, --cp);
continue;
- case HELPSW:
+ case HELPSW:
snprintf (buf, sizeof(buf),
"%s [+folder] %s[switches] [switches for showproc]",
invo_name, mode == SHOW ? "[msgs] ": "");
print_version(invo_name);
done (0);
- case DRFTSW:
+ case DRFTSW:
if (file)
adios (NULL, "only one file at a time!");
draftsw++;
adios (NULL,
"usage: %s [+folder] [switches] [switches for showproc]",
invo_name);
- case FILESW:
+ case FILESW:
if (mode != SHOW)
goto usage;
if (draftsw || file)
file = path (cp, TFILE);
continue;
- case HEADSW:
- headersw++;
- continue;
- case NHEADSW:
- headersw = 0;
- continue;
-
case FORMSW:
app_msgarg(&vec, --cp);
if (!(cp = *argp++) || *cp == '-')
app_msgarg(&vec, cp);
continue;
- case SHOWSW:
+ case SHOWSW:
if (!(showproc = *argp++) || *showproc == '-')
adios (NULL, "missing argument to %s", argp[-2]);
nshow = 0;
continue;
- case NSHOWSW:
+ case NSHOWSW:
nshow++;
continue;
app_msgarg(&vec, getcpy (m_draft (folder, NULL, 1, &isdf)));
else
app_msgarg(&vec, file);
+ headersw = 0;
goto go_to_it;
}
context_replace (pfolder, folder); /* update current folder */
context_save (); /* save the context file */
- if (headersw && vec.size == 1)
- printf ("(Message %s:%s)\n", folder, vec.msgs[0]);
-
go_to_it: ;
- fflush (stdout);
/*
* Decide which "proc" to use
if (folder && !draftsw && !file)
m_putenv ("mhfolder", folder);
- if (strcmp (r1bindex (proc, '/'), "mhl") == 0) {
+ if (strcmp (r1bindex (proc, '/'), "cat") == 0) {
+
+ if (headersw && vec.size == 1)
+ printf ("(Message %s:%s)\n", folder, vec.msgs[0]);
+
+ } else if (strcmp (r1bindex (proc, '/'), "mhl") == 0) {
+
+ if (headersw && vec.size == 1)
+ printf ("(Message %s:%s)\n", folder, vec.msgs[0]);
+
/* If "mhl", then run it internally */
argsplit_insert(&vec, "mhl", &program);
app_msgarg(&vec, NULL);
mhl (vec.size, vec.msgs);
done (0);
+
} else {
int i;
char **mp;
app_msgarg(&vec, vec.msgs[vec.size - 1]);
vec.msgs[vec.size - 2] = "-file";
}
+ } else {
+ if (headersw && vec.size == 1)
+ printf ("(Message %s:%s)\n", folder, vec.msgs[0]);
}
}
+ fflush (stdout);
+
argsplit_insert(&vec, proc, &program);
app_msgarg(&vec, NULL);
execvp (program, vec.msgs);
#include <h/mh.h>
#include <fcntl.h>
-#include <h/signals.h>
#include <h/md5.h>
#include <h/mts.h>
#include <h/tws.h>