Listing 4

/** array_first. Returns a pointer to the value of the first
 * element in the array and initializes a status marker
 **/
void *array_first (PARRAY array, void **control)
{
    *control = (void *) array->first;
    return (array->first) ? array->first->value : NULL;
}
/** array_last. Returns a pointer to the value of the last
 * element in the array and initializes a status marker
 **/
void *array_last (PARRAY array, void **control)
{
    *control = (void *) array->last;
    return (array->last) ? array->last->value : NULL;
}
/** array_next. Returns a pointer to the next element in the array
 * and updates a status marker
 **/
void *array_next (void **control)
{
    PELEMENT el;
    el = ((PELEMENT) *control);
    if (el)
    {
        *control = el->next;
        return (el->next) ? el->next->value : NULL;
    }
    else
        return NULL;
}
/** array_prev. Returns a pointer to the previous element in the
 * array and updates a status marker
 **/
void *array_prev (void **control)
{
    PELEMENT el;
    el = ((PELEMENT) *control);
    if (el)
    {
        *control = el->prev;
        return (el->prev) ? el->prev->value : NULL;
    }
    else
        return NULL;
}