| T X T _ S T R T O K ( )
| | | | | SOURCE: qdev_autodocs.txt 1.163 (12/09/2014) English INDEP - TXT_#?
----------------------------------------------------------------------------
NAME
txt_strtok() - General purpose tokenisator.
SYNOPSIS
token = txt_strtok(str1, str2, tptr);
UBYTE *txt_strtok(UBYTE *, const UBYTE *, ULONG *);
FUNCTION
This func. allows to tokenise a NULL terminated string,
so that programmer can build configuration parser quite
easily for example.
INPUTS
str1 - String that will be parsed. Only first time op.
requires the string, all other ops use NULL!
str2 - String with delimiter/separator characters.
tptr - Pointer to 8 byte buffer, 'ULONG buf[2]' will
be just fine.
RETURNS
Returns token every call, or NULL if no tokens or the
end of string has been reached.
BASES
None.
NOTES
This function is somewhat different than standard one
as found in many C libraries. Firstly it not only
remembers the address in user variable but also last
character that was destroyed so effecitevly this func.
does not require a copy of the data to be worked on
and not at least if data is not being shared amongst
other threads or tasks.
The recommended way of using this function is through
the macros that can be found in the header file.
SEE ALSO
EXAMPLE
...
UBYTE *token;
UBYTE *string = "red,green,blue";
QDEV_TXT_STRTOKTYPE(tdata);
if ((token = QDEV_TXT_STRTOKINIT(string, ",", tdata)))
{
do
{
FPrintf(Output(), "Colour: %s\n", (LONG)token);
} while ((token = QDEV_TXT_STRTOKNEXT(",", tdata)));
QDEV_TXT_STRTOKTERM(tdata); /* This is very important */
}
BUGS
None known.
----------------------------------------------------------------------------
| |
| |