What would the world be like without Captain Hook? – Dustin Hoffman as Captain Hook, Hook, 1991
I spent a fair bit of time this week converting an ugly bit of code written exclusively for a tutorial into a more useful static library. And I stated several times that the code has a long way to go before it can be considered mature.
Does it ever!
This morning I added one hook (of many planned hooks) and removed some now-useless configuration code. It’s always nice to blow away huge swaths of useless code.
I’m trying to make
libwpd more library-like.
I added a callback to support configuration changes. Originally, the daemon code looked at a configuration file followed by command line parameters. I don’t like this idea in a library, though: It doesn’t makes sense to override an application’s parameters for use in this library, so I nixed the command line argument code entirely. Instead, I added a reconfiguration hook which is called immediately after the daemon object is instantiated, but before any signal handlers are installed.
The callback looks something like this:
1 2 3 4 5 6 7
Ultimately, this is a lot more flexible. The callback is now passed directly to the
wp_daemonizer_initialize method rather than a whole configuration object. This simplifies the external API considerably, since the configuration object methods are now wrapped entirely within the callback handler and the user no longer needs to worry about configuration initialization and cleanup.