dbdb - the database datebook, or vice-versa. by aaron brick, aa@lithic.org 8/1998 - 3/2000, under professor scott smith. released under the GPL. OVERVIEW dbdb is a client-server datebook utility written in C. It is responsive to requests from TCP/IP networks (e.g., the internet) and authenticates its users with passwords. the server is a multithreaded daemon program, meant to be started at boot and stopped at shutdown along with other daemons on the system. since the client's functionality is very simple, the included one can be replaced or supplemented by others, designed to run on various machines in various manners. DATA TYPES each datebook entry is stored in a C struct 'entry' which includes its unique ID number, information about its start and end times, which entry (if any) it depends upon, its priority, and so on. each includes a pointer to its parent member of the master linked list (a 'record_list'), which also points to the storage places of strings of arbitrary length (a 'var_len_strings') and extrapolated dependency information (a 'dep_struct'). on disk, entries are stored in a linear format as a string. the struct 'entry' is transcribed, followed by a list of lengths of each of the strings which must also be stored; they follow. the rest of the information which resides in memory's data structures is constructed at connection time and as needed. DATA STORAGE records unique to each user are stored in files specific to the data primitive library gdbm. when a user makes a connection with the server, his data is read into memory and referenced in several complex ways. the entries are read into a linked list, which is supplemented by an array of pointers into it indexed by ID number and a similar array used to refer to the entries in certain sorted orders. each entry in the linked list has several memory structures of its own, to reflect arbitrary-length strings (such as the entry text), and information about the other entries which depend on it; this latter includes another linked list of pointers to dependent records. at the event of the addition or removal of a record, the change is reflected in the files stored on disk and in these data structures in memory. NETWORKING ASPECTS the server listens on TCP port 6104, as assigned by the IANA. when a client connects, it sends a packet introducing itself to the server, which then awaits commands. the server may return one or many packets, whose contents the client processes or prints out verbatim; the last packet the server sends is marked as such, and upon its receipt the client acts appropriately by awaiting another command, reporting an error, and/or quitting. the packets are not compressed because they are not large. a packet carring a new entry to the server with will only consume about 30 bytes more than the sum of the lengths of the strings it includes, before the addition of TCP headers. printed-out packets occupy one line of text in normal mode and somewhat more in full-report mode; the latter does not truncate text fields. the retrieval of a large number of records could represent significant load to the network, but that is to be expected. PERFORMANCE AND EFFICIENCY the records are stored as a linked list, so that changes made to them run in constant time. the operations performed in adding or removing records are iterations through the list, or through the array of pointers into it, both of which run in O(n) time, depending on the number of entries in that user's database. the sorting algorithm used for the ordered listing and removal of entries is quicksort, as implemented in the stdlib; in the worst case, it runs in O(n^2) time, but usually is not so slow. TIME PARSING the time parsing engine can understand dates and times given in a variety of manners. the basic format is ,