Plugin Entry and Exit


Intorduction
You will need to implement a function called messiahEntry() so that messiah can load your plugin. This is just like the main() function of a normal C program; its where things start. You may also implement a function called messiahExit() which will get called when your plugin is being unloaded; unlike messiahEntry() this function is not required. Rather than hard coding the signatures of these functions you are advised to use the Entry Point Macros. These macros, _pluginEntry() and _pluginExit(), define the signatures of messiahEntry() and messiahExit() respectively. Using these macros will help to shield your code from changes in messiahAPI.
The entry and exit points for your plugin should be placed in your project's Main Plugin File.
PluginLifetime.gif

Entry Sequence
The fist thing that needs to be done when a plugin loads is a bit of setup. You will need to make sure that your plugin is compatible with the program that is loading it, you will also need to make sure that the API version is compatible. Next you'll need to provide a name for your plugin (note: this is the name for the whole plugin, not an individual Module). Finally you'll need to use the _API_GETAPIFUNC() macro, this will allow you to retrieve messiahAPI Components. Using the Plugin Entry Point Setup Macros you can:

// Check API VERSION
_API_CHECKVERSION(_MESSIAH_API_VERSION);

// Check the program
_API_CHECKPROGRAM(_MESSIAH_PROGRAM_STUDIO); // Only run in messiah:studio

// Set the plugin's name
_API_PLUGIN_NAME("YourPluginName");

// Set component retrieval function
_API_GETAPIFUNC;
After that you can retrieve the Components that you will be using. You can do this manually or you can get all of the Components and perform the above setup using one macro:

_MESSIAH_PLUGIN_ALL("YourPluginName");
Pretty easy, huh? You could also retrieve only selective components with other _MESSIAH_PLUGIN_* macros (see Components for details ). At this point you can begin to register your plugin's modules ( see Modules for details ).
Plugin Exit
This function, while not required, allows you to perform any cleanup that might be nescessary when your plugin unloads from messiah. This might be where you release any system resources (memory, file handles, threads etc.) that you might have aquired when your plugin was loaded.
Summary
So a typical PluginMain.c file might look something like:

#define _MAINPLUGIN_FILE
#include "YourPluginName.h"

_pluginEntry
{
        // Plugin Setup and Component Retrieval
        _MESSIAH_PLUGIN_ALL("YourPluginName");

        // Register Modules
        // ...

        return FX_PLUGIN_OK;
}

_pluginExit
{
        // Cleanup
        // ...
}


© 2003 pmG WorldWide, LLC.


www.projectmessiah.com

groups.yahoo.com/pmGmessiah

Last Updated on Thu Jul 10 04:49:37 2003