[c5c522c] | 1 | .\" $Id: libdspam.3,v 1.13 2011/06/28 00:13:48 sbajic Exp $ |
---|
| 2 | .\" -*- nroff -*- |
---|
| 3 | .\" |
---|
| 4 | .\" dspam3.9 |
---|
| 5 | .\" |
---|
| 6 | .\" Authors: Jonathan A. Zdziarski <jonathan@nuclearelephant.com> |
---|
| 7 | .\" Stevan Bajic <stevan@bajic.ch> |
---|
| 8 | .\" |
---|
| 9 | .\" Copyright (C) 2002-2012 DSPAM Project |
---|
| 10 | .\" All rights reserved |
---|
| 11 | .\" |
---|
| 12 | .TH libdspam 3 "Apr 17, 2010" "libdspam" "libdspam" |
---|
| 13 | |
---|
| 14 | .SH NAME |
---|
| 15 | libdspam - Core message processing and classification library for DSPAM |
---|
| 16 | .PP |
---|
| 17 | \fBDSPAM\fP Core Analyis Engine Functions |
---|
| 18 | |
---|
| 19 | .SH SYNOPSIS |
---|
| 20 | .nf |
---|
| 21 | .B #include <libdspam.h> |
---|
| 22 | .sp |
---|
| 23 | .BI "DSPAM_CTX *dspam_init(const char *" username ", const char *" group ", " |
---|
| 24 | .BI " const char *" home ", int " operating_mode ", u_int32_t " flags ");" |
---|
| 25 | .sp |
---|
| 26 | .BI "DSPAM_CTX *dspam_create(const char *" username ", const char *" group ", " |
---|
| 27 | .BI " const char *" home ", int " operating_mode ", u_int32_t " flags ");" |
---|
| 28 | .sp |
---|
| 29 | .BI "int dspam_addattribute(DSPAM_CTX *" CTX ", const char *" key ", " |
---|
| 30 | .BI " const char *" value ");" |
---|
| 31 | .sp |
---|
| 32 | .BI "int dspam_clearattributes(DSPAM_CTX *" CTX ");" |
---|
| 33 | .sp |
---|
| 34 | .BI "int dspam_attach(DSPAM_CTX *" CTX ", void *" dbh ");" |
---|
| 35 | .sp |
---|
| 36 | .BI "int dspam_process(DSPAM_CTX *" CTX ", const char *" message ");" |
---|
| 37 | .sp |
---|
| 38 | .BI "int dspam_getsource(DSPAM_CTX *" CTX ", char *" buf ", size_t " size ");" |
---|
| 39 | .sp |
---|
| 40 | .BI "int dspam_detach(DSPAM_CTX *" CTX ");" |
---|
| 41 | .sp |
---|
| 42 | .BI "int dspam_destroy(DSPAM_CTX *" CTX ");" |
---|
| 43 | .fi |
---|
| 44 | .SH DESCRIPTION |
---|
| 45 | \fBlibdspam\fP provides core message processing and classification |
---|
| 46 | functionality. |
---|
| 47 | .PP |
---|
| 48 | The \fBdspam_init()\fP function creates and initializes a new classification |
---|
| 49 | context and attaches the context to whatever backend storage facility was |
---|
| 50 | configured. The \fBuser\fP and \fBgroup\fP arguments provided are used to |
---|
| 51 | read and write information stored for the user and group specified. The |
---|
| 52 | \fBhome\fP argument is used to configure libdspam's storage around the |
---|
| 53 | base directory specified. The \fBmode\fP specifies the operating mode to |
---|
| 54 | initialize the classification context with and may be one of: |
---|
| 55 | .PP |
---|
| 56 | \fBDSM_PROCESS\fP Classify and learn the supplied message using whatever training mode is specified |
---|
| 57 | \fBDSM_CLASSIFY\fP Classify the supplied message only; do not learn or update any counters. |
---|
| 58 | \fBDSM_TOOLS\fP No processing, attach to storage only |
---|
| 59 | .PP |
---|
| 60 | The \fBflags\fP provided further tune the classification context for a specific |
---|
| 61 | function. Multiple flags may be OR'd together. |
---|
| 62 | .PP |
---|
| 63 | \fBDSF_UNLEARN\fP Unlearn the message |
---|
| 64 | \fBDSF_BIAS\fP Assign processor bias to unknown tokens |
---|
| 65 | \fBDSF_SIGNATURE\fP A binary signature is requested/provided |
---|
| 66 | \fBDSF_NOISE\fP Apply Bayesian Noise Reduction logic |
---|
| 67 | \fBDSF_WHITELIST\fP Use automatic whitelisting logic |
---|
| 68 | \fBDSF_MERGED\fP Merge group metadata with user's in memory |
---|
| 69 | .PP |
---|
| 70 | Upon successful completion, \fBdspam_init()\fP will return a pointer to a new |
---|
| 71 | \fBclassification context\fP structure containing a copy of the configuration |
---|
| 72 | passed into dspam_init(), a connected storage driver handle, and a set of |
---|
| 73 | preliminary user control data read from storage. |
---|
| 74 | .PP |
---|
| 75 | The \fBdspam_create()\fP function performs in exactly the same manner as |
---|
| 76 | the dspam_init() function, but does not attach to storage. Instead, the |
---|
| 77 | caller must also call \fBdspam_attach()\fP after setting any storage- |
---|
| 78 | specific attributes using \fBdspam_addattribute()\fP. This is useful for |
---|
| 79 | cases where the implementor would prefer to configure storage internally |
---|
| 80 | rather than having libdspam read a configuration from a file. |
---|
| 81 | .PP |
---|
| 82 | The \fBdspam_addattribute()\fP function is called to set attributes within |
---|
| 83 | the classification context. Some storage drivers support the use of passing |
---|
| 84 | specific attributes such as server connect information. The driver-independent |
---|
| 85 | attributes supported by DSPAM include: |
---|
| 86 | .PP |
---|
| 87 | \fBIgnoreHeader\fP Specify a specific header to ignore |
---|
| 88 | \fBLocalMX\fP Specify a local mail exchanger to assist in |
---|
| 89 | correct results from \fBdspam_getsource()\fP. |
---|
| 90 | .PP |
---|
| 91 | Only driver-dependent attributes need be set prior to a call to |
---|
| 92 | \fBdspam_attach()\fP. Driver-independent attributes may be set both before |
---|
| 93 | and after storage has been attached. |
---|
| 94 | .PP |
---|
| 95 | The \fBdspam_attach()\fP function attaches the storage interface to the |
---|
| 96 | classification context and alternatively established an initial connection with |
---|
| 97 | storage if \fBdbh\fP is \fBNULL\fP. Some storage drivers support only a |
---|
| 98 | NULL value for dbh, while others (such as mysql_drv, pgsql_drv, and |
---|
| 99 | sqlite_drv) allow an open database handle to be attached. This function |
---|
| 100 | should only be called after an initial call to \fBdspam_create()\fP and |
---|
| 101 | should never be called if using \fBdspam_init()\fP, as storage is |
---|
| 102 | automatically attached by a call to dspam_init(). |
---|
| 103 | .PP |
---|
| 104 | The \fBdspam_process()\fP function performs analysis of the \fBmessage\fP |
---|
| 105 | passed into it and will return zero on successful completion. If successful, |
---|
| 106 | CTX->result will be set to one of three classification results: |
---|
| 107 | .PP |
---|
| 108 | \fBDSR_ISSPAM\fP Message was classified as spam |
---|
| 109 | \fBDSR_ISINNOCENT\fP Message was classified as nonspam |
---|
| 110 | \fBDSR_ISWHITELISTED\fP Recipient was automatically whitelisted |
---|
| 111 | .PP |
---|
| 112 | Should the call fail, one of the following errors will be returned: |
---|
| 113 | .PP |
---|
| 114 | \fBEINVAL\fP An invalid call or invalid parameter used. |
---|
| 115 | \fBEUNKNOWN\fP Unexpected error, such as malloc() failure |
---|
| 116 | \fBEFILE\fP Error opening or writing to a file or file handle |
---|
| 117 | \fBELOCK\fP Locking failure |
---|
| 118 | \fBEFAILURE\fP The operation itself has failed |
---|
| 119 | .PP |
---|
| 120 | The \fBdspam_getsource()\fP function extracts the source sender from the |
---|
| 121 | message passed in during a call to \fBdspam_process()\fP and writes not more |
---|
| 122 | than \fBsize\fP bytes to \fBbuf\fP. |
---|
| 123 | .PP |
---|
| 124 | The \fBdspam_detach()\fP function can be called when a detachment from |
---|
| 125 | storage is desired, but the context is still needed. The storage driver |
---|
| 126 | is closed, leaving the classification context in place. Once the context |
---|
| 127 | is no longer needed, another call to \fBdspam_destroy()\fP should be |
---|
| 128 | made. If you are closing storage and destroying the context at the same |
---|
| 129 | time, it is not necessary to call this function. Instead you may call |
---|
| 130 | \fBdspam_destroy()\fP directly. |
---|
| 131 | .PP |
---|
| 132 | The \fBdspam_clearattributes()\fP function is called to clear any attributes |
---|
| 133 | previously set using \fBdspam_addattribute()\fP within the classification |
---|
| 134 | context. It is necessary to call this function prior to replacing any |
---|
| 135 | attributes already written. |
---|
| 136 | .PP |
---|
| 137 | The \fBdspam_destroy()\fP function should be called when the context is |
---|
| 138 | no longer needed. If a connection was established to storage internally, |
---|
| 139 | the connection is closed and all data is flushed and written. If a |
---|
| 140 | handle was attached, the handle will remain open. |
---|
| 141 | .PP |
---|
| 142 | .SH COPYRIGHT |
---|
| 143 | Copyright \(co 2002\-2012 DSPAM Project |
---|
| 144 | .br |
---|
| 145 | All rights reserved. |
---|
| 146 | .br |
---|
| 147 | |
---|
| 148 | For more information, see http://dspam.sourceforge.net. |
---|
| 149 | |
---|
| 150 | .SH "SEE ALSO" |
---|
| 151 | .BR dspam (1), |
---|
| 152 | .BR dspam_admin (1), |
---|
| 153 | .BR dspam_clean (1), |
---|
| 154 | .BR dspam_crc (1), |
---|
| 155 | .BR dspam_dump (1), |
---|
| 156 | .BR dspam_logrotate (1), |
---|
| 157 | .BR dspam_merge (1), |
---|
| 158 | .BR dspam_stats (1), |
---|
| 159 | .BR dspam_train (1) |
---|