Stream Structure

The Prolog representation of a Prolog stream provides a way of retrieving information from its corresponding C stream structure. It is currently represented as a Prolog term in the form of '$stream'(N) where N is an integer to identify the stream. However, a user application should not explicitly create such a Prolog term as a Prolog stream, it should only be obtained through open/[3,4], open_null_stream/1, or stream_code/2. In C code, a Prolog stream is represented as a pointer to structure of type QP_stream. The formatting information along with bottom layer functions of a stream is stored in its QP_stream structure. A stream behavior depends on the values of fields in its QP_stream structure. The options specified in open/4 are converted and stored in the QP_stream structure created for the stream.

Selected fields in QP_stream that can be accessed and modified by an application are described in the remainder of the section. Most of these fields are option fields, which can be specified in open/4.