Database Abstraction

Doug Beardsley dgbeards at southern.edu
Thu Sep 26 21:41:18 CEST 2002


Has anyone implemented this database abstraction layer yet?

Doug

> On Wed, Sep 18, 2002 at 11:01:33PM -0400, Gyepi SAM wrote:
> > 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