BerkeleyDB

Gyepi SAM gyepi at praxis-sw.com
Thu Sep 19 05:01:33 CEST 2002


On Wed, Sep 18, 2002 at 07:28:43PM -0700, Adrian Otto wrote:
> > ESR initially tried the autodaemon approach, which
> > incurs that cost once, but decided the it was a bad idea and
> > instead accepted my DB3 patch.
> Once we have all the functionality in the system that we want, we should
> revisit this issue, and use some of the very good suggestions that have been
> discussed on this list. As long as we properly abstract the use of the
> BerkeleyDB code so that it can be easily replaced in the future, it should
> be safe to leave it in place.
> 
> I do advocate a limited scope effort to make abstractions for get_word_value
> and set_word_value types of operations. This is already present to some
> degree, but could be abstracted a little bit more to make future changes
> easier.

I sent a patch to ESR about a week ago, which abstracts the database calls so that one could
easily replace the database by implementating the interface. The patch will not apply
cleanly to the current cvs version so I need to rework it. Here's the header file
from my original implementation. I would certainly appreciate comments on this.

 
/* API for bogofilter datastore. If you write a datastore, it MUST have this interface */

#ifndef DATASTORE_H_GUARD
#define DATASTORE_H_GUARD

#include "bogofilter.h"

/* Initialize datastore.
   Return 0 on success, 1 otherwise.
   On input, list->name, list->file, list->count_file are set to correct values.
   On output, list->db and list->msgcount should be set to correct values on success.
*/
int datastore_init(wordlist_t *);

/* Increments freq for given key. */
void datastore_increment(wordlist_t *, char *,wordprop_t *);

/* Decrement count for a given word_prop_t, if it exists in the datastore. */
void datastore_decrement(wordlist_t *, char *,wordprop_t *);

/* get the count associated with a given word in a list */
int datastore_getcount(wordlist_t *, char *);

/* Allows the datastore to close files and clean up. */
void  datastore_deinit(wordlist_t *);

/* Dumps state of datastore to stdout */
int datastore_dump(char * /* filename */);

#endif



More information about the bogofilter-dev mailing list