.TH GETFIELDS 2.SH NAMEgetfields, gettokens, tokenize \- break a string into fields.SH SYNOPSIS.B #include <u.h>.br.B #include <libc.h>.PP.ta \w'\fLchar* \fP'u.Bint getfields(char *str, char **args, int maxargs, int multiflag,.br.B char *delims).PP.Bint gettokens(char *str, char **args, int maxargs, char *delims).PP.Bint tokenize(char *str, char **args, int maxargs).SH DESCRIPTION.I Getfieldsplaces into the array.I argspointers to the first.I maxargsfields of the null terminated.SM UTFstring.IR str .Delimiters between these fields are set to.SM NULbytes..PPFields are substrings of.I strwhose definition depends on the value of.IR multiflag.If.I multiflagis zero,adjacent fields are separated by exactly one delimiter.For example.EX getfields("#alice#bob##charles###", arg, 3, 0, "#");.EEyields three substrings:null-string ,.BR "alice" ,and.BR "bob##charles###" .If the.I multiflagargument is not zero,a field is a non-empty string of non-delimiters.For example.EX getfields("#alice#bob##charles###", arg, 3, 1, "#");.EEyields the three substrings:.BR "alice" ,.BR "bob" ,and.BR "charles###" ..PPGetfields returns the number of fields pointed to..PP.I Gettokensis the same as.I getfieldswith.I multiflagnon-zero,except that fields may be quoted using single quotes, in the mannerof.IR rc (1).Any such quotes remain in the resulting.IR args .See.IR quote (2)for related quote-handling software..PP.I Tokenizeis similar to.I gettokenswith .I delimsset to \f5"\et\er\en\ "\fP,except that quotes are interpreted but do not appear in the resulting.IR args ..SH SOURCE.B /sys/src/libc/port/tokenize.c.SH SEE ALSO.I strtokin.IR strcat (2),.IR quote (2).
.TH GETFIELDS 2
.SH NAME
getfields, gettokens, tokenize \- break a string into fields
.SH SYNOPSIS
.B #include <u.h>
.br
.B #include <libc.h>
.PP
.ta \w'\fLchar* \fP'u
.B
int getfields(char *str, char **args, int maxargs, int multiflag,
.br
.B
char *delims)
.PP
.B
int gettokens(char *str, char **args, int maxargs, char *delims)
.PP
.B
int tokenize(char *str, char **args, int maxargs)
.SH DESCRIPTION
.I Getfields
places into the array
.I args
pointers to the first
.I maxargs
fields of the null terminated
.SM UTF
string
.IR str .
Delimiters between these fields are set to
.SM NUL
bytes.
.PP
Fields are substrings of
.I str
whose definition depends on the value of
.IR multiflag.
If
.I multiflag
is zero,
adjacent fields are separated by exactly one delimiter.
For example
.EX
getfields("#alice#bob##charles###", arg, 3, 0, "#");
.EE
yields three substrings:
null-string ,
.BR "alice" ,
and
.BR "bob##charles###" .
If the
.I multiflag
argument is not zero,
a field is a non-empty string of non-delimiters.
For example
.EX
getfields("#alice#bob##charles###", arg, 3, 1, "#");
.EE
yields the three substrings:
.BR "alice" ,
.BR "bob" ,
and
.BR "charles###" .
.PP
Getfields returns the number of fields pointed to.
.PP
.I Gettokens
is the same as
.I getfields
with
.I multiflag
non-zero,
except that fields may be quoted using single quotes, in the manner
of
.IR rc (1).
Any such quotes remain in the resulting
.IR args .
See
.IR quote (2)
for related quote-handling software.
.PP
.I Tokenize
is similar to
.I gettokens
with
.I delims
set to \f5"\et\er\en\ "\fP,
except that quotes are interpreted but do not appear in the resulting
.IR args .
.SH SOURCE
.B /sys/src/libc/port/tokenize.c
.SH SEE ALSO
.I strtok
in
.IR strcat (2),
.IR quote (2).