@LISTHASH_PREFIX@_list_new(3)

NAME
@LISTHASH_PREFIX@_list_new, @LISTHASH_PREFIX@_list_free, @LISTHASH_PREFIX@_list_next, @LISTHASH_PREFIX@_list_prev, @LISTHASH_PREFIX@_list_add, @LISTHASH_PREFIX@_list_del, @LISTHASH_PREFIX@_list_search, @LISTHASH_PREFIX@_list_dup, @LISTHASH_PREFIX@_list_merge, @LISTHASH_PREFIX@_list_add_str - linked list routines

SYNOPSIS
#include <@LISTHASH_PREFIX@.h>

@LISTHASH_PREFIX@_list_t *@LISTHASH_PREFIX@_list_new(int flags, int (*cmpfunc)());
void @LISTHASH_PREFIX@_list_free(@LISTHASH_PREFIX@_list_t *l, void (*freefunc)());
int @LISTHASH_PREFIX@_list_add_str(@LISTHASH_PREFIX@_list_t *l, char *str, char *delim);
int @LISTHASH_PREFIX@_list_add(@LISTHASH_PREFIX@_list_t *l, void *data);
void @LISTHASH_PREFIX@_list_del(@LISTHASH_PREFIX@_list_t *l, @LISTHASH_PREFIX@_node_t **n);
int @LISTHASH_PREFIX@_list_search(@LISTHASH_PREFIX@_list_t *l, @LISTHASH_PREFIX@_node_t **n, void *data, int (*matchfunc)());
int @LISTHASH_PREFIX@_list_next(@LISTHASH_PREFIX@_list_t *l, @LISTHASH_PREFIX@_node_t **n);
int @LISTHASH_PREFIX@_list_prev(@LISTHASH_PREFIX@_list_t *l, @LISTHASH_PREFIX@_node_t **n);
@LISTHASH_PREFIX@_list_t *@LISTHASH_PREFIX@_list_dup(@LISTHASH_PREFIX@_list_t *l);
@LISTHASH_PREFIX@_list_t *@LISTHASH_PREFIX@_list_merge(int (*cmpfunc)(), int flags, @LISTHASH_PREFIX@_list_t *list1, @LISTHASH_PREFIX@_list_t *list2);

DESCRIPTION
The @LISTHASH_PREFIX@_list_new() function creates a new list. The flags argument must be one of the following values:

LIST_USERFUNC
    The cmpfunc argument points to a user-supplied function which determines the ordering of the list.

LIST_STACK
    Use the list as a stack. New elements are added to the front of the list.

LIST_QUEUE
    Use the list as a queue. New elements are added to the end of the list.

The @LISTHASH_PREFIX@_list_free() function deallocates all memory associated with the list l. If freefunc is not NULL, it is called to free memory associated with each node in the list. The @LISTHASH_PREFIX@_list_add() function adds the element pointed to by data to the list l. The position of the new element will be determined by the flags passed to @LISTHASH_PREFIX@_list_new() when the list was created. The @LISTHASH_PREFIX@_list_add_str() function tokenizes the string str using the delimiter characters in the string delim. The resulting tokens are added to list l using @LISTHASH_PREFIX@_list_add(). The @LISTHASH_PREFIX@_list_search() function searches for an element which matches data using the matching function matchfunc. If matchfunc is NULL, a default matching function designed for ASCII strings is used. Searching begins from the node pointed to by n. The @LISTHASH_PREFIX@_list_del() function removes the entry pointed to by n from the list pointed to by l. The @LISTHASH_PREFIX@_list_dup() function creates a copy of the list l using dynamically allocated memory. The @LISTHASH_PREFIX@_list_merge() function creates a new list with flags and cmpfunc, in the same way as @LISTHASH_PREFIX@_list_new(). It then adds all elements from list1 and list2 using @LISTHASH_PREFIX@_list_add().

RETURN VALUE
The @LISTHASH_PREFIX@_list_new(), @LISTHASH_PREFIX@_list_dup(), and @LISTHASH_PREFIX@_list_merge() functions return a pointer to the new list structure, or NULL on error. The @LISTHASH_PREFIX@_list_next(), @LISTHASH_PREFIX@_list_prev(), and @LISTHASH_PREFIX@_list_search() functions return 1 when valid data is returned, or 0 otherwise. The @LISTHASH_PREFIX@_list_add() and @LISTHASH_PREFIX@_list_add_str() functions return 0 on success, or -1 on error.

SEE ALSO
@LISTHASH_PREFIX@_hash_new(3)