axl main logo
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules Pages
char * axl_stream_get_until_zero ( axlStream stream,
char *  valid_chars,
int *  chunk_matched,
axl_bool  accept_terminator,
int  chunk_num,

Allows to get the next string until the separators provided are found or the end of the stream memory is reached.

axlStream type was designed to support parsing xml documents. This documents have elements that allows to now where the input has finished. Howerver, axlStream abstraction has showed to be powerful enough to be usable to parse other kinds of elements that don't have lexical terminators to let the user to provide that chunk to be matched.

In those cases, this function allows to perform the same function as axl_stream_get_until but also checking, and using, as terminator the end of the stream.

This allows to parse expressions like:

1 int chunk_matched;
2 axlStream * stream;
3 char * string;
5 // create the stream
6 stream = axl_stream_new ("array.value", -1, NULL, -1, &error);
8 // parse first array identifier
9 string = axl_stream_get_until_zero (stream, NULL, &chunk_matched,
10  axl_false, 2, "[", ".", NULL);
12 // received "array"
14 // parse again
15 string = axl_stream_get_until_zero (stream, NULL, &chunk_matched,
16  axl_false, 2, "[", ".", NULL);
18 // received "value" and chunk_matched == (-2)
streamThe stream were the chunk will be extracted.
valid_charsThe valid set of characters, to validate content to be returned. Currently this is not implemented, so, you can provide a NULL value.
chunk_matchedAn optional pointer to an integer to notify the chunk matched by the function. Chunk matching notification starts from 0 up to number of chunks to match - 1. If the end of the stream is reached while searching for the content to match, chunk_matched is configured to -2.
accept_terminatorWhile calling to this function, the terminator detected to stop the operation could also be accepted by the stream, making it not necessary to accept the terminator once the function have ended. However, this could be a problem while performing peeking code. You can provide a AXL_FALSE value to make the function to not accept the terminator found as to be consumed.
chunk_numThe number of chunks to be checked as a valid terminators.
The chunk recognizied, not including the terminator that have made this operation to stop. Rembember to check the chunk_matched variable to be equal to -2. This will mean that the string returned doesn't match any terminator provided because end of the stream was reached while looking for them.

References axl_false, axl_stream_get_untilv(), and axl_true.