2002-03-27 19:00:00 +01:00
|
|
|
/*=========================================================================*\
|
|
|
|
* Buffered input/output routines
|
2003-03-28 22:08:50 +01:00
|
|
|
*
|
2002-03-27 19:00:00 +01:00
|
|
|
* RCS ID: $Id$
|
|
|
|
\*=========================================================================*/
|
2003-05-25 03:54:13 +02:00
|
|
|
#ifndef BUF_H
|
|
|
|
#define BUF_H
|
2002-03-27 19:00:00 +01:00
|
|
|
|
|
|
|
#include <lua.h>
|
2003-05-25 03:54:13 +02:00
|
|
|
#include "io.h"
|
|
|
|
#include "tm.h"
|
2002-03-27 19:00:00 +01:00
|
|
|
|
|
|
|
/* buffer size in bytes */
|
|
|
|
#define BUF_SIZE 8192
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*\
|
|
|
|
* Buffer control structure
|
|
|
|
\*-------------------------------------------------------------------------*/
|
2003-05-25 03:54:13 +02:00
|
|
|
typedef struct t_buf_ {
|
|
|
|
p_io io; /* IO driver used for this buffer */
|
|
|
|
p_tm tm; /* timeout management for this buffer */
|
|
|
|
size_t first, last; /* index of first and last bytes of stored data */
|
|
|
|
char data[BUF_SIZE]; /* storage space for buffer data */
|
2002-03-27 19:00:00 +01:00
|
|
|
} t_buf;
|
|
|
|
typedef t_buf *p_buf;
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*\
|
|
|
|
* Exported functions
|
|
|
|
\*-------------------------------------------------------------------------*/
|
|
|
|
void buf_open(lua_State *L);
|
2003-05-25 03:54:13 +02:00
|
|
|
void buf_init(p_buf buf, p_io io, p_tm tm);
|
|
|
|
int buf_meth_send(lua_State *L, p_buf buf);
|
|
|
|
int buf_meth_receive(lua_State *L, p_buf buf);
|
|
|
|
int buf_isempty(p_buf buf);
|
2002-03-27 19:00:00 +01:00
|
|
|
|
2003-05-25 03:54:13 +02:00
|
|
|
#endif /* BUF_H */
|