Library Configuration

I have the basic foundations for the library based configuration programmed into the library now. I've tested it pretty well but not 100%. I'll yet dig up some bugs, but I wanted to start plugging in the new configuration into the existing modules so that I can be sure that I like the API. Right now it's pretty simple.

The module would call a function to initialize the configuration. Mostly this is memory allocation, and setting up the options that would be common to each module. The configuration is held in a linked list of attributes. These attributes each specify a single option that can be set. There is a function that adds attributes and it need a name, which will be what the Lua scripts will use as a global variable, and must be unique. There are also a set of long and short options for the getopt_long() functions to use. Finally there is a set of flags and the default value.

The flags determine how the attribute is handled. It can be found in the opendax.conf file or the module.conf file or the command line. Any combination is allowable. The value that is stored in all the attributes after configuration is a NULL terminated string. It will be up to the module to convert these strings to something useful. There are a couple of functions for getting and setting the values of these options.

The module can also add a C function to the module.conf Lua state (right now not the opendax.conf state). This will allow the module to set up some pretty sophisticated configuration capabilities. There is also a mechanism for adding callback functions for each attribute. I am not quite sure I have this implemented the way it should be. The callback is called every time the configuration parser finds any attribute, whether that attribute is to be stored or not (based on precedence). I guess this is probably the right way to do it so that the module can determine priorities.

I think I may need to add a flag to the system so that the configuration parser won't even try to store a value. This will give the module complete control. I may also add a way for the module to get the Lua state at certain points in the configuration. There may be a little bit more need for hooks into other parts of the processing.

Right now the default priority is that any options given on the command line will have precedence over any in the Lua scripts and the module.conf file will have precedence over the opendax.conf file.

I need to spend a bit more time with it to decide if I have covered all the bases but right now it seems like a pretty flexible interface. The modules can easily bypass the whole thing if they want to configure themselves. They would still have to call the initialization function to create the attributes needed by the library itself and then use the option setting functions to make sure that the library had the information it needed to work, such as timeouts, ports, IP addresses, socket names, etc.