GNU PROLOG with UTF8 support
Macros | Functions | Variables
stream_supp.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "engine_pl.h"
#include "bips_pl.h"
#include "linedit.h"
#include <unistd.h>
Include dependency graph for stream_supp.c:

Macros

#define STREAM_SUPP_FILE
 
#define START_ALIAS_TBL_SIZE   128
 
#define STR_STREAM_WRITE_BLOCK   1024
 
#define TTY_BUFFER_SIZE   1024
 
#define BIG_BUFFER   65535
 
#define ERR_TELL_OR_SEEK_UNDEFINED   "fct tell or seek undefined\n"
 
#define INIT_FCT(f, d)   pstm->f = (f) ? f : (StmFct) d
 
#define SAVE_FOR_REENTRANCY
 
#define RESTORE_FOR_REENTRANCY
 
#define Before_Reading(pstm, file)
 
#define Update_Counters(pstm, c)
 

Functions

static void Init_Stream_Supp ()
 
static int Find_Free_Stream (void)
 
static void Del_Aliases_Of_Stream (int stm)
 
static void Update_Mirrors_To_Del_Stream (int stm)
 
static Bool Remove_In_Stream_List (int stm, StmLst **p_start)
 
static int TTY_Getc (void)
 
static CHAR32_T TTY_Get_Key (Bool echo, Bool catch_ctrl_c)
 
static void TTY_Clearerr (void)
 
static CHAR32_T Basic_Call_Fct_Getc (StmInf *pstm)
 
static void Basic_Call_Fct_Putc (CHAR32_T c, StmInf *pstm)
 
static int Str_Stream_Getc (StrSInf *str_stream)
 
static void Str_Stream_Putc (CHAR32_T c, StrSInf *str_stream)
 
StmProp Pl_Prop_And_Stdio_Mode (int mode, Bool text, char *open_str)
 
int Pl_Add_Stream_For_Stdio_Desc (FILE *f, int atom_path, int mode, int text)
 
int Pl_Add_Stream_For_Stdio_File (char *path, int mode, Bool text)
 
static void Init_Stream_Struct (int atom_file_name, PlLong file, StmProp prop, StmFct fct_getc, StmFct fct_putc, StmFct fct_flush, StmFct fct_close, StmFct fct_tell, StmFct fct_seek, StmFct fct_clearerr, StmInf *pstm)
 
int Pl_Add_Stream (int atom_file_name, PlLong file, StmProp prop, StmFct fct_getc, StmFct fct_putc, StmFct fct_flush, StmFct fct_close, StmFct fct_tell, StmFct fct_seek, StmFct fct_clearerr)
 
void Pl_Delete_Stream (int stm)
 
int Pl_Find_Stream_By_Alias (int atom_alias)
 
Bool Pl_Add_Alias_To_Stream (int atom_alias, int stm)
 
void Pl_Reassign_Alias (int atom_alias, int stm)
 
void Pl_Add_Mirror_To_Stream (int stm, int m_stm)
 
Bool Pl_Del_Mirror_From_Stream (int stm, int m_stm)
 
int Pl_Find_Stream_From_PStm (StmInf *pstm)
 
void Pl_Flush_All_Streams (void)
 
void Pl_Set_Stream_Buffering (int stm)
 
int Pl_Get_Stream_Or_Alias (WamWord sora_word, int test)
 
void Pl_Check_Stream_Type (int stm, Bool check_text, Bool for_input)
 
WamWord Pl_Make_Stream_Tagged_Word (int stm)
 
Bool Pl_Stdio_Is_Repositionable (FILE *f)
 
void Pl_Stdio_Set_Buffering (FILE *f, int buffering)
 
FILE * Pl_Stdio_Desc_Of_Stream (int stm)
 
int Pl_Io_Fileno_Of_Stream (int stm)
 
void Pl_PB_Empty_Buffer (StmInf *pstm)
 
CHAR32_T Pl_Stream_Get_Key (StmInf *pstm, int echo, int catch_ctrl_c)
 
CHAR32_T Pl_Stream_Getc (StmInf *pstm)
 
