Specifications

CHAPTER 5. IMPLEMENTATION 41
be subsequently invoked, since function references the module’s function mod get data().
Once called, it returns the required pointer to the module’s data structure ModuleData. The
returned pointer is assigned to the new list element’s module member data:
/* Assign the pointer to the module’s ModuleData to the member data. */
module->data = function();
The new element is added to the head of the double linked list by setting up the member
prev and next correspondingly:
/* Set "prev" to NULL. */
module->prev = NULL;
/* Set "next" to the previous list head. */
module->next = modules_list_head;
/* If the list was not empty before, let the previous list head’s member "prev"
* point to new module.
*/
if (module->next != NULL)
module->next->prev = module;
/* Let the list head refer the new module. */
modules_list_head = module;
Figure 5.6 shows the double linked list with three list elements. The member data of
each element refers to the corresponding ModuleData structure of an Input Abstraction Layer
module. The daemon can use this single reference to access all other data structures of the
module, such as the module’s options ModuleOption.
modules_list_head
IalModule
.prev .next .data
IalModule
.prev .next .data
IalModule
.prev .next .data
NULL
NULL
ModuleData
ModuleOption
Double Linked List Modules
ModuleData
ModuleOption
ModuleData
ModuleOption
Figure 5.6: Input Abstraction Layer Module List
At this point, the daemon has accomplished stage one—the loading of the modules is
accomplished. Though, the modules are not yet running. They are just loaded into memory
and the daemon is able to access all necessary data structures. Before actually executing the
modules, the daemon needs to set up the configuration for the modules and the daemon itself.