old swi library: replace by original yap code
This commit is contained in:
parent
eabf145052
commit
c652f79f26
@ -113,6 +113,9 @@ typedef struct io_position
|
||||
intptr_t reserved[2]; /* future extensions */
|
||||
} IOPOS;
|
||||
|
||||
#if defined(YAP_H)
|
||||
typedef encoding_t IOENC;
|
||||
#else
|
||||
/* NOTE: check with encoding_names */
|
||||
/* in pl-file.c */
|
||||
typedef enum
|
||||
@ -126,6 +129,7 @@ typedef enum
|
||||
ENC_UNICODE_LE, /* little endian unicode file */
|
||||
ENC_WCHAR /* pl_wchar_t */
|
||||
} IOENC;
|
||||
#endif
|
||||
|
||||
#define SIO_NL_POSIX 0 /* newline as \n */
|
||||
#define SIO_NL_DOS 1 /* newline as \r\n */
|
||||
@ -307,62 +311,7 @@ PL_EXPORT(int) Speekcode(IOSTREAM *s);
|
||||
#define fopen Sopen_file
|
||||
#define fdopen Sfdopen
|
||||
#define fileno Sfileno
|
||||
#define popen Sopen_pipe
|
||||
|
||||
#endif /*IOSTREAM_REPLACES_STDIO*/
|
||||
|
||||
/*******************************
|
||||
* PROTOTYPES *
|
||||
*******************************/
|
||||
|
||||
PL_EXPORT(void) SinitStreams(void);
|
||||
PL_EXPORT(void) Scleanup(void);
|
||||
PL_EXPORT(void) Sreset(void);
|
||||
PL_EXPORT(int) S__fupdatefilepos_getc(IOSTREAM *s, int c);
|
||||
PL_EXPORT(int) S__fcheckpasteeof(IOSTREAM *s, int c);
|
||||
PL_EXPORT(int) S__fillbuf(IOSTREAM *s);
|
||||
PL_EXPORT(int) Sunit_size(IOSTREAM *s);
|
||||
/* byte I/O */
|
||||
PL_EXPORT(int) Sputc(int c, IOSTREAM *s);
|
||||
PL_EXPORT(int) Sfgetc(IOSTREAM *s);
|
||||
PL_EXPORT(int) Sungetc(int c, IOSTREAM *s);
|
||||
/* multibyte I/O */
|
||||
PL_EXPORT(int) Scanrepresent(int c, IOSTREAM *s);
|
||||
PL_EXPORT(int) Sputcode(int c, IOSTREAM *s);
|
||||
PL_EXPORT(int) Sgetcode(IOSTREAM *s);
|
||||
PL_EXPORT(int) Sungetcode(int c, IOSTREAM *s);
|
||||
/* word I/O */
|
||||
PL_EXPORT(int) Sputw(int w, IOSTREAM *s);
|
||||
PL_EXPORT(int) Sgetw(IOSTREAM *s);
|
||||
PL_EXPORT(size_t) Sfread(void *data, size_t size, size_t elems,
|
||||
IOSTREAM *s);
|
||||
PL_EXPORT(size_t) Sfwrite(const void *data, size_t size, size_t elems,
|
||||
IOSTREAM *s);
|
||||
PL_EXPORT(int) Sfeof(IOSTREAM *s);
|
||||
PL_EXPORT(int) Sfpasteof(IOSTREAM *s);
|
||||
PL_EXPORT(int) Sferror(IOSTREAM *s);
|
||||
PL_EXPORT(void) Sclearerr(IOSTREAM *s);
|
||||
PL_EXPORT(void) Sseterr(IOSTREAM *s, int which, const char *message);
|
||||
PL_EXPORT(void) Sset_exception(IOSTREAM *s, term_t ex);
|
||||
PL_EXPORT(int) Ssetenc(IOSTREAM *s, IOENC new_enc, IOENC *old_enc);
|
||||
PL_EXPORT(int) Sflush(IOSTREAM *s);
|
||||
PL_EXPORT(int64_t) Ssize(IOSTREAM *s);
|
||||
PL_EXPORT(int) Sseek(IOSTREAM *s, long pos, int whence);
|
||||
PL_EXPORT(long) Stell(IOSTREAM *s);
|
||||
PL_EXPORT(int) Sclose(IOSTREAM *s);
|
||||
PL_EXPORT(char *) Sfgets(char *buf, int n, IOSTREAM *s);
|
||||
PL_EXPORT(char *) Sgets(char *buf);
|
||||
PL_EXPORT(ssize_t) Sread_pending(IOSTREAM *s,
|
||||
char *buf, size_t limit, int flags);
|
||||
PL_EXPORT(int) Sfputs(const char *q, IOSTREAM *s);
|
||||
PL_EXPORT(int) Sputs(const char *q);
|
||||
PL_EXPORT(int) Sfprintf(IOSTREAM *s, const char *fm, ...);
|
||||
PL_EXPORT(int) Sprintf(const char *fm, ...);
|
||||
PL_EXPORT(int) Svprintf(const char *fm, va_list args);
|
||||
PL_EXPORT(int) Svfprintf(IOSTREAM *s, const char *fm, va_list args);
|
||||
PL_EXPORT(int) Ssprintf(char *buf, const char *fm, ...);
|
||||
PL_EXPORT(int) Svsprintf(char *buf, const char *fm, va_list args);
|
||||
PL_EXPORT(int) Svdprintf(const char *fm, va_list args);
|
||||
Svdprintf(const char *fm, va_list args);
|
||||
PL_EXPORT(int) Sdprintf(const char *fm, ...);
|
||||
PL_EXPORT(int) Slock(IOSTREAM *s);
|
||||
PL_EXPORT(int) StryLock(IOSTREAM *s);
|
||||
@ -399,4 +348,6 @@ PL_EXPORT(ssize_t) Sread_user(void *handle, char *buf, size_t size);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /*_PL_STREAM_H*/
|
@ -22,6 +22,9 @@
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef PL_ERROR_H
|
||||
#define PL_ERROR_H 1
|
||||
|
||||
#ifndef COMMON
|
||||
#define COMMON(type) extern type
|
||||
#endif
|
||||
@ -88,3 +91,4 @@ COMMON(int) PL_get_module_ex(term_t name, module_t *m);
|
||||
COMMON(int) PL_get_arg_ex(int n, term_t term, term_t arg);
|
||||
COMMON(int) check_float(double f);
|
||||
|
||||
#endif
|
@ -5784,70 +5784,6 @@ EndPredDefs
|
||||
|
||||
#if __YAP_PROLOG__
|
||||
|
||||
void Yap_flush(void)
|
||||
{
|
||||
GET_LD
|
||||
flush_output(0 PASS_LD);
|
||||
}
|
||||
|
||||
void *
|
||||
Yap_GetStreamHandle(Atom at)
|
||||
{ GET_LD
|
||||
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)
|
||||
{ GET_LD
|
||||
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)
|
||||
{ GET_LD
|
||||
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
|
||||
pl_get_time(term_t t)
|
||||
{ return PL_unify_float(t, WallTime());
|
1640
library/dialect/swi/os/pl-read.c
Normal file
1640
library/dialect/swi/os/pl-read.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -84,7 +84,7 @@ COMMON(int) get_string_text(atom_t atom, PL_chars_t *text ARG_LD);
|
||||
static inline int
|
||||
text_get_char(const PL_chars_t *t, size_t i)
|
||||
{ assert(t->canonical);
|
||||
return t->encoding == ENC_ISO_LATIN_1 ? t->text.t[i]&0xff
|
||||
return t->encoding == ENC_ISO_LATIN1 ? t->text.t[i]&0xff
|
||||
: t->text.w[i];
|
||||
}
|
||||
|
1640
os/pl-read.c
1640
os/pl-read.c
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user