36 #ifndef R_CONNECTIONS_H_
37 #define R_CONNECTIONS_H_
38 #include <R_ext/Boolean.h>
43 #if defined(HAVE_OFF_T) && defined(HAVE_FSEEKO) && defined(HAVE_SYS_TYPES_H)
44 #include <sys/types.h>
53 #ifndef HAVE_RCONNECTION_TYPEDEF
54 typedef struct Rconn *Rconnection;
61 Rboolean text, isopen, incomplete, canread, canwrite, canseek, blocking,
63 Rboolean (*open)(
struct Rconn *);
64 void (*close)(
struct Rconn *);
65 void (*destroy)(
struct Rconn *);
66 int (*vfprintf)(
struct Rconn *,
const char *, va_list);
67 int (*fgetc)(
struct Rconn *);
68 int (*fgetc_internal)(
struct Rconn *);
69 double (*seek)(
struct Rconn *, double, int, int);
70 void (*truncate)(
struct Rconn *);
71 int (*fflush)(
struct Rconn *);
72 size_t (*read)(
void *, size_t, size_t,
struct Rconn *);
73 size_t (*write)(
const void *, size_t, size_t,
struct Rconn *);
74 int nPushBack, posPushBack;
79 void *inconv, *outconv;
81 char iconvbuff[25], oconvbuff[50], *next, init_out[25];
82 short navail, inavail;
83 Rboolean EOF_signalled;
91 typedef enum {HTTPsh, FTPsh, HTTPSsh} UrlScheme;
94 typedef struct urlconn {
100 typedef struct sockconn {
106 char inbuf[4096], *pstart, *pend;
110 typedef struct clpconn {
112 int pos, len, last, sizeKB;
116 #define init_con Rf_init_con
117 #define con_pushback Rf_con_pushback
119 int Rconn_fgetc(Rconnection con);
120 int Rconn_ungetc(
int c, Rconnection con);
121 int Rconn_getline(Rconnection con,
char *buf,
int bufsize);
122 int Rconn_printf(Rconnection con,
const char *format, ...);
123 Rconnection getConnection(
int n);
124 Rconnection getConnection_no_err(
int n);
125 Rboolean switch_stdout(
int icon,
int closeOnExit);
126 void init_con(Rconnection newconn,
const char *description,
int enc,
127 const char *
const mode);
128 Rconnection R_newurl(
const char *description,
const char *
const mode);
129 Rconnection R_newsock(
const char *host,
int port,
int server,
const char *
const mode,
int timeout);
130 Rconnection in_R_newsock(
const char *host,
int port,
int server,
const char *
const mode,
int timeout);
131 Rconnection R_newunz(
const char *description,
const char *
const mode);
132 int dummy_fgetc(Rconnection con);
133 int dummy_vfprintf(Rconnection con,
const char *format, va_list ap);
134 int getActiveSink(
int n);
135 void con_pushback(Rconnection con, Rboolean newLine,
char *line);
136 size_t R_WriteConnection(Rconnection con,
const void *buf,
size_t n);
138 int Rsockselect(
int nsock,
int *insockfd,
int *ready,
int *write,
double timeout);
140 #define set_iconv Rf_set_iconv
141 void set_iconv(Rconnection con);