smf_modules.h File Reference

The module-interface of the spmfilter. More...

#include <stdint.h>
#include "smf_settings.h"
#include "smf_session.h"
#include "smf_list.h"
Include dependency graph for smf_modules.h:

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_Tsmf_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_Tsmf_module_create (const char *name)
 Creates a new module.
 
SMFModule_Tsmf_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)
 

Detailed Description

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.

Function Documentation

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.

Parameters
nameThe name of the module. This is also the name of the library.
Returns
The module-instance. If the shared-library could not be loaded, NULL is returned.
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.

Parameters
nameThe name of the module.
callbackThe callback which is invoked. If you pass NULL here, then it still tries to load the shared-object (as fallback).
Returns
The module-instance. If the callback is NULL and the shared-object could not be located, NULL is returned.
See Also
smf_module_create
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.

Parameters
moduleThe module be be destroy
Returns
On success 0 is returned
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.

Parameters
settingsthe settiogs.
moduleThe module is invoke
sessionThe session os passed to the load-function of the module
Returns
If the load-function could be located, then the return-code of the load-invocation is returned. Otherwise -1 is returned.
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