Database Abstraction

Doug Beardsley dgbeards at southern.edu
Thu Sep 19 21:19:51 CEST 2002


I really like this interface that Gyepi is proposing.  I think we should
go to it or something similar.  I think it will help quite a bit.  An OO
approach is another options, but I don't see what we will gain from
doing that way that we won't get by doing it this way.  Any other
thoughts?

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