RAPI
|
00001 /* 00002 * R : A Computer Language for Statistical Data Analysis 00003 * Copyright (C) 2000-2016 The R Core Team. 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, a copy is available at 00017 * https://www.R-project.org/Licenses/ 00018 */ 00019 00020 #ifndef R_EXT_CONNECTIONS_H_ 00021 #define R_EXT_CONNECTIONS_H_ 00022 00023 #include <R_ext/Boolean.h> 00024 00025 #ifndef NO_C_HEADERS 00026 # if defined(__cplusplus) && !defined(DO_NOT_USE_CXX_HEADERS) 00027 # include <cstddef> 00028 # include <cstdarg> 00029 # else 00030 # include <stddef.h> /* for size_t */ 00031 # include <stdarg.h> /* for va_list */ 00032 # endif 00033 #endif 00034 00035 /* IMPORTANT: we do not expect future connection APIs to be 00036 backward-compatible so if you use this, you *must* check the version 00037 and proceed only if it matches what you expect 00038 00039 We explicitly reserve the right to change the connection 00040 implementation without a compatibility layer. 00041 */ 00042 #define R_CONNECTIONS_VERSION 1 00043 00044 /* this allows the opaque pointer definition to be made available 00045 in Rinternals.h */ 00046 #ifndef HAVE_RCONNECTION_TYPEDEF 00047 typedef struct Rconn *Rconnection; 00048 #endif 00049 struct Rconn { 00050 char* class; 00051 char* description; 00052 int enc; /* the encoding of 'description' */ 00053 char mode[5]; 00054 Rboolean text, isopen, incomplete, canread, canwrite, canseek, blocking, 00055 isGzcon; 00056 Rboolean (*open)(struct Rconn *); 00057 void (*close)(struct Rconn *); /* routine closing after auto open */ 00058 void (*destroy)(struct Rconn *); /* when closing connection */ 00059 int (*vfprintf)(struct Rconn *, const char *, va_list); 00060 int (*fgetc)(struct Rconn *); 00061 int (*fgetc_internal)(struct Rconn *); 00062 double (*seek)(struct Rconn *, double, int, int); 00063 void (*truncate)(struct Rconn *); 00064 int (*fflush)(struct Rconn *); 00065 size_t (*read)(void *, size_t, size_t, struct Rconn *); 00066 size_t (*write)(const void *, size_t, size_t, struct Rconn *); 00067 int nPushBack, posPushBack; /* number of lines, position on top line */ 00068 char **PushBack; 00069 int save, save2; 00070 char encname[101]; 00071 /* will be iconv_t, which is a pointer. NULL if not in use */ 00072 void *inconv, *outconv; 00073 /* The idea here is that no MBCS char will ever not fit */ 00074 char iconvbuff[25], oconvbuff[50], *next, init_out[25]; 00075 short navail, inavail; 00076 Rboolean EOF_signalled; 00077 Rboolean UTF8out; 00078 void *id; 00079 void *ex_ptr; 00080 void *private; 00081 int status; /* for pipes etc */ 00082 }; 00083 00084 #ifdef __cplusplus 00085 extern "C" { 00086 #endif 00087 00088 SEXP R_new_custom_connection(const char *description, const char *mode, const char *class_name, Rconnection *ptr); 00089 size_t R_ReadConnection(Rconnection con, void *buf, size_t n); 00090 size_t R_WriteConnection(Rconnection con, void *buf, size_t n); 00091 Rconnection R_GetConnection(SEXP sConn); 00092 00093 #ifdef __cplusplus 00094 } 00095 #endif 00096 00097 #endif