]> diplodocus.org Git - nmh/commitdiff
Merge remote-tracking branch 'origin/convertargs'
authorDavid Levine <levinedl@acm.org>
Mon, 23 Feb 2015 03:21:40 +0000 (21:21 -0600)
committerDavid Levine <levinedl@acm.org>
Mon, 23 Feb 2015 03:21:40 +0000 (21:21 -0600)
39 files changed:
Makefile.am
config/config.c
configure.ac
etc/mhn.defaults.sh
etc/mhshow.header [new file with mode: 0644]
h/mh.h
h/mhparse.h
h/nmh.h
man/mh-format.man
man/mhlist.man
man/mhshow.man
man/mhstore.man
man/show.man
sbr/context_save.c
sbr/getansreadline.c
sbr/lock_file.c
test/bad-input/test-header
test/common.sh.in
test/mhparam/test-mhparam
test/mhshow/test-charset
test/mhshow/test-cte-binary
test/mhshow/test-msg-buffer-boundaries
test/mhshow/test-qp
test/mhshow/test-subpart
test/mhshow/test-textcharset
test/show/test-show [new file with mode: 0755]
uip/inc.c
uip/mhbuild.c
uip/mhbuildsbr.c
uip/mhcachesbr.c
uip/mhlistsbr.c
uip/mhn.c
uip/mhoutsbr.c
uip/mhparse.c
uip/mhshow.c
uip/mhshowsbr.c
uip/mhstoresbr.c
uip/show.c
uip/viamail.c

index 90dee63..ec523ec 100644 (file)
@@ -97,6 +97,7 @@ TESTS = test/ali/test-ali test/anno/test-anno \
        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 \
index 5c0591c..919c1ee 100644 (file)
@@ -242,13 +242,6 @@ char *moreproc = NULL;
 
 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.  
  */
@@ -299,13 +292,6 @@ char *showmimeproc = nmhbindir (/mhshow);
 
 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
  */
index 754ccb6..0936556 100644 (file)
@@ -307,7 +307,7 @@ AS_IF([test x"$DISABLE_SETGID_MAIL" != x -a x"$DISABLE_SETGID_MAIL" != x0],
 
 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
index bfc7924..e2821db 100755 (executable)
@@ -306,7 +306,7 @@ $PGM "'-child -dump -force_html ${charset:+--assume_charset "$charset"} '"\
     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
diff --git a/etc/mhshow.header b/etc/mhshow.header
new file mode 100644 (file)
index 0000000..2f9bafe
--- /dev/null
@@ -0,0 +1,5 @@
+%;
+%; 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) ]
diff --git a/h/mh.h b/h/mh.h
index b8c60ca..4b3818c 100644 (file)
--- a/h/mh.h
+++ b/h/mh.h
@@ -377,7 +377,6 @@ typedef struct m_getfld_state *m_getfld_state_t;
 #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 */
 
index d1c9442..3efec9c 100644 (file)
@@ -502,8 +502,7 @@ char *get_param_value(PM pm, char replace);
  * 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
diff --git a/h/nmh.h b/h/nmh.h
index ca32f58..2468919 100644 (file)
--- a/h/nmh.h
+++ b/h/nmh.h
@@ -74,5 +74,3 @@
 
 #define DEFAULT_PAGER "more"
 #define DEFAULT_EDITOR "vi"
-
-#include <signal.h>
index 4b58b3f..baad070 100644 (file)
@@ -137,7 +137,7 @@ For string valued functions or components, the condition is true
 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.
index 093b7a8..ee70811 100644 (file)
@@ -1,4 +1,4 @@
-.TH MHLIST %manext1% "August 20, 2014" "%nmhversion%"
+.TH MHLIST %manext1% "February 6, 2015" "%nmhversion%"
 .\"
 .\" %nmhwarning%
 .\"
@@ -98,24 +98,46 @@ By default,
 .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.
