Next: str_tokbqenize_free, Previous: str_tokqcnt, Up: Strings
tokenize a string at specified delimiters
#include <suplib/str.h>int str_tokbqenize( char *string, char ***string_argv, 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
char ***string_argv
- to store the parsed tokens
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 tokenizes the string using str_tokbq
. The
invoking routine calls str_tokbqenize
once to parse all the tokens
for a given delimiter. The tokens are stored in string_argv.
if the restore
argument is false, str_tokbqenize
will
allocate memory for each of the tokens; otherwise it will return
pointers to the locations in the original string.
The routine str_tokbqenize_free
is provided to free the memory
allocated by str_tokbqenize
The number of tokens. The third argument, string_argv
,
contains the parsed tokens.
On error, str_tokbqenize
returns 0
and sets errno
accordingly. The following errors are recognized:
EINVAL
ENOMEM
Diab Jerius Dan Nguyen