1libtar_list_new(3)              C Library Calls             libtar_list_new(3)
2
3
4

NAME

6       libtar_list_new,  libtar_list_free, libtar_list_next, libtar_list_prev,
7       libtar_list_add, libtar_list_del, libtar_list_search,  libtar_list_dup,
8       libtar_list_merge, libtar_list_add_str - linked list routines
9

SYNOPSIS

11       #include <libtar.h>
12
13       libtar_list_t *libtar_list_new(int flags, int (*cmpfunc)());
14       void libtar_list_free(libtar_list_t *l, void (*freefunc)());
15       int libtar_list_add_str(libtar_list_t *l, char *str, char *delim);
16       int libtar_list_add(libtar_list_t *l, void *data);
17       void libtar_list_del(libtar_list_t *l, libtar_node_t **n);
18       int libtar_list_search(libtar_list_t *l, libtar_node_t **n, void *data,
19       int (*matchfunc)());
20       int libtar_list_next(libtar_list_t *l, libtar_node_t **n);
21       int libtar_list_prev(libtar_list_t *l, libtar_node_t **n);
22       libtar_list_t *libtar_list_dup(libtar_list_t *l);
23       libtar_list_t  *libtar_list_merge(int  (*cmpfunc)(),  int  flags,  lib‐
24       tar_list_t *list1, libtar_list_t *list2);
25

DESCRIPTION

27       The  libtar_list_new() function creates a new list.  The flags argument
28       must be one of the following values:
29
30       LIST_USERFUNC
31              The cmpfunc argument points to a  user-supplied  function  which
32              determines the ordering of the list.
33
34       LIST_STACK
35              Use the list as a stack.  New elements are added to the front of
36              the list.
37
38       LIST_QUEUE
39              Use the list as a queue.  New elements are added to the  end  of
40              the list.
41
42       The  libtar_list_free() function deallocates all memory associated with
43       the list l.  If freefunc is not NULL, it is called to free memory asso‐
44       ciated with each node in the list.
45
46       The  libtar_list_add()  function adds the element pointed to by data to
47       the list l.  The position of the new element will be determined by  the
48       flags passed to libtar_list_new() when the list was created.
49
50       The  libtar_list_add_str()  function tokenizes the string str using the
51       delimiter characters in the string delim.   The  resulting  tokens  are
52       added to list l using libtar_list_add().
53
54       The libtar_list_search() function searches for an element which matches
55       data using the matching function matchfunc.  If matchfunc  is  NULL,  a
56       default  matching function designed for ASCII strings is used.  Search‐
57       ing begins from the node pointed to by n.
58
59       The libtar_list_del() function removes the entry pointed to by  n  from
60       the list pointed to by l.
61
62       The  libtar_list_dup()  function  creates  a  copy  of the list l using
63       dynamically allocated memory.
64
65       The libtar_list_merge() function creates a new list with flags and cmp‐
66       func,  in the same way as libtar_list_new().  It then adds all elements
67       from list1 and list2 using libtar_list_add().
68

RETURN VALUE

70       The libtar_list_new(), libtar_list_dup(), and libtar_list_merge() func‐
71       tions return a pointer to the new list structure, or NULL on error.
72
73       The  libtar_list_next(),  libtar_list_prev(),  and libtar_list_search()
74       functions return 1 when valid data is returned, or 0 otherwise.
75
76       The libtar_list_add() and libtar_list_add_str() functions return  0  on
77       success, or -1 on error.
78

SEE ALSO

80       libtar_hash_new(3)
81
82
83
84University of Illinois             Jan 2000                 libtar_list_new(3)
Impressum