Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ (2) — Plan9 3rd Edition

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

strcat(2)

quote(2)

GETFIELDS(2)

NAME

getfields, tokenize − break a string into fields

SYNOPSIS

­#include <u.h>
­#include <libc.h>

intgetfields(char ∗str, char ∗∗args, int maxargs, int multiflag,
    char ∗delims)

inttokenize(char ∗str, char ∗∗args, int maxargs)

DESCRIPTION

­Getfields breaks the null-terminated UTF string ­str into at most ­maxargs null-terminated fields and places pointers to the start of these fields in the array args. Some of the bytes in ­str are overwritten.  If there are more than ­maxargs fields, only the first ­maxargs fields will be set.  ­Delims is a UTF string defining a set of delimiters. 

If ­multiflag is zero, adjacent fields are separated by exactly one delimiter.  A string containing ­n delimiter characters contains n+1 fields. If the ­multiflag argument is not zero, a field is a non-empty string of non-delimiters. 

Getfields return the number of tokens processed. 

­Tokenize is the same as ­getfields with ­multiflag non-zero and ­delims "\t\r\n ", except that fields may be quoted using single quotes, in the manner of rc(1). See quote(2) for related quote-handling software.

SOURCE

­/sys/src/libc/port/tokenize.c

SEE ALSO

­strtok in strcat(2), quote(2).

Plan 9  —  March 27, 2001

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026