For most streams you don't have to know anything about the
internal representatio, but there may be occasions when you have to set
some fields manually or do some processing on all streams of a
particular type. SICStus Prolog maintains a circular list of
stream objects of type SP_stream
.
SP_stream *backward;
SP_stream *forward;
SP_make_stream()
and the deletion is done from the Prolog
predicate close/1
.
char *filename;
""
, by
SP_make_stream()
. May be set to a suitable encoded string,
provided the string will not be overwritten until the stream is
closed.
unsigned long mode;
void SP_set_tty(SP_stream *s)
int fd;
void *user_handle;
user_handle
could be a pointer to the
standard I/O FILE
.
There is no standard way to tell if a stream is user defined. You have to save pointers to the streams created or check if one of the stream functions installed is user defined, i.e:
int is_my_stream(SP_stream *s) { return (s->sclose == my_close); }