void Pl_Stream_Ungetc (CHAR32_T c, StmInf *pstm)
 
CHAR32_T Pl_Stream_Peekc (StmInf *pstm)
 
char * Pl_Stream_Gets (char *str, int size, StmInf *pstm)
 
char * Pl_Stream_Gets_Prompt (char *prompt, StmInf *pstm_o, char *str, int size, StmInf *pstm_i)
 
void Pl_Stream_Putc (CHAR32_T c, StmInf *pstm)
 
int Pl_Stream_Puts (char *str, StmInf *pstm)
 
int Pl_Stream_Printf (StmInf *pstm, char *format,...)
 
void Pl_Stream_Flush (StmInf *pstm)
 
int Pl_Stream_Close (StmInf *pstm)
 
int Pl_Stream_End_Of_Stream (StmInf *pstm)
 
void Pl_Stream_Get_Position (StmInf *pstm, PlLong *offset, PlLong *char_count, PlLong *line_count, PlLong *line_pos)
 
int Pl_Stream_Set_Position (StmInf *pstm, int whence, PlLong offset, PlLong char_count, PlLong line_count, PlLong line_pos)
 
int Pl_Stream_Set_Position_LC (StmInf *pstm, PlLong line_count, PlLong line_pos)
 
int Pl_Add_Str_Stream (char *buff, int prop_other)
 
void Pl_Delete_Str_Stream (int stm)
 
char * Pl_Term_Write_Str_Stream (int stm)
 

Variables

void(* pl_init_stream_supp )() = Init_Stream_Supp
 
static int atom_constant_term_stream
 
static WamWord stream_1
 
static WamWord word_current_input_stream
 
static WamWord word_current_output_stream
 
static StrSInf static_str_stream_rd = { NULL, NULL, 0 }
 
static StrSInf static_str_stream_wr = { NULL, NULL, 0 }
 
static char tty_first_buff [TTY_BUFFER_SIZE]
 
static char * tty_buff
 
static char * tty_ptr = NULL
 

Macro Definition Documentation

#define Before_Reading (   pstm,
  file 
)
Value:
{ \
if (pstm->eof_reached) \
{ \
if (pstm->prop.eof_action == STREAM_EOF_ACTION_ERROR) \
\
if (pstm->prop.eof_action == STREAM_EOF_ACTION_EOF_CODE) \
return EOF; \
\
/* here: eof_action == STREAM_EOF_ACTION_RESET */ \
pstm->eof_reached = FALSE; \
if (pstm->prop.reposition) \
Pl_Stream_Set_Position(pstm, SEEK_SET, 0, 0, 0, 0); \
if (pstm->fct_clearerr != STREAM_FCT_UNDEFINED) \
(*pstm->fct_clearerr) (file); \
} \
}
WamWord pl_last_input_sora
static WamWord word_current_input_stream
Definition: stream_supp.c:112
int pl_permission_operation_input
int pl_permission_type_past_end_of_stream
#define FALSE
Definition: bool.h:49
int Pl_Stream_Set_Position(StmInf *pstm, int whence, PlLong offset, PlLong char_count, PlLong line_count, PlLong line_pos)
Definition: stream_supp.c:1684
void Pl_Err_Permission(int atom_oper, int atom_perm, WamWord term)
Definition: error_supp.c:609
#define NOT_A_WAM_WORD
Definition: wam_inst.h:48
#define STREAM_FCT_UNDEFINED
Definition: stream_supp.h:81
#define STREAM_EOF_ACTION_EOF_CODE
Definition: stream_supp.h:58
#define STREAM_EOF_ACTION_ERROR
Definition: stream_supp.h:57
#define BIG_BUFFER   65535
#define ERR_TELL_OR_SEEK_UNDEFINED   "fct tell or seek undefined\n"
#define INIT_FCT (   f,
  d 
)    pstm->f = (f) ? f : (StmFct) d
#define RESTORE_FOR_REENTRANCY
Value:
SYS_VAR_OPTION_MASK = save_sys_var_option_mask; \
pl_last_read_line = save_last_read_line; \
pl_last_read_col = save_last_read_col; \
}
int pl_last_read_col
Definition: parse_supp.h:87
int pl_last_read_line
Definition: parse_supp.h:86
#define SYS_VAR_OPTION_MASK
Definition: flag_supp.h:156
#define SAVE_FOR_REENTRANCY
Value:
{ \
int save_sys_var_option_mask = SYS_VAR_OPTION_MASK; \
int save_last_read_line = pl_last_read_line; \
int save_last_read_col = pl_last_read_col;
int pl_last_read_col
Definition: parse_supp.h:87
int pl_last_read_line
Definition: parse_supp.h:86
#define SYS_VAR_OPTION_MASK
Definition: flag_supp.h:156
#define START_ALIAS_TBL_SIZE   128
#define STR_STREAM_WRITE_BLOCK   1024
#define STREAM_SUPP_FILE
#define TTY_BUFFER_SIZE   1024
#define Update_Counters (   pstm,
  c 
)
Value:
if (c != EOF) \
pstm->char_count++; \
if (c == '\n') \
{ \
pstm->line_count++; \
pstm->line_pos = 0; \
} \
else \
pstm->line_pos++
static CHAR32_T c
Definition: scan_supp.c:65

