The module-interface of the spmfilter. More...
Go to the source code of this file.
Data Structures | |
struct | SMFModule_T |
Defines a module. More... | |
struct | SMFProcessQueue_T |
Typedefs | |
typedef int(* | ModuleLoadFunction )(SMFSettings_T *settings, SMFSession_T *session) |
typedef int(* | LoadEngine )(SMFSettings_T *settings) |
Functions | |
SMFProcessQueue_T * | smf_modules_pqueue_init (int(*loaderr)(SMFSettings_T *settings, SMFSession_T *session), int(*processerr)(SMFSettings_T *settings, SMFSession_T *session, int retval), int(*nhoperr)(SMFSettings_T *settings, SMFSession_T *session)) |
SMFModule_T * | smf_module_create (const char *name) |
Creates a new module. | |
SMFModule_T * | smf_module_create_callback (const char *name, ModuleLoadFunction callback) |
Creates a new new module, which invokes the given callback. | |
int | smf_module_destroy (SMFModule_T *module) |
Destroys the module-instance again. | |
int | smf_module_invoke (SMFSettings_T *settings, SMFModule_T *module, SMFSession_T *session) |
Invokes the module. | |
int | smf_modules_process (SMFProcessQueue_T *q, SMFSession_T *session, SMFSettings_T *settings) |
int | smf_modules_deliver_nexthop (SMFSettings_T *settings, SMFProcessQueue_T *q, SMFSession_T *session) |
int | smf_modules_flush_dirty (SMFSettings_T *settings, SMFSession_T *session, SMFList_T *initial_headers) |
int | smf_modules_engine_load (SMFSettings_T *settings) |
The module-interface of the spmfilter.
Each message is processed in a new session, with unique session id. The session data itself is stored in a SMFSession_T object, whereas the email content is stored on disk instead, but connection informations and message headers are hold in memory. If you need to modify an email in the current session, you have to use the session functions.
If a header of a session object has been modified, the session will be marked as "dirty" - that means the header will be flushed to disk before the final delivery is initialized, to keep the message in sync with the modified data.
SMFModule_T* smf_module_create | ( | const char * | name | ) |
Creates a new module.
The module is a shared-object located in the library-path configured during the build of the smpfilter. If name is the path of the shared-library, then the path is not resolved and the library is laoded directly.
name | The name of the module. This is also the name of the library. |
SMFModule_T* smf_module_create_callback | ( | const char * | name, |
ModuleLoadFunction | callback | ||
) |
Creates a new new module, which invokes the given callback.
Instead of loading an external shared-object, a invocatio of smf_module_invoke() will invoke the given callback.
name | The name of the module. |
callback | The callback which is invoked. If you pass NULL here, then it still tries to load the shared-object (as fallback). |
int smf_module_destroy | ( | SMFModule_T * | module | ) |
Destroys the module-instance again.
All the memory allocated for the moduke is released again, unloads the module's shared-library.
module | The module be be destroy |
int smf_module_invoke | ( | SMFSettings_T * | settings, |
SMFModule_T * | module, | ||
SMFSession_T * | session | ||
) |
Invokes the module.
The functions locates the load
-symbol from the module's shared-object. The load-function must be declared like ModuleLoadFunction and should return 0 on success.
settings | the settiogs. |
module | The module is invoke |
session | The session os passed to the load-function of the module |
int smf_modules_deliver_nexthop | ( | SMFSettings_T * | settings, |
SMFProcessQueue_T * | q, | ||
SMFSession_T * | session | ||
) |
deliver a message to the nexthop
int smf_modules_flush_dirty | ( | SMFSettings_T * | settings, |
SMFSession_T * | session, | ||
SMFList_T * | initial_headers | ||
) |
Flush modified message headers to queue file
SMFProcessQueue_T* smf_modules_pqueue_init | ( | int(*)(SMFSettings_T *settings, SMFSession_T *session) | loaderr, |
int(*)(SMFSettings_T *settings, SMFSession_T *session, int retval) | processerr, | ||
int(*)(SMFSettings_T *settings, SMFSession_T *session) | nhoperr | ||
) |
initialize the process queue
int smf_modules_process | ( | SMFProcessQueue_T * | q, |
SMFSession_T * | session, | ||
SMFSettings_T * | settings | ||
) |
load all modules and run them