stream_code/2stream_code(-Stream, +CStream)
stream_code(+Stream, -CStream)
Converts between Prolog representation, Stream, and C representation, CStream, of a stream.
stream_code/2 is used when there are input/output related operations
performed on the same stream in both Prolog code and foreign code.
Stream argument is a valid type if it is user, user_input,
user_output, user_error, a variable, or a value obtained through
open/[3,4] or previous stream_code/2 call.
Such a valid Stream value can be used as the stream argument to
any of the Prolog built-in I/O predicates taking a stream argument.
CStream argument is a valid type if it is a variable, a value obtained
through previous stream_code/2 call, a value obtained through
QP_fopen(), QP_fdopen(), or a value of pointer to
QP_stream structure obtained through foreign function call.
Such a valid CStream value can be used as the stream argument to
any of the QP foreign function taking stream as an argument.
instantiation_error
type_error
existence_error
The most frequent use of stream_code/2 is
to get a stream value to be used in Prolog code for a stream created
in foreign code. This is necessary when a desired stream can not be
obtained through open/[3,4]; e.g. a stream referring to a socket
or an encrypted file.
open/[3,4], QP_fopen(), QP_fdopen()