improve SWI compatibility.

This commit is contained in:
Vitor Santos Costa
2009-03-13 19:40:27 +00:00
parent d6a06fe092
commit 67b29f3c85
8 changed files with 283 additions and 233 deletions

View File

@@ -19,6 +19,7 @@
#include <stdarg.h>
#include <stdlib.h>
#include <stddef.h>
#include <wchar.h>
#if HAVE_TIME_H
#include <time.h>
#endif
@@ -450,10 +451,16 @@ UNICODE file functions.
#ifdef SIO_MAGIC /* defined from <SWI-Stream.h> */
extern X_API int PL_unify_stream(term_t t, IOSTREAM *s);
extern X_API int PL_open_stream(term_t t, IOSTREAM *s); /* compat */
extern X_API int PL_get_stream_handle(term_t t, IOSTREAM **s);
#define PL_open_stream PL_unify_stream
extern X_API int PL_get_stream_handle(term_t t, IOSTREAM **s);\
extern X_API IOSTREAM *Snew(void *handle,int flags,IOFUNCTIONS *functions);
extern X_API int Sgetcode(IOSTREAM *);
extern X_API int Sfeof(IOSTREAM *);
#endif
#define succeed return TRUE
#define fail return FALSE
extern X_API const char *PL_cwd(void);
void swi_install(void);

View File

@@ -164,6 +164,8 @@ typedef struct io_stream
struct io_stream * upstream; /* stream providing our input */
struct io_stream * downstream; /* stream providing our output */
unsigned newline : 2; /* Newline mode */
int io_errno; /* Save errno value */
void * exception; /* pending exception (record_t) */
intptr_t reserved[3]; /* reserved for extension */
} IOSTREAM;
@@ -224,6 +226,8 @@ typedef struct io_stream
#define SIO_GETSIZE (1) /* get size of underlying object */
#define SIO_GETFILENO (2) /* get underlying file (if any) */
#define SIO_SETENCODING (3) /* modify encoding of stream */
#define SIO_FLUSHOUTPUT (4) /* flush output */
#define SIO_LASTERROR (5) /* string holding last error */
/* Sread_pending() */
#define SIO_RP_BLOCK 0x1 /* wait for new input */