OpenCBM
Macros | Functions
plugin.c File Reference

Program to install and uninstall the OPENCBM driver; handling of plugins. More...

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <direct.h>
#include <getopt.h>
#include "archlib.h"
#include "archlib-windows.h"
#include "cbmioctl.h"
#include "configuration.h"
#include "version.h"
#include "arch.h"
#include "i_opencbm.h"
#include "libmisc.h"
#include "debug.h"
#include "instcbm.h"
#include "opencbm-plugin.h"

Go to the source code of this file.

Macros

#define DBG_USERMODE
 
#define DBG_PROGNAME   "INSTCBM.EXE"
 
#define DBG_IS_DEBUG_C
 
#define PLUGIN_PREFIX   "opencbm-"
 name prefix for the plugin executable More...
 
#define PLUGIN_SUFFIX   ".dll"
 name suffix for the plugin executable More...
 

Functions

void PluginListFree (cbm_install_parameter_t *InstallParameter)
 Free all the memory occupied by plugin management. More...
 
BOOL ProcessPluginCommandlineAndAddIt (cbm_install_parameter_t *InstallParameter, const char *const PluginName, int Argc, char *const Argv[])
 Process the command-line parameters for a plugin and add that plugin to the plugin list. More...
 
BOOL get_all_plugins (cbm_install_parameter_t *InstallParameter)
 Get all the plugins. More...
 
BOOL get_all_installed_plugins (cbm_install_parameter_t *InstallParameter)
 Get all the installed plugins. More...
 
BOOL PluginForAll (cbm_install_parameter_t *InstallParameter, PluginForAll_Callback_t *Callback, void *Context)
 Execute a callback function for all plugins in the plugin list. More...
 

Detailed Description

Program to install and uninstall the OPENCBM driver; handling of plugins.



Author
Spiro Trikaliotis

Definition in file plugin.c.

Macro Definition Documentation

#define DBG_IS_DEBUG_C

This file is "like" debug.c, that is, define some variables

Definition at line 44 of file plugin.c.

#define DBG_PROGNAME   "INSTCBM.EXE"

The name of the executable

Definition at line 41 of file plugin.c.

#define DBG_USERMODE

Mark: We are in user-space (for debug.h)

Definition at line 38 of file plugin.c.

#define PLUGIN_PREFIX   "opencbm-"

name prefix for the plugin executable

Remarks
The "main" executable for the plugin has to be named as follows:

If the plugin if named "AAA", the plugin file must be named

PLUGIN_PREFIX "AAA" PLUGIN_SUFFIX

Definition at line 61 of file plugin.c.

Referenced by get_all_plugins().

#define PLUGIN_SUFFIX   ".dll"

name suffix for the plugin executable

Remarks
The "main" executable for the plugin has to be named as follows:

If the plugin if named "AAA", the plugin file must be named

PLUGIN_PREFIX "AAA" PLUGIN_SUFFIX

Definition at line 72 of file plugin.c.

Referenced by get_all_plugins().

Function Documentation

BOOL get_all_installed_plugins ( cbm_install_parameter_t InstallParameter)

Get all the installed plugins.

This function searches all installed plugins and adds an entry for that plugin to the plugin list.

Parameters
InstallParameterThe install parameters which contain the plugin list.
Returns
TRUE on error, else FALSE.
Remarks
An installed plugin is a plugin which is mentioned in the configuration file.

Definition at line 596 of file plugin.c.

References DBG_PREFIX, DBG_PRINT, FUNC_ENTER, FUNC_LEAVE_BOOL, LoadLocalOpenCBMDll(), opencbm_configuration_close(), and opencbm_plugin_get_all_plugin_names().

BOOL get_all_plugins ( cbm_install_parameter_t InstallParameter)

Get all the plugins.

This function searches for all plugins available and adds an entry for that plugin to the plugin list.

Parameters
InstallParameterThe install parameters which contain the plugin list.
Returns
TRUE on error, else FALSE.
Remarks
An available plugin is a plugin in the current directory. A plugin is determined by all files that match the pattern PLUGIN_PREFIX "*" PLUGIN_SUFFIX.

Definition at line 486 of file plugin.c.

References cbmlibmisc_strfree(), FUNC_ENTER, FUNC_LEAVE_BOOL, PLUGIN_PREFIX, and PLUGIN_SUFFIX.

BOOL PluginForAll ( cbm_install_parameter_t InstallParameter,
PluginForAll_Callback_t Callback,
void *  Context 
)

Execute a callback function for all plugins in the plugin list.

Parameters
InstallParameterThe install parameters which contain the plugin list.
CallbackCallback function to execute for each plugin.
ContextContext data to give to the Callback function. This data is Callback specific; it is not interpreted in any way by this function here.
Returns
TRUE if an error occurred (that is, a callback returned TRUE); else FALSE:
Remarks
If a callback function returns TRUE, this indicates an error. In this case, all subsequent plugins will not be processed.

Definition at line 663 of file plugin.c.

References FUNC_ENTER, and FUNC_LEAVE_BOOL.

void PluginListFree ( cbm_install_parameter_t InstallParameter)

Free all the memory occupied by plugin management.

This function frees all the memory that was needed in order to remember plugins and their data.

Parameters
InstallParameterThe install parameters from which to free the plugin list.
Remarks
The plugin functions are not multi-thread safe!

Definition at line 214 of file plugin.c.

References DBG_ASSERT, FUNC_ENTER, and FUNC_LEAVE.

Referenced by main().

BOOL ProcessPluginCommandlineAndAddIt ( cbm_install_parameter_t InstallParameter,
const char *const  PluginName,
int  Argc,
char *const  Argv[] 
)

Process the command-line parameters for a plugin and add that plugin to the plugin list.

This function lets the specified plugin process its own command-line parameters. Afterwards, an entry for that plugin with the plugin-specific data is added to the plugin list.

Parameters
InstallParameterThe install parameters which contain the plugin list.
PluginNameThe name of the plugin.
ArgcThe (remaining) argc value, as if given to int main(int, char **);
ArgvThe (remaining) argv value, as if given to int main(int, char **);
Returns
TRUE on error, else FALSE.

Definition at line 447 of file plugin.c.

References FUNC_ENTER, and FUNC_LEAVE_BOOL.