PMX_ENGINE Methods

destroy()
void (*destroy)(PMX_ENGINE e);
The destroy() method should be called to release all resources held by the PMX_ENGINE object. This destroys the embedded Perl interpreter. If the engine has been used to instantiate any PMX_MESSAGE , PMX_HASH or PMX_WEIGHT objects, then those must be destroyed prior to the destruction of the PMX_ENGINE object.
create_message()
PMX_ERROR (*create_message)(PMX_ENGINE e, PMX_MESSAGE *m);
Creates an instance of the default implementation of the PMX_MESSAGE object. The pmx_append_to_message() function can be used to add the actual message content to the object.
add_attribute()
PMX_ERROR (*add_attribute)(PMX_ENGINE e, const char *name, PMX_TYPE t,
                           const void *value, size_t sz, int replace);
Adds an attribute that is used to configure the engine and its plug-ins. The replace parameter indicates that all previous values for this parameter should be discarded. If the replace flag is 0 and the attribute is already set, the value will be added to a list of values for that attribute. (Certain attributes can have multiple values).
del_attribute()
PMX_ERROR (*del_attribute)(PMX_ENGINE e, const char *name, int all);
Deletes the specified attribute. If the all flag is set to 0, then only the first entry in the list of attribute values is deleted. If the all flag is set to a non-zero value, then all the values for that attribute will be deleted.
enumerate_attributes()
int (*enumerate_attributes)(PMX_ENGINE e, const char *name,
                            PMX_ATTRIBUTE_CB cb, void *host);
The engine (and its plug-ins) can be configured using attributes. Some attributes can have multiple values (all of the same PMX_TYPE).

The replace parameter to add_attribute() indicates that all previous values for this parameter should be discarded.

If the all flag to del_attribute() is 0, then only the first entry in the list of attribute values is deleted.

If an attribute of type PMX_TYPE_MESSAGE , PMX_TYPE_HASH or PMX_TYPE_WEIGHTS is added to the engine, then that object becomes owned by the engine and should no longer be accessed by the hosting application. The del_attribute() method invokes the destructors as necessary.

load_plugin()
PMX_ERROR (*load_plugin)(PMX_ENGINE e, const char *plugin);
Loads the specified spam detection plug-in, enabling it for use.
enumerate_loaded_plugins()
int (*enumerate_loaded_plugins)(PMX_ENGINE e, PMX_PLUGIN_CB cb, void *host);
Invokes the callback cb for each plug-in that has been loaded.
enumerate_plugins()
int (*enumerate_plugins)(PMX_ENGINE e, PMX_PLUGIN_CB cb, void *host);
The engine library includes a number of spam detection plug-ins. Only the plug-ins loaded into the engine are used to determine spam features and probabilities. A feature group must be loaded before its attributes are set or modified.
load_antispam_data()
PMX_ERROR (*load_antispam_data)(PMX_ENGINE e);
Load antispam data from core.datadir . This auto-loads all plug-ins required to run the data, declaring their attributes immediately. The application must set the core.datadir attribute before calling this method, so that the engine can find the asdb.antispam file.
scan_message()
PMX_ERROR (*scan_message)(PMX_ENGINE e, PMX_MESSAGE m, PMX_WEIGHTS w,
                          PMX_SCAN_CB cb, void *host);
The scan_message() method parses the message in the PMX_MESSAGE object, detecting spam features using the loaded plug-ins. Found features are reported to the PMX_SCAN_CB callback. They are accumulated with weights from PMX_WEIGHTS to determine a final spam probability rating, which is also reported to the callback. The callback can record these events for future use after scan_message() has returned.
compile()
PMX_ERROR (*compile)(PMX_ENGINE e);
The compile() method reloads all plug-ins and clears or refreshes any internally cached values. If any plug-in fails to initialize correctly, compile generates log messages describing the failure. If the core.compile attribute is set to true, calling scan_message() causes the engine to automatically call this method; failures are ignored internally.
create_hash()
PMX_ERROR (*create_hash)(PMX_ENGINE e, PMX_HASH *h, const char *file, int readonly);
The create_hash() method creates an instance of the default implementation of the PMX_HASH object. The current implementation uses a file to store the table.
Note
It is not safe to update the table while other processes or threads may be reading the same table.