Next: str_trim, Previous: str_tokbq_restore, Up: Strings
count the number of tokens in a string
#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 );
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
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.
Upon success it returns the number of tokens in the string. On error it returns ‘-1’.
Diab Jerius