Specifications
CHAPTER 5. IMPLEMENTATION 47
which is requested for creation. No additional flags are passed since the third argument is
set to 0. If the D-BUS daemon is not able to create the requested service, the structure
dbus error is filled with information. This structure is of type DBusError and represents a
D-BUS exception.
Module Invocation
Once the connection to the system message bus is established and the service is acquired, the
daemon is completely initialized. At this point, it is safe to start all available modules. This
approach is realized by the function modules load(), which is implemented by the mo dule
loader. The essential part of the function’s source code follows:
/* Create a pointer to the list head. */
IalModule *module = modules_list_head;
/* Iterate all modules. */
while (module) {
if (module->data->load() == FALSE) {
/* Module failed to load. */
WARNING(("Failed to load %s.", module->data->name));
}
else {
/* Module successfully loaded. */
INFO(("%s loaded.", module->data->name));
}
module = module->next;
}
The while loop iterates the module list and invokes the loading function of each module.
The member load (module->data->load) of each module’s ModuleData data structure con-
tains a function pointer to its loading function. It is each module’s responsibility to perform
the following three steps at this point:
– Verify module options
– Initialize module variables and kernel interface
– Return TRUE on success and FALSE in case of failure
The module’s loading function has to check carefully if the configuration file parser and
the command line parser have initialized the module’s options correctly. If they are set up
correctly, the values of the options have to be assigned to the corresponding variables of the
module. Subsequently, the module has to check whether it is able to access the kernel interface
for which the module is designed for. If everything succeeds, the loading function has to return
TRUE. Otherwise, FALSE has to be returned. As soon as all available modules are invoked,
stage five is completed.