NWSM_LIST_PTR

Specifies the beginning and ending list elements containing list information.

Syntax

  typedef struct 
  { 
     NWSM_LIST  *head; 
     NWSM_LIST  *tail; 
     int         (*sortProc)(); 
     void        (*freeProcedure)(void *memoryPointer); 
  } NWSM_LIST_PTR;
  

Fields

head

Specifies the first element as returned by NWSMGetListHead.

tail

Specifies the last element.

sortProc

Specifies the function that compares the text portion of an element.

freeProcedure

Specifies a function that frees the memory allocated to an element's otherInfo field.

Remarks

The following figure shows the relationship between NWSM_LIST_PTR and NWSM_LIST:

Relationship between NWSM_LIST_PTR and NWSM_LIST

For example, suppose that a program needs to display a list of resources and resource information (free space, block size, etc.) when the user selects a resource name. The list functions can be used to put the resource name and resource information into the above structure to associate them as a unit.

Call NWSMGetListHead to get the list head, rather than traversing the list.

To get the list tail, find the list head and traverse the list until you find NULL.

The function specified by sortProc performs a case insensitive sort. sortProc is always set by the utilities library, but you can reset this pointer to another sort function. The prototype of sortProc is:

  int sortProc(char *s1, char *s2);
  

The return values are:

  >0   String s1 is greater than s2. 
  0   The strings match. 
  <0   String s1 is less than s2.
  

s1 and s2 are NULL-terminated strings.

Call NWSMInitList to initialize freeProcedure. The function pointed to by this field is called when you call NWSMDestroyList.

If otherInfo contains a non-allocated value such as an integer, freeProcedure must be set to NULL. It's prototype is:

  void freeProcedure(void *ptr);