Next: , Previous: str_tokbq_restore, Up: Strings


4.17 str_tokbqcnt

count the number of tokens in a string

Synopsis

     #include <suplib/str.h>
     
     
     
int str_tokbqcnt( char *string, const char *delim, const char *open_quote, const char *close_quote, char escape_char, int actions, struct str_tokbqdata *tbqd, int *error );

Parameters

char *string
the string to parse
const char *delim
the set of characters that delimit tokens
const char *open_quote
the set of characters that delimit opening quotes. e.g., ‘"'{[
const char *close_quote
the set of matching characters that delimit closing quotes. These must be in the same order as the opening characters in open_quote, e.g., ‘"'}]
char escape_char
the escape character
int actions
skip, restore, and escape modes
struct str_tokbqdata *tbqd
state information
int *error
returned error code

Description

This routine counts the number of tokens in a string as would be returned by str_tokbq. It does change the input string, but restores it to its initial state upon completion. A constant string (e.g., a statically declared string) should not be passed.

Returns

Upon success it returns the number of tokens in the string. On error it returns ‘-1’.

Author

Diab Jerius