@@ -177,7 +199,7 @@ but is also implemented in
 .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
index 67516be..c2bba35 100644 (file)
@@ -1,4 +1,4 @@
-.TH MHSHOW %manext1% "April 9, 2014" "%nmhversion%"
+.TH MHSHOW %manext1% "February 8, 2015" "%nmhversion%"
 .\"
 .\" %nmhwarning%
 .\"
@@ -24,6 +24,7 @@ mhshow \- display MIME messages
 .RB [ \-concat " | " \-noconcat ]
 .RB [ \-textonly " | " \-notextonly ]
 .RB [ \-inlineonly " | " \-noinlineonly ]
+.RB [ \-header " | " \-noheader ]
 .RB [ \-form
 .IR formfile ]
 .RB [ \-markform
@@ -59,14 +60,13 @@ and
 .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
@@ -75,6 +75,22 @@ switches will override the default settings of
 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
@@ -140,6 +156,16 @@ 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.
@@ -671,8 +697,9 @@ next.  The default marker can be changed using the
 .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
@@ -722,6 +749,7 @@ is checked.
 ^%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 ^ ~
index 2484d69..fb0f57d 100644 (file)
@@ -1,4 +1,4 @@
-.TH MHSTORE %manext1% "March 2, 2014" "%nmhversion%"
+.TH MHSTORE %manext1% "February 6, 2015" "%nmhversion%"
 .\"
 .\" %nmhwarning%
 .\"
@@ -51,13 +51,12 @@ By default,
 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
@@ -83,21 +82,40 @@ messages, see
 .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
@@ -145,7 +163,7 @@ but is also implemented in
 .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
index a248e6a..57832c3 100644 (file)
@@ -1,4 +1,4 @@
-.TH SHOW %manext1% "June 6, 2012" "%nmhversion%"
+.TH SHOW %manext1% "February 8, 2015" "%nmhversion%"
 .\"
 .\" %nmhwarning%
 .\"
@@ -43,7 +43,11 @@ manual page for the details about this
 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
index 7080959..27d55e9 100644 (file)
@@ -7,19 +7,18 @@
  * 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;
@@ -33,9 +32,6 @@ context_save (void)
        return;
     ctxflags &= ~CTXMOD;
 
-    if ((action = m_chkids ()) > 0)
-       return;                 /* child did it for us */
-
     /* block a few signals */
     sigemptyset (&set);
     sigaddset (&set, SIGHUP);
@@ -57,48 +53,4 @@ context_save (void)
     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;
 }
index e68cba8..5d80dd9 100644 (file)
@@ -8,7 +8,6 @@
  */
 
 #include <h/mh.h>
-#include <h/signals.h>
 
 #ifdef READLINE_SUPPORT
 #include <readline/readline.h>
index f4d3902..a8a9811 100644 (file)
@@ -561,7 +561,7 @@ lockit (struct lockinfo *li)
     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;
     }
 
index 1716ff1..eeacc83 100755 (executable)
@@ -38,7 +38,7 @@ cat >"$expected" <<EOF
   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
@@ -55,10 +55,11 @@ This is a multi-part message in MIME format.
 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
@@ -72,7 +73,7 @@ This is a multi-part message in MIME format.
 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"
@@ -86,8 +87,8 @@ scan: eof encountered in field "Received"
 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"
