Node:Installing a New Stream, Next:, Previous:Low Level I/O Functions, Up:Defining a New Stream



Installing a New Stream

A new stream is made accessible to Prolog using one of the functions:

int SP_make_stream(
        void *handle,
        int (*sgetc)(),
        int (*sputc)(),
        int (*sflush)(),
        int (*seof)(),
        void (*sclrerr)(),
        int (*sclose)(),
        SP_stream **stream)

int SP_make_stream_context(
        void *handle,
        int (*sgetc)(),
        int (*sputc)(),
        int (*sflush)(),
        int (*seof)(),
        void (*sclrerr)(),
        int (*sclose)(),
        SP_stream **stream,
        SP_atom option,
        int context)

The functions return SP_SUCCESS on success and SP_ERROR for invalid usage, and will:

The handle pointer will be supplied as the handle argument in the calls to the low level functions.

A stream without a close function will be treated as not closable i.e. close/1 will not have any effect on it.

The SP_make_stream_context function has two additional arguments supplying information related to the handling of wide characters; see WCX Foreign Interface.