The R Project SVN R

Rev

Rev 4622 | Rev 34748 | 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
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, write to the Free Software
5458 ripley 17
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
654 rgentlem 18
 */
19
 
20
/*
21
 *  I/O Support for Consoles and Character Vectors
22
 *
23
 *  This code provides analogues for the stdio routines "fgetc" and
24
 *  "ungetc" for "consoles" and character vectors.  These routines
25
 *  are used for parsing input from the console window and character
26
 *  vectors.
27
 */
28
 
29
#include <stdio.h>
30
#include "Defn.h"
31
 
32
#define IOBSIZE 4096
33
 
34
typedef struct BufferListItem {
3921 pd 35
	unsigned char			buf[IOBSIZE];
654 rgentlem 36
	struct BufferListItem	*next;
37
} BufferListItem;
38
 
39
typedef struct IoBuffer {
40
	BufferListItem	*start_buf;		/* First buffer item */
41
	BufferListItem	*write_buf;		/* Write pointer location */
3921 pd 42
	unsigned char	*write_ptr;		/* Write pointer location */
654 rgentlem 43
	int		 write_offset;		/* Write pointer location */
44
	BufferListItem	*read_buf;		/* Read pointer location */
3921 pd 45
	unsigned  char	*read_ptr;		/* Read pointer location */
654 rgentlem 46
	int		 read_offset;		/* Read pointer location */
47
} IoBuffer;
48
 
49
 
50
typedef struct TextBuffer {
51
	char	*vmax;				/* Memory stack top */
4622 maechler 52
	unsigned char	*buf;			/* Line buffer */
53
	unsigned char	*bufp;			/* Line buffer location */
654 rgentlem 54
	SEXP	text;				/* String Vector */
55
	int	ntext;				/* Vector length */
56
	int	offset;				/* Offset within vector */
57
} TextBuffer;
58
 
4622 maechler 59
#ifndef __MAIN__
60
extern
61
#endif
62
IoBuffer R_ConsoleIob;	    			/* Console IO Buffer */
63
 
1016 maechler 64
/*- some of these really could be void */
654 rgentlem 65
int R_IoBufferInit(IoBuffer*);
66
int R_IoBufferFree(IoBuffer*);
67
int R_IoBufferReadReset(IoBuffer*);
68
int R_IoBufferWriteReset(IoBuffer*);
69
int R_IoBufferGetc(IoBuffer*);
70
int R_IoBufferUngetc(int, IoBuffer*);
71
int R_IoBufferPutc(int, IoBuffer*);
72
int R_IoBufferPuts(char*, IoBuffer*);
73
 
74
int R_TextBufferInit(TextBuffer*, SEXP);
75
int R_TextBufferFree(TextBuffer*);
76
int R_TextBufferGetc(TextBuffer*);
77
int R_TextBufferUngetc(int, TextBuffer*);