[WIP] add a buffer for ungetc
This commit is contained in:
parent
9897f7581f
commit
4e495c6fcc
|
@ -15,11 +15,19 @@ enum pic_port_status {
|
||||||
PIC_PORT_CLOSE,
|
PIC_PORT_CLOSE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define PIC_UBUFSIZ 3
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
/* buffered IO */
|
||||||
char *buf;
|
char *buf;
|
||||||
int mode;
|
int mode;
|
||||||
int bufsiz;
|
int bufsiz;
|
||||||
char *s, *c, *e;
|
char *s, *c, *e;
|
||||||
|
/* ungetc buf */
|
||||||
|
char ub[PIC_UBUFSIZ];
|
||||||
|
int us;
|
||||||
|
int ur;
|
||||||
|
/* operators */
|
||||||
struct {
|
struct {
|
||||||
void *cookie;
|
void *cookie;
|
||||||
int (*read)(void *, char *, int);
|
int (*read)(void *, char *, int);
|
||||||
|
|
|
@ -94,6 +94,8 @@ pic_funopen(void *cookie,
|
||||||
file->buf = NULL;
|
file->buf = NULL;
|
||||||
file->mode = _IONBF;
|
file->mode = _IONBF;
|
||||||
file->bufsiz = 0;
|
file->bufsiz = 0;
|
||||||
|
file->us = PIC_UBUFSIZ;
|
||||||
|
file->ur = 0;
|
||||||
/* set vtable */
|
/* set vtable */
|
||||||
file->vtable.cookie = cookie;
|
file->vtable.cookie = cookie;
|
||||||
file->vtable.read = read;
|
file->vtable.read = read;
|
||||||
|
|
Loading…
Reference in New Issue