> "Sullivan N. Beck" <[EMAIL PROTECTED]> writes:
> > I'm trying to get mhshow to automatically open up various applications
> > when different MIME types are present, and most of them work, but there
> > are a few exceptions.
> >
> > The temporary files created by mhshow are names like: mhshowXXXXXX ,
> > and a few apps require a suffix in order to work correctly.
> >
> > For example, with application/PostScript , I can get it to work
> > by using the line:
> > mhshow-show-application/PostScript: %pgv -
> > but NOT
> > mhshow-show-application/PostScript: %pgv '%F'
> > because gs/gv won't take a filename without the .ps suffix correctly (if
> > the file doesn't end in .ps, it appends it and then can't find the
> > resulting file). Although this isn't so important (because I've got
> > a workaround), I'd like to use staroffice to automatically open with
> > application/msword (and others) types. With a suffix, it's working
> > fine. Without, it doesn't.
> >
> > I could also write a simple wrapper script, but I'd rather not since
> > that means that I have to make changes in two places every time I add
> > a new MIME application.
> >
> > Any suggestions? Am I missing something basic? Probably so.
>
> No, you're not missing anything. It's unfortunate that you can add suffixes
> on mhn.defaults' mhstore directives:
>
> mhstore-store-application/PostScript: %m%P.ps
> mhstore-store-text/richtext: %m%P.rt
> mhstore-store-text: %m%P.txt
> mhstore-store-video/mpeg: %m%P.mpg
>
> but not on the mhshow directives. When I was adding a check for lynx in
> mhn.defaults.sh recently, I almost started to implement the ability to add
> extensions, but then I found lynx's -force_html flag:
>
> mhshow-show-text/html: %plynx -force_html '%F'
>
> so I put it off. Dan Winship was recently mucking around in the %-escape
> code -- maybe he has an idea of how hard or easy it'd be to implement this.
Well... it turned out to not be terribly hard. I created variables of
the format:
mhshow-suffix-TYPE:
mhshow-suffix-TYPE/SUBTYPE:
for example:
mhshow-suffix-application/msword: .doc
mhshow-suffix-application/PostScript: .ps
Then, I applied the patch below and things worked great. This only affects
openBase64. I added the same lines to the openQuoted and it dumped core
on me. I don't have time to look into it any more tonight, but in the
meantime, Base64 is working great.
*** uip/mhparse.c.orig Fri Mar 3 18:15:09 2000
--- uip/mhparse.c Fri Mar 3 19:03:29 2000
***************
*** 1568,1573 ****
--- 1568,1575 ----
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;
***************
*** 1597,1602 ****
--- 1599,1614 ----
ce->ce_file = add (*file, NULL);
ce->ce_unlink = 0;
}
+
+ /* [EMAIL PROTECTED] -- handle suffixes */
+ ci = &ct->c_ctinfo;
+ snprintf (buffer, sizeof(buffer), "%s-suffix-%s/%s",
+ invo_name, ci->ci_type, ci->ci_subtype);
+ if ((cp = context_find (buffer)) == NULL || *cp == '\0')
+ snprintf (buffer, sizeof(buffer), "%s-suffix-%s", invo_name,
+ ci->ci_type);
+ if ((cp = context_find (buffer)) != 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");
--------------------------| Sullivan Beck |---------------------------
mailto:[EMAIL PROTECTED] | Senior System Programmer
http://www.cise.ufl.edu/~sbeck | University of Florida
PH : (352) 392-1057 | CISE Department
Fax: (352) 392-1220 | CSE 314E
------------------------------------------------------------------------