SP_create_stream()
#include <sicstus/sicstus.h> spio_t_error_code SP_create_stream( void *user_data, void const *user_class, spio_t_simple_device_read *user_read, spio_t_simple_device_write *user_write, spio_t_simple_device_flush_output *user_flush_output, spio_t_simple_device_seek *user_seek, spio_t_simple_device_close *user_close, spio_t_simple_device_interrupt *user_interrupt, spio_t_simple_device_ioctl *user_ioctl, spio_t_bits create_stream_options, SP_stream **pstream);
Create a Prolog stream that will call user defined functions to perform stream operations.
NULL
.
SP_get_stream_user_data()
,
which see.
Note that both user_read
and user_write
can be
specified, signifying a bidirectional stream.
user_write
is NULL
. Can be NULL
if
the stream need not be flushed, e.g. if user_write
always
ensures that any output reaches its destination immediately.
See cpg-ref-user_flush_output for details.
NULL
.
NULL
.
NULL
.
NULL
.
SP_CREATE_STREAM_OPTION_BINARY
user_read
and user_write
methods transfer bytes.
SP_CREATE_STREAM_OPTION_TEXT
user_read
and user_write
methods transfer wide characters.
SP_CREATE_STREAM_OPTION_AUTOFLUSH
flush_output/1
. In essence this ensures that the stream behaves
as if it were unbuffered.
SP_CREATE_STREAM_OPTION_INTERACTIVE
SP_CREATE_STREAM_OPTION_AUTOFLUSH
.
SP_CREATE_STREAM_OPTION_EOF_ON_EOF
SP_CREATE_STREAM_OPTION_RESET_ON_EOF
open/4
options eof_action(eof)
and eof_action(reset)
respectively. The default is to give an
error if reading after reaching end of file.
Exactly one of SP_CREATE_STREAM_OPTION_BINARY
and
SP_CREATE_STREAM_OPTION_TEXT
must be set.
SP_fclose()
or close/[1,2]
.
On success, *pstream
is assigned, and
SPIO_S_NOERR
or some other success code is returned. You should
use the SPIO_FAILED()
macro to determine if the return value
signifies failure or success.