From c085eca6dea41bf9c0ac2749215e256cc54ff628 Mon Sep 17 00:00:00 2001 From: Dan Harkless Date: Tue, 14 Mar 2000 02:29:26 +0000 Subject: [PATCH] Applied Sullivan N. Beck 's mhshow-suffix patch: With the patch below, you can add lines like: mhshow-suffix-application/msword: .doc mhshow-suffix-application/PostScript: .ps to the mhn.defaults file to append the given suffix to a scratch file. This allows applications which require a certain suffix to run properly. Removed -force_html from lynx entry in mhn.defaults.sh (I believe older versions of lynx lack that option) and added "mhshow-suffix-text/html: .html". --- ChangeLog | 26 ++++++++++++++++++++++---- etc/mhn.defaults.sh | 12 +++++++++++- man/mhn.man | 38 ++++++++++++++++++++++++++++++++++++++ man/mhshow.man | 38 ++++++++++++++++++++++++++++++++++++++ uip/mhparse.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 160 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7aa74d4..dc73246 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,12 +1,30 @@ +Mon Mar 13 18:26:03 2000 Dan Harkless + + * Applied Sullivan N. Beck 's mhshow-suffix patch: + + With the patch below, you can add lines like: + + mhshow-suffix-application/msword: .doc + mhshow-suffix-application/PostScript: .ps + + to the mhn.defaults file to append the given suffix to a + scratch file. This allows applications which require a + certain suffix to run properly. + + * Removed -force_html from lynx entry in mhn.defaults.sh (I + believe older versions of lynx lack that option) and added + "mhshow-suffix-text/html: .html". + Mon Mar 06 12:20:20 2000 Dan Harkless * Applied Neil W Rickert 's msh.c patch: - I finally tracked down the problem in msh that was causing errors - whenever I tried to examine a 'mmdf' style mailbox. + I finally tracked down the problem in msh that was causing + errors whenever I tried to examine a 'mmdf' style mailbox. - It turns out that not enough memory was being allocated with - calloc(), causing memory pointers to be overwritten and corrupted. + It turns out that not enough memory was being allocated with + calloc(), causing memory pointers to be overwritten and + corrupted. Fri Mar 03 16:07:33 2000 Dan Harkless diff --git a/etc/mhn.defaults.sh b/etc/mhn.defaults.sh index 5630bcc..8b29fcd 100755 --- a/etc/mhn.defaults.sh +++ b/etc/mhn.defaults.sh @@ -126,13 +126,15 @@ if [ ! -z "$PGM" ]; then echo "mhshow-show-application/x-ivs: %p$PGM -o '%F'" >> $TMP fi +echo "mhshow-suffix-text/html: .html" >> $TMP + # I'd like to check if netscape is available and use it preferentially to lynx, # but only once I've added a new %-escape that makes more permanent temp files, # so netscape -remote can be used (without -remote you get a complaint dialog # that another netscape is already running and certain things can't be done). PGM="`$SEARCHPROG $SEARCHPATH lynx`" if [ ! -z "$PGM" ]; then - echo "mhshow-show-text/html: %p$PGM -force_html '%F'" >> $TMP + echo "mhshow-show-text/html: %p$PGM '%F'" >> $TMP fi PGM="`$SEARCHPROG $SEARCHPATH richtext`" @@ -145,6 +147,13 @@ else fi fi +# staroffice to read .doc files +PGM="`$SEARCHPROG $SEARCHPATH soffice`" +if [ ! -z "$PGM" ]; then + echo "mhshow-show-application/msword: %psoffice '%F'" >> $TMP + echo "mhshow-suffix-application/msword: .doc" >> $TMP +fi + PGM="`$SEARCHPROG $SEARCHPATH xterm`" if [ ! -z "$PGM" ]; then echo "mhshow-charset-iso-8859-1: xterm -fn '-*-*-medium-r-normal-*-*-120-*-*-c-*-iso8859-*' -e '%s'" >> $TMP @@ -164,6 +173,7 @@ else PGM="`$SEARCHPROG $SEARCHPATH gs`" if [ ! -z "$PGM" ]; then echo "mhshow-show-application/PostScript: %p$PGM -- '%F'" >> $TMP + echo "mhshow-suffix-application/PostScript: .ps" >> $TMP fi fi diff --git a/man/mhn.man b/man/mhn.man index e4719dc..473f4ac 100644 --- a/man/mhn.man +++ b/man/mhn.man @@ -150,6 +150,44 @@ You may specify an alternate format file with the `\-form formfile' switch. If the format file \fImhl.null\fR is specified, then the display of the message headers is suppressed. +Next, the contents are extracted from the message and are stored in +a temporary file. Usually, the name of the temporary file the +word "mhn" followed by a string of characters. Occasionally, +the method used to display a content (described next), requires that +the file end in a specific suffix. For example, the \fIsoffice\fR +command (part of the StarOffice package) can be used to display +MicroSoft Word content, but it uses the suffix to determine how to display +the file. If no suffix is present, the file is not correctly loaded. +Similarily, older versions of the \fIgs\fR command append a ".ps" suffix to +the filename if one was missing. As a result, these cannot be used to read +the default temporary file. + +To get around this, your profile can contain lines of the form: +.sp +.in +.5i +mhn-suffix-/: +.in -.5i +.sp +or +.sp +.in +.5i +mhn-suffix-: +.in -.5i +.sp +to specify a suffix which can be automatically added to the temporary +file created for a specific content type. For example, the following +lines might appear in your profile: +.sp +.nf +.in +.5i +mhn-suffix-text: .txt +mhn-suffix-application/msword: .doc +mhn-suffix-application/PostScript: .ps +.in -.5i +.fi +.sp +to automatically append a suffix to the temporary files. + The method used to display the different contents in the messages bodies will be determined by a \*(lqdisplay string\*(rq. To find the display string, \fImhn\fR will first search your profile for an entry of the form: diff --git a/man/mhshow.man b/man/mhshow.man index 30a925f..f4b42ea 100644 --- a/man/mhshow.man +++ b/man/mhshow.man @@ -111,6 +111,44 @@ You may specify an alternate format file with the `\-form formfile' switch. If the format file \fImhl.null\fR is specified, then the display of the message headers is suppressed. +Next, the contents are extracted from the message and are stored in +a temporary file. Usually, the name of the temporary file the +word "mhshow" followed by a string of characters. Occasionally, +the method used to display a content (described next), requires that +the file end in a specific suffix. For example, the \fIsoffice\fR +command (part of the StarOffice package) can be used to display +MicroSoft Word content, but it uses the suffix to determine how to display +the file. If no suffix is present, the file is not correctly loaded. +Similarily, older versions of the \fIgs\fR command append a ".ps" suffix to +the filename if one was missing. As a result, these cannot be used to read +the default temporary file. + +To get around this, your profile can contain lines of the form: +.sp +.in +.5i +mhshow-suffix-/: +.in -.5i +.sp +or +.sp +.in +.5i +mhshow-suffix-: +.in -.5i +.sp +to specify a suffix which can be automatically added to the temporary +file created for a specific content type. For example, the following +lines might appear in your profile: +.sp +.nf +.in +.5i +mhshow-suffix-text: .txt +mhshow-suffix-application/msword: .doc +mhshow-suffix-application/PostScript: .ps +.in -.5i +.fi +.sp +to automatically append a suffix to the temporary files. + The method used to display the different contents in the messages bodies will be determined by a \*(lqdisplay string\*(rq. To find the display string, \fImhshow\fR will first search your profile for an entry of the diff --git a/uip/mhparse.c b/uip/mhparse.c index 86a08b7..1c46076 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -1568,6 +1568,8 @@ openBase64 (CT ct, char **file) unsigned long bits; unsigned char value, *b, *b1, *b2, *b3; char *cp, *ep, buffer[BUFSIZ]; + /* sbeck -- handle prefixes */ + CI ci; CE ce; MD5_CTX mdContext; @@ -1598,6 +1600,19 @@ openBase64 (CT ct, char **file) ce->ce_unlink = 0; } + /* sbeck@cise.ufl.edu -- handle suffixes */ + ci = &ct->c_ctinfo; + snprintf (buffer, sizeof(buffer), "%s-suffix-%s/%s", + invo_name, ci->ci_type, ci->ci_subtype); + cp = context_find (buffer); + if (cp == NULL || *cp == '\0') { + snprintf (buffer, sizeof(buffer), "%s-suffix-%s", invo_name, + ci->ci_type); + cp = context_find (buffer); + } + if (cp != NULL && *cp != '\0') + ce->ce_file = add (cp, ce->ce_file); + if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) { content_error (ce->ce_file, ct, "unable to fopen for reading/writing"); return NOTOK; @@ -1767,6 +1782,8 @@ openQuoted (CT ct, char **file) char buffer[BUFSIZ]; unsigned char mask; CE ce; + /* sbeck -- handle prefixes */ + CI ci; MD5_CTX mdContext; ce = ct->c_cefile; @@ -1791,6 +1808,24 @@ openQuoted (CT ct, char **file) ce->ce_unlink = 0; } + /* sbeck@cise.ufl.edu -- handle suffixes */ + ci = &ct->c_ctinfo; + snprintf (buffer, sizeof(buffer), "%s-suffix-%s/%s", + invo_name, ci->ci_type, ci->ci_subtype); + cp = context_find (buffer); + if (cp == NULL || *cp == '\0') { + snprintf (buffer, sizeof(buffer), "%s-suffix-%s", invo_name, + ci->ci_type); + cp = context_find (buffer); + } + if (cp != NULL && *cp != '\0') + ce->ce_file = add (cp, ce->ce_file); + + if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) { + content_error (ce->ce_file, ct, "unable to fopen for reading/writing"); + return NOTOK; + } + if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) { content_error (ce->ce_file, ct, "unable to fopen for reading/writing"); return NOTOK; @@ -1965,6 +2000,9 @@ open7Bit (CT ct, char **file) { int cc, fd, len; char buffer[BUFSIZ]; + /* sbeck -- handle prefixes */ + char *cp; + CI ci; CE ce; ce = ct->c_cefile; @@ -1989,6 +2027,19 @@ open7Bit (CT ct, char **file) ce->ce_unlink = 0; } + /* sbeck@cise.ufl.edu -- handle suffixes */ + ci = &ct->c_ctinfo; + snprintf (buffer, sizeof(buffer), "%s-suffix-%s/%s", + invo_name, ci->ci_type, ci->ci_subtype); + cp = context_find (buffer); + if (cp == NULL || *cp == '\0') { + snprintf (buffer, sizeof(buffer), "%s-suffix-%s", invo_name, + ci->ci_type); + cp = context_find (buffer); + } + if (cp != NULL && *cp != '\0') + ce->ce_file = add (cp, ce->ce_file); + if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) { content_error (ce->ce_file, ct, "unable to fopen for reading/writing"); return NOTOK; -- 1.7.10.4