@@ -100,7 +101,7 @@ cat >"$expected" <<EOF
 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() {
@@ -135,8 +136,8 @@ scan: eol encountered in field "If a header field name has at least 512 characte
 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
index e84d8e6..aa1e845 100644 (file)
@@ -155,23 +155,26 @@ prepare_space() {
 
 #### 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
@@ -193,7 +196,7 @@ check() {
         #### 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 ]
@@ -289,7 +292,16 @@ mhbuild: -nocontentid
 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
index 8a48b8d..29dd11f 100755 (executable)
@@ -84,18 +84,18 @@ $MH_INST_DIR$bindir/refile
 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
index e0a0b6e..6c3c763 100755 (executable)
@@ -43,6 +43,7 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100
 EOF
 
 cat > $expected <<EOF
+[ Message inbox:11 ]
 Date:    Sun, 18 Dec 2005 00:52:39 +0100
 To:      bar@example.edu
 From:    foo@example.edu
@@ -56,6 +57,6 @@ This is a test
 EOF
 
 run_prog mhshow $msgnum > $actual 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : bogus quoted-printable data
 
 exit $failed
index fdf1ca7..f872e3b 100755 (executable)
@@ -35,6 +35,7 @@ EOF
 
 # 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
@@ -47,7 +48,7 @@ Content-Disposition: inline
 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
 
index 47005cc..ca1e7cd 100755 (executable)
@@ -153,12 +153,13 @@ EOF
 
 # 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
@@ -293,12 +294,13 @@ EOF
 
 # 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
@@ -434,12 +436,13 @@ EOF
 
 # 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
index dae70a5..1b78c8e 100755 (executable)
@@ -47,6 +47,7 @@ EOF
 
 # 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
@@ -69,6 +70,6 @@ just a newline
 =\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
index 161dcea..27fb907 100755 (executable)
@@ -51,18 +51,22 @@ EOF
 
 # 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"
 
@@ -71,7 +75,7 @@ Content-type: multipart/alternative;
  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.
@@ -105,36 +109,42 @@ EOF
 
 # 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.
@@ -142,10 +152,11 @@ EOF
 
 # 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  ]
@@ -155,10 +166,11 @@ EOF
 
 # 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  ]
@@ -167,6 +179,6 @@ This is the final text/plain signature part.
 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
index d4d7ef0..f8d854f 100755 (executable)
@@ -28,6 +28,7 @@ actual="$MH_TEST_DIR"/$$.actual
 
 # check charset conversion
 msgfile=`mhpath new`
+msgnum=`basename $msgfile`
 cat >"$msgfile" <<'EOF'
 From: foo@example.edu
 To: bar@example.edu
@@ -40,7 +41,8 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100
 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
@@ -53,7 +55,7 @@ MIME-Version: 1.0
 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}
@@ -62,6 +64,7 @@ EOF
 
 # check expansion of %{charset} by itself
 msgfile=`mhpath new`
+msgnum=`basename $msgfile`
 cat >"$msgfile" <<'EOF'
 From: foo@example.edu
 To: bar@example.edu
@@ -74,7 +77,8 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100
 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
@@ -86,11 +90,13 @@ UTF-8
 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
@@ -103,7 +109,8 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100
 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
@@ -115,7 +122,7 @@ MIME-Version: 1.0
 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"
@@ -125,7 +132,8 @@ mhshow-show-text/plain: charset=%{charset}; echo ${charset:+-I $charset}
 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
@@ -136,12 +144,13 @@ MIME-Version: 1.0
 -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
@@ -153,14 +162,15 @@ MIME-Version: 1.0
 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
@@ -171,12 +181,13 @@ MIME-Version: 1.0
 -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
@@ -188,7 +199,7 @@ file
 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"
@@ -196,6 +207,7 @@ mv -f "$MH.new" "$MH"
 
 # check parameter value quoting
 msgfile=`mhpath new`
+msgnum=`basename $msgfile`
 cat >"$msgfile" <<'EOF'
 From: foo@example.edu
 To: bar@example.edu
@@ -208,7 +220,10 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100
 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
@@ -220,7 +235,7 @@ MIME-Version: 1.0
 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"
@@ -228,6 +243,7 @@ mv -f "$MH.new" "$MH"
 
 # check that unknown parameter is not expanded
 msgfile=`mhpath new`
+msgnum=`basename $msgfile`
 cat >"$msgfile" <<'EOF'
 From: foo@example.edu
 To: bar@example.edu
@@ -240,7 +256,8 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100
 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
@@ -252,7 +269,7 @@ file
 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"
@@ -263,6 +280,7 @@ EOF
 
 # check parameter value quoting with text following
 msgfile=`mhpath new`
+msgnum=`basename $msgfile`
 cat >"$msgfile" <<'EOF'
 From: foo@example.edu
 To: bar@example.edu
@@ -274,7 +292,8 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100
 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
@@ -285,7 +304,7 @@ MIME-Version: 1.0
 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
@@ -294,6 +313,7 @@ check "$expected" "$actual"
 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
@@ -728,7 +748,8 @@ one of the glass buildings.
 =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
@@ -1155,6 +1176,6 @@ one of the glass buildings.
 EOF
 
 run_prog mhshow last >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : large file conversion to UTF-8
 
 exit $failed
diff --git a/test/show/test-show b/test/show/test-show
new file mode 100755 (executable)
index 0000000..1554094
--- /dev/null
@@ -0,0 +1,125 @@
+#!/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
index 8b9fe7a..7d12842 100644 (file)
--- a/uip/inc.c
+++ b/uip/inc.c
@@ -8,7 +8,13 @@
  */
 
 #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
@@ -127,10 +133,16 @@ static FILE *pf = NULL;
  * 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 */
@@ -947,6 +959,7 @@ skip:
 static void
 inc_done (int status)
 {
+    done = exit;
     if (packfile && pd != NOTOK)
        mbx_close (packfile, pd);
     if (locked)
index de0fdaa..58b37c4 100644 (file)
@@ -9,7 +9,6 @@
 
 #include <h/mh.h>
 #include <fcntl.h>
-#include <h/signals.h>
 #include <h/md5.h>
 #include <h/mts.h>
 #include <h/tws.h>
index 2e177c4..b998993 100644 (file)
@@ -17,7 +17,6 @@
 
 #include <h/mh.h>
 #include <fcntl.h>
-#include <h/signals.h>
 #include <h/md5.h>
 #include <h/mts.h>
 #include <h/tws.h>
index 201b78e..ae563c2 100644 (file)
@@ -9,7 +9,6 @@
 
 #include <h/mh.h>
 #include <fcntl.h>
-#include <h/signals.h>
 #include <h/md5.h>
 #include <h/mts.h>
 #include <h/tws.h>
index 0110d9e..5a45d03 100644 (file)
@@ -10,7 +10,6 @@
 
 #include <h/mh.h>
 #include <fcntl.h>
-#include <h/signals.h>
 #include <h/mts.h>
 #include <h/tws.h>
 #include <h/mime.h>
index be433d6..ea56379 100644 (file)
--- a/uip/mhn.c
+++ b/uip/mhn.c
@@ -554,7 +554,7 @@ do_cache:
      * 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++)
index 0c0a297..066a4b9 100644 (file)
@@ -10,7 +10,6 @@
 
 #include <h/mh.h>
 #include <fcntl.h>
-#include <h/signals.h>
 #include <h/md5.h>
 #include <h/mts.h>
 #include <h/tws.h>
index f021b07..dd4c5e9 100644 (file)
@@ -9,7 +9,6 @@
 
 #include <h/mh.h>
 #include <fcntl.h>
-#include <h/signals.h>
 #include <h/md5.h>
 #include <h/mts.h>
 #include <h/tws.h>
index c834376..b2a4c0d 100644 (file)
@@ -31,6 +31,9 @@
     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) \
@@ -70,6 +73,10 @@ extern char *cache_private;
 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;
@@ -110,7 +117,7 @@ int
 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 };
