|
|
@ -10,8 +10,8 @@ typedef struct buffer {
|
|
|
|
int (*op)();
|
|
|
|
int (*op)();
|
|
|
|
} buffer;
|
|
|
|
} buffer;
|
|
|
|
|
|
|
|
|
|
|
|
#define BUFFER_INIT(op,fd,buf,len) { (buf), 0, (len), 0, (fd), (op) }
|
|
|
|
#define BUFFER_INIT(op,fd,buf,len) { (buf), 0, 0, (len), (fd), (op) }
|
|
|
|
#define BUFFER_INIT_READ(op,fd,buf,len) { (buf), 0, 0, (len), (fd), (op) }
|
|
|
|
#define BUFFER_INIT_READ(op,fd,buf,len) BUFFER_INIT(op,fd,buf,len) /*obsolete*/
|
|
|
|
#define BUFFER_INSIZE 8192
|
|
|
|
#define BUFFER_INSIZE 8192
|
|
|
|
#define BUFFER_OUTSIZE 8192
|
|
|
|
#define BUFFER_OUTSIZE 8192
|
|
|
|
|
|
|
|
|
|
|
@ -28,7 +28,7 @@ extern int buffer_putsflush(buffer* b,const char* x);
|
|
|
|
extern int buffer_putspace(buffer* b);
|
|
|
|
extern int buffer_putspace(buffer* b);
|
|
|
|
|
|
|
|
|
|
|
|
#define buffer_PUTC(s,c) \
|
|
|
|
#define buffer_PUTC(s,c) \
|
|
|
|
( ((s)->n != (s)->p) \
|
|
|
|
( ((s)->a != (s)->p) \
|
|
|
|
? ( (s)->x[(s)->p++] = (c), 0 ) \
|
|
|
|
? ( (s)->x[(s)->p++] = (c), 0 ) \
|
|
|
|
: buffer_put((s),&(c),1) \
|
|
|
|
: buffer_put((s),&(c),1) \
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -44,12 +44,12 @@ extern int buffer_get_token(buffer* b,char* x,unsigned int len,const char* chars
|
|
|
|
extern char *buffer_peek(buffer* b);
|
|
|
|
extern char *buffer_peek(buffer* b);
|
|
|
|
extern void buffer_seek(buffer* b,unsigned int len);
|
|
|
|
extern void buffer_seek(buffer* b,unsigned int len);
|
|
|
|
|
|
|
|
|
|
|
|
#define buffer_PEEK(s) ( (s)->x + (s)->n )
|
|
|
|
#define buffer_PEEK(s) ( (s)->x + (s)->p )
|
|
|
|
#define buffer_SEEK(s,len) ( ( (s)->p -= (len) ) , ( (s)->n += (len) ) )
|
|
|
|
#define buffer_SEEK(s,len) ( (s)->p += (len) )
|
|
|
|
|
|
|
|
|
|
|
|
#define buffer_GETC(s,c) \
|
|
|
|
#define buffer_GETC(s,c) \
|
|
|
|
( ((s)->p > 0) \
|
|
|
|
( ((s)->p < (s>->n) \
|
|
|
|
? ( *(c) = (s)->x[(s)->n], buffer_SEEK((s),1), 1 ) \
|
|
|
|
? ( *(c) = *buffer_PEEK(s), buffer_SEEK((s),1), 1 ) \
|
|
|
|
: buffer_get((s),(c),1) \
|
|
|
|
: buffer_get((s),(c),1) \
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|