avoid unnecessrily using slots in Input/Output calls or just because I need a stream. This can lead to hard to
catch stack bugs.
This commit is contained in:
parent
d777ff863a
commit
1531002f26
@ -2704,11 +2704,11 @@ YAP_TermToStream(Term t)
|
|||||||
{
|
{
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
IOSTREAM *s;
|
IOSTREAM *s;
|
||||||
int rc;
|
|
||||||
extern int PL_get_stream_handle(Int t, IOSTREAM **s);
|
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
|
|
||||||
if ( (rc=PL_get_stream_handle(Yap_InitSlot(t PASS_REGS), &s)) ) {
|
if (IsVarTerm(t) || !IsAtomTerm(t))
|
||||||
|
return NULL;
|
||||||
|
if ( (s=Yap_GetStreamHandle(AtomOfTerm(t))) ) {
|
||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
15
C/iopreds.c
15
C/iopreds.c
@ -745,19 +745,24 @@ p_read ( USES_REGS1 )
|
|||||||
return do_read(Yap_Scurin(), 7 PASS_REGS);
|
return do_read(Yap_Scurin(), 7 PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int Yap_getInputStream(Int, IOSTREAM **);
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_read2 ( USES_REGS1 )
|
p_read2 ( USES_REGS1 )
|
||||||
{ /* '$read2'(+Flag,?Term,?Module,?Vars,-Pos,-Err,+Stream) */
|
{ /* '$read2'(+Flag,?Term,?Module,?Vars,-Pos,-Err,+Stream) */
|
||||||
IOSTREAM *inp_stream;
|
IOSTREAM *inp_stream;
|
||||||
Int out;
|
Int out;
|
||||||
|
Term t8 = Deref(ARG8);
|
||||||
|
|
||||||
if (!Yap_getInputStream(Yap_InitSlot(Deref(ARG8) PASS_REGS), &inp_stream)) {
|
if (IsVarTerm(t8)) {
|
||||||
Yap_RecoverSlots(1 PASS_REGS);
|
Yap_Error(INSTANTIATION_ERROR,t8,"read_term/3");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!IsAtomTerm(t8)) {
|
||||||
|
Yap_Error(TYPE_ERROR_LIST,t8,"read_term/3");
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
if (!(inp_stream = Yap_GetInputStream(AtomOfTerm(t8))) ) {
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
Yap_RecoverSlots(1 PASS_REGS);
|
|
||||||
out = do_read(inp_stream, 8 PASS_REGS);
|
out = do_read(inp_stream, 8 PASS_REGS);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
15
C/pl-yap.c
15
C/pl-yap.c
@ -989,21 +989,6 @@ int PL_unify_integer__LD(term_t t, intptr_t i ARG_LD)
|
|||||||
return Yap_unify(Yap_GetFromSlot(t PASS_REGS),iterm);
|
return Yap_unify(Yap_GetFromSlot(t PASS_REGS),iterm);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int Yap_getInputStream(term_t t, IOSTREAM **s);
|
|
||||||
|
|
||||||
int Yap_getInputStream(term_t t, IOSTREAM **s)
|
|
||||||
{
|
|
||||||
GET_LD
|
|
||||||
return getInputStream(t, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern int Yap_getOutputStream(term_t t, IOSTREAM **s);
|
|
||||||
|
|
||||||
int Yap_getOutputStream(term_t t, IOSTREAM **s)
|
|
||||||
{
|
|
||||||
GET_LD
|
|
||||||
return getOutputStream(t, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
22
C/qlyr.c
22
C/qlyr.c
@ -976,8 +976,17 @@ static Int
|
|||||||
p_read_module_preds( USES_REGS1 )
|
p_read_module_preds( USES_REGS1 )
|
||||||
{
|
{
|
||||||
IOSTREAM *stream;
|
IOSTREAM *stream;
|
||||||
|
Term t1 = Deref(ARG1);
|
||||||
|
|
||||||
if (!Yap_getInputStream(Yap_InitSlot(Deref(ARG1) PASS_REGS), &stream)) {
|
if (IsVarTerm(t1)) {
|
||||||
|
Yap_Error(INSTANTIATION_ERROR,t1,"read_qly/3");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!IsAtomTerm(t1)) {
|
||||||
|
Yap_Error(TYPE_ERROR_ATOM,t1,"read_qly/3");
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
if (!(stream = Yap_GetInputStream(AtomOfTerm(t1))) ) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
read_module(stream);
|
read_module(stream);
|
||||||
@ -989,8 +998,17 @@ p_read_program( USES_REGS1 )
|
|||||||
{
|
{
|
||||||
IOSTREAM *stream;
|
IOSTREAM *stream;
|
||||||
void YAP_Reset(void);
|
void YAP_Reset(void);
|
||||||
|
Term t1 = Deref(ARG1);
|
||||||
|
|
||||||
if (!Yap_getInputStream(Yap_InitSlot(Deref(ARG1) PASS_REGS), &stream)) {
|
if (IsVarTerm(t1)) {
|
||||||
|
Yap_Error(INSTANTIATION_ERROR,t1,"read_program/3");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!IsAtomTerm(t1)) {
|
||||||
|
Yap_Error(TYPE_ERROR_ATOM,t1,"read_program/3");
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
if (!(stream = Yap_GetInputStream(AtomOfTerm(t1))) ) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
YAP_Reset();
|
YAP_Reset();
|
||||||
|
22
C/qlyw.c
22
C/qlyw.c
@ -701,8 +701,17 @@ p_save_module_preds( USES_REGS1 )
|
|||||||
{
|
{
|
||||||
IOSTREAM *stream;
|
IOSTREAM *stream;
|
||||||
Term tmod = Deref(ARG2);
|
Term tmod = Deref(ARG2);
|
||||||
|
Term t1 = Deref(ARG1);
|
||||||
|
|
||||||
if (!Yap_getOutputStream(Yap_InitSlot(Deref(ARG1) PASS_REGS), &stream)) {
|
if (IsVarTerm(t1)) {
|
||||||
|
Yap_Error(INSTANTIATION_ERROR,t1,"save_module/3");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!IsAtomTerm(t1)) {
|
||||||
|
Yap_Error(TYPE_ERROR_ATOM,t1,"save_module/3");
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
if (!(stream = Yap_GetOutputStream(AtomOfTerm(t1))) ) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (IsVarTerm(tmod)) {
|
if (IsVarTerm(tmod)) {
|
||||||
@ -720,8 +729,17 @@ static Int
|
|||||||
p_save_program( USES_REGS1 )
|
p_save_program( USES_REGS1 )
|
||||||
{
|
{
|
||||||
IOSTREAM *stream;
|
IOSTREAM *stream;
|
||||||
|
Term t1 = Deref(ARG1);
|
||||||
|
|
||||||
if (!Yap_getOutputStream(Yap_InitSlot(Deref(ARG1) PASS_REGS), &stream)) {
|
if (IsVarTerm(t1)) {
|
||||||
|
Yap_Error(INSTANTIATION_ERROR,t1,"save_program/3");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!IsAtomTerm(t1)) {
|
||||||
|
Yap_Error(TYPE_ERROR_ATOM,t1,"save_program/3");
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
if (!(stream = Yap_GetOutputStream(AtomOfTerm(t1))) ) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return save_program(stream) != 0;
|
return save_program(stream) != 0;
|
||||||
|
@ -257,11 +257,13 @@ int STD_PROTO(Yap_eq,(Term, Term));
|
|||||||
/* iopreds.c */
|
/* iopreds.c */
|
||||||
void STD_PROTO(Yap_InitBackIO,(void));
|
void STD_PROTO(Yap_InitBackIO,(void));
|
||||||
void STD_PROTO(Yap_InitIOPreds,(void));
|
void STD_PROTO(Yap_InitIOPreds,(void));
|
||||||
|
void *Yap_GetStreamHandle(Atom at);
|
||||||
|
void *Yap_GetInputStream(Atom at);
|
||||||
|
void *Yap_GetOutputStream(Atom at);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
extern void Yap_DebugPlWrite (Term t);
|
extern void Yap_DebugPlWrite (Term t);
|
||||||
extern void Yap_DebugErrorPutc (int n);
|
extern void Yap_DebugErrorPutc (int n);
|
||||||
#endif
|
#endif
|
||||||
int STD_PROTO(Yap_LookupSWIStream,(void *));
|
|
||||||
int STD_PROTO(Yap_readTerm, (void *, Term *, Term *, Term *, Term *));
|
int STD_PROTO(Yap_readTerm, (void *, Term *, Term *, Term *, Term *));
|
||||||
void STD_PROTO(Yap_PlWriteToStream, (Term, int, int));
|
void STD_PROTO(Yap_PlWriteToStream, (Term, int, int));
|
||||||
/* depth_lim.c */
|
/* depth_lim.c */
|
||||||
@ -502,8 +504,4 @@ gc_P(yamop *p, yamop *cp)
|
|||||||
return (p->opc == Yap_opcode(_execute_cpred) ? cp : p);
|
return (p->opc == Yap_opcode(_execute_cpred) ? cp : p);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _PL_STREAM_H
|
|
||||||
extern int Yap_getInputStream(Int t, IOSTREAM **s);
|
|
||||||
extern int Yap_getOutputStream(Int t, IOSTREAM **s);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
@ -31,11 +31,12 @@ typedef YAP_Term (*Func)(term_t); /* foreign functions */
|
|||||||
extern const char *Yap_GetCurrentPredName(void);
|
extern const char *Yap_GetCurrentPredName(void);
|
||||||
extern YAP_Int Yap_GetCurrentPredArity(void);
|
extern YAP_Int Yap_GetCurrentPredArity(void);
|
||||||
extern int Yap_read_term(term_t t, IOSTREAM *st, term_t *exc, term_t vs);
|
extern int Yap_read_term(term_t t, IOSTREAM *st, term_t *exc, term_t vs);
|
||||||
extern int Yap_LookupSWIStream(void *swi_s);
|
|
||||||
extern term_t Yap_fetch_module_for_format(term_t args, YAP_Term *modp);
|
extern term_t Yap_fetch_module_for_format(term_t args, YAP_Term *modp);
|
||||||
extern IOENC Yap_DefaultEncoding(void);
|
extern IOENC Yap_DefaultEncoding(void);
|
||||||
extern void Yap_SetDefaultEncoding(IOENC);
|
extern void Yap_SetDefaultEncoding(IOENC);
|
||||||
|
|
||||||
|
extern void *Yap_GetStreamHandle(Atom at);
|
||||||
|
|
||||||
extern atom_t codeToAtom(int chrcode);
|
extern atom_t codeToAtom(int chrcode);
|
||||||
|
|
||||||
#define valTermRef(t) ((Word)YAP_AddressFromSlot(t))
|
#define valTermRef(t) ((Word)YAP_AddressFromSlot(t))
|
||||||
|
@ -484,9 +484,12 @@ static Int p_abolish_all_tables( USES_REGS1 ) {
|
|||||||
static Int p_show_tabled_predicates( USES_REGS1 ) {
|
static Int p_show_tabled_predicates( USES_REGS1 ) {
|
||||||
IOSTREAM *out;
|
IOSTREAM *out;
|
||||||
tab_ent_ptr tab_ent;
|
tab_ent_ptr tab_ent;
|
||||||
|
Term t = Deref(ARG1);
|
||||||
|
|
||||||
if (!PL_get_stream_handle(Yap_InitSlot(Deref(ARG1) PASS_REGS), &out))
|
if (IsVarTerm(t) || !IsAtomTerm(t))
|
||||||
return (FALSE);
|
return FALSE;
|
||||||
|
if (!(out = Yap_GetStreamHandle(AtomOfTerm(t))))
|
||||||
|
return FALSE;
|
||||||
tab_ent = GLOBAL_root_tab_ent;
|
tab_ent = GLOBAL_root_tab_ent;
|
||||||
Sfprintf(out, "Tabled predicates\n");
|
Sfprintf(out, "Tabled predicates\n");
|
||||||
if (tab_ent == NULL)
|
if (tab_ent == NULL)
|
||||||
@ -504,9 +507,12 @@ static Int p_show_table( USES_REGS1 ) {
|
|||||||
IOSTREAM *out;
|
IOSTREAM *out;
|
||||||
Term mod, t;
|
Term mod, t;
|
||||||
tab_ent_ptr tab_ent;
|
tab_ent_ptr tab_ent;
|
||||||
|
Term t1 = Deref(ARG1);
|
||||||
|
|
||||||
if (!PL_get_stream_handle(Yap_InitSlot(Deref(ARG1) PASS_REGS), &out))
|
if (IsVarTerm(t1) || !IsAtomTerm(t1))
|
||||||
return (FALSE);
|
return FALSE;
|
||||||
|
if (!(out = Yap_GetStreamHandle(AtomOfTerm(t1))))
|
||||||
|
return FALSE;
|
||||||
mod = Deref(ARG2);
|
mod = Deref(ARG2);
|
||||||
t = Deref(ARG3);
|
t = Deref(ARG3);
|
||||||
if (IsAtomTerm(t))
|
if (IsAtomTerm(t))
|
||||||
@ -526,9 +532,12 @@ static Int p_show_table( USES_REGS1 ) {
|
|||||||
static Int p_show_all_tables( USES_REGS1 ) {
|
static Int p_show_all_tables( USES_REGS1 ) {
|
||||||
IOSTREAM *out;
|
IOSTREAM *out;
|
||||||
tab_ent_ptr tab_ent;
|
tab_ent_ptr tab_ent;
|
||||||
|
Term t = Deref(ARG1);
|
||||||
|
|
||||||
if (!PL_get_stream_handle(Yap_InitSlot(Deref(ARG1) PASS_REGS), &out))
|
if (IsVarTerm(t) || !IsAtomTerm(t))
|
||||||
return (FALSE);
|
return FALSE;
|
||||||
|
if (!(out = Yap_GetStreamHandle(AtomOfTerm(t))))
|
||||||
|
return FALSE;
|
||||||
tab_ent = GLOBAL_root_tab_ent;
|
tab_ent = GLOBAL_root_tab_ent;
|
||||||
while(tab_ent) {
|
while(tab_ent) {
|
||||||
show_table(tab_ent, SHOW_MODE_STRUCTURE, out);
|
show_table(tab_ent, SHOW_MODE_STRUCTURE, out);
|
||||||
@ -541,9 +550,12 @@ static Int p_show_all_tables( USES_REGS1 ) {
|
|||||||
|
|
||||||
static Int p_show_global_trie( USES_REGS1 ) {
|
static Int p_show_global_trie( USES_REGS1 ) {
|
||||||
IOSTREAM *out;
|
IOSTREAM *out;
|
||||||
|
Term t = Deref(ARG1);
|
||||||
|
|
||||||
if (!PL_get_stream_handle(Yap_InitSlot(Deref(ARG1) PASS_REGS), &out))
|
if (IsVarTerm(t) || !IsAtomTerm(t))
|
||||||
return (FALSE);
|
return FALSE;
|
||||||
|
if (!(out = Yap_GetStreamHandle(AtomOfTerm(t))))
|
||||||
|
return FALSE;
|
||||||
show_global_trie(SHOW_MODE_STRUCTURE, out);
|
show_global_trie(SHOW_MODE_STRUCTURE, out);
|
||||||
PL_release_stream(out);
|
PL_release_stream(out);
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
@ -554,9 +566,12 @@ static Int p_show_statistics_table( USES_REGS1 ) {
|
|||||||
IOSTREAM *out;
|
IOSTREAM *out;
|
||||||
Term mod, t;
|
Term mod, t;
|
||||||
tab_ent_ptr tab_ent;
|
tab_ent_ptr tab_ent;
|
||||||
|
Term t1 = Deref(ARG1);
|
||||||
|
|
||||||
if (!PL_get_stream_handle(Yap_InitSlot(Deref(ARG1) PASS_REGS), &out))
|
if (IsVarTerm(t1) || !IsAtomTerm(t1))
|
||||||
return (FALSE);
|
return FALSE;
|
||||||
|
if (!(out = Yap_GetStreamHandle(AtomOfTerm(t1))))
|
||||||
|
return FALSE;
|
||||||
mod = Deref(ARG2);
|
mod = Deref(ARG2);
|
||||||
t = Deref(ARG3);
|
t = Deref(ARG3);
|
||||||
if (IsAtomTerm(t))
|
if (IsAtomTerm(t))
|
||||||
@ -580,9 +595,12 @@ static Int p_show_statistics_tabling( USES_REGS1 ) {
|
|||||||
long total_pages = 0;
|
long total_pages = 0;
|
||||||
#endif /* USE_PAGES_MALLOC */
|
#endif /* USE_PAGES_MALLOC */
|
||||||
IOSTREAM *out;
|
IOSTREAM *out;
|
||||||
|
Term t = Deref(ARG1);
|
||||||
|
|
||||||
if (!PL_get_stream_handle(Yap_InitSlot(Deref(ARG1) PASS_REGS), &out))
|
if (IsVarTerm(t) || !IsAtomTerm(t))
|
||||||
return (FALSE);
|
return FALSE;
|
||||||
|
if (!(out = Yap_GetStreamHandle(AtomOfTerm(t))))
|
||||||
|
return FALSE;
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
Sfprintf(out, "Execution data structures\n");
|
Sfprintf(out, "Execution data structures\n");
|
||||||
stats = show_statistics_table_entries(out);
|
stats = show_statistics_table_entries(out);
|
||||||
@ -636,9 +654,12 @@ static Int p_show_statistics_tabling( USES_REGS1 ) {
|
|||||||
|
|
||||||
static Int p_show_statistics_global_trie( USES_REGS1 ) {
|
static Int p_show_statistics_global_trie( USES_REGS1 ) {
|
||||||
IOSTREAM *out;
|
IOSTREAM *out;
|
||||||
|
Term t = Deref(ARG1);
|
||||||
|
|
||||||
if (!PL_get_stream_handle(Yap_InitSlot(Deref(ARG1) PASS_REGS), &out))
|
if (IsVarTerm(t) || !IsAtomTerm(t))
|
||||||
return (FALSE);
|
return FALSE;
|
||||||
|
if (!(out = Yap_GetStreamHandle(AtomOfTerm(t))))
|
||||||
|
return FALSE;
|
||||||
show_global_trie(SHOW_MODE_STATISTICS, out);
|
show_global_trie(SHOW_MODE_STATISTICS, out);
|
||||||
PL_release_stream(out);
|
PL_release_stream(out);
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
@ -765,9 +786,12 @@ static Int p_show_statistics_or( USES_REGS1 ) {
|
|||||||
long total_pages = 0;
|
long total_pages = 0;
|
||||||
#endif /* USE_PAGES_MALLOC */
|
#endif /* USE_PAGES_MALLOC */
|
||||||
IOSTREAM *out;
|
IOSTREAM *out;
|
||||||
|
Term t = Deref(ARG1);
|
||||||
|
|
||||||
if (!PL_get_stream_handle(Yap_InitSlot(Deref(ARG1) PASS_REGS), &out))
|
if (IsVarTerm(t) || !IsAtomTerm(t))
|
||||||
return (FALSE);
|
return FALSE;
|
||||||
|
if (!(out = Yap_GetStreamHandle(AtomOfTerm(t))))
|
||||||
|
return FALSE;
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
Sfprintf(out, "Execution data structures\n");
|
Sfprintf(out, "Execution data structures\n");
|
||||||
stats = show_statistics_or_frames(out);
|
stats = show_statistics_or_frames(out);
|
||||||
@ -808,10 +832,12 @@ static Int p_show_statistics_opt( USES_REGS1 ) {
|
|||||||
#ifdef USE_PAGES_MALLOC
|
#ifdef USE_PAGES_MALLOC
|
||||||
long total_pages = 0;
|
long total_pages = 0;
|
||||||
#endif /* USE_PAGES_MALLOC */
|
#endif /* USE_PAGES_MALLOC */
|
||||||
IOSTREAM *out;
|
Term t = Deref(ARG1);
|
||||||
|
|
||||||
if (!PL_get_stream_handle(Yap_InitSlot(Deref(ARG1) PASS_REGS), &out))
|
if (IsVarTerm(t) || !IsAtomTerm(t))
|
||||||
return (FALSE);
|
return FALSE;
|
||||||
|
if (!(out = Yap_GetStreamHandle(AtomOfTerm(t))))
|
||||||
|
return FALSE;
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
Sfprintf(out, "Execution data structures\n");
|
Sfprintf(out, "Execution data structures\n");
|
||||||
stats = show_statistics_table_entries(out);
|
stats = show_statistics_table_entries(out);
|
||||||
|
56
os/pl-file.c
56
os/pl-file.c
@ -636,7 +636,6 @@ PL_get_stream_handle(term_t t, IOSTREAM **s)
|
|||||||
return term_stream_handle(t, s, SH_ERRORS|SH_ALIAS PASS_LD);
|
return term_stream_handle(t, s, SH_ERRORS|SH_ALIAS PASS_LD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unify_stream_ref(term_t t, IOSTREAM *s)
|
unify_stream_ref(term_t t, IOSTREAM *s)
|
||||||
{ GET_LD
|
{ GET_LD
|
||||||
@ -4672,6 +4671,61 @@ EndPredDefs
|
|||||||
|
|
||||||
#if __YAP_PROLOG__
|
#if __YAP_PROLOG__
|
||||||
|
|
||||||
|
void *
|
||||||
|
Yap_GetStreamHandle(Atom at)
|
||||||
|
{ atom_t a;
|
||||||
|
IOSTREAM *s;
|
||||||
|
|
||||||
|
a = YAP_SWIAtomFromAtom(at);
|
||||||
|
if (!get_stream_handle(a, &s, SH_ERRORS|SH_ALIAS))
|
||||||
|
return NULL;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *Yap_GetInputStream(Atom at)
|
||||||
|
{ atom_t a;
|
||||||
|
IOSTREAM *s;
|
||||||
|
if ( at == AtomUser ) {
|
||||||
|
if ( (s = getStream(Suser_input)) )
|
||||||
|
return s;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
a = YAP_SWIAtomFromAtom(at);
|
||||||
|
if ( !get_stream_handle(a, &s, SH_ERRORS|SH_ALIAS|SH_INPUT) )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if ( !(s->flags &SIO_INPUT) )
|
||||||
|
{ releaseStream(s);
|
||||||
|
return Yap_Error(PERMISSION_ERROR_INPUT_STREAM, MkAtomTerm(at),
|
||||||
|
"read or ql");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *Yap_GetOutputStream(Atom at)
|
||||||
|
{ atom_t a;
|
||||||
|
IOSTREAM *s;
|
||||||
|
if ( at == AtomUser ) {
|
||||||
|
if ( (s = getStream(Suser_output)) )
|
||||||
|
return s;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
a = YAP_SWIAtomFromAtom(at);
|
||||||
|
if ( !get_stream_handle(a, &s, SH_ERRORS|SH_ALIAS|SH_OUTPUT) )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if ( !(s->flags &SIO_OUTPUT) )
|
||||||
|
{ releaseStream(s);
|
||||||
|
return Yap_Error(PERMISSION_ERROR_OUTPUT_STREAM, MkAtomTerm(at),
|
||||||
|
"write or ql");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
pl_get_time(term_t t)
|
pl_get_time(term_t t)
|
||||||
{ return PL_unify_float(t, WallTime());
|
{ return PL_unify_float(t, WallTime());
|
||||||
|
Reference in New Issue
Block a user