Creation

The exact mechanism for creating a stream depends upon the source for that particular stream, but typically it will involve a call to a creation function, such as fz_open_file.


\begin{lstlisting}
/*
fz_open_file: Open the named file and wrap it in a stream...
...fz_stream *fz_open_file(fz_context *ctx, const char *filename);
\end{lstlisting}

Alternative functions exist to allow creating streams from C level FILE pointers:


\begin{lstlisting}
/*
fz_open_file: Wrap an open file descriptor in a stream.
\...
...r.
*/
fz_stream *fz_open_file_ptr(fz_context *ctx, FILE *file);
\end{lstlisting}

from direct memory blocks:


\begin{lstlisting}
/*
fz_open_memory: Open a block of memory as a stream.
\par
...
..._open_memory(fz_context *ctx, unsigned char *data, size_t len);
\end{lstlisting}

and from fz_buffers:


\begin{lstlisting}
/*
fz_open_buffer: Open a buffer as a stream.
\par
buf: The ...
...
*/
fz_stream *fz_open_buffer(fz_context *ctx, fz_buffer *buf);
\end{lstlisting}

There are too many other options for creating streams to list them all here, but their use should be self evident from the header file definitions. Once created, all streams can be used in the same ways.