[Botan-devel] SQLite3 encryption codec with Botan
mr.diggilin at gmail.com
Sat Apr 25 23:07:39 EDT 2009
On Mon, 2009-04-20 at 17:09 -0400, Jack Lloyd wrote:
> On Sun, Apr 19, 2009 at 12:27:34PM +0800, Mr Diggilin wrote:
> > Hi Jack,
> > I've got another question in regards to this codec... how should I deal
> > with the LibraryInitializer?
> > Obviously I don't have a main function to put it in. There can be
> > multiple "codecs" loaded at once so constructor/destructor is also out.
> > Also... there's the possibility of the user using botan in their own
> > code.
> > Is there a way to check the state of the LibraryInitializer?
> Yes, though it's a bit ugly:
> There is a function declared in libstate.h, swap_global_state():
> Library_State* swap_global_state(Library_State*);
> It sets a new state and returns the old one. So one way to detect
> if botan is initialized is
> bool is_initialized = false;
> Library_State* state = swap_global_state(0);
> is_initialized = true;
> swap_global_state(state); // should return NULL
> The problem: if any access to botan is made between the swaps (for
> instance in another thread) the state will be reinitialized. This
> case could be detected by checking the return value of the second
I've got everything compiling and theoretically working with this being
the only thing standing in the way. I'm still way back in 1.6.4, and I'm
guessing that this was added later as it doesn't compile. I suppose I'll
have to upgrade after 1.8.3 anyhow.
Just a thought though... would it be very difficult to have
LibraryInitializer::initialize check to see if it's already initialized?
Or just have a static get_is_initialized or some such function?
More information about the botan-devel