Implementation Under Unix Operating Systems

Parts of the mailcap file format are operating system dependent. Mostly, this is due to the semantics of local command execution. There are a few other issues, such as where the mailcap file is kept.

Under Unix operating systems, all program commands in the view, compose, composetyped, edit, print, test fields are represented as complete program command lines (with parameters) as if they were implicitly preceded by “/bin/sh -c”.

The location of the mailcap file is defined for Unix. First, any application looking for a mailcap file should check the MAILCAPS environment variable. Next, it should check at least the following path, although a longer path may be checked as well:

$HOME/.mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap

Under Unix, some handy substitution variables may be used in a mailcap file, as shown in Table 8-2. They are meant to allow program command lines and other fields to take the appropriate temporary filename, Content-type, or Content-type parameters as arguments at the time the mailcap file is parsed.

Table 8-2. Unix Argument Substitutions

Tag

Description

%s

Substitute a temporary filename.

%t

Substitute the Content-type.

%{<parameter>}

Substitute the named parameter to the Content-type.

Anytime a %s symbol is found in a program command line, it is replaced by the name of the temporary file generated. Suppose that we have some data with a Contenttype of image/jpeg. We get the data handler from the mailcap file, and note that the line looks like this:

image/jpeg;/usr/X11R6/bin/xv %s

Since xv takes filenames as arguments, we save our image/jpeg data to a temporary file (which we name), and call xv with that name substituted where the %s occurs in the command line.

The Content-type itself may be substituted with the %t symbol. This can be useful for data handlers that deal with more than one type of data and where the Contenttype is a command-line argument to the handler.

Parameters to Content-types may be substituted into program command lines by use of the %{} syntax. For example, %{boundary} yields the MIME boundary for a Content-type of multipart/mixed.

If you wish to use a literal percentage sign (%) in a mailcap line, you can do so by escaping the sign with a backslash (\%). No substitution will then occur. Quotes (") and semicolons (;) may also be escaped with backslashes to allow for their use.

An example Unix mailcap file might look like this:

# # This is a sample mailcap file to handle MIME Content-types # for Web browsers and mail user
agents. # # Handle Adobe PDF documents by sending them to an Adobe # Acrobat reader, but only
if X is running.
application/pdf;/usr/local/bin/xpdf %s;test=/usr/local/bin/testX

# Handle JPEG, GIF and other images with xv.
image/*;/usr/X11R6/bin/xv %s

# Handle RealAudio files
audio/x-pn-realaudio; rvplayer %s

# Here is a multiline entry that shows how to print # Postscript documents. Note that automatically
handling # Postscript documents can be dangerous! # Note the escaped semicolon in the view
command.

application/postscript;                                
       lpr %s ; echo SENT FILE TO PRINTER;            
       description="A Postscript File";                
       compose="getfilename Postscript %s"

# Two ways to decrypt PGP mail
application/pgp;                                       
       pgp -f < %s | metamail; needsterminal;          
       test=test %{encapsulation}=entity               
application/pgp; pgp %s; needsterminal
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.36.141