Universal Mime Plugin 1.1 for Netscape
Copyright (C) 1996 Carl Shimer (harshaw@wpi.edu)
Update 1.1 from 1.0 by Michael J. Long (mjlong@mindspring.com)
All documentation and code has been updated by Michael J. Long.

This is a pretty simple program that supports embedded mime types in
Netscape.  I developed it because I wanted to listen to the midi music
that everyone has started to put on their web pages.

This program has not been extensively tested; there may be numerous bugs.

First thing you may want to do is edit the Makefile to meet your
system specifications.  The two main things you may want to change
are the NETSCAPE_DIR and the CONF_FILE variables.

Some other settings you may want to change are the STDOUT_FILE and
STDERR_FILE variables.  These variables control where stdout and
stderr messages are sent.  By default, these are set to /dev/null
and /tmp/mimeplugin.err.txt, respectively.  This means that all
stdout messages will go to the "bit bucket" and the stderr messages
will be logged to a file in the /tmp directory.

If you have the NPX_PLUGIN_PATH variable defined when you run
netscape, the variable NETSCAPE_DIR only effects where the plugin
and the default configuration file are installed.

To compile, type:
$> make

That should create the mimeplugin shared library (mimeplugin.so)
in the source directory.

To install, type:
make install

That should install the mimeplugin.so in the $(NETSCAPE_DIR)plugins/
directory.  It will also install the default configuration file as
$(NETSCAPE_DIR)$(CONF_FILE) (e.g., /usr/local/lib/netscape/mimeplugin.conf)

If you do not have a compiler available, you can run install and
install the precompiled plugin in the $(NETSCAPE_DIR/plugins
directory.  You can override the location where you would like
to install the plugin by changing the NETSCAPE_DIR and setting
the NPX_PLUGIN_PATH environment variable.  However, you cannot
override the name of the configuration file, that has already
been compiled into the plugin.

Keep in mind, $(NETSCAPE_DIR)plugins/ must either be in the NPX_PLUGIN_PATH
variable OR $(NETSCAPE_DIR) must be set to "/usr/local/lib/netscape/" or
"$(HOME)/.netscape/".

To see if the plugin is correctly installed, start netscape and go to
the "Help" menu, and choose "About Plugins".  If the plugin was
successfully installed, the plugin along with the settings in the
configuration file should show up correctly.

Configuration:

If you used a version <= 1.0, there is a configuration file conversion
utility available.  The conversion utility automatically converts an
old style configuration file to the new configuration file format.
Note:  perl 4.036 or greater is required to run this conversion utility

The syntax is:
	convertConfig.pl <configFile>

The above command will copy the old configuration file to <configFile>.old
and update the <configFile> to the new format.  That's it!

The configuration file has a very simple format and there are
just a few very basic rules for the configuration file:
	- any blank line or a line with the hash ('#') as the first
	  character is ignored
	- each line is a semi-colon (';') delimeted entry with the
	  following fields (in the following order):
		- MIME type of the form type/sub-type
		- a comma (',') list of extensions
		- the command line with "%s" being the space
		  holder for the data file name;  if %s is not in
		  the command line, the data file name is appended
		  to the command line as the last argument
		- an optional description for the entry;  if a
		  description is not provided, the default
		  description of 'Generic Linux Plug-in' is
		  used

The following lines register three MIME types with Netscape.

audio/midi;     mid, midi;    playmidi %s;               Plays MIDI files
audio/x-midi;   mid, midi;    playmidi %s;               Plays MIDI files
audio/wav;      wav;          /usr/local/bin/wavplay -q        

As you can tell, more than one MIME type can be associated with the
same extensions and/or application.

The command line can be one that is absolute (i.e., if there is a
slash ('/') in the application name) or just the application name.
If the application is not absolute, the application name is sought
in the PATH, if found it is executed, else an error will be printed.

Spaces are irrelevent, except for the description.  Of course, since the
description will be displayed in HTML, the extra spaces will be "eaten"
by the browser anyway.

Just like Netscape, it is possible to have global and personal
configuration files.  The global configuration file is first loaded
and then the local configuration file.  If there are any MIME types
in the local file that are the same as a MIME type in the global
configuration file, the entry in the local configuration file take
precedence.

Configuration files are found by using the NPX_PLUGIN_PATH environment
variable.  Each component of the variable is taken as a directory that
contains Netscape plugins.  The configuration file is appended to the
end of each directory and is then read.  For example, if the 
NPX_PLUGIN_PATH contained
"/usr/lib/netscape/plugins/:/home/username/.netscape/plugins/", the
first configuration file to be read would be
"/usr/lib/netscape/plugins/../mimeplugin.conf", the second would be
"/home/username/.netscape/plugins/../mimeplugin.conf".  Of course this
all assumes the name of the configuration file compiled in was
mimeplugin.conf and the NPX_PLUGIN_PATH was set in the environment
prior to running Netscape.  If the variable NPX_PLUGIN_PATH is not
set, the assumed value is
"/usr/local/lib/netscape/plugins/:~/.netscape/plugins/".

NOTE: The configuration file format is simple and the error checking
      is minimal.  If you put something strange in there or have some
      strange characters, it will may crash Netscape although I hope
      there is enough error checking to prevent it.

To get the error and/or output messages, see the settings of the
variables STDOUT_FILE and STDERR_FILE in the Makefile.

If you would like more debugging information, use the DEBUG variable
defined in the Makefile.  Since this is not yet cleanly implemented,
you will get messages displayed everywhere, sorry.
