Specifications

CHAPTER 5. IMPLEMENTATION 45
These functions are responsible for evaluating the supplied configuration options. The Input
Abstraction Layer’s most imp ortant functions for this task are the ones handling the com-
mand line options of the modules. They are invoked by the command line options list,
list-verbose and module-options. The command line options list and list-verbose
provide information about the modules and their possible configuration options.
If the configuration option list (short option l) is supplied, the function opt list() is
invoked. This function iterates the double linked list and extracts the name of each module’s
data structure. The following source code shows a slightly shortened version of opt list():
/* Create a pointer to the list head. */
IalModule *module = modules_list_head;
/* Iterate all modules. */
while (module) {
/* Print the name of the current module. */
printf("%s\n", module->data->name);
module = module->next;
}
The function opt list verbose() is called if the command line option list-verbose
(short option L) is supplied. It is implemented similarly to opt list(). Additionally, it
prints the possible configuration options of the modules by iterating each module’s options.
To accomplish this approach, pointer arithmetic is used. The following example shows the
iteration of the options array for one module:
/* Create a pointer to the module’s option array. */
ModuleOption *option = module->data->options;
while(option->name) {
/* Print the description, name and default value of the module option. */
printf("%s, default: %s=%s\n", opt->descr, opt->name, opt->value);
/* Go to the next element of the options array. */
*option++;
}
Configuration options for Input Abstraction Layer modules are parsed by the function
opt modules opts(). This function is invoked if the daemon is started with configuration
option module-options (short option m). This configuration option requires an argument
mod options, which is a string. This string contains the configuration options for one or more
modules. The format of the string mod options is defined as:
mod_options := <mod_option>[,<mod_option>]
mod_option := <token>:<option>=<value>[:<option>=<value>]
token := Module token
option := Option name
value := Option value