int success = InitPlugin(hwPluginBase *self, hwPluginAPI *cl, STRPTR path);
InitPlugin()
implementation must fill out all fields of the
hwPluginBase
structure that is passed to it:
typedef struct _hwPluginBase { ULONG CapsMask; // [out] int Version; // [out] int Revision; // [out] int hwVersion; // [in/out] int hwRevision; // [in/out] STRPTR Name; // [out] STRPTR ModuleName; // [out] STRPTR Author; // [out] STRPTR Description; // [out] STRPTR Copyright; // [out] STRPTR URL; // [out] STRPTR Date; // [out] STRPTR Settings; // [out] STRPTR HelpFile; // [out] } hwPluginBase; |
Here is an explanation about the function of the different structure members:
CapsMask:
HWPLUG_CAPS_CONVERT
HWPLUG_CAPS_LIBRARY
HWPLUG_CAPS_IMAGE
HWPLUG_CAPS_ANIM
HWPLUG_CAPS_SOUND
HWPLUG_CAPS_VECTOR
HWPLUG_CAPS_VIDEO
HWPLUG_CAPS_SAVEIMAGE
HWPLUG_CAPS_SAVEANIM
HWPLUG_CAPS_SAVESAMPLE
HWPLUG_CAPS_REQUIRE
@REQUIRE
on it. See Require hook plugins for details. (V6.0)
HWPLUG_CAPS_DISPLAYADAPTER
HWPLUG_CAPS_TIMERADAPTER
HWPLUG_CAPS_REQUESTERADAPTER
HWPLUG_CAPS_FILEADAPTER
HWPLUG_CAPS_DIRADAPTER
HWPLUG_CAPS_AUDIOADAPTER
HWPLUG_CAPS_EXTENSION
HWPLUG_CAPS_NETWORKADAPTER
HWPLUG_CAPS_SERIALIZE
HWPLUG_CAPS_ICON
HWPLUG_CAPS_SAVEICON
HWPLUG_CAPS_IPCADAPTER
HWPLUG_CAPS_FONT
HWPLUG_CAPS_FILESYSADAPTER
You have to implement all functions for every capability bit you set in CapsMask
otherwise Hollywood will fail to load your plugin.
Version:
Revision:
hwVersion:
hwRevision:
Name:
ModuleName:
*.hwp
extension. If
file and module names do not match, Hollywood will refuse to load your plugin.
This may only contain ASCII characters which are allowed in file names.
Author:
Description:
Copyright:
URL:
NULL
.
Date:
NULL
. If set, it should
use the format "dd.mm.yy".
Settings:
InitPlugin()
. This will tell
you where the user has installed your plugin. If you set this member, the user will
be able to launch the external program from the Hollywood GUI. If your plugin
doesn't feature such a program, set this member to NULL
.
HelpFile:
InitPlugin()
. This will tell you where the user has
installed your plugin. If you set this member, the user will be able to open this
help file from the Hollywood GUI. If your plugin doesn't come with a help file,
set this member to NULL
.
Note that all string pointers you use to initialize the hwPluginBase
structure must stay valid until ClosePlugin() is called.
The second parameter that is passed to InitPlugin()
is a pointer to a
hwPluginAPI
vector which is the gateway to all plugin API functions
provided by Hollywood. Plugin API functions are grouped into several different
library bases like GfxBase
and SysBase
. Please note that
this parameter can be NULL
. If this is the case, your plugin should not initialize
itself but just fill out the hwPluginBase
structure and return True
.
If Hollywood passes NULL
in hwPluginAPI
it only wants to collect
information about your plugin without actually loading it.
Important: You have to be very careful about the plugin API functions you
call from your InitPlugin() implementation. This is because an older Hollywood
version might have called your InitPlugin()
function and if you try to call
newer plugin API functions that are unavailable in the Hollywood version that
has just called InitPlugin()
, your plugin will crash terribly. You always have
to check the hwVersion
and hwRevision
members of the hwPluginBase
structure
that is passed to your InitPlugin()
function before you call any of the plugin
APIs. These checks only have to be done in InitPlugin()
and ClosePlugin()
since they can be called by any Hollywood version. All the other functions of
your plugin will only be called if the host Hollywood version matches the one
you request in your InitPlugin()
implementation using the hwVersion
and hwRevision
members. InitPlugin()
and ClosePlugin(), however, may be
called by any arbitrary Hollywood version and the only assumption you can make
is that it will be at least Hollywood 5.0 which is calling you because 5.0 is
the version that introduced the new plugin system explained here. Please take
this advice very seriously because a plugin which does not cleanly work with
older Hollywood versions will also crash all executables compiled by these
previous Hollywood versions because they will usually also scan and load all
available plugins and if there is a plugin which isn't compatible with older
versions, projects compiled with older Hollywood versions will suddenly crash
badly.
Additionally, InitPlugin()
can also be called by Hollywood Designer. In that
case you have to be careful as well, because Hollywood Designer supports only
a subset of the official Hollywood plugin API so many function pointers inside
hwPluginBase
will be NULL
and you cannot call them. That is why your InitPlugin()
implementation also has to check whether it was called by Hollywood or by
Hollywood Designer and act accordingly then. See Designer compatibility for details.
The third parameter contains the full path to the plugin's location on the user's hard drive. This may be useful information if you need to load files from the plugin's directory or store preferences files in the plugin's directory, etc.
InitPlugin()
has to return either True
or False
to signal success or failure.
If it returns False
, ClosePlugin() won't ever be called on
this plugin.
NULL
(see above)True
or False
indicating whether initialization was successful