Query: bufsplit
OS: linux
Section: 3gen
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
bufsplit(3GEN) String Pattern-Matching Library Functions bufsplit(3GEN)NAMEbufsplit - split buffer into fieldsSYNOPSIScc [ flag ... ] file ... -lgen [ library ... ] #include <libgen.h> size_t bufsplit(char *buf, size_t n, char **a);DESCRIPTIONbufsplit() examines the buffer, buf, and assigns values to the pointer array, a, so that the pointers point to the first n fields in buf that are delimited by TABs or NEWLINEs. To change the characters used to separate fields, call bufsplit() with buf pointing to the string of characters, and n and a set to zero. For example, to use colon (:), period (.), and comma (,), as separators along with TAB and NEWLINE: bufsplit (":., ", 0, (char**)0 );RETURN VALUESThe number of fields assigned in the array a. If buf is zero, the return value is zero and the array is unchanged. Otherwise the value is at least one. The remainder of the elements in the array are assigned the address of the null byte at the end of the buffer.EXAMPLESExample 1: Example of bufsplit() function. /* * set a[0] = "This", a[1] = "is", a[2] = "a", * a[3] = "test" */ bufsplit("This is a test ", 4, a);NOTESbufsplit() changes the delimiters to null bytes in buf. When compiling multithreaded applications, the _REENTRANT flag must be defined on the compile line. This flag should only be used in mul- tithreaded applications.ATTRIBUTESSee attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+SEE ALSOattributes(5) SunOS 5.10 29 Dec 1996 bufsplit(3GEN)