@@ -131,13 +138,13 @@ main (int argc, char **argv)
     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);
@@ -235,8 +242,20 @@ do_cache:
                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;
 
@@ -257,10 +276,10 @@ do_cache:
                    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:
@@ -338,6 +357,8 @@ do_cache:
 
        if ((ct = parse_mime (file)))
            *ctp++ = ct;
+
+       headersw = 0;
     } else {
        /*
         * message(s) are coming from a folder
@@ -430,7 +451,7 @@ do_cache:
     /*
      * 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++)
index 31d25eb..056c2f4 100644 (file)
@@ -33,6 +33,12 @@ char *progsw = NULL;
 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);
@@ -59,7 +65,9 @@ static int show_external (CT, int, int, int, int, struct format *);
 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);
@@ -69,6 +77,7 @@ 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;
@@ -89,11 +98,10 @@ static struct param_comp_list *dispo_pc_list = 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
@@ -103,9 +111,10 @@ show_all_messages (CT *cts, int concatsw, int textonly, int inlineonly,
        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.
@@ -118,12 +127,15 @@ show_all_messages (CT *cts, int concatsw, int textonly, int inlineonly,
 
        /* 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);
 }
 
 
@@ -1252,6 +1264,7 @@ convert_content_charset (CT ct, char **file) {
  * 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}" \
@@ -1259,7 +1272,29 @@ convert_content_charset (CT ct, char **file) {
                       "%(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;
@@ -1267,10 +1302,10 @@ compile_marker(char *markerform)
     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:
@@ -1316,13 +1351,46 @@ compile_marker(char *markerform)
  * 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.
@@ -1360,13 +1428,18 @@ output_marker(CT ct, struct format *fmt, int hidden)
     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);
 
@@ -1385,6 +1458,7 @@ free_markercomps(void)
 {
     struct param_comp_list *pc_entry, *pc2;
 
+    folder_comp = NULL;
     part_comp = NULL;
     ctype_comp = NULL;
     description_comp = NULL;
index c53f7ad..62b2f4a 100644 (file)
@@ -9,7 +9,6 @@
 
 #include <h/mh.h>
 #include <fcntl.h>
-#include <h/signals.h>
 #include <h/md5.h>
 #include <h/mts.h>
 #include <h/tws.h>
index e5b71ef..f891078 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * show.c -- show/list messages
  *
@@ -79,23 +78,29 @@ main (int argc, char **argv)
     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] ": "");
@@ -105,7 +110,7 @@ main (int argc, char **argv)
                    print_version(invo_name);
                    done (0);
 
-               case DRFTSW: 
+               case DRFTSW:
                    if (file)
                        adios (NULL, "only one file at a time!");
                    draftsw++;
@@ -115,7 +120,7 @@ usage:
                    adios (NULL,
                            "usage: %s [+folder] [switches] [switches for showproc]",
                            invo_name);
-               case FILESW: 
+               case FILESW:
                    if (mode != SHOW)
                        goto usage;
                    if (draftsw || file)
@@ -125,13 +130,6 @@ usage:
                    file = path (cp, TFILE);
                    continue;
 
-               case HEADSW: 
-                   headersw++;
-                   continue;
-               case NHEADSW: 
-                   headersw = 0;
-                   continue;
-
                case FORMSW:
                    app_msgarg(&vec, --cp);
                    if (!(cp = *argp++) || *cp == '-')
@@ -149,12 +147,12 @@ usage:
                    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;
 
@@ -194,6 +192,7 @@ usage:
            app_msgarg(&vec, getcpy (m_draft (folder, NULL, 1, &isdf)));
        else
            app_msgarg(&vec, file);
+       headersw = 0;
        goto go_to_it;
     }
 
@@ -252,11 +251,7 @@ usage:
     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
@@ -290,12 +285,22 @@ go_to_it: ;
     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;
@@ -324,9 +329,14 @@ go_to_it: ;
                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);
index 0ff765c..050ca0f 100644 (file)
@@ -9,7 +9,6 @@
 
 #include <h/mh.h>
 #include <fcntl.h>
-#include <h/signals.h>
 #include <h/md5.h>
 #include <h/mts.h>
 #include <h/tws.h>