Prolog streams are designed by default to be channels for I/O operations to a file or a terminal. User defined streams enable these operations to be performed on other types of object: notably, windows or a network channel.
The embedding input/output functions create the default Prolog streams and provide the user with the default parameters for creating a user-defined stream. It is possible to change these defaults. However, in general it is not necessary or even advantageous to do this.
Such replacement is only required when the application in which the Prolog code is embedded demands full control of the I/O system and does not want Prolog to make direct calls to the operating systen to perform I/O. One instance of such usage is to embed a Prolog program within an application that uses a graphical window-oriented user interface.
The embedding layer for input/output contains four functions:
QU_stream_param()
QP_stream
structure.
QU_initio()
QU_open()
open/[3,4]
and QP_fopen()
.
QU_fdopen()
open(2)
.
Details of each function can be found in the individual reference pages.
Any of these functions can be supplied in linking a Prolog system
through qld
. If any function is not supplied, the default
version of that function is linked in.
A number of C macros and functions are provided in
<quintus/quintus.h>
and e.g. libqp.a
to access and manipulate
Prolog streams where it is more convenient to access them from C
rather than calling a Prolog builtin. For example, QP_getc()
will get a character from a Prolog stream in the same way as
get0/2
. These macros and functions are listed in
fli-ios-bio.