Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / include / R_ext / Connections.h @ 2486

History | View | Annotate | Download (3 kB)

1
/*
2
 *  R : A Computer Language for Statistical Data Analysis
3
 *  Copyright (C) 2000-2013   The R Core Team.
4
 *
5
 *  This program is free software; you can redistribute it and/or modify
6
 *  it under the terms of the GNU General Public License as published by
7
 *  the Free Software Foundation; either version 2 of the License, or
8
 *  (at your option) any later version.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, a copy is available at
17
 *  http://www.r-project.org/Licenses/
18
 */
19

    
20
#ifndef R_EXT_CONNECTIONS_H_
21
#define R_EXT_CONNECTIONS_H_
22

    
23
#include <R_ext/Boolean.h>
24

    
25
#ifndef NO_C_HEADERS
26
# include <stddef.h> /* for size_t */
27
# include <stdarg.h> /* for va_list */
28
#endif
29

    
30
/* IMPORTANT: we do not expect future connection APIs to be
31
   backward-compatible so if you use this, you *must* check the version
32
   and proceed only if it matches what you expect
33

34
   We explicitly reserve the right to change the connection
35
   implementation without a compatibility layer.
36
 */
37
#define R_CONNECTIONS_VERSION 1
38

    
39
/* this allows the opaque pointer definition to be made available 
40
   in Rinternals.h */
41
#ifndef HAVE_RCONNECTION_TYPEDEF
42
typedef struct Rconn  *Rconnection;
43
#endif
44
struct Rconn {
45
    char* class;
46
    char* description;
47
    int enc; /* the encoding of 'description' */
48
    char mode[5];
49
    Rboolean text, isopen, incomplete, canread, canwrite, canseek, blocking, 
50
        isGzcon;
51
    Rboolean (*open)(struct Rconn *);
52
    void (*close)(struct Rconn *); /* routine closing after auto open */
53
    void (*destroy)(struct Rconn *); /* when closing connection */
54
    int (*vfprintf)(struct Rconn *, const char *, va_list);
55
    int (*fgetc)(struct Rconn *);
56
    int (*fgetc_internal)(struct Rconn *);
57
    double (*seek)(struct Rconn *, double, int, int);
58
    void (*truncate)(struct Rconn *);
59
    int (*fflush)(struct Rconn *);
60
    size_t (*read)(void *, size_t, size_t, struct Rconn *);
61
    size_t (*write)(const void *, size_t, size_t, struct Rconn *);
62
    int nPushBack, posPushBack; /* number of lines, position on top line */
63
    char **PushBack;
64
    int save, save2;
65
    char encname[101];
66
    /* will be iconv_t, which is a pointer. NULL if not in use */
67
    void *inconv, *outconv;
68
    /* The idea here is that no MBCS char will ever not fit */
69
    char iconvbuff[25], oconvbuff[50], *next, init_out[25];
70
    short navail, inavail;
71
    Rboolean EOF_signalled;
72
    Rboolean UTF8out;
73
    void *id;
74
    void *ex_ptr;
75
    void *private;
76
    int status; /* for pipes etc */
77
};
78

    
79
#ifdef  __cplusplus
80
extern "C" {
81
#endif
82

    
83
SEXP   R_new_custom_connection(const char *description, const char *mode, const char *class_name, Rconnection *ptr);
84
size_t R_ReadConnection(Rconnection con, void *buf, size_t n);
85
size_t R_WriteConnection(Rconnection con, void *buf, size_t n);
86

    
87
#ifdef  __cplusplus
88
}
89
#endif
90

    
91
#endif