Stream Operations

Main operations on streams.

YAP uses streams to perform Input/Output. Streams are non-backtrackable objects loosely based on the Unix library IO primitives. They must be open, their properties can be queried or modified, and ultimately they need to be closed.

Define:

1. strncat:

1. strncpy:

1. MB_LEN_MAX:

1. OPEN_DEFS:

1. PAR:

1. PAR:

1. PAR:

1. PAR:

1. CheckStream:

1. CLOSE_DEFS:

Functions:

1. static int get_wchar_from_file(int):

1. char * Yap_VF(const char *path):

1. char * Yap_VFAlloc(const char *path):

1. static int past_eof(StreamDesc *s):

1. static int EOFWGetc(int sno):

1. static int EOFGetc(int sno):

1. void Yap_stream_id(StreamDesc *s, Term user_name, Atom system_name):

1. void Yap_default_peek(StreamDesc *st):

1. static int NullPutc(int sno, int ch):

1. void Yap_EOF_Stream(StreamDesc *st):

1. int post_process_eof(StreamDesc *s):

1. int post_process_read_wchar(int ch, size_t n, StreamDesc *s):

1. int post_process_read_char(int ch, StreamDesc *s):

1. void Yap_DefaultStreamOps(StreamDesc *st):

1. static void InitStdStream(int sno, SMALLUNSGN flags, FILE file, VFS_t vfsp):

1. void Yap_InitStdStream(int sno, unsigned int flags, FILE file, VFS_t vfsp):

1. static void InitStdStreams(void):

1. void Yap_InitStdStreams(void):

1. Int PlIOError__(const char file, const char function, int lineno, yap_error_number type, Term culprit,...):

1. bool UnixIOError__(const char file, const char function, int lineno, int error, io_kind_t io_type, Term culprit,...):

1. void Yap_DebugSetIFile(char *fname):

1. void Yap_DebugEndline():

1. int Yap_DebugGetc():

1. int Yap_DebugPutc(FILE *s, wchar_t ch):

1. int Yap_DebugPuts(FILE s, const char sch):

1. void Yap_DebugErrorPuts(const char *s):

1. void Yap_DebugPlWrite(Term t):

1. void Yap_DebugPlWriteln(Term t):

1. void Yap_DebugErrorPutc(int c):

1. void Yap_DebugWriteIndicator(PredEntry *ap):

1. int FilePutc(int sno, int ch):

1. void * Yap_RepStreamFromId(int sno):

1. int EOFPeek(int sno): : caled after EOF found a peek, it just calls console_post_process to conclude the job.

sno return:
EOF

1. int EOFWPeek(int sno):

1. int PlGetc(int sno):

1. static int handle_write_encoding_error(int sno, wchar_t ch):

1. int put_wchar(int sno, wchar_t ch):

1. int Yap_PlGetchar(void):

1. int Yap_PlGetWchar(void):

1. int Yap_PlFGetchar(void):

1. Term Yap_MkStream(int n):

1. Int GetStreamFd(int sno):

1. Int Yap_GetStreamFd(int sno):

1. static int binary_file(const char *file_name):

1. static int write_bom(int sno, StreamDesc *st):

1. static int check_bom(int sno, StreamDesc *st):

1. bool Yap_initStream__(const char f, const char func, int line, int sno, FILE file, Atom name, const char io_mode, Term file_name, encoding_t encoding, stream_flags_t flags, void *vfs):

1. static bool scan_failed(int sno, long pos, encoding_t onc):

1. static bool scan_encoding(int sno):

1. static bool open_header(int sno, Atom open_mode):

1. static bool fill_stream(int sno, StreamDesc st, Term tin, const char io_mode, Term user_name, bool *avoid_bomp, encoding_t enc):

1. static Int do_open(Term file_name, Term t2, Term tlist USES_REGS):

1. static Int ope/3(USES_REGS1):

1. static Int ope/4(USES_REGS1):

1. static Int p_file_expansion(USES_REGS1):

1. static Int p_open_null_stream(USES_REGS1):

1. int Yap_OpenStream(Term tin, const char *io_mode, Term user_name, encoding_t enc):

1. int Yap_FileStream(FILE fd, Atom name, Term file_name, estream_f flags, VFS_t vfsp):

1. static int CheckStream__(const char file, const char f, int line, Term arg, estream_f kind, const char *msg):

1. int Yap_CheckStream__(const char file, const char f, int line, Term arg, estream_f kind, const char *msg):

1. int Yap_CheckTextStream__(const char file, const char f, int line, Term arg, estream_f kind, const char *msg):

1. int Yap_CheckTextWriteStream__(const char file, const char f, int line, Term arg, const char *msg):

1. int Yap_CheckTextReadStream__(const char file, const char f, int line, Term arg, const char *msg):

1. int Yap_CheckBinaryStream__(const char file, const char f, int line, Term arg, estream_f kind, const char *msg):

1. int Yap_CheckOutputBinaryStream__(const char file, const char f, int line, Term arg, estream_f kind, const char *msg):

1. int Yap_GetFreeStreamDForReading(void):

1. static Int always_prompt_user(USES_REGS1):

@class always_prompt_userUaUU0UU7cU_0 ** "always_prompt_user " ** Input_Stream_f;

Ensure that the stream always prompts before asking the standard input stream for data.

1. static Int clos/1(USES_REGS1):

1. static Int clos/2(USES_REGS1):

1. Term read_line(int sno):

1. void Yap_InitPlIO(struct yap_boot_params *argi):

1. void Yap_InitIOPreds(void):

Var:

1. FILE* Yap_stdin:

1. FILE* Yap_stdout:

1. FILE* Yap_stderr:

1. int eolflg:

1. char my_line[200][200]:

1. char* lp:

1. FILE* curfile:

1. FILE * Yap_logfile:

1. bool Yap_Option[256][256]:

1. const param_t open_defs[][]:

1. const param_t close_defs[][]:

Typedef:

1. typedef enum open_enum_choices open_choices_t:

1. typedef enum close_enum_choices close_choices_t:

Enum:

1. open_enum_choices:

1. close_enum_choices: