Mercurial > luasocket
comparison src/buffer.h @ 0:4b915342e2a8
LuaSocket 2.0.2 + CMake build description.
author | Eric Wing <ewing . public |-at-| gmail . com> |
---|---|
date | Tue, 26 Aug 2008 18:40:01 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4b915342e2a8 |
---|---|
1 #ifndef BUF_H | |
2 #define BUF_H | |
3 /*=========================================================================*\ | |
4 * Input/Output interface for Lua programs | |
5 * LuaSocket toolkit | |
6 * | |
7 * Line patterns require buffering. Reading one character at a time involves | |
8 * too many system calls and is very slow. This module implements the | |
9 * LuaSocket interface for input/output on connected objects, as seen by | |
10 * Lua programs. | |
11 * | |
12 * Input is buffered. Output is *not* buffered because there was no simple | |
13 * way of making sure the buffered output data would ever be sent. | |
14 * | |
15 * The module is built on top of the I/O abstraction defined in io.h and the | |
16 * timeout management is done with the timeout.h interface. | |
17 * | |
18 * RCS ID: $Id: buffer.h,v 1.12 2005/10/07 04:40:59 diego Exp $ | |
19 \*=========================================================================*/ | |
20 #include "lua.h" | |
21 | |
22 #include "io.h" | |
23 #include "timeout.h" | |
24 | |
25 /* buffer size in bytes */ | |
26 #define BUF_SIZE 8192 | |
27 | |
28 /* buffer control structure */ | |
29 typedef struct t_buffer_ { | |
30 double birthday; /* throttle support info: creation time, */ | |
31 size_t sent, received; /* bytes sent, and bytes received */ | |
32 p_io io; /* IO driver used for this buffer */ | |
33 p_timeout tm; /* timeout management for this buffer */ | |
34 size_t first, last; /* index of first and last bytes of stored data */ | |
35 char data[BUF_SIZE]; /* storage space for buffer data */ | |
36 } t_buffer; | |
37 typedef t_buffer *p_buffer; | |
38 | |
39 int buffer_open(lua_State *L); | |
40 void buffer_init(p_buffer buf, p_io io, p_timeout tm); | |
41 int buffer_meth_send(lua_State *L, p_buffer buf); | |
42 int buffer_meth_receive(lua_State *L, p_buffer buf); | |
43 int buffer_meth_getstats(lua_State *L, p_buffer buf); | |
44 int buffer_meth_setstats(lua_State *L, p_buffer buf); | |
45 int buffer_isempty(p_buffer buf); | |
46 | |
47 #endif /* BUF_H */ |