Select db backend at runtime
Fast Bayesian spam filter along lines suggested by Paul Graham
Brought to you by:
m-a
As-is, one has to select a db backend like bdb/sqlite/lmdb at compile time. This is a bit unfortunate for packaging bogofilter, as the packager either decides to just support the default backend or to create a separate package for each backend. As a user who installs bogofilter via the distribution's package manager a suboptimal situation.
Looking at the code, adding some kind of runtime dispatch shouldn't be a big deal.
Is this something the bogofilter team would be interested in?
I wonder what the concept would look like, and if we went that way, if we could replace one layer of indirection with a new one, rather than adding one in between...
I would implement it like this:
Then declare the backend API functions as weak in the executables such that they can be directly called - i.e. after the dlopen. This also allows for linking the binaries without the definitions of those functions being available.
A more conservative appraoch (for platforms without weak symbols):
I don't know if there are interesting platforms with shared libraries but without weak symbols. Probably not.