DragonFly On-Line Manual Pages

Search: Section:  


encap_list_new(3)               C Library Calls              encap_list_new(3)

NAME

encap_list_new, encap_list_free, encap_list_next, encap_list_prev, encap_list_add, encap_list_del, encap_list_search, encap_list_dup, encap_list_merge, encap_list_add_str - linked list routines

SYNOPSIS

#include <encap.h> encap_list_t *encap_list_new(int flags, int (*cmpfunc)()); void encap_list_free(encap_list_t *l, void (*freefunc)()); int encap_list_add_str(encap_list_t *l, char *str, char *delim); int encap_list_add(encap_list_t *l, void *data); void encap_list_del(encap_list_t *l, encap_node_t **n); int encap_list_search(encap_list_t *l, encap_node_t **n, void *data, int (*matchfunc)()); int encap_list_next(encap_list_t *l, encap_node_t **n); int encap_list_prev(encap_list_t *l, encap_node_t **n); encap_list_t *encap_list_dup(encap_list_t *l); encap_list_t *encap_list_merge(int (*cmpfunc)(), int flags, encap_list_t *list1, encap_list_t *list2);

DESCRIPTION

The encap_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 encap_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 encap_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 encap_list_new() when the list was created. The encap_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 encap_list_add(). The encap_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 encap_list_del() function removes the entry pointed to by n from the list pointed to by l. The encap_list_dup() function creates a copy of the list l using dynamically allocated memory. The encap_list_merge() function creates a new list with flags and cmpfunc, in the same way as encap_list_new(). It then adds all elements from list1 and list2 using encap_list_add().

RETURN VALUE

The encap_list_new(), encap_list_dup(), and encap_list_merge() functions return a pointer to the new list structure, or NULL on error. The encap_list_next(), encap_list_prev(), and encap_list_search() functions return 1 when valid data is returned, or 0 otherwise. The encap_list_add() and encap_list_add_str() functions return 0 on success, or -1 on error.

SEE ALSO

encap_hash_new(3) University of Illinois Jan 2000 encap_list_new(3)

Search: Section: