RE: [dspam-users] Example.c File

From: . kibble . <jelly_bean_junky@hotmail.com>
Date: Wed Sep 07 2005 - 17:11:47 EDT

Excellent, thanks for the pointer, I will do this over the next few days as
I'm away but will take the laptop with me and a copy of dspam's source code
to review...

>From: "Russ Fink" <russfink@hotmail.com>
>To: jelly_bean_junky@hotmail.com, dspam-users@lists.nuclearelephant.com
>Subject: RE: [dspam-users] Example.c File
>Date: Wed, 07 Sep 2005 11:21:22 -0400
>
>Sorry, I have been out for a few days.
>
>From your code snippet, I don't see where SIG is getting populated, just
>declared. The code sets CTX->signature to &SIG, but SIG has nothing in it
>- just an empty structure at this point. You need to populate it using the
>driver of MySQL.
>
>My advice, what I would have to do, is look at how dspam.c does it. Grep
>for "signature" and you should find the answer.
>
>In generic terms, the spam "signature" is really a unique identifier
>assigned by the back-end database implementation. In the case of sqlite3,
>it takes a hash of the system time and date and assigns that as the
>signature of the message. Of course, this assumes only one message is
>processed at a given time/date, and I believe this will be changed at some
>point in the future. The "CTX->signature" is a pointer to the signature
>structure, which is created from this hash by a call.
>
>If you're using pristine mode, no signature is needed, and no signature is
>generated.
>
>Spend some time with dspam.c and it should help. I think that's kinda what
>everyone else does that programs directly to the API.
>
>Russ
>
>>>>int report_spam(int spamflag) {
>>>>
>>>> int sflag = 0;
>>>> char * message = malloc(1);
>>>> DSPAM_CTX * CTX = NULL; /** DSPAM Context */
>>>> struct _ds_spam_signature SIG; /** Example signature */
>>>>
>>>> message = read_emailmem(message);
>>>>
>>>> switch (spamflag) {
>>>> case SPAMREPT: /** set up the context for error correction as
>>>>spam */
>>>> log_write(0, LOG_MAIN, "LOG: SPAMREPT function reached");
>>>> CTX = dspam_create((char *)sender_address, NULL, NULL,
>>>>DSM_PROCESS, DSF_CHAINED);
>>>> CTX = attach_ctx_dbaccess(CTX);
>>>> if (CTX == NULL) {
>>>> log_write(0, LOG_MAIN, "ERROR: dspam_create failed!\n");
>>>> sflag = 1;
>>>> }
>>>> CTX->classification = DSR_ISSPAM;
>>>> CTX->source = DSS_ERROR;
>>>> CTX->algorithms = DSA_GRAHAM | DSA_BURTON | DSP_GRAHAM;
>>>> break;
>>>> case FALSEPOS: /** set up the context for error correction as
>>>>innocent */
>>>> log_write(0, LOG_MAIN, "LOG: FALSEPOS function reached");
>>>> CTX = dspam_create((char *)sender_address, NULL, NULL,
>>>>DSM_PROCESS, DSF_CHAINED | DSF_SIGNATURE);
>>>> CTX = attach_ctx_dbaccess(CTX);
>>>> if (CTX == NULL) {
>>>> log_write(0, LOG_MAIN, "ERROR: dspam_create failed!\n");
>>>> sflag = 1;
>>>> }
>>>> CTX->classification = DSR_ISINNOCENT;
>>>> CTX->source = DSS_ERROR;
>>>> CTX->algorithms = DSA_GRAHAM | DSA_BURTON | DSP_GRAHAM;
>>>> CTX->signature = &SIG; /** Attach the signature to
>>>>the context */
>>>> break;
>>>> default: /** no reporting required, scan for spam perhaps ?
>>>>*/
>>>> log_write(0, LOG_MAIN, "report_spam -> no reporting
>>>>required");
>>>> break;
>>>> }
>>>>
>>>> log_write(0, LOG_MAIN, "LOG: Processing spam...");
>>>> if (dspam_process(CTX, message) != 0) { /** Call DSPAM */
>>>> log_write(0, LOG_MAIN, "ERROR: dspam_process failed!");
>>>> sflag = 1;
>>>> }
>>>>
>>>> log_write(0, LOG_MAIN, "ERROR: report_spam: dspam_destroy
>>>>beginning");
>>>> dspam_destroy(CTX); /** Destroy the context */
>>>>
>>>> memset(message, 0x0, sizeof(message));
>>>> free(message);
>>>> memset(&CTX, 0x0, sizeof(CTX));
>>>> free(CTX);
>>>>
>>>> if (sflag == 0) {
>>>> log_write(0, LOG_MAIN, "<= %s [%s] P=%s A=%s:%s",
>>>> (char *)sender_address, (char *)sender_host_address, (char
>>>>*)received_protocol,
>>>> (char *)sender_host_authenticated, (char *)sender_address);
>>>> log_write(0, LOG_MAIN, "=> (null) <%s> R=system_localuser
>>>>T=local_delivery",
>>>> (char *)recipients_list[0].address);
>>>> }
>>>>
>>>> /** if we are reporting, which is pretty much so if you reach here,
>>>>we blackhole the email */
>>>> recipients_count = 0;
>>>>
>>>> return(sflag);
>>>>} /** report_spam */
>
>

_________________________________________________________________
Be the first to hear what's new at MSN - sign up to our free newsletters!
http://www.msn.co.uk/newsletters
Received on Wed Sep 7 17:12:58 2005

This archive was generated by hypermail 2.1.8 : Thu Sep 29 2005 - 13:51:29 EDT