1bufsplit(3GEN) String Pattern-Matching Library Functions bufsplit(3GEN)
2
3
4
6 bufsplit - split buffer into fields
7
9 cc [ flag ... ] file ... -lgen [ library ... ]
10 #include <libgen.h>
11
12 size_t bufsplit(char *buf, size_t n, char **a);
13
14
16 bufsplit() examines the buffer, buf, and assigns values to the pointer
17 array, a, so that the pointers point to the first n fields in buf that
18 are delimited by TABs or NEWLINEs.
19
20
21 To change the characters used to separate fields, call bufsplit() with
22 buf pointing to the string of characters, and n and a set to zero. For
23 example, to use colon (:), period (.), and comma (,), as separators
24 along with TAB and NEWLINE:
25
26
27 bufsplit (":.,\t\n", 0, (char**)0 );
28
30 The number of fields assigned in the array a. If buf is zero, the
31 return value is zero and the array is unchanged. Otherwise the value
32 is at least one. The remainder of the elements in the array are
33 assigned the address of the null byte at the end of the buffer.
34
36 Example 1 Example of bufsplit() function.
37
38 /*
39 * set a[0] = "This", a[1] = "is", a[2] = "a",
40 * a[3] = "test"
41 */
42 bufsplit("This\tis\ta\ttest\n", 4, a);
43
44
46 bufsplit() changes the delimiters to null bytes in buf.
47
48
49 When compiling multithreaded applications, the _REENTRANT flag must be
50 defined on the compile line. This flag should only be used in multi‐
51 threaded applications.
52
54 See attributes(5) for descriptions of the following attributes:
55
56
57
58
59 ┌─────────────────────────────┬─────────────────────────────┐
60 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
61 ├─────────────────────────────┼─────────────────────────────┤
62 │MT-Level │MT-Safe │
63 └─────────────────────────────┴─────────────────────────────┘
64
66 attributes(5)
67
68
69
70SunOS 5.11 29 Dec 1996 bufsplit(3GEN)