Download SICStus Prolog User`s Manual
Transcript
Chapter 9: Mixing C and Prolog
191
void *user_handle;
This is the pointer to the user supplied private data for the stream. In the case
of SICStus Prolog predefined file streams the 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);
}
9.5.3 Hookable Standard Streams
As of release 3.7, the standard I/O streams (input, output, and error) are hookable, i.e. the
streams can be redefined by the user.
SP_UserStreamHook *SP_set_user_stream_hook(SP_UserStreamHook *hook)
Sets the user-stream hook to hook.
SP_UserStreamPostHook *SP_set_user_stream_post_hook(SP_UserStreamPostHook
*hook)
Sets the user-stream post-hook to hook.
These hook functions must be called before SP_initialize() (see Section 9.7.4.1 [Initializing the Prolog Engine], page 202). In custom built development systems, they may be
called in the hook function SU_initialize(). See Section 9.7.3 [The spld utility], page 194.
9.5.3.1 Writing User-stream Hooks
The user-stream hook is, if defined, called during SP_initialize(). It has the following
prototype:
SP_stream *user_stream_hook(int which)
If the hook is not defined, SICStus will attempt to open the standard TTY/console versions
of these streams. If they are unavailable (such as for windowed executables under Windows),
the result is undefined.
It is called three times, one for each stream. The which argument indicates which stream
it is called for. The value of which is one of:
SP_STREAMHOOK_STDIN
Create stream for standard input.
SP_STREAMHOOK_STDOUT
Create stream for standard output.
Related documents
SICStus Prolog User`s Manual
SICStus Prolog User`s Manual
SICStus Prolog User's Manual
SICStus Prolog User`s Manual
Planning using Situation Calculus, Prolog and a - CEUR
Ciao Manual - The Ciao System
SICStus Prolog Release Notes
Sec - SICStus Prolog 3
PR Pilot 575 User Manual
Design and Applied Technology (Secondary 4 – 6)
AX50 Color Screen Digital Mobile Phone User Manual