1STRINGLIST(3bsd)                     LOCAL                    STRINGLIST(3bsd)
2

NAME

4     stringlist, sl_init, sl_add, sl_free, sl_find, sl_delete — stringlist
5     manipulation functions
6

LIBRARY

8     Utility functions from BSD systems (libbsd, -lbsd)
9

SYNOPSIS

11     #include <stringlist.h>
12     (See libbsd(7) for include usage.)
13
14     StringList *
15     sl_init(void);
16
17     int
18     sl_add(StringList *sl, char *item);
19
20     void
21     sl_free(StringList *sl, int freeall);
22
23     char *
24     sl_find(StringList *sl, const char *item);
25
26     int
27     sl_delete(StringList *sl, const char *item, int freeit);
28

DESCRIPTION

30     The stringlist functions manipulate stringlists, which are lists of
31     strings that extend automatically if necessary.
32
33     The StringList structure has the following definition:
34
35           typedef struct _stringlist {
36                   char    **sl_str;
37                   size_t    sl_max;
38                   size_t    sl_cur;
39           } StringList;
40
41     where:
42
43           sl_str  is a pointer to the base of the array containing the list,
44
45           sl_max  is the size of sl_str, and
46
47           sl_cur  is the offset in sl_str of the current element.
48
49     The following stringlist manipulation functions are available:
50
51       sl_init()    Create a stringlist.  Returns a pointer to a StringList,
52                    or NULL in case of failure.
53
54       sl_free()    Releases memory occupied by sl and the sl->sl_str array.
55                    If freeall is non-zero, then each of the items within
56                    sl->sl_str is released as well.
57
58       sl_add()     Add item to sl->sl_str at sl->sl_cur, extending the size
59                    of sl->sl_str.  Returns zero upon success, -1 upon fail‐
60                    ure.
61
62       sl_find()    Find item in sl, returning NULL if it's not found.
63
64       sl_delete()  Remove item from the list.  If freeit is non-zero, the
65                    string is freed.  Returns 0 if the name is found and -1 if
66                    the name is not found.
67

SEE ALSO

69     free(3), malloc(3)
70

HISTORY

72     The stringlist functions appeared in FreeBSD 2.2.6 and NetBSD 1.3.
73
74BSD                               May 6, 2010                              BSD
Impressum