The R Project SVN R

Rev

Rev 34748 | Rev 36820 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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