These are the source code for the plugins for EvenMore. They are written in the
AmigaE and ECX programming languages, but there is no reason why you should not
be able to create plugins using any programming language.
USAGE
=====
These source codes have been uploaded to Aminet so that others can see how to
create their own plugins for EvenMore. You are free to use and modify this code
for your own personal use. The only thing I would ask is, if you are interested
in writing a plugin for EvenMore, to let me know so I can put it up on my
website. If you do want to use some of this code for your own programming, I
have no objection to that, so long as you mention where you got it from in your
documentation. Apart from some example code taken from the ROM Kernel manuals,
this is all my own work, and represents many years work. I also take no
responsibility for any bugs left in it!
THE PLUGIN SYSTEM
=================
The old EvenMore plugin system used the Amiga library system. EvenMore would
open these libraries sequentially and check to see if the plugin criteria
matched those of the open file. If a match was found, EvenMore passed the file
onto the plugin, which then processed the file and returned the results. This
system worked well for AmigaE, but when I moved onto the ECX compiler to make a
MorphOS version of EvenMore, I found it was not able to compile Amiga libraries.
So I had to come up with an alternative method of creating the plugins. Now each
plugin is compiled as an executable file. When EvenMore opens, it launches these
plugins. Each plugin opens a port through which it communicates with the main
program, and passes information to and from it as necessary. While this uses up
a little more memory than your average plugin system, it is quite fast as the
plugin code is always resident in memory. The only real processor power being
used is to convert the file.
PLUGIN TYPES
============
There are several main types of file plugin that can be created for EvenMore.
Each of these has a specific ID tag. They are as follows, and are called by
EvenMore in this order.
FTYP
|
No-+-Yes
|
ARCH
|
No-+-Yes
| |
PACK |
| |
FILE |
| |
No-+-Yes-+
| |
DTYP |
| |
No-+-Yes----+
| |
GENE |
| |
No-+-Yes-------+
| |
+--------------+
|
FRMT
FTYP
The FTYP plugins will be called before the file is opened by EvenMore. These
plugins just check the extension name of the file to see if it needs to be
passed onto another program specified in the filetypes.txt file rather than
opened in EvenMore. For example, PDF files, picture or sound files.
ARCH
ARCH plugins can be used for browsing archived files and directories. EvenMore
does not open the file at this stage, but passes only the name of the file onto
the plugin. It is then up to the plugin to analyze the file and construct a
textual version of its contents if necessary. There is a subfilename string
which can be set in order to extract and browse a particular file in the
archive.
PACK
PACK plugins enable EvenMore to open compressed files such as XPK and
PowerPacker. They are called before the main file conversion plugins. EvenMore
opens the file and passes it onto these plugins. The plugin then analyzes it,
performs any necessary operations and returns the buffer back to the main
program. EvenMore then passes the updated buffer onto the file conversion
plugins.
FILE
The FILE plugins are used to convert one document format into another. For
example, MSWord files, AmigaGuide, etc into plain text. If the file does not
match the criteria of any of these plugins, it is passed onto the following two
plugin types.
DTYP
The DTYP plugins will check the file against any text datatypes the user
has installed on the operating system. As these datatypes generally do not allow
for ANSI escape code sequences, they are called after the main file conversion
plugins. But if there is a particular filetype you want the DTYP plugin to
handle instead of the FILE plugin, it is just a case of deleting that particular
FILE plugin.
GENE
If the file does not match the criteria of any of the file conversion or
datatype plugins, it will be checked against the generic plugins. These are
fall-back plugins which will analyze the file for ASCII text and discard
anything that is unprintable. Sometimes this works for more obscure document
formats that do not have a particular plugin made for them.
FRMT
EvenMore will then pass the file onto the FRMT plugins for formatting. Even if a
plugin has already been found for the file, EvenMore will still pass it on to
these plugins. These will make minor formatting changes to the document. One
such plugin is the wordwrapping plugin, which ensures that the document appears
in a format that is easy to read.
The other two plugins that EvenMore uses are for controlling the preferences.
MPRF
The MPRF plugin holds the main GUI and settings for the EvenMore preference
window.
PREF
The PREF plugins are used for creating additional pages in the preference window
to store settings for specific plugins.
HOW THEY WORK
=============
The plugins are executable files that EvenMore launches whenever the main
program starts. EvenMore opens a special port called EVENMOREP and then executes
the plugin. The plugin initializes itself and passes a message back to the
EVENMOREP port to signal that it is ready.
When EvenMore is opening a file, it will scan through all the plugin ports,
passing a status ID and file information to them. The status ID tells the plugin
what function to execute in relation to the file.
STATUS
-1 - Close the plugin, EvenMore is quitting
0 - Not used
1 - Initialize the plugin, open libraries, etc if necessary
2 - Examine the filename or file contents to see if we can process it
RETURNS:
FALSE - The file did not match the criteria specified
TRUE - A match has been found but we do not need to allocate memory, just
modify the original text buffer in place
1 - Signal EvenMore to allocate an area of memory for a new file
buffer
2 - Signal EvenMore to create a linked list for a new file buffer
3 - Run the file conversion routine on the file
4 - Load the plugin preference file
5 - Save the plugin preference file
6 - Open the plugin preference GUI
7 - Return plugin title for the information page
EvenMore used to always allocate a section of memory for file conversion, but
this was unstable because there was a chance the output format could overrun the
buffer allocated. I have tried to get as many of the plugins to use the linked
list format as possible, as this memory is dynamically allocated.
I hope this source code can be of some benefit to the Amiga community.
|