Unix/Linux Go Back    

Plan 9 - man page for getfields (plan9 section 2)

Linux & Unix Commands - Search Man Pages
Man Page or Keyword Search:   man
Select Man Page Set:       apropos Keyword Search (sections above)

GETFIELDS(2)									     GETFIELDS(2)

       getfields, getmfields, setfields, tokenize - break a string into fields

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

       int   getfields(char *str, char **ptrs, int nptrs)

       int   getmfields(char *str, char **ptrs, int nptrs)

       char* setfields(char *fielddelim)

       int   tokenize(char *str, char **args, int max)

       Getfields  breaks the null-terminated string str into at most nptrs null-terminated fields
       and places pointers to the start of these fields in the array ptrs.  It returns the number
       of  fields and terminates the list of pointers with a zero pointer.  It overwrites some of
       the bytes in str.  If there are nptr or more fields, the list will not end with	zero  and
       the last `field' will extend to the end of the input string and may contain delimiters.

       A  field  is defined as a maximal sequence of characters not in a set of field delimiters.
       Adjacent fields are separated by exactly one delimiter.	No field follows a  delimiter  at
       the  end  of  string.   Thus  a string of just two delimiter characters contains two empty
       fields, and a nonempty string with no delimiters contains one field.

       Getmfields is the same as getfields except that fields are separated by maximal strings of
       field delimiters rather than just one.

       Setfields  makes  the field delimiters (space and tab by default) be the characters of the
       string fielddelim and returns a pointer to a string of the previous delimiters.

       Tokenize breaks null-terminated string str into tokens by replacing every blank or newline
       with a null byte.  Pointers to successive non-empty tokens are placed in args.  Processing
       stops after max tokens are processed.  Tokenize returns the number  of  tokens  processed.
       Tokenize does not terminate args with a null pointer.

       Of these routines, only tokenize is in Alef.


       strtok in strcat(2)

Unix & Linux Commands & Man Pages : ©2000 - 2018 Unix and Linux Forums

All times are GMT -4. The time now is 03:46 PM.