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



Low Level I/O Functions

For each new stream the appropriate low level I/O functions have to be defined. Error handling, prompt handling and character counting is handled in a layer above these functions. They all operate on a user defined private data structure pointed out by user_handle in SP_stream.

User defined low level I/O functions may invoke Prolog code and use the support functions described in the other sections of this chapter.

int my_fgetc(void *handle)
Should return the character read or -1 on end of file.
int my_fputc(char c, void *handle)
Should write the character c and return the character written.
int my_flush(void *handle)
Should flush the (output) stream and return 0 on success, -1 on error.
int my_eof(void *handle)
Should return 1 on end of file, else 0.
void my_clrerr(void *handle)
Should reset the stream's error and EOF indicators.
int my_close(void *handle)
Should close the stream and return zero.