In order to implement the contact list, we implemented a linked list which is a well known data structure. Our linked list has two types of data entries -- a UIN and contact name. The linked list is implemented in the files:
The operations over the linked list are rather standard and include adding a new entry to the list, searching for a specific entry, deleting an entry from the list and cleaning up the list. We also added special features that enable reading a list given a file descriptor. This includes locking the file (to avoid two threads trying to write to a file at the same time) and reading the contacts from the file.
Then we implemented a flat database that uses the linked list. The database knows the naming conventions of the database, it opens the correct file. Then it uses the linked list functionality to read or write the contact list. The flat database is implemented in the files:
Then we implemented a set of high-level functions that can handle a link environment and call the correct database functions in order to initialize the contact list, add or remove contacts and terminate the contact list when needed. These functions are implemented in the files: