Input/Output

NAME
    
DLL_SaveList, DLL_LoadList

SYNOPSIS
#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 *))

DESCRIPTION
    
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.

DLL_SaveList
    
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.

DLL_LoadList
    
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. The list->current_index will have an arbitrary value it depending on the sort algorithm used. Use one of the DLL_CurrentPointerToHead or DLL_CurrentPointerToTail functions to get the known location.

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)
      {
      return(strcmp(rcrd->info_element,
                    cmp->info_element));
      }

EXAMPLE
    
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 2012-01-15