axlStream * axl_stream_new ( const char *  stream_source,
int  stream_size,
const char *  file_path,
int  fd_handler,
axlError **  error 
)

Creates a new byte stream using as data the string pointer and the size.

The axlStream object is an abstraction that allows to interface with a memory chunk, a file descriptor (or a socket) or a direct path, with a contenience API that allows inspecting and accepting the streamed content.

Here is an example on how to create an stream from a memory chunk:

 axlStream * stream;
 axlError  * error;

 // create the stream and check result 
 stream = axl_stream_new (source_content, size_content, -1, NULL, &error);
 if (stream == NULL) {
     printf ("An error was found: %s\n", axl_error_get (error));
     axl_error_free (error);
     return;
 }
 
 // stream created

In the case an stream is required to parse a file descriptor (including a socket):

 stream = axl_stream_new (NULL, -1, NULL, fd, &error);

You can also provide a file path to let the axl stream module to open the file and buffer it as it requires to consume characters:

 stream = axl_stream_new (NULL, -1, "c:/myFiles/document.xml", -1, &error);

Once initialized the axlStream object, you can use the following function to check and consume characters:

There alternatives APIs that allows to get the content until some patter is found (or a set of patterns):

Parameters:
stream_source A pointer to the memory where the data to be streamed is located.
stream_size How many bytes are available to perform streaming. You can pass a -1 value to allow the function to calculate the stream source size (stream_source param).
file_path Optional parameter to allow reading the stream from a file using the open API.
fd_handler Optional parameter to allow reading the stream from a file descriptor, that could be a file, a socket, etc..
error Optional axlError reference where errors will be reported.
Returns:
A newly allocated stream instance that should be deallocated by using axl_stream_free. The function could return a NULL value is received a NULL stream or a non positive stream size.