/
IOStuff.h
83 lines (71 loc) · 2.54 KB
/
IOStuff.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* R : A Computer Language for Statistical Data Analysis
* Copyright (C) 1997 Robert Gentleman and Ross Ihaka
* Copyright (C) 2005 R Development Core Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, a copy is available at
* http://www.r-project.org/Licenses/
*/
#ifndef R_IOSTUFF_H
#define R_IOSTUFF_H
/*
* I/O Support for Consoles and Character Vectors
*
* This code provides analogues for the stdio routines "fgetc" and
* (formerly) "ungetc" for "consoles" and character vectors. These routines
* are used for parsing input from the console window and character
* vectors.
*/
#include <Defn.h>
#include <stdio.h>
#define IOBSIZE 4096
typedef struct BufferListItem {
unsigned char buf[IOBSIZE];
struct BufferListItem *next;
} BufferListItem;
typedef struct IoBuffer {
BufferListItem *start_buf; /* First buffer item */
BufferListItem *write_buf; /* Write pointer location */
unsigned char *write_ptr; /* Write pointer location */
int write_offset; /* Write pointer location */
BufferListItem *read_buf; /* Read pointer location */
unsigned char *read_ptr; /* Read pointer location */
int read_offset; /* Read pointer location */
} IoBuffer;
typedef struct TextBuffer {
void *vmax; /* Memory stack top */
unsigned char *buf; /* Line buffer */
unsigned char *bufp; /* Line buffer location */
SEXP text; /* String Vector */
int ntext; /* Vector length */
int offset; /* Offset within vector */
} TextBuffer;
#ifndef __MAIN__
extern
#else
attribute_hidden
#endif
IoBuffer R_ConsoleIob; /* Console IO Buffer */
/*- some of these really could be void */
int R_IoBufferInit(IoBuffer*);
int R_IoBufferFree(IoBuffer*);
int R_IoBufferReadReset(IoBuffer*);
int R_IoBufferWriteReset(IoBuffer*);
int R_IoBufferGetc(IoBuffer*);
int R_IoBufferPutc(int, IoBuffer*);
int R_IoBufferPuts(char*, IoBuffer*);
int R_TextBufferInit(TextBuffer*, SEXP);
int R_TextBufferFree(TextBuffer*);
int R_TextBufferGetc(TextBuffer*);
#endif /* not R_IOSTUFF_H */