Function Documentation

static CHAR32_T Basic_Call_Fct_Getc ( StmInf pstm)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static void Basic_Call_Fct_Putc ( CHAR32_T  c,
StmInf pstm 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

void Del_Aliases_Of_Stream ( int  stm)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static int Find_Free_Stream ( void  )
static

Here is the call graph for this function:

Here is the caller graph for this function:

static void Init_Stream_Struct ( int  atom_file_name,
PlLong  file,
StmProp  prop,
StmFct  fct_getc,
StmFct  fct_putc,
StmFct  fct_flush,
StmFct  fct_close,
StmFct  fct_tell,
StmFct  fct_seek,
StmFct  fct_clearerr,
StmInf pstm 
)
static

Here is the caller graph for this function:

static void Init_Stream_Supp ( void  )
static

Here is the call graph for this function:

Bool Pl_Add_Alias_To_Stream ( int  atom_alias,
int  stm 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void Pl_Add_Mirror_To_Stream ( int  stm,
int  m_stm 
)

Here is the caller graph for this function:

int Pl_Add_Str_Stream ( char *  buff,
int  prop_other 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int Pl_Add_Stream ( int  atom_file_name,
PlLong  file,
StmProp  prop,
StmFct  fct_getc,
StmFct  fct_putc,
StmFct  fct_flush,
StmFct  fct_close,
StmFct  fct_tell,
StmFct  fct_seek,
StmFct  fct_clearerr 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int Pl_Add_Stream_For_Stdio_Desc ( FILE *  f,
int  atom_path,
int  mode,
int  text 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int Pl_Add_Stream_For_Stdio_File ( char *  path,
int  mode,
Bool  text 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void Pl_Check_Stream_Type ( int  stm,
Bool  check_text,
Bool  for_input 
)

Here is the call graph for this function:

Here is the caller graph for this function:

Bool Pl_Del_Mirror_From_Stream ( int  stm,
int  m_stm 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void Pl_Delete_Str_Stream ( int  stm)

Here is the call graph for this function:

Here is the caller graph for this function:

void Pl_Delete_Stream ( int  stm)

Here is the call graph for this function:

Here is the caller graph for this function:

int Pl_Find_Stream_By_Alias ( int  atom_alias)

Here is the call graph for this function:

Here is the caller graph for this function:

int Pl_Find_Stream_From_PStm ( StmInf pstm)

Here is the caller graph for this function:

void Pl_Flush_All_Streams ( void  )

Here is the call graph for this function:

Here is the caller graph for this function:

int Pl_Get_Stream_Or_Alias ( WamWord  sora_word,
int  test 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int Pl_Io_Fileno_Of_Stream ( int  stm)

Here is the call graph for this function:

Here is the caller graph for this function:

WamWord Pl_Make_Stream_Tagged_Word ( int  stm)
void Pl_PB_Empty_Buffer ( StmInf pstm)

Here is the caller graph for this function:

StmProp Pl_Prop_And_Stdio_Mode ( int  mode,
Bool  text,
char *  open_str 
)

Here is the caller graph for this function:

void Pl_Reassign_Alias ( int  atom_alias,
int  stm 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void Pl_Set_Stream_Buffering ( int  stm)

Here is the call graph for this function:

Here is the caller graph for this function:

FILE* Pl_Stdio_Desc_Of_Stream ( int  stm)

Here is the caller graph for this function:

Bool Pl_Stdio_Is_Repositionable ( FILE *  f)

Here is the caller graph for this function:

void Pl_Stdio_Set_Buffering ( FILE *  f,
int  buffering 
)

Here is the caller graph for this function:

int Pl_Stream_Close ( StmInf pstm)

Here is the caller graph for this function:

int Pl_Stream_End_Of_Stream ( StmInf pstm)

Here is the call graph for this function:

Here is the caller graph for this function:

void Pl_Stream_Flush ( StmInf pstm)

Here is the caller graph for this function:

CHAR32_T Pl_Stream_Get_Key ( StmInf pstm,
int  echo,
int  catch_ctrl_c 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void Pl_Stream_Get_Position ( StmInf pstm,
PlLong offset,
PlLong char_count,
PlLong line_count,
PlLong line_pos 
)

Here is the caller graph for this function:

CHAR32_T Pl_Stream_Getc ( StmInf pstm)

Here is the call graph for this function:

Here is the caller graph for this function:

char* Pl_Stream_Gets ( char *  str,
int  size,
StmInf pstm 
)

Here is the call graph for this function:

Here is the caller graph for this function:

char* Pl_Stream_Gets_Prompt ( char *  prompt,
StmInf pstm_o,
char *  str,
int  size,
StmInf pstm_i 
)

Here is the call graph for this function:

Here is the caller graph for this function:

CHAR32_T Pl_Stream_Peekc ( StmInf pstm)

Here is the call graph for this function:

Here is the caller graph for this function:

int Pl_Stream_Printf ( StmInf pstm,
char *  format,
  ... 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void Pl_Stream_Putc ( CHAR32_T  c,
StmInf pstm 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int Pl_Stream_Puts ( char *  str,
StmInf pstm 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int Pl_Stream_Set_Position ( StmInf pstm,
int  whence,
PlLong  offset,
PlLong  char_count,
PlLong  line_count,
PlLong  line_pos 
)

Here is the caller graph for this function:

int Pl_Stream_Set_Position_LC ( StmInf pstm,
PlLong  line_count,
PlLong  line_pos 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void Pl_Stream_Ungetc ( CHAR32_T  c,
StmInf pstm 
)

Here is the call graph for this function:

Here is the caller graph for this function:

char* Pl_Term_Write_Str_Stream ( int  stm)

Here is the caller graph for this function:

static Bool Remove_In_Stream_List ( int  stm,
StmLst **  p_start 
)
static

Here is the caller graph for this function:

static int Str_Stream_Getc ( StrSInf str_stream)
static

Here is the caller graph for this function:

static void Str_Stream_Putc ( CHAR32_T  c,
StrSInf str_stream 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static void TTY_Clearerr ( void  )
static

Here is the caller graph for this function:

static CHAR32_T TTY_Get_Key ( Bool  echo,
Bool  catch_ctrl_c 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static int TTY_Getc ( void  )
static

Here is the call graph for this function:

Here is the caller graph for this function:

static void Update_Mirrors_To_Del_Stream ( int  stm)
static

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

int atom_constant_term_stream
static
void(* pl_init_stream_supp) () = Init_Stream_Supp
StrSInf static_str_stream_rd = { NULL, NULL, 0 }
static
StrSInf static_str_stream_wr = { NULL, NULL, 0 }
static
WamWord stream_1
static
char* tty_buff
static
char tty_first_buff[TTY_BUFFER_SIZE]
static
char* tty_ptr = NULL
static
WamWord word_current_input_stream
static
WamWord word_current_output_stream
static