summaryrefslogtreecommitdiff
path: root/static/plan9-4e/man2/getfields.2
diff options
context:
space:
mode:
Diffstat (limited to 'static/plan9-4e/man2/getfields.2')
-rw-r--r--static/plan9-4e/man2/getfields.288
1 files changed, 88 insertions, 0 deletions
diff --git a/static/plan9-4e/man2/getfields.2 b/static/plan9-4e/man2/getfields.2
new file mode 100644
index 00000000..9f899773
--- /dev/null
+++ b/static/plan9-4e/man2/getfields.2
@@ -0,0 +1,88 @@
+.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
+breaks the null-terminated
+.SM UTF
+string
+.I str
+into at most
+.I maxargs
+null-terminated fields and places pointers to the start of these fields in the array
+.IR args .
+Some of the bytes in
+.I str
+are overwritten.
+If there are more than
+.I maxargs
+fields,
+only the first
+.I maxargs
+fields will be set.
+.I Delims
+is a
+.SM UTF
+string defining a set of delimiters.
+.PP
+If
+.I multiflag
+is zero,
+adjacent fields are separated by exactly one delimiter.
+A string containing
+.I n
+delimiter characters
+contains
+.IR n +1
+fields.
+If the
+.I multiflag
+argument is not zero,
+a field is a non-empty string of non-delimiters.
+.PP
+Getfields
+returns the number of tokens processed.
+.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).
+See
+.IR quote (2)
+for related quote-handling software.
+.PP
+.I Tokenize
+is
+.I gettokens
+with
+.I delims
+set to \f5"\et\er\en "\fP.
+.SH SOURCE
+.B /sys/src/libc/port/tokenize.c
+.SH SEE ALSO
+.I strtok
+in
+.IR strcat (2),
+.IR quote (2).