DLL_SaveList, DLL_LoadList - Input/Output Functions.

#include <linklist.h>

DLL_Return DLL_SaveList(List *list, const char *path);
DLL_Return DLL_LoadList(List *list, const char *path,
            int (*pFun)(Info *, Info *))

These functions are designed to easily write and read the link list data to a disk. They take advantage of their ability to access the Top Level Struct for saving and loading data quickly; however, this will only be useful in limited cases as most implementations will need application specific file formats. Both return the enumerated type DLL_Return and take as their first argument, list, the pointer returned by DLL_CreateList, and as their second argument, path, a pointer to the file name.

This function saves all the Info structures including any NULL characters in the elements. The record size is equal to, infosize, the second argument of the DLL_InitializeList function.

The value DLL_NULL_LIST, if returned, indicates that the list is empty; DLL_OPEN_ERROR indicates that the file could not be opened for writing; DLL_WRITE_ERROR indicates that there was an error while writing to the file meaning that the data in the list should not be trusted; DLL_NOT_MODIFIED indicates that the list has not been modified since the last save and no updating to the file was done; and DLL_NORMAL indicates that the function succeeded in its task.

This function retrieves from a file data based on the same criteria that it was saved with. See DLL_SaveList above. The third argument pFun is a pointer to a sorting function the same as can be found in DLL_AddRecord. A NULL function pointer can be passes if no sorting is needed.

Where the return value is

   less than zero:     arg1 < arg2,

   zero:               arg1 == arg2, or

   greater than zero:  arg1 > arg2.

Below is an example of this function:

   int sort_foo(Info *record, Info *compare)

Examples of most of these functions can be seen in the source file dll_test.c used in the testing of the link list API.

Carl J. Nobile 2007-06-24