gd_strtok(3)

NAME
gd_strtok — tokenise a string using the GetData parser

SYNOPSIS
#include <getdata.h>

char *gd_strtok(DIRFILE *dirfile, const char *string);

DESCRIPTION
The function parses a string into a series of tokens according to the rules of the Dirfile metadata syntax (see dirfile-format(5)). The first time is called, the string to be parsed should be passed in The first token will be returned. In subsequent calls to parse the same string, should be NULL (as with Each time is called like this, the next token is returned.

Operation of the Dirfile tokeniser varies between Dirfile Standards Versions. The Standards Version used is the current Version of the loaded DIRFILE Use to retrieve or change this value. Changing the Standards Version of while parsing a string will affect the parsing of subsequent tokens, but does not affect tokens already returned. A copy of the string is cached in the object. Calling with different will parse different strings.

RETURN VALUE
Upon successful completion, returns a copy of the first token, if is non-NULL, or else a subsequent token from the previously specified string, if is NULL. Every non-NULL pointer returned by points to a new buffer allocated on the heap. By default, is used the allocate the buffers, but an alternate memory manager may be used by calling before calling this function. The caller is responsible for deallocating all these buffers.

If no more tokens are available, or if an error occurred, NULL is returned. If an error has occurred, it will also set the dirfile error a non-zero error value. Possible error values are: A memory allocation error occurred. There was no string to parse (i.e. was NULL, but no previous call specified a string to parse). The supplied dirfile was invalid. A syntax error was found in the string.

The dirfile error may be retrieved by calling A descriptive error string for the last error encountered can be obtained from a call to

HISTORY
The function appeared in GetData-0.8.0.

SEE ALSO
dirfile-format(5)