libdspam(3)

πŸ“¦ version 3.10.2, in nixos 26.05, nixpkgs unstable

🌸 NAME 🌸

okay so bestie, this is the libdspam(3) manual page β€” the entry for libdspam, the core message processing and classification library for DSPAM. it's also got the subtitle DSPAM Core Analyis Engine Functions (spelled exactly like that, no cap πŸ™ˆ).


✨ SYNOPSIS ✨

here's the whole function lineup. signatures stay exactly as-is because we do not mess with code, periodt:

#include <libdspam.h>

DSPAM_CTX *dspam_init(const char *username, const char *group,
  const char *home, int operating_mode, u_int32_t flags);

DSPAM_CTX *dspam_create(const char *username, const char *group,
  const char *home, int operating_mode, u_int32_t flags);

int dspam_addattribute(DSPAM_CTX *CTX, const char *key,
  const char *value);

int dspam_clearattributes(DSPAM_CTX *CTX);

int dspam_attach(DSPAM_CTX *CTX, void *dbh);

int dspam_process(DSPAM_CTX *CTX, const char *message);

int dspam_getsource(DSPAM_CTX *CTX, char *buf, size_t size);

int dspam_detach(DSPAM_CTX *CTX);

int dspam_destroy(DSPAM_CTX *CTX);

πŸ’… DESCRIPTION πŸ’…

libdspam provides core message processing and classification functionality. that's the whole vibe: it's the library doing the message-classification main character work 🫢.

dspam_init() creates and initializes a new classification context and attaches that context to whatever backend storage facility was configured. the username and group arguments provided are used to read and write information stored for the user and group specified. the home argument is used to configure libdspam's storage around the base directory specified. the operating_mode specifies the operating mode to initialize the classification context with, and it may be one of:

  • DSM_PROCESS β€” classify and learn the supplied message using whatever training mode is specified ✨
  • DSM_CLASSIFY β€” classify the supplied message only; do not learn or update any counters 🚫
  • DSM_TOOLS β€” no processing, attach to storage only 🧰

the flags provided further tune the classification context for a specific function. multiple flags may be OR'd together, bestie πŸ’….

  • DSF_UNLEARN β€” unlearn the message
  • DSF_BIAS β€” assign processor bias to unknown tokens
  • DSF_SIGNATURE β€” a binary signature is requested/provided
  • DSF_NOISE β€” apply Bayesian Noise Reduction logic
  • DSF_WHITELIST β€” use automatic whitelisting logic
  • DSF_MERGED β€” merge group metadata with user's in memory

upon successful completion, dspam_init() will return a pointer to a new classification context structure containing a copy of the configuration passed into dspam_init(), a connected storage driver handle, and a set of preliminary user control data read from storage. it's giving main character context structure, honestly πŸ‘‘.

dspam_create() performs in exactly the same manner as dspam_init(), but does not attach to storage. instead, the caller must also call dspam_attach() after setting any storage-specific attributes using dspam_addattribute(). this is useful for cases where the implementor would prefer to configure storage internally rather than having libdspam read a configuration from a file πŸ¦‹.

dspam_addattribute() is called to set attributes within the classification context. some storage drivers support the use of passing specific attributes such as server connect information. the driver-independent attributes supported by DSPAM include:

  • IgnoreHeader β€” specify a specific header to ignore
  • LocalMX β€” specify a local mail exchanger to assist in correct results from dspam_getsource()

only driver-dependent attributes need be set prior to a call to dspam_attach(). driver-independent attributes may be set both before and after storage has been attached 🌈.

dspam_attach() attaches the storage interface to the classification context and alternatively established an initial connection with storage if dbh is NULL. some storage drivers support only a NULL value for dbh, while others (such as mysql_drv, pgsql_drv, and sqlite_drv) allow an open database handle to be attached. this function should only be called after an initial call to dspam_create() and should never be called if using dspam_init(), as storage is automatically attached by a call to dspam_init().

bestie, this is one of those "read the rule twice" situations: dspam_attach() is for the dspam_create() path, not the dspam_init() path πŸ’€.

dspam_process() performs analysis of the message passed into it and will return zero on successful completion. if successful, CTX->result will be set to one of three classification results:

  • DSR_ISSPAM β€” message was classified as spam
  • DSR_ISINNOCENT β€” message was classified as nonspam
  • DSR_ISWHITELISTED β€” recipient was automatically whitelisted

should the call fail, one of the following errors will be returned:

  • EINVAL β€” an invalid call or invalid parameter used.
  • EUNKNOWN β€” unexpected error, such as malloc() failure
  • EFILE β€” error opening or writing to a file or file handle
  • ELOCK β€” locking failure
  • EFAILURE β€” the operation itself has failed

dspam_getsource() extracts the source sender from the message passed in during a call to dspam_process() and writes not more than size bytes to buf πŸŽ€.

dspam_detach() can be called when a detachment from storage is desired, but the context is still needed. the storage driver is closed, leaving the classification context in place. once the context is no longer needed, another call to dspam_destroy() should be made. if you are closing storage and destroying the context at the same time, it is not necessary to call this function. instead you may call dspam_destroy() directly πŸ’–.

dspam_clearattributes() is called to clear any attributes previously set using dspam_addattribute() within the classification context. it is necessary to call this function prior to replacing any attributes already written 🌸.

dspam_destroy() should be called when the context is no longer needed. if a connection was established to storage internally, the connection is closed and all data is flushed and written. if a handle was attached, the handle will remain open πŸ¦‹.


Copyright Β© 2002-2012 DSPAM Project All rights reserved.

for more information, see http://dspam.sourceforge.net.


πŸ¦‹ SEE ALSO πŸ¦‹

xoxo, your libdspam(3) bestie πŸ’– β€” source/version: libdspam Β· date: Apr 17, 2010 Β· manual: libdspam(3). bye bestie, go classify something iconic βœ¨πŸ¦‹

πŸ“¦ where